Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:gator410.hostgator.com': 0.09; '~ethan~': 0.09; 'def': 0.14; 'cc:addr:python-list': 0.15; 'roy': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.23; 'cc:2**0': 0.25; '(in': 0.26; 'skip:_ 20': 0.27; 'cc:addr:python.org': 0.29; 'class': 0.29; "skip:' 10": 0.30; 'words,': 0.32; 'header:User-Agent:1': 0.33; 'skip:@ 10': 0.34; 'subject:: ': 0.39; 'skip:_ 10': 0.40; 'received:websitewelcome.com': 0.64; 'ever': 0.65; 'received:184': 0.67; 'received:69.56': 0.73 Date: Wed, 16 Nov 2011 19:24:02 -0800 From: Ethan Furman User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Roy Smith Subject: Re: staticmethod makes my brain hurt References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: c-67-170-168-84.hsd1.or.comcast.net ([192.168.74.8]) [67.170.168.84]:2640 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1321501935 news.xs4all.nl 6877 [2001:888:2000:d::a6]:37971 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:15803 Roy Smith wrote: > class User(Document): > @staticmethod > def _get_next_id(): > [blah, blah, blah] > return id > > user_id = IntField(required=True, default=_get_next_id) If you don't call '_get_next_id()' from any class methods (in other words, if you don't need to ever say 'self._gen_next_id()') then you can remove the '@staticmethod': def _get_next_id(): [blah, blah, blah] return id user_id = IntField(required=True, default=_get_next_id) If you do need to sometimes call it from a method then still leave off the '@staticmethod', and give 'self' a default of 'None': def _get_next_id(self=None): [blah, blah, blah] return id user_id = IntField(required=True, default=_get_next_id) ~Ethan~