Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63034
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ethan@stoneleaf.us> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; '(at': 0.04; 'float': 0.07; 'suppose': 0.07; '*args,': 0.09; 'false.': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'propagate': 0.09; 'true)': 0.09; '~ethan~': 0.09; 'def': 0.12; "(i'm": 0.16; '**kwargs):': 0.16; '__getitem__,': 0.16; '__new__': 0.16; 'fine.': 0.16; 'happily': 0.16; 'inability': 0.16; 'least)': 0.16; 'name):': 0.16; 'nan': 0.16; 'received:gateway13.websitewelcome.com': 0.16; 'wrote:': 0.18; 'code,': 0.22; 'header:User-Agent:1': 0.23; "haven't": 0.24; 'looks': 0.24; "i've": 0.25; 'class.': 0.26; 'pass': 0.26; 'header :In-Reply-To:1': 0.27; 'chris': 0.29; "i'm": 0.30; "they'll": 0.31; 'class': 0.32; 'probably': 0.32; 'call.': 0.33; 'actual': 0.34; 'skip:_ 10': 0.34; 'could': 0.34; 'info': 0.35; 'except': 0.35; 'but': 0.35; 'add': 0.35; 'crazy': 0.36; 'false': 0.36; 'done': 0.36; 'method': 0.36; 'charset:us-ascii': 0.36; "i'll": 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'applicable': 0.60; 'expression': 0.60; 'real': 0.63; 'become': 0.64; 'production': 0.68; 'lose': 0.68; 'online': 0.71; 'calls,': 0.84; 'can...': 0.84; 'examples.': 0.84; 'received:67.18.68': 0.84; 'x):': 0.84; 'inheritance,': 0.93; 'ultimate': 0.93 |
| Date | Thu, 02 Jan 2014 20:16:51 -0800 |
| From | Ethan Furman <ethan@stoneleaf.us> |
| User-Agent | Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Ifs and assignments |
| References | <52C59FF6.5000607@allsup.co> <52C5BD90.9020609@islandtraining.com> <mailman.4811.1388704420.18130.python-list@python.org> <roy-8601CA.18361502012014@news.panix.com> <CAPTjJmoA130Q4+2PHLWiPp1FNaB+c6HgUTWpst4Z_qL3qqoR2w@mail.gmail.com> |
| In-Reply-To | <CAPTjJmoA130Q4+2PHLWiPp1FNaB+c6HgUTWpst4Z_qL3qqoR2w@mail.gmail.com> |
| Content-Type | text/plain; charset=us-ascii; 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 - gator3304.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-IP | 50.38.15.216 |
| X-Source | |
| X-Source-Args | |
| X-Source-Dir | |
| X-Source-Sender | ([192.168.1.42]) [50.38.15.216]:59795 |
| X-Source-Auth | ethan+stoneleaf.us |
| X-Email-Count | 1 |
| X-Source-Cap | dG9idWs7dG9idWs7Z2F0b3IzMzA0Lmhvc3RnYXRvci5jb20= |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4831.1388724082.18130.python-list@python.org> (permalink) |
| Lines | 38 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1388724082 news.xs4all.nl 2912 [2001:888:2000:d::a6]:49068 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:63034 |
Show key headers only | View raw
On 01/02/2014 04:06 PM, Chris Angelico wrote: > > Here's a crazy idea. Suppose we have a "sticky falseness" that can > quietly propagate through an expression the way a NaN can... then we > could just float that right through the .group() call. > > class truth: > def __new__(cls, x): > if x: return x > return object.__new__(cls) > def __bool__(self): > return False > def __getattr__(self, name): > return self > def __call__(self, *args, **kwargs): > return self > def __repr__(self): > return repr(False) > > Pass any object through truth() and it'll either stay the same (if > it's true) or become this object (if it's false). You can then carry > on with other method calls, and they'll all happily return false. An interesting idea. You'd need to add (at least) __getitem__, and I'll probably call it `maybe`, myself. ;) > (I'm not sure if I'm using __new__ correctly; I've never actually done > it in production code, and the info I found online was mainly Py2 > examples. Should that be done with super(), or is that applicable only > once there's an actual instance with a real MRO?) I haven't tested it, but your __new__ looks fine. The only thing you lose by not calling super() is the inability for cooperative multiple inheritance, except as the ultimate base class. -- ~Ethan~
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Ifs and assignments John Allsup <pydev@allsup.co> - 2014-01-02 21:44 +0000
Re: Ifs and assignments Roy Smith <roy@panix.com> - 2014-01-02 18:36 -0500
Re: Ifs and assignments Chris Angelico <rosuav@gmail.com> - 2014-01-03 11:07 +1100
Re: Ifs and assignments Chris Angelico <rosuav@gmail.com> - 2014-01-03 11:06 +1100
Re: Ifs and assignments Ethan Furman <ethan@stoneleaf.us> - 2014-01-02 20:16 -0800
Re: Ifs and assignments Chris Angelico <rosuav@gmail.com> - 2014-01-03 16:35 +1100
csiph-web