Why is it different from the example on the tutorial?

2014-07-06 Thread rxjwg98
Hi, I type the following sample codes on Python, but it echoes differently. Regular expressions are compiled into pattern objects, which have methods for various operations such as searching for pattern matches or performing string substitutions. import re p = re.compile('ab*') p

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread Tim Chase
On 2014-07-06 05:13, rxjw...@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: Why is it different from the example on the tutorial?

2014-07-06 Thread rxjwg98
On Sunday, July 6, 2014 8:54:42 AM UTC-4, Tim Chase wrote: On 2014-07-06 05:13, rxjw...@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

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread Rick Johnson
On Sunday, July 6, 2014 8:38:41 AM UTC-5, rxj...@gmail.com wrote: When I get match result: pypattern='abcd' pyprog = re.compile(pattern) pystring='abcd' pyresult = prog.match(string) pyresult _sre.SRE_Match object at 0x6eda5e0 pyresult.group(0) 'abcd' It looks like 'result' is

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread Mark Lawrence
On 06/07/2014 14:38, rxjw...@gmail.com wrote: On Sunday, July 6, 2014 8:54:42 AM UTC-4, Tim Chase wrote: On 2014-07-06 05:13, rxjw...@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,

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread Roy Smith
In article 21e704ee-648b-423d-8682-11cb310a3...@googlegroups.com, Rick Johnson rantingrickjohn...@gmail.com wrote: On Sunday, July 6, 2014 8:38:41 AM UTC-5, rxj...@gmail.com wrote: When I get match result: pypattern='abcd' pyprog = re.compile(pattern) pystring='abcd' pyresult =

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread Chris Angelico
On Mon, Jul 7, 2014 at 12:34 AM, Roy Smith r...@panix.com wrote: * You can print type(foo), to find out exactly what it is (useful when even printing repr() doesn't explain what's going on). And very VERY occasionally, print(id(type(foo))) comes in handy, because two types might look the same,

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread Mark Lawrence
On 06/07/2014 15:34, Roy Smith wrote: * You can print foo itself, to find out its value, but this can get tricky, since sometimes objects print themselves in confusing ways. Printing repr(foo) will usually get you more detail. For the OP the pretty print module is usually better than plain

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread rxjwg98
On Sunday, July 6, 2014 10:18:53 AM UTC-4, Rick Johnson wrote: On Sunday, July 6, 2014 8:38:41 AM UTC-5, rxj...@gmail.com wrote: When I get match result: pypattern='abcd' pyprog = re.compile(pattern) pystring='abcd' pyresult = prog.match(string) pyresult _sre.SRE_Match

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread Peter Otten
rxjw...@gmail.com wrote: I use cygwin Python, I type help of an object 'result'. It does show up the help content, but it never quits the help afterwards. It is annoying, and time wasting. To quit help try hitting the 'q' key. -- https://mail.python.org/mailman/listinfo/python-list

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread Rick Johnson
On Sunday, July 6, 2014 9:34:44 AM UTC-5, Roy Smith wrote: * You can print dict(foo), which just prints out the attributes the object has. Looks like a typo there. I think you probably meant to say dir(foo) INTERACTIVE SESSION:

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread Roy Smith
In article 6fd77d6a-3487-474b-bb96-8da6ab800...@googlegroups.com, Rick Johnson rantingrickjohn...@gmail.com wrote: On Sunday, July 6, 2014 9:34:44 AM UTC-5, Roy Smith wrote: * You can print dict(foo), which just prints out the attributes the object has. Looks like a typo there. I

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread Rick Johnson
On Sunday, July 6, 2014 10:03:48 AM UTC-5, rxj...@gmail.com wrote: Thanks. I do not want to waste everyone's time. Oh NOW you tell us! I could be ranting about flashlights, but here i am wasting time with you again! For a jump start, there are small errors making me frustrating. Your help

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread Rustom Mody
On Sunday, July 6, 2014 5:43:55 PM UTC+5:30, rxj...@gmail.com wrote: Hi, I type the following sample codes on Python, but it echoes differently. Regular expressions are compiled into pattern objects, which have methods for various operations such as searching for pattern matches or

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread Mark Lawrence
On 06/07/2014 16:03, rxjw...@gmail.com wrote: Thanks. I do not want to waste everyone's time. For a jump start, there are small errors making me frustrating. Your help does help me, confirm the usage etc. After a basic familiarity, I do not want to post more. I use cygwin Python, I type help of

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread Larry Hudson
On 07/06/2014 08:03 AM, rxjw...@gmail.com wrote: snip Thanks. I do not want to waste everyone's time. For a jump start, there are small errors making me frustrating. Your help does help me, confirm the usage etc. After a basic familiarity, I do not want to post more. I use cygwin Python, I

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread rxjwg98
On Sunday, July 6, 2014 4:32:14 PM UTC-4, Larry Hudson wrote: On 07/06/2014 08:03 AM, rxjw...@gmail.com wrote: snip Thanks. I do not want to waste everyone's time. For a jump start, there are small errors making me frustrating. Your help does help me, confirm the usage etc.