Is it a bug?

Gleb Belov gbelov at gmail.com
Tue Aug 25 23:12:47 CEST 2009


On Aug 26, 12:59 am, Stephen Fairchild <someb... at somewhere.com> wrote:
> 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

Oh, thank you! That makes sense! Should have thought of the escape
character issue...



More information about the Python-list mailing list