On Sep 11, 4:48*pm, Manuel Ebert <maeb...@uos.de wrote:
-----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 857 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 -a
Linux euler 2.4.20-8 #1 Thu Mar 13 17:18:24 EST 2003 i686 athlon i386
|
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 pattern ?
I want to get the value of the Count tag.
2- My file does not contain the standalone header ? How can I deal with
|
by: Sridhar |
last post by:
HI All,
Currently writing a small program and here is my xml file and program.
---------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<abc>
<featureKey id="F1/1">
<description>Lawful interception</description>
<start>2000-01-01</start>
|
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 I am
missing that feature. Maybe there is something wrong with my programming
style, but I rather think it is generally useful.
I fully agree with the following posting where somebody complains why so
very basic and useful things are not part...
|
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 certain
attributes. Would anyone know of a site or could any one provide me
with such an example?
Best Regards
Ty
| |
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 that both eventually call the
same code that imports xml.parsers.expat. Both give me different
results...
The code that gets called is (print statements have been added for
debugging):
|
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 large number) have
to be removed (say when ToBeRemoved = true).
class SomeObj
ToBeRemoved be a boolean field
end class
|
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 a class which have zero, one or more custom attributes
associated with each field. I'd like to get a list of the attributes
present for a given field, and then iterate over them to find
associated values.
Where I've coded for the presence of...
|
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 xml parser, for an xml file that just loads
the content of each tag into a dict (the xml file doesn't have
multiple hierarchies in it, it's flat other than the parent node)
so we have
<parent>
|
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:
/usr/lib/libc.a(shr.o)
Cannot find /unix --- Is there a problem here?
/usr/lib/libcrypt.a(shr.o)
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |