thanks
Yury

On Wed, Feb 25, 2009 at 9:47 AM, chadrik <[email protected]> wrote:

>
> list comprehension:
> http://docs.python.org/tutorial/datastructures.html#list-comprehensions
>
> string formatting:
> http://docs.python.org/library/stdtypes.html#string-formatting-operations
> here's some common examples:
>
> # strings
> >>> f = 'foo'
> >>> '%8s' % f
> '     foo'
> >>> '%-8s' % f
> 'foo     '
>
> # ints
> >>> '%04d' % 10
> '0010'
> >>> '% 04d' % 10
> ' 010'
> >>> '% 04d' % -10
> '-010'
>
> #floats
> >>> '%.3f' % 1.123456
> '1.123'
> >>>
>
>
>
> On Feb 25, 2009, at 6:33 AM, yury nedelin wrote:
>
> Chad,
> can you describe what's going on in
>
> >>> [ '%.02f' % x for x in a]
> ['1.11', '2.22', '3.33']
>
> I have never seen such syntax
> thanks
> yury
>
> On Wed, Feb 25, 2009 at 4:53 AM, barakooda <[email protected]> wrote:
>
>>
>> Thanx !
>> that really helpful and fast way.
>> i just have lots of Bboxs to check
>> thank you thank you
>> :=)
>> Barak
>>
>>
>>
>> On 25 פברואר, 02:00, Chad Dombrova <[email protected]> wrote:
>> > list comprehension:
>> >
>> >  >>> a= [ 1.1111, 2.2222, 3.3333]
>> >  >>> [ round(x,2) for x in a]
>> > [ 1.11, 2.22, 3.33]
>> >
>> > if you're rounding these values for the sake of printing them out then
>> > you should use:
>> >
>> >  >>> [ '%.02f' % x for x in a]
>> > ['1.11', '2.22', '3.33']
>> >
>> > On Feb 24, 2009, at 9:41 PM, barakooda wrote:
>> >
>> >
>> >
>> > > that what i did
>> > > but there is function that deal automatically with list or touple ?
>> > > that was my question basically
>> >
>> > > On 25 פברואר, 00:59, Chad Dombrova <[email protected]> wrote:
>> > >> python to the rescue:
>> >
>> > >>  >>> round( 1.24343, 2)
>> > >> 1.24
>> >
>> > >> On Feb 24, 2009, at 7:31 PM, barakooda wrote:
>> >
>> > >>> for example i have A=(1.2323,1.3232,1.454
>> >
>> > >>> i`m looking for automate function that will output same A but with 2
>> > >>> decimal points less
>> >
>> > >>> the new A will be:
>> > >>> 1.2,1.3,1.4)
>> >
>> > >>> i can do it manually but in my script  it wont be fun at all :-)
>> > >>> thank you !!!
>> >
>> >
>>
>>
>
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to