Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39755
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'skip:` 10': 0.05; 'ugly': 0.07; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:184.172': 0.09; 'received:gator410.hostgator.com': 0.09; 'throw': 0.09; '~ethan~': 0.09; 'language': 0.14; 'guys,': 0.16; 'underscores': 0.16; 'string': 0.17; "shouldn't": 0.17; 'question.': 0.20; 'written': 0.20; 'init': 0.22; 'example': 0.23; 'for?': 0.23; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'convert': 0.29; 'probably': 0.29; 'code': 0.31; 'skip:_ 30': 0.32; 'int': 0.33; 'null': 0.33; 'to:addr:python-list': 0.33; 'should': 0.36; 'being': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'email addr:gmail.com': 0.63; 'hey,': 0.72; '(is': 0.84; 'received:64.5': 0.84; 'starters,': 0.84; 'to:name:python': 0.84; 'wrong!': 0.84; 'hungarian': 0.91; 'feet': 0.96 |
| Date | Sun, 24 Feb 2013 08:23:33 -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 <python-list@python.org> |
| Subject | Re: intX.__str__() ?? |
| 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]:59504 |
| 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.2412.1361723520.2939.python-list@python.org> (permalink) |
| Lines | 38 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1361723520 news.xs4all.nl 6890 [2001:888:2000:d::a6]:56476 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:39755 |
Show key headers only | View raw
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?
intLength1 = 5 # feet
intLength2 = 13 # centimeters
.
.
.
intLength1 + intLength2 # oops!
vs
ftLength1 = 5
cmLength2 = 13
.
.
.
ftLength1 + cmLength2 # hey, that's wrong! better throw in a conversion
--
~Ethan~
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: intX.__str__() ?? Ethan Furman <ethan@stoneleaf.us> - 2013-02-24 08:23 -0800
csiph-web