Re: trouble to print array contents using slice operator

2005-04-16 Thread Diez B. Roggisch
praba kar wrote:

> Dear all,
> 
>In Php array_slice function base
> we can print array contents as per our desire
> eg)
> 
> $a = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
> $arr = array_slice($a,10,10);
> 
> this function will print 11,12,13,14,15
> 
> But I try to print the same thing in python
> using slice operator
> 
> eg) print a[10:10]
> 
> This statement print [] empty array.
> 
> How I need to get my desired output like php
> array_slice function?

Slicing indices in python are [start:stop], not [start:lengh]. So use

print a[10:10+10]




-- 
Regards,

Diez B. Roggisch
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: trouble to print array contents using slice operator

2005-04-16 Thread Michael . Coll-Barth
print a[10:15] 
or 
print a[10:]



-Original Message-
From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
n.org]On Behalf Of praba kar
Sent: Saturday, April 16, 2005 10:28 AM
To: python-list@python.org
Subject: trouble to print array contents using slice operator


Dear all,

   In Php array_slice function base
we can print array contents as per our desire
eg)

$a = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
$arr = array_slice($a,10,10);

this function will print 11,12,13,14,15

But I try to print the same thing in python
using slice operator 

eg) print a[10:10] 

This statement print [] empty array.  

How I need to get my desired output like php
array_slice function?

with regards
Prabahar



 


Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony
-- 
http://mail.python.org/mailman/listinfo/python-list
___
The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure.  If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof.  Thank you.

-- 
http://mail.python.org/mailman/listinfo/python-list