473,899 Members | 4,012 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 Aug 31, 11:19 am, Tim Golden <m...@timgolden .me.ukwrote:
Tim Golden wrote:
Erik Max Francis wrote:
Paddy wrote:
>I say the 'oll' in troll like the 'ol' in frolic, and pronounce roll
and role similarly.
>My accent is probably from the East Midlands of the UK, but is not
pronounced.
_Troll_ and _frolic_ aren't pronounced with the same "o" sound in any
accent I've ever heard of. Which you pronounce _boat_ and _bot_ the
same way, too?
[Amusingly contemplating a trolling war about the pronunciation of "troll"]
Well they sound the same in my more-or-less South London accent.
I can't write those funny phonetic symbols (and I hate to
imagine the Unicode encoding hoops I'd have to jump through
to make them readable anyway) but both "o"s sound short to me.
Like "bot" rather than "boat" using your example.

Since we're talking... I'm still a little startled when I listen
to some of the excellent webcasts that are being produced these
days (showmedo.com and friends) and hear American voices pronounce
Python... well, the way they do, with the stress and something of a
drawl on the second syllable. I'm sure it's just as amusing the other
way round: we pronounce it with the stress on the first syllable and
the characteristic short vowel sound in the second.
(Something like: Pie'thun).

TJG
The only true way of pronouncing Python (the computing language), is
the way it is done at the beginning of Monty Pythons Flying Circus of
course :-)

Your right, the American way does make me pause.

- Paddy.

Aug 31 '07 #61
In message <ma************ *************** ***********@pyt hon.org>, Carsten
Haese wrote:
On Thu, 2007-08-30 at 11:21 -0700, zz******@aol.co m wrote:
>I wish they were not
getting rid of dict.has_key() in Python 3, which I prefer to IN.

That wish will only come true if you maintain your own fork of Python 3.
has_key() will go away, period. It has been made obsolete by "in", which
is faster and more concise.
And is also a backdoor way of introducing non-virtual methods into Python,
is it not.
Sep 1 '07 #62
On Sat, 2007-09-01 at 13:50 +1200, Lawrence D'Oliveiro wrote:
In message <ma************ *************** ***********@pyt hon.org>, Carsten
Haese wrote:
has_key() will go away, period. It has been made obsolete by "in", which
is faster and more concise.

And is also a backdoor way of introducing non-virtual methods into Python,
is it not.
If by that you mean that "in" tests can't be overridden, that's not
true:
>>class LyingDict(dict) :
.... def __contains__(se lf, key): return False
....
>>d = LyingDict()
d[1] = 42
1 in d
False

If you mean something else, please clarify.

--
Carsten Haese
http://informixdb.sourceforge.net
Sep 1 '07 #63
"Erik Max Francis" <ma...e.comwrot e:

Hendrik van Rooyen wrote:
weird this - maybe a native English speaker can comment -
when I pronounce what fishermen do - it rhymes with roll,
but when I am talking about the thing that lives under bridges
and munches goats, the "O" sound is shorter, and more
towards the back of my mouth.

Native English accents vary as well, but _roll_ rhymes with _troll_, not
_trawl_. _Trawl_ would rhyme with _fall_, and _fall_ definitely doesn't
rhyme with _roll_.
I did not mean using a net to scour the seabed - Trawl,
I meant using a spoon to see what you can induce to strike - Troll

- Hendrik

Sep 1 '07 #64
Dennis Lee Bieber wrote:
On Fri, 31 Aug 2007 21:15:10 +0100, DaveM <as****@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 -------------

Sep 1 '07 #65
"Paddy" <pad....o.mail. comwrote:
>
I say the 'oll' in troll like the 'ol' in frolic, and pronounce roll
and role similarly.

My accent is probably from the East Midlands of the UK, but is not
pronounced.
Same here - when the Troll lives under a bridge - I could not think
of something to rhyme with it - frolic is just right.

- Hendrik

Sep 1 '07 #66
"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

Sep 1 '07 #67
Hendrik van Rooyen wrote:
"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?
I think you are seeking consistency where none exists. I don't believe
anyone uses different pronunciations for the noun and the verb (which I
guess will make those who *do* come out of the woodwork in double-quick
time).

Where's Godwin's Law when yo need it?

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 #68
On Sep 1, 7:40 am, "Hendrik van Rooyen" <m...@microcorp .co.zawrote:
"Paddy" <pad....o.mail. comwrote:
I say the 'oll' in troll like the 'ol' in frolic, and pronounce roll
and role similarly.

Same here - when the Troll lives under a bridge - I could not think
of something to rhyme with it - frolic is just right.

- Hendrik
Yep, they would have posted about it way-back if they had the tech...

http://uk.youtube.com/watch?v=zZ3fjQa5Hls

(Gershwin doesn't seem to have a line about troll though :-)

- Paddy.
Sep 1 '07 #69
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.

--
\ "Rightful liberty is unobstructed action, according to our |
`\ will, within limits drawn around us by the equal rights of |
_o__) others." -- Thomas Jefferson |
Ben Finney
Sep 1 '07 #70

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
10863
jinu1996
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...
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
10494
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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.