On 06/07/2011 06:30 PM, Roy Smith wrote: > On 06/06/2011 08:33 AM, rusi wrote: >>> Evidently for syntactic, implementation and cultural reasons, Perl >>> programmers are likely to get (and then overuse) regexes faster than >>> python programmers. > > "ru...@yahoo.com" <ru...@yahoo.com> wrote: >> I don't see how the different Perl and Python cultures themselves >> would make learning regexes harder for Python programmers. > > Oh, that part's obvious. People don't learn things in a vacuum. They > read about something, try it, fail, and ask for help. If, in one > community, the response they get is, "I see what's wrong with your > regex, you need to ...", and in another they get, "You shouldn't be > using a regex there, you should use this string method instead...", it > should not be a surprise that it's easier to learn about regexes in the > first community.
I think we are just using different definitions of "harder". I said, immediately after the sentence you quoted, >> At >> most I can see the Perl culture encouraging their use and >> the Python culture discouraging it, but that doesn't change >> the ease or difficulty of learning. Constantly being told not to use regexes certainly discourages one from learning them, but I don't think that's the same as being *harder* to learn in Python. The syntax of regexes is, at least at the basic level, pretty universal, and it is in learning to understand that syntax that most of any difficulty lies. Whether to express a regex as "/code (blue)|(red)/i" in Perl or "(r'code (blue)|(red)', re.I)" in Python is a superficial difference, as is, say, using match results: "$alert = $1' vs "alert = m.group(1)". A Google for "python regular expression tutorial" produces lots of results including the Python docs HOWTO. And because the syntax is pretty universal, leaving the "python" off that search string will yield many, many more that are applicable. Although one does get some "don't do that" responses to regex questions on this list (and some are good advice), there are also usually answers too. So I think of it as more of a Python culture thing, rather then being actually harder to learn to use regexes in Python although I see how one can view it your way too. -- http://mail.python.org/mailman/listinfo/python-list