Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: intX.__str__() ??

Reply
Thread Tools

Re: intX.__str__() ??

 
 
Ethan Furman
Guest
Posts: n/a
 
      02-24-2013
On 02/24/2013 07:46 AM, http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments