I find itertools.islice() useful, so for Python 3.x I may like to see
it removed from the itertools module, and the normal slicing syntax
[::] extended to work with generators/iterators too.
from itertools import islice
primes = (x for x in xrange(1,999) if all(x % y for y in xrange(2,
x)))
print list(islice(primes, 0, 20))
==>
print list(primes[:20])
Bye,
bearophile 3 2334
[castiro]
Slice literals are a logical next step, precedented by raw strings and
bytes. slice= islice is too, precedented by range= xrange.
Looking closely at the [::] notation, I think it can easily be
confused with an open box of fleas. IMO, the one unequivocal,
explicit way of checking for lice is itertools.is_lice().
Raymond
_ ~
@ @
\_/
On Mar 7, 7:49 am, bearophileH...@lycos.com wrote:
I find itertools.islice() useful, so for Python 3.x I may like to see
it removed from the itertools module, and the normal slicing syntax
[::] extended to work with generators/iterators too.
from itertools import islice
primes = (x for x in xrange(1,999) if all(x % y for y in xrange(2,
x)))
print list(islice(primes, 0, 20))
==>
print list(primes[:20])
Bye,
bearophile
I had posted some time ago an OO wrapper of itertools; slice notation
for islice was one motivation: http://aspn.activestate.com/ASPN/Coo.../Recipe/498272
George This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steven Bethard |
last post by:
Is there a reason that itertools.islice doesn't support None arguments
for start and step? This would be handy for use with slice objects:
>>> r = range(20)
>>> s1 = slice(2, 10, 2)
>>> s2 =...
|
by: Christian Schmidbauer |
last post by:
Hello!
I prepare my XML document like this way:
-------------------------------------------------------
PrintWriter writer;
Document domDocument;
Element domElement;
// Root tag
|
by: Eshrath |
last post by:
Hi,
What I am trying to do:
=======================
I need to form a table in html using the xsl but the table that is
formed is quite long and cannot be viewed in our application. So we
are...
|
by: Donald Firesmith |
last post by:
I am having trouble having Google Adsense code stored in XSL converted
properly into HTML. The <> unfortunately become < and > and then
no longer work.
XSL code is:
<script...
|
by: Arne Schirmacher |
last post by:
I want to display a MySQL database field that can contain HTML markup.
If I use <esql:get-string> then I get all of the database field, but
all tags are escaped which is not what I want. If I use...
|
by: Mark Moore |
last post by:
It looks like there's a pretty serious CSS bug in IE6
(v6.0.2800.1106). The HTML below is validated STRICT HTML 4.01 and
renders as I would expect in Opera, FrontPage, and Netscape.
For some...
|
by: Les Paul |
last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's
just like a Wiki page, but my own very simple version. It's a page full
of plain old HTML content, and then at the bottom,...
|
by: bissatch |
last post by:
Hi,
I am currently writing a simple PHP program that uses an XML file to
output rows for a 'Whats New' page. Once written, I will only require
updating the XML file and any pages that use the...
|
by: vdex42 |
last post by:
Apologies if this has been asked before, but I haven't been able to
find the answer to this yet:
My problem is that .NET will not allow me to insert escaped '>'
characters (i.e. >) within the...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |