[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: Does anyone else use this little idiom?

Thomas Dybdahl Ahle

2/3/2008 7:37:00 PM


On Sat, 2008-02-02 at 18:03 -0800, miller.paul.w@gmail.com wrote:
> for _ in xrange (1,n):
> some code

I'd always use i for loop variables I don't know what to call. It stands
for iterator or something. In a nested loop the next variable would
simply be called j and so on.

I also tend to use _, but in cases like:
_, _, something, _ = somecall()
where I only need one variable from a tupple. I only use this if I'm
sure the other values will probably never be of any use for the code.

However a large problem with _ is, that it is also the standard name of
the translate function of e.g. gettext.
In gui code you'll often find widget.setText(_("Save")). If you have
renamed _ this will give you problems.

> An alternative way of indicating that you don't care about the loop
> index would be
>
> for dummy in xrange (1,n):
> some code

I don't like dummy, as it is too long. I generelly spend more times
looking into long variable than short ones.

Regards, Thomas


1 Answer

Smirnoff

5/20/2008 12:27:00 AM

0



<retrogrouch@comcast.net> wrote in message
news:1so3341roogs1f55fja97a2one2qh8ts9s@4ax.com
> On Mon, 19 May 2008 08:21:25 -1000, "Jerry Okamura"
> <okamuraj005@hawaii.rr.com> wrote:
>
>>
>>"Smirnoff" <Unlised@unlisted.com> wrote in message
>>news:_5%Xj.4498$lU5.4256@newsread1.mlpsca01.us.to.verio.net...
>>>
>>>
>>> "Jerry Okamura" <okamuraj005@hawaii.rr.com> wrote in
>>> message news:48307898$0$30479$4c368faf@roadrunner.com
>>>> "Smirnoff" <Unlised@unlisted.com> wrote in message
>>>> news:lEFXj.4359$lU5.406@newsread1.mlpsca01.us.to.verio.net...
>>>>>
>>>>>
>
>>> You must be referring to the Americans that have been
>>> shocked.
>>>
>>
>>Only because the occupation has been a whole lot harder
>>than was anticipated. The war will go down in history as
>>one of the most successful ever conducted by any country
>>to date.
>
>
> Damn - warn me when you're going to get that absurd. I
> damn near spit tea all over my monitor.
>
> LOL.

I think he was trying to frost that cake walk, put some candles on it and
blow as hard as he can.