Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #74016
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Subject | Re: Why is it different from the example on the tutorial? |
| Date | 2014-07-06 15:25 +0100 |
| References | <f949d1c4-98c4-417f-9abc-58fe72b4c0a0@googlegroups.com> <mailman.11537.1404651349.18130.python-list@python.org> <c8f935e5-cd8f-4589-a70c-b172a985e22b@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.11540.1404656725.18130.python-list@python.org> (permalink) |
On 06/07/2014 14:38, rxjwg98@gmail.com wrote:
> On Sunday, July 6, 2014 8:54:42 AM UTC-4, Tim Chase wrote:
>> On 2014-07-06 05:13, rxjwg98@gmail.com wrote:
>>
>>> What I get on Python console:
>>
>>>
>>
>>> $ python
>>
>>> Python 2.7.5 (default, Oct 2 2013, 22:34:09)
>>
>>> [GCC 4.8.1] on cygwin
>>
>>> Type "help", "copyright", "credits" or "license" for more
>>
>>> information.
>>
>>>>>> import re
>>
>>>>>> p = re.compile('ab*')
>>
>>> File "<stdin>", line 1
>>
>>> p = re.compile('ab*')
>>
>>> ^
>>
>>> SyntaxError: invalid syntax
>>
>>>>>>
>>
>>
>>
>> Are you sure that you copied/pasted that directly from the console
>>
>> instead of transcribing it with some mistake?
>>
>>
>>
>> I just did the same thing at the console and it worked perfectly
>>
>> fine
>>
>>
>>
>> $ python
>>
>> Python 2.7.3 (default, Mar 13 2014, 11:03:55)
>>
>> [GCC 4.7.2] on linux2
>>
>> Type "help", "copyright", "credits" or "license" for more information.
>>
>>>>> import re
>>
>>>>> p = re.compile('ab*')
>>
>>>>>
>>
>>
>>
>>
>>
>> -tkc
> Thanks. It did be caused by unclear copy&paste. I shall be careful in future.
>
> When I enter:
>>>> counter=100
>>>> counter
> 100
>
> When I get match result:
>
>>>> pattern='abcd'
>>>> prog = re.compile(pattern)
>>>> string='abcd'
>>>> result = prog.match(string)
>>>> result
> <_sre.SRE_Match object at 0x6ffffeda5e0>
>
>>>> result.group(0)
> 'abcd'
>
> It looks like 'result' is different from a simple 'counter' variable. I do not
> yet find the definition of 'result' object. What do you call 'result' object?
> Where can I find it (what topic would be in a tutorial)?
>
> Thanks,
>
>
>>> help(result)
Help on SRE_Match object:
class SRE_Match(builtins.object)
| The result of re.match() and re.search().
etc
https://docs.python.org/3/library/re.html#module-re
https://docs.python.org/3/library/re.html#match-objects
https://docs.python.org/3/library/re.html#re.match
https://docs.python.org/3/library/re.html#re.search
https://docs.python.org/3/library/re.html#regular-expression-examples
A slight aside, would you please use the mailing list
https://mail.python.org/mailman/listinfo/python-list or read and action
this https://wiki.python.org/moin/GoogleGroupsPython to prevent us
seeing double line spacing and single line paragraphs, thanks.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why is it different from the example on the tutorial? rxjwg98@gmail.com - 2014-07-06 05:13 -0700
Re: Why is it different from the example on the tutorial? Tim Chase <python.list@tim.thechases.com> - 2014-07-06 07:54 -0500
Re: Why is it different from the example on the tutorial? rxjwg98@gmail.com - 2014-07-06 06:38 -0700
Re: Why is it different from the example on the tutorial? Rick Johnson <rantingrickjohnson@gmail.com> - 2014-07-06 07:18 -0700
Re: Why is it different from the example on the tutorial? Roy Smith <roy@panix.com> - 2014-07-06 10:34 -0400
Re: Why is it different from the example on the tutorial? Chris Angelico <rosuav@gmail.com> - 2014-07-07 00:45 +1000
Re: Why is it different from the example on the tutorial? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-07-06 15:47 +0100
Re: Why is it different from the example on the tutorial? Rick Johnson <rantingrickjohnson@gmail.com> - 2014-07-06 08:53 -0700
Re: Why is it different from the example on the tutorial? Roy Smith <roy@panix.com> - 2014-07-06 12:01 -0400
Re: Why is it different from the example on the tutorial? rxjwg98@gmail.com - 2014-07-06 08:03 -0700
Re: Why is it different from the example on the tutorial? Peter Otten <__peter__@web.de> - 2014-07-06 17:46 +0200
Re: Why is it different from the example on the tutorial? Rick Johnson <rantingrickjohnson@gmail.com> - 2014-07-06 09:02 -0700
Re: Why is it different from the example on the tutorial? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-07-06 19:29 +0100
Re: Why is it different from the example on the tutorial? Larry Hudson <orgnut@yahoo.com> - 2014-07-06 13:32 -0700
Re: Why is it different from the example on the tutorial? rxjwg98@gmail.com - 2014-07-06 13:42 -0700
Re: Why is it different from the example on the tutorial? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-07-06 15:25 +0100
Re: Why is it different from the example on the tutorial? Rustom Mody <rustompmody@gmail.com> - 2014-07-06 09:01 -0700
csiph-web