On Sep 11, 4:48*pm, Manuel Ebert <maeb...@uos.dewrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ah, well. Don't know whether it meets your aesthetic standards, but:
*>>my_list = ['tree', 'hug', 'flower', 'hug', 'bear', 'run']
*>>my_list[0:len(a):2]
['tree', 'flower', 'bear']
*>>my_list[1:len(a):2]
['hug', 'hug', 'run']
and hence
*>>zip(my_list[0:len(a):2], my_list[1:len(a):2])
[('tree', 'hug'), ('flower', 'hug'), ('bear', 'run')]
and furthermore
*>>for a, b in zip(my_list[0:len(a):2], my_list[1:len(a):2]):
... * * print a, b
...
tree hug
flower hug
bear run
or the slightly less obfuscated:
*>>for index in range(0, len(my_list), 2):
... * * print my_list[index], my_list[index + 1]
... * *
tree hug
flower hug
bear run
[snip]
I don't know what the "len(a)" is, but the end position defaults to
the end:
>>zip(my_list[0::2], my_list[1::2])
[('tree', 'hug'), ('flower', 'hug'), ('bear', 'run')] 0 846 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ingo Blank |
last post by:
Hi,
while 95% of my 'psycoed' applications run fine, it throws SIGSEGVs in
conjunction with expat. Anybody noticed the same ?
Python 2.3.2 (#4, Nov 13 2003, 02:10:49)
on linux2
$ uname...
|
by: David |
last post by:
Hi,
I'm trying to parse an xml file and am a bit confused. I have created my
class XmlParser.
Also I have 3 other questions.
1-How to the GetAttribute to search for the value of a specific...
|
by: Sridhar |
last post by:
HI All,
Currently writing a small program and here is my xml file and program.
---------------------------------------------------------------------------------
<?xml version="1.0"...
|
by: Christoph Zwerschke |
last post by:
This is probably a FAQ, but I dare to ask it nevertheless since I
haven't found a satisfying answer yet: Why isn't there an "ordered
dictionary" class at least in the standard list? Time and again...
|
by: tvmaly |
last post by:
I was trying to find some examples of using expat 2.0 with C++.
Specifically I was looking for an example, that if it found a certain
start tag, then it would grab the whole string or possibly just...
| |
by: dwelch91 |
last post by:
Hi, c.l.p.'ers-
I am having a problem with the import of xml.parsers.expat that has
gotten me completely stumped. I have two programs, one a PyQt program
and one a command line (text) program...
|
by: pamelafluente |
last post by:
Hi
I have a sorted list with several thousands items. In my case, but this
is not important, objects are stored only in Keys, Values are all
Nothing. Several of the stored objects (might be a...
|
by: davearkley |
last post by:
I've recently 'discover' the wonders of custom attributes and
reflection. There's one aspect that has stumping me and I've been
unable to find samples in the docs or on the web.
I have fields in...
|
by: kaens |
last post by:
Hey everyone, this may be a stupid question, but I noticed the
following and as I'm pretty new to using xml and python, I was
wondering if I could get an explanation.
Let's say I write a simple...
|
by: vadlapatlahari |
last post by:
Hi,
I get the following error with Expat while configuring my application server. Can anyone suggest a solution?
When i do an ldd, i get the following :
$ldd Expat.so
Expat.so needs:...
|
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: 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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |