Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39769
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'operator': 0.03; 'method.': 0.05; 'skip:` 10': 0.05; 'ugly': 0.07; 'python': 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; 'notation': 0.09; 'received:184.172': 0.09; 'received:gator410.hostgator.com': 0.09; 'scripts,': 0.09; 'underscore': 0.09; '~ethan~': 0.09; 'language': 0.14; 'guys,': 0.16; 'performed.': 0.16; 'underscores': 0.16; 'string': 0.17; 'wrote:': 0.17; "shouldn't": 0.17; '>>>': 0.18; 'code.': 0.20; 'define': 0.20; 'question.': 0.20; 'written': 0.20; 'init': 0.22; 'example': 0.23; 'for?': 0.23; 'least': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'wonder': 0.27; 'convert': 0.29; 'skip:_ 10': 0.29; 'probably': 0.29; 'class': 0.29; 'code': 0.31; 'skip:_ 30': 0.32; "he's": 0.33; 'int': 0.33; 'null': 0.33; 'to:addr:python-list': 0.33; 'another': 0.33; 'explain': 0.36; 'michael': 0.36; 'should': 0.36; 'being': 0.37; 'why': 0.37; 'maintaining': 0.37; 'subject:: ': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'first': 0.61; 'email addr:gmail.com': 0.63; 'received:69.56': 0.65; '(is': 0.84; 'actually,': 0.84; 'furman': 0.84; 'overloading': 0.84; 'starters,': 0.84; 'ethan': 0.91; 'hungarian': 0.91 |
| Date | Sun, 24 Feb 2013 10:04:42 -0800 |
| From | Ethan Furman <ethan@stoneleaf.us> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: intX.__str__() ?? |
| References | <512A3E85.6000307@stoneleaf.us> <512A4DF4.6060105@gmail.com> |
| In-Reply-To | <512A4DF4.6060105@gmail.com> |
| 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 | yes |
| X-Source | |
| X-Source-Args | |
| X-Source-Dir | |
| X-Source-Sender | ([173.12.184.235]) [173.12.184.235]:59551 |
| X-Source-Auth | ethan+stoneleaf.us |
| X-Email-Count | 1 |
| X-Source-Cap | dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== |
| 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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2422.1361730917.2939.python-list@python.org> (permalink) |
| Lines | 40 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1361730917 news.xs4all.nl 6928 [2001:888:2000:d::a6]:50899 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:39769 |
Show key headers only | View raw
On 02/24/2013 09:29 AM, Michael Torrie wrote: > On 02/24/2013 09:23 AM, Ethan Furman wrote: >> On 02/24/2013 07:46 AM, piterrr.dolinski@gmail.com wrote:> Hi guys, >>> >>> Question. Have this code >>> >>> intX = 32 # decl + init int var >>> intX_asString = None # decl + init with NULL string var >>> >>> intX_asString = intX.__str__ () # convert int to string >>> >>> What are these ugly underscores for? _________________str___________________ >> >> This is a good example of why you shouldn't program language X in language Y. >> >> For starters, `intX.__str__` should be written as `str(intX)`; >> >> For middlers, intX_asString is probably not necessary (is it being printed? then >> do a `print intX`, or a `print "size left on disk: %d" % intX`, etc. >> >> For finishers, why the System Hungarian Notation? > > I think he's maintaining existing code. It's unfortunate that his first > exposure to python is code written by someone else in such a poor style, > and in a way that definitely isn't pythonic. No wonder he's struggling > to like python! On the bright side, if this is one of his 2000 line scripts, he should be able to get it down to at least half that once he has a good feel for Python and re-writes it. > Another way to explain the double underscore methods is that they are > how things like operator overloading is performed. Want to make a class > that you can use the [index] notation on instances? Define the > __get_attr__() method. Actually, it's the __getitem__ method. -- ~Ethan~
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: intX.__str__() ?? Ethan Furman <ethan@stoneleaf.us> - 2013-02-24 10:04 -0800 Re: intX.__str__() ?? Roy Smith <roy@panix.com> - 2013-02-24 13:54 -0500
csiph-web