473,899 Members | 3,313 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

list index()

What's with the index() function of lists throwing an exception on not
found? Let's hope this is rectified in Python 3. If nothing else, add
a function that doesn't throw an exception. There are a million
situations where you can have an item not be in a list and it is not
an exception situation.

Aug 30 '07
96 4648
On Sep 1, 7:57 am, "Hendrik van Rooyen" <m...@microcorp .co.zawrote:
"Richie Hindle" <richi...ian.co mwrote:
But - the word for someone who posts to the internet with the intention of
stirring up trouble derives from the word for what fishermen do, not from
the word for something that lives under a bridge. It derives from "trolling
for suckers" or "trolling for newbies".

So am I right in asserting that there is a difference in pronunciation
of the noun and the verb?

He is a Troll - like the excellent frolic example
He likes to Troll - rhymes with roll?

- Hendrik
No difference. A troll is a troll is a troll.

:-)

- Paddy.
Sep 1 '07 #71
On Sep 1, 7:32 am, Steve Holden <st...@holdenwe b.comwrote:
Dennis Lee Bieber wrote:
On Fri, 31 Aug 2007 21:15:10 +0100, DaveM <asm...@dsl.pip ex.com>
declaimed the following in comp.lang.pytho n:
No - but I would pronounce "lever" and "fever" the same way, if that helps.
<shudderTo me, those are different... I suppose you also add an
extra "i" to aluminum <G>

No, he just spells it with two i's like sensible people do. Who would
ever want *three* I's in "aluminium" (which, by the way, you misspelled ;-)?

Such things are matters of practical significance to me, since I have
adopted a policy of using English spelling when in the UK and US
spelling when elsewhere. Since I am now pretty much full-time in the US,
I am finally having to come to terms with its crazy spelling.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
Since the language that inspired the programming language is most
definitely English as spoken in the UK, could it be that the highest
levels of Pythonistic Nirvana are to be reached only by ....
Nah - can't do it! (just spell colour right and I'll be OK).

- Paddy.

Sep 1 '07 #72
On Sat, 01 Sep 2007 17:23:04 +1000, Ben Finney wrote:
Dennis Lee Bieber <wl*****@ix.net com.comwrites:
>I suppose you also add an extra "i" to aluminum <G>

We're not out to rewrite the table of elements. There's no such thing as
"aluminum", and "aluminium" always has just the two "i"s.
Although aluminium is the one and only correct spelling *grins*, it is
not actually true that it has always been spelt that way (or for you
Merkins out there, spelled). The discoverer of aluminium, Sir Humphrey
Davy, originally spelt it alumium, then aluminum, and finally
standardized on aluminium.

http://www.worldwidewords.org/articles/aluminium.htm
--
Steven.
Sep 1 '07 #73
"Steve Holden" <st***@holdenwe b.comwrote:

Paddy wrote:
My accent is probably from the East Midlands of the UK, but is not
pronounced.
If your accent isn't pronounced how do we know what it sounds like?
When he says pronounced, he doesn't mean pronounced, he means pronounced!

- To shamelessly paraphrase the Master - (Plum of course)

; - ) - Hendrik

Sep 1 '07 #74
"Steve Holden" <s...web.comwro te:

Where's Godwin's Law when yo need it?
Hitler would not have spellt "you" like that...

- Hendrik

Sep 1 '07 #75
Paddy wrote:
On Sep 1, 7:57 am, "Hendrik van Rooyen" <m...@microcorp .co.zawrote:
>"Richie Hindle" <richi...ian.co mwrote:
>>But - the word for someone who posts to the internet with the intention of
stirring up trouble derives from the word for what fishermen do, not from
the word for something that lives under a bridge. It derives from "trolling
for suckers" or "trolling for newbies".
So am I right in asserting that there is a difference in pronunciation
of the noun and the verb?

He is a Troll - like the excellent frolic example
He likes to Troll - rhymes with roll?

- Hendrik

No difference. A troll is a troll is a troll.

:-)

- Paddy.

BTW people , the word for what fishermen do is T R A W L and not troll
(Ha! and I'm not a native English speaker).
Sep 1 '07 #76
Ricardo Aráoz wrote:
Paddy wrote:
>On Sep 1, 7:57 am, "Hendrik van Rooyen" <m...@microcorp .co.zawrote:
>>"Richie Hindle" <richi...ian.co mwrote:
But - the word for someone who posts to the internet with the intention of
stirring up trouble derives from the word for what fishermen do, not from
the word for something that lives under a bridge. It derives from "trolling
for suckers" or "trolling for newbies".
So am I right in asserting that there is a difference in pronunciation
of the noun and the verb?

He is a Troll - like the excellent frolic example
He likes to Troll - rhymes with roll?

- Hendrik
No difference. A troll is a troll is a troll.

:-)

- Paddy.


BTW people , the word for what fishermen do is T R A W L and not troll
(Ha! and I'm not a native English speaker).
Just read the whole thread, or use a dictionary: in fishing, trolling
and trawling are two different things; the first is done with a net, the
second with a line.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

Sep 1 '07 #77
Steve Holden wrote:
Ricardo Aráoz wrote:
>Paddy wrote:
>>On Sep 1, 7:57 am, "Hendrik van Rooyen" <m...@microcorp .co.zawrote:
"Richie Hindle" <richi...ian.co mwrote:
But - the word for someone who posts to the internet with the intention of
stirring up trouble derives from the word for what fishermen do, not from
the word for something that lives under a bridge. It derives from "trolling
for suckers" or "trolling for newbies".
So am I right in asserting that there is a difference in pronunciation
of the noun and the verb?

He is a Troll - like the excellent frolic example
He likes to Troll - rhymes with roll?

- Hendrik
No difference. A troll is a troll is a troll.

:-)

- Paddy.

BTW people , the word for what fishermen do is T R A W L and not troll
(Ha! and I'm not a native English speaker).

Just read the whole thread, or use a dictionary: in fishing, trolling
and trawling are two different things; the first is done with a net, the
second with a line.

regards
Steve
Damn Wikipedia! It always gets things upside down, specially when I
'read the whole thread' :

"Trolling for fish" is a form of angling where lines with hook-rigged
lures are dragged behind a boat to entice fish to bite. Compare the term
"Trawling for fish," which involves dragging a net behind a boat to
catch large numbers of fish.

;c)

(Don't mind me. Just trolling...)


Sep 1 '07 #78
On Aug 30, 7:00 pm, Steve Holden <st...@holdenwe b.comwrote:
You can also generate the files that are in one directory but ot the
other with

(afiles | bfiles) - (afiles & bfiles)
Or just (afiles ^ bfiles).

Nicko

--
(lambda f: lambda *a:f(f,*a))(
lambda f,l,i:l[i][1]+f(f,l,l[i][0]) if l[i][0]>0 else "")(
sorted(enumerat e('~ooiirnncc@-kk.og'),key=lam bda a:a[1]),0)[1:]

Sep 1 '07 #79
Alex Martelli wrote:
is the "one obvious way to do it" (the set(...) is just a simple and
powerful optimization -- checking membership in a set is roughly O(1),
while checking membership in a list of N items is O(N)...).
Depending on a how a set is stored, I'd estimate any membership check in
a set to be O(log N). That's if it's stored in a tree of some kind,
which you'd need to fast finding. Say a balanced binary tree. Worst
case, you'd have to search half of the elements to find what you were
looking for.
>

Alex
Sep 1 '07 #80

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1490
by: questions? | last post by:
I want to do list index function. >>> y= >>> y >>> y.index Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: unsubscriptable object It works with y=. Anyone has any hint, what's the reason
9
17435
by: William Meyer | last post by:
hi, I need to get the index of an object in a list. I know that no two objects in the list are the same, but objects might evaluate as equal. for example list = for object in list: objectIndex = list.index(object) print objectIndex
8
28506
by: sam | last post by:
hey everybody, this is my first time posting here. i'm pretty new to python and programming in general (as you'll soon work out for yourselves...) i'm trying to code a version of a selection sort and the heart of the code is as follows (no_lines is simply the number of items to be sorted, read out of an input file): for j in range(0, no_lines):
35
29275
by: erikwickstrom | last post by:
Hi all, I'm sorry about the newbie question, but I've been searching all afternoon and can't find the answer! I'm trying to get this bit of code to work without triggering the IndexError. import shutil, os, sys
7
10817
by: python101 | last post by:
My code s= for k in range(len(s)): st=s.count(s) if st>=2: print s.pop(s.index(s)) Traceback (most recent call last):
3
2431
by: Riccardo Murri | last post by:
Hello, I have some code that stops when trying to find a graph in a list of similar graphs:: (Pydb) list 110 try: 111 canonical = self.base 112 except ValueError: 113 raise ValueError, \
2
3792
by: Georgy Panterov | last post by:
I am a relatively new python user. I am writing an economic simulation of acard-game. The simulation runs fine for a few iteration but then it gives an error of "list index out of range." The strange thing is that it will sometimes run for 10 iterations sometimesfor only a few and sometimes won't run at all (seemingly arbitrary). Here is some of the code: for _ in range(100): handA=deal_hand(DECK) #deals 2 'hole' cards from a DECK...
5
18939
by: Mr.SpOOn | last post by:
Hi, is there any way to search elements in a list using wildcards? I have a list of various elements and I need to search for elements starting with 'no', extract them and put in a new list. I was thinking about something like: mylist.index('no*') Of course this doesn't work.
2
4395
by: Chriskim | last post by:
I wrote a program that uses PyQt4, mathplotlib to generates graphs. I made a executable file using Py2exe. Everything is working fine, but when I exit from my program, a window message pops out and tells me to look at the log file. In the log file, here is what they said C:\Users\dmckinnon\Desktop\ChrisKim\eSimulator_original\src\dist\library.zip\matplotlib\__init__.py:572: UserWarning: Could not find matplotlibrc; using defaults...
0
9997
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9843
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11272
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10971
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,...
0
9666
agi2029
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...
1
8039
isladogs
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...
0
5887
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4300
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.