Is it a bug?

Stephen Fairchild somebody at somewhere.com
Tue Aug 25 16:59:00 EDT 2009


Gleb Belov wrote:

> Hey everyone! I'm quite new to Python and equally new to newsgroups in
> general, so apologies if this makes no sense.
> 
> Basically, I was just exploring Python "arrays" on my own, since I
> come from C++. What I did was:
>>>> words = ["Hi!", "What's up?", "Bye!"]
>>>> print words
> ['Hi!', "What's up?", 'Bye!']
> 
> I have two questions:
> 1) Is it possible and if so, how do I access each individual element?
> Are there any indexes and what is the syntax?

For the first element:
>>> words[0]

> 2) I just noticed that the first and the last words in the output are
> enclosed in single quotes, and the middle one is enclosed in double
> quotes. Is it a bug? If not, why does the output work that way?

The output is valid python code. To represent with single quotes for the
second item, there would have to be a \ escape character for the
apostrophe.
-- 
Stephen Fairchild



More information about the Python-list mailing list