Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #74302 > unrolled thread
| Started by | fl <rxjwg98@gmail.com> |
|---|---|
| First post | 2014-07-10 07:04 -0700 |
| Last post | 2014-07-10 10:14 -0400 |
| Articles | 6 — 5 participants |
Back to article view | Back to comp.lang.python
What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? fl <rxjwg98@gmail.com> - 2014-07-10 07:04 -0700
Re: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2014-07-10 16:14 +0200
Re: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? fl <rxjwg98@gmail.com> - 2014-07-10 08:23 -0700
Re: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? MRAB <python@mrabarnett.plus.com> - 2014-07-10 17:48 +0100
Re: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? Ian Kelly <ian.g.kelly@gmail.com> - 2014-07-10 10:22 -0600
Re: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? Joel Goldstick <joel.goldstick@gmail.com> - 2014-07-10 10:14 -0400
| From | fl <rxjwg98@gmail.com> |
|---|---|
| Date | 2014-07-10 07:04 -0700 |
| Subject | What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? |
| Message-ID | <b0f2c8d2-c5a7-4b12-90f1-4aa8bfed9783@googlegroups.com> |
Hi,
For me, it is difficult to understand the last line of the paragraph below in
parenthesis (A ``quote'' is the character used to open the string,
i.e. either ' or ".)
It talks about triple-quoted strings. Where is ``quote'' from? It has two ` and '.
What this different ` and ' do for here?
The link is here:
https://docs.python.org/2.0/ref/strings.html
Thank you for helping me to learn Python.
............................
In plain English: String literals can be enclosed in matching single quotes (') or
double quotes ("). They can also be enclosed in matching groups of three single
or double quotes (these are generally referred to as triple-quoted strings). The
backslash (\) character is used to escape characters that otherwise have a special eaning, such as newline, backslash itself, or the quote character. String literals
may optionally be prefixed with a letter `r' or `R'; such strings are called raw
strings and use different rules for backslash escape sequences.
In triple-quoted strings, unescaped newlines and quotes are allowed (and are
retained), except that three unescaped quotes in a row terminate the string. (A
``quote'' is the character used to open the string, i.e. either ' or ".)
[toc] | [next] | [standalone]
| From | Chris “Kwpolska” Warrick <kwpolska@gmail.com> |
|---|---|
| Date | 2014-07-10 16:14 +0200 |
| Subject | Re: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? |
| Message-ID | <mailman.11727.1405001662.18130.python-list@python.org> |
| In reply to | #74302 |
On Thu, Jul 10, 2014 at 4:04 PM, fl <rxjwg98@gmail.com> wrote: > Hi, > > For me, it is difficult to understand the last line of the paragraph below in > parenthesis (A ``quote'' is the character used to open the string, > i.e. either ' or ".) > > It talks about triple-quoted strings. Where is ``quote'' from? It has two ` and '. > What this different ` and ' do for here? > > The link is here: > https://docs.python.org/2.0/ref/strings.html > > Thank you for helping me to learn Python. Please don’t learn from this link. It’s from 2001. You should learn from modern documentation: https://docs.python.org/ (if not running 3.4.x, change the version in the top) You also should not read the language reference, it’s meant for people who really care about what’s under the hood. The official tutorial is better for learning: https://docs.python.org/3/tutorial/index.html -- Chris “Kwpolska” Warrick <http://chriswarrick.com/> PGP: 5EAAEA16 stop html mail | always bottom-post | only UTF-8 makes sense
[toc] | [prev] | [next] | [standalone]
| From | fl <rxjwg98@gmail.com> |
|---|---|
| Date | 2014-07-10 08:23 -0700 |
| Subject | Re: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? |
| Message-ID | <47595855-295a-43ee-8b4b-98dda4466669@googlegroups.com> |
| In reply to | #74305 |
On Thursday, July 10, 2014 10:14:14 AM UTC-4, Chris "Kwpolska" Warrick wrote: > > > > > Please don't learn from this link. It's from 2001. You should learn > > from modern documentation: https://docs.python.org/ (if not running > > 3.4.x, change the version in the top) > > > > You also should not read the language reference, it's meant for people > > who really care about what's under the hood. The official tutorial is > > better for learning: https://docs.python.org/3/tutorial/index.html > > Thank you for your advice. My OP was originated from a question from this link: https://wiki.python.org/moin/RegularExpression It has several useful examples. Several of them are not clear to me. Please explain it to me. Is '\A' the same with '^'? Is '\Z' the same with '$'? Thanks,
[toc] | [prev] | [next] | [standalone]
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2014-07-10 17:48 +0100 |
| Subject | Re: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? |
| Message-ID | <mailman.11732.1405010910.18130.python-list@python.org> |
| In reply to | #74311 |
On 2014-07-10 16:23, fl wrote: > On Thursday, July 10, 2014 10:14:14 AM UTC-4, Chris "Kwpolska" Warrick wrote: >> > >> >> >> Please don't learn from this link. It's from 2001. You should learn >> >> from modern documentation: https://docs.python.org/ (if not running >> >> 3.4.x, change the version in the top) >> >> >> >> You also should not read the language reference, it's meant for people >> >> who really care about what's under the hood. The official tutorial is >> >> better for learning: https://docs.python.org/3/tutorial/index.html >> >> > Thank you for your advice. My OP was originated from a question from this link: > https://wiki.python.org/moin/RegularExpression > > It has several useful examples. Several of them are not clear to me. Please > explain it to me. > > Is '\A' the same with '^'? > Is '\Z' the same with '$'? > \A matches at the start of the string. \Z matches at the end of the string. Normally, ^ matches at the start of the string, but if the re.MULTILINE flag is turned on, it matches at the start of a line. Normally, $ matches at the end of the string, or just before the final '\n' if that '\n' is the final character, but if the re.MULTILINE flag is turned on, it matches at the end of a line.
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2014-07-10 10:22 -0600 |
| Subject | Re: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? |
| Message-ID | <mailman.11738.1405013103.18130.python-list@python.org> |
| In reply to | #74311 |
On Thu, Jul 10, 2014 at 9:23 AM, fl <rxjwg98@gmail.com> wrote: > Is '\A' the same with '^'? > Is '\Z' the same with '$'? The meanings of these are explained at: https://docs.python.org/library/re.html#regular-expression-syntax Outside of multiline mode, they're equivalent. In multiline mode, ^ and $ will also match at the beginning and end of individual lines, while \A and \Z still only match the beginning and end of the input string.
[toc] | [prev] | [next] | [standalone]
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2014-07-10 10:14 -0400 |
| Subject | Re: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? |
| Message-ID | <mailman.11728.1405001678.18130.python-list@python.org> |
| In reply to | #74302 |
On Thu, Jul 10, 2014 at 10:04 AM, fl <rxjwg98@gmail.com> wrote:
> Hi,
>
> For me, it is difficult to understand the last line of the paragraph below in
> parenthesis (A ``quote'' is the character used to open the string,
> i.e. either ' or ".)
>
> It talks about triple-quoted strings. Where is ``quote'' from? It has two ` and '.
> What this different ` and ' do for here?
>
> The link is here:
> https://docs.python.org/2.0/ref/strings.html
>
> Thank you for helping me to learn Python.
>
>
> ............................
> In plain English: String literals can be enclosed in matching single quotes (') or
> double quotes ("). They can also be enclosed in matching groups of three single
> or double quotes (these are generally referred to as triple-quoted strings). The
> backslash (\) character is used to escape characters that otherwise have a special eaning, such as newline, backslash itself, or the quote character. String literals
> may optionally be prefixed with a letter `r' or `R'; such strings are called raw
> strings and use different rules for backslash escape sequences.
>
> In triple-quoted strings, unescaped newlines and quotes are allowed (and are
> retained), except that three unescaped quotes in a row terminate the string. (A
> ``quote'' is the character used to open the string, i.e. either ' or ".)
> --
> https://mail.python.org/mailman/listinfo/python-list
Here are some examples:
'this is a single quoted string'
"this is a double quoted string"
"""this is a triple quoted string. Note that it starts and ends with
three double quote characters.
It can also span lines
"""
'''If you like you can use single quotes (three of them) for the same effect'''
--
Joel Goldstick
http://joelgoldstick.com
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web