Re: context manager based alternative to Re: Proposal: === and !===

2014-07-10 Thread Chris Angelico
On Fri, Jul 11, 2014 at 11:17 AM, Roy Smith wrote: > In article , > Cameron Simpson wrote: > >> Q: How many user support people does it take to change a light bulb? >> A: We have an exact copy of the light bulb here and it seems to be >> working fine. Can you tell me what kind of system you

Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example

2014-07-10 Thread Chris Angelico
On Fri, Jul 11, 2014 at 1:33 PM, Roy Smith wrote: >> Or heck, use a multi-line verbose expression and comment it for >> clarity: >> >> r = re.compile(r""" >> (# begin a capture group >> \({2} # two literal "(" characters >> [^)]+ # one or more non-close-pare

Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example

2014-07-10 Thread Roy Smith
In article , Tim Chase wrote: > On 2014-07-10 22:18, Roy Smith wrote: > > > Outside this are \( and \): these are literal opening and closing > > > bracket characters. So: > > > > > >\(\([^)]+\)\) > > > > although, even better would be to use to utterly awesome > >> re.VERBOSE > > flag, an

Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example

2014-07-10 Thread Tim Chase
On 2014-07-10 22:18, Roy Smith wrote: > > Outside this are \( and \): these are literal opening and closing > > bracket characters. So: > > > >\(\([^)]+\)\) > > although, even better would be to use to utterly awesome >> re.VERBOSE > flag, and write it as: > > \({2} [^)]+ \){2} Or heck

Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example

2014-07-10 Thread Roy Smith
In article , Cameron Simpson wrote: > Outside this are \( and \): these are literal opening and closing bracket > characters. So: > >\(\([^)]+\)\) > Two opening brackets, then at least one character which is not a > closing bracket, then two closing brackets. This is a

Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example

2014-07-10 Thread Cameron Simpson
On 10Jul2014 08:37, fl wrote: This example is from the link: https://wiki.python.org/moin/RegularExpression I have thought about it quite a while without a clue yet. I notice that it uses double quote ", in contrast to ' which I see more often until now. With raw strings (r', r") this doesn'

Re: How can i get http body??

2014-07-10 Thread Frank Liou
Got it Thanks you -- https://mail.python.org/mailman/listinfo/python-list

Re: context manager based alternative to Re: Proposal: === and !===

2014-07-10 Thread Roy Smith
In article , Cameron Simpson wrote: > Q: How many user support people does it take to change a light bulb? > A: We have an exact copy of the light bulb here and it seems to be > working fine. Can you tell me what kind of system you have? So, what are we talking about here? my_lightbulb ==

Re: context manager based alternative to Re: Proposal: === and !===

2014-07-10 Thread Ethan Furman
On 07/10/2014 05:20 PM, Cameron Simpson wrote: I posted this the other day and haven't seen a response, not even a scathing rejection... Here's an alternative proposal that doesn't involve a new operator. [snip float-context manager stuff] Decimal has a context manager like that already (I

context manager based alternative to Re: Proposal: === and !===

2014-07-10 Thread Cameron Simpson
operators Reply-To: In-Reply-To: <20140709231623.ga66...@cskk.homeip.net> I posted this the other day and haven't seen a response, not even a scathing rejection... Here's an alternative proposal that doesn't involve a new operator. Consider this code snippet: with float.behaviour(nan_eq=Tr

Re: Solution-resistant AttributeError: 'modle' object has no attribute...

2014-07-10 Thread Steven D'Aprano
On Thu, 10 Jul 2014 13:31:56 -0400, Joel Goldstick wrote: >> dummy = higgins.models.extract_guid_from_visi_filename >> AttributeError: 'module' object has no attribute >> 'extract_guid_from_visi_filename' > > Do you need to add parens? is this a method, not at attribute? > dummy = higgin

Re: open() and EOFError

2014-07-10 Thread Anssi Saari
Roy Smith writes: > I once knew a guy who linked /dev/tty.c to /dev/tty, then he could do > "cc /dev/tty.c" and type a C program in to the compiler from the > terminal. I thought some old C compilers took input from stdin without that kind of trickery? Oh, looks like modern gcc does it too, as

Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example

2014-07-10 Thread Albert-Jan Roskam
- Original Message - > From: Joel Goldstick > To: fl > Cc: "python-list@python.org" > Sent: Thursday, July 10, 2014 7:05 PM > Subject: Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example > > On Thu, Jul 10, 2014 at 11:37 AM, fl wrote: >> Hi, >> >> This example is from

Re: Help me write better Code

2014-07-10 Thread Rustom Mody
On Wednesday, July 9, 2014 9:14:01 PM UTC+5:30, Mark Lawrence wrote: > On 09/07/2014 15:27, sssdevelop wrote: > > Hello, > > I have working code - but looking for better/improved code. Better coding > > practices, better algorithm :) > > Problem: Given sequence of increasing integers, print blocks

Re: I am confused about ' and "

2014-07-10 Thread Chris “Kwpolska” Warrick
On Jul 10, 2014 7:53 PM, "fl" wrote: > > Hi, > > It is still in the Regular expression operations concept, this link: > > has example using single quote mark: ' > > https://docs.python.org/2/library/re.html#re.split > > > While in this link: > > https://docs.python.org/3/howto/regex.html > > > It

Re: I am confused about ' and "

2014-07-10 Thread Joel Goldstick
On Thu, Jul 10, 2014 at 1:01 PM, fl wrote: > Hi, > > It is still in the Regular expression operations concept, this link: You must have missed my comment about quote and double quote. In python you can write a string using either. Just make sure if you start with double quote, you must end with

Re: Emperor's New Coroutines?

2014-07-10 Thread Marko Rauhamaa
Marko Rauhamaa : > The asyncio module comes with coroutine support. Investigating the > topic on the net reveals that FSM's are for old people and the brave > new world uses coroutines. Unfortunately, all examples I could find > seem to be overly simplistic, and I'm left thinking coroutines have >

Re: I am confused about ' and "

2014-07-10 Thread Chris Angelico
On Fri, Jul 11, 2014 at 3:01 AM, fl wrote: > Please tell me because I have looked it around for one hour about it. > It's high time you started at the beginning, rather than trying to learn regexps without understanding Python. https://docs.python.org/3/tutorial/index.html Start there. You will

Re: Solution-resistant AttributeError: 'modle' object has no attribute...

2014-07-10 Thread Joel Goldstick
On Thu, Jul 10, 2014 at 12:41 PM, Dan Stromberg wrote: > Hi folks. > > I'm having trouble with a strange AttributeError. I'm using RQ (Redis > Queue) and Django, both of which are new to me, so perhaps they are > somehow relevant. > > Anyway, the traceback looks like: > Traceback (most recent cal

Re: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean?

2014-07-10 Thread Ian Kelly
On Thu, Jul 10, 2014 at 9:23 AM, fl 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

Re: Solution-resistant AttributeError: 'modle' object has no attribute...

2014-07-10 Thread Dan Stromberg
On Thu, Jul 10, 2014 at 9:41 AM, Dan Stromberg wrote: > Hi folks. > > I'm having trouble with a strange AttributeError. I'm using RQ (Redis > Queue) and Django, both of which are new to me, so perhaps they are > somehow relevant. > > Anyway, the traceback looks like: > Traceback (most recent call

Re: I am confused about ' and "

2014-07-10 Thread John Gordon
In fl writes: > Please tell me because I have looked it around for one hour about it. There is no difference between ' and " when used to enclose strings, with one exception: a double-quoted string can contain single-quotes without the need to escape them with a backslash, and vice-versa. For

Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example

2014-07-10 Thread Joel Goldstick
On Thu, Jul 10, 2014 at 11:37 AM, fl wrote: > Hi, > > This example is from the link: > > https://wiki.python.org/moin/RegularExpression > > > I have thought about it quite a while without a clue yet. I notice that it > uses > double quote ", in contrast to ' which I see more often until now. Dou

I am confused about ' and "

2014-07-10 Thread fl
Hi, It is still in the Regular expression operations concept, this link: has example using single quote mark: ' https://docs.python.org/2/library/re.html#re.split While in this link: https://docs.python.org/3/howto/regex.html It gives table with quote: " Regular String Raw string "ab*"

Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example

2014-07-10 Thread MRAB
On 2014-07-10 16:37, fl wrote: Hi, This example is from the link: https://wiki.python.org/moin/RegularExpression I have thought about it quite a while without a clue yet. I notice that it uses double quote ", in contrast to ' which I see more often until now. It looks very complicated to me.

Re: Solution-resistant AttributeError: 'modle' object has no attribute...

2014-07-10 Thread Chris Angelico
On Fri, Jul 11, 2014 at 2:41 AM, Dan Stromberg wrote: > It's as though an old version of the module is being > seen, rather than the current version. > > Anyone have any (further) suggestions for me? > Wipe out *.pyc and try again? Restart any processes that are running Django, in case they have

Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example

2014-07-10 Thread Peter Otten
fl wrote: > Hi, > > This example is from the link: > > https://wiki.python.org/moin/RegularExpression > > > I have thought about it quite a while without a clue yet. I notice that it > uses double quote ", in contrast to ' which I see more often until now. > It looks very complicated to me. Co

Re: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean?

2014-07-10 Thread MRAB
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) Yo

Solution-resistant AttributeError: 'modle' object has no attribute...

2014-07-10 Thread Dan Stromberg
Hi folks. I'm having trouble with a strange AttributeError. I'm using RQ (Redis Queue) and Django, both of which are new to me, so perhaps they are somehow relevant. Anyway, the traceback looks like: Traceback (most recent call last): File "/home/ec2-user/miniconda/envs/sciencedb/lib/python2.

Re: Proposal: === and !=== operators

2014-07-10 Thread Alex Burke
On 9 July 2014 09:00, Steven D'Aprano wrote: > At the moment, Python has two (in)equality operators, == and != which > call __eq__ and __ne__ methods. Some problems with those: > > > * Many people expect == to always be reflexive (that is, x == x for > every x) but classes which customise __eq__

How to decipher :re.split(r"(\(\([^)]+\)\))" in the example

2014-07-10 Thread fl
Hi, This example is from the link: https://wiki.python.org/moin/RegularExpression I have thought about it quite a while without a clue yet. I notice that it uses double quote ", in contrast to ' which I see more often until now. It looks very complicated to me. Could you simplified it to a simp

Re: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean?

2014-07-10 Thread fl
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 sho

Re: Help me write better Code

2014-07-10 Thread Mark Lawrence
On 10/07/2014 15:39, sssdevelop wrote: Mark - thank you so much. You have suggested be new best tool/module. It's going to help me many places. Was not aware of such powerful tool. thank you, I'm pleased to see that you have several answers. In return would you please use the mailing list

Re: Help me write better Code

2014-07-10 Thread sssdevelop
Mark - thank you so much. You have suggested be new best tool/module. It's going to help me many places. Was not aware of such powerful tool. thank you, On Wednesday, July 9, 2014 9:14:01 PM UTC+5:30, Mark Lawrence wrote: > On 09/07/2014 15:27, sssdevelop wrote: > > > Hello, > > > > > > I

Re: Help me write better Code

2014-07-10 Thread sssdevelop
thank you so much! On Wednesday, July 9, 2014 11:46:41 PM UTC+5:30, Ian wrote: > On Wed, Jul 9, 2014 at 8:27 AM, sssdevelop wrote: > > > prev = 0 > > > blocks = [] > > > tmp = [] > > > last = 0 > > > for element in a: > > >if prev == 0: > > > > Is 0 allowed to be in the input list?

Re: Help me write better Code

2014-07-10 Thread sssdevelop
Thank you so much Terry Jan Reedy. You have given best advice - yup, i am beginner in Python. Your reply has done grooming :) thx, On Thursday, July 10, 2014 12:16:48 AM UTC+5:30, Terry Reedy wrote: > On 7/9/2014 10:27 AM, sssdevelop wrote: > > > Hello, > > > > > > I have working code -

Re: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean?

2014-07-10 Thread Joel Goldstick
On Thu, Jul 10, 2014 at 10:04 AM, fl 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

Re: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean?

2014-07-10 Thread Chris “Kwpolska” Warrick
On Thu, Jul 10, 2014 at 4:04 PM, fl 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 t

Re: Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]?

2014-07-10 Thread MRAB
On 2014-07-10 14:32, fl wrote: On Thursday, July 10, 2014 7:18:01 AM UTC-4, MRAB wrote: It's equivalent to [ \t\n\r\f], i.e. it also includes a space, so either the tutorial is wrong, or you didn't look closely enough. :-) The string starts with ' ', not '\t'. The string starts with ' ', which

What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean?

2014-07-10 Thread fl
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?

Re: How can i get http body??

2014-07-10 Thread Roy Smith
In article <4574254f-e813-4f16-bafb-cbd649496...@googlegroups.com>, Frank Liou wrote: > https://lh5.googleusercontent.com/-6t5tmr5T4Ys/U74FdF128oI/Bvo/bYyaHzs > dw9Q/s1600/%E6%9C%AA%E5%91%BD%E5%90%8D.jpg > > how can i catch the "body" when i was post ?? Take a look at the wonderful r

Re: Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]?

2014-07-10 Thread Ned Batchelder
On 7/10/14 9:32 AM, fl wrote: On Thursday, July 10, 2014 7:18:01 AM UTC-4, MRAB wrote: On 2014-07-10 11:05, r...@gmail.com wrote: It's equivalent to [ \t\n\r\f], i.e. it also includes a space, so either the tutorial is wrong, or you didn't look closely enough. :-) The string starts with ' ',

Re: Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]?

2014-07-10 Thread fl
On Thursday, July 10, 2014 7:18:01 AM UTC-4, MRAB wrote: > On 2014-07-10 11:05, r...@gmail.com wrote: > > It's equivalent to [ \t\n\r\f], i.e. it also includes a space, so > > either the tutorial is wrong, or you didn't look closely enough. :-) > > > The string starts with ' ', not '\t'. > >

Re: NaN comparisons - Call For Anecdotes

2014-07-10 Thread Chris Angelico
On Thu, Jul 10, 2014 at 9:28 PM, MRAB wrote: > I can think of one place where equality of NaNs would be useful: > sorting. > > However, in that use-case, you would also want it to be orderable, > perhaps greater than any other non-NaN float. In that case, you're setting special rules, so you prob

Re: NaN comparisons - Call For Anecdotes

2014-07-10 Thread MRAB
On 2014-07-10 01:57, Ben Finney wrote: "Anders J. Munch" <2...@jmunch.dk> writes: Joel Goldstick wrote: > I've been following along here, and it seems you haven't received > the answer you want or need. So far I received exactly the answer I was expecting. 0 examples of NaN!=NaN being benefici

Re: Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]?

2014-07-10 Thread MRAB
On 2014-07-10 11:05, rxjw...@gmail.com wrote: Hi, On a tutorial it says that '\s': Matches whitespace. Equivalent to [\t\n\r\f]. It's equivalent to [ \t\n\r\f], i.e. it also includes a space, so either the tutorial is wrong, or you didn't look closely enough. :-) I test it with: re.match(r

Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]?

2014-07-10 Thread rxjwg98
Hi, On a tutorial it says that '\s': Matches whitespace. Equivalent to [\t\n\r\f]. I test it with: >>> re.match(r'\s*\d\d*$', ' 111') <_sre.SRE_Match object at 0x03642BB8> >>> re.match(r'\t\n\r\f*\d\d*$', ' 111')# fails >>> re.match(r'[\t\n\r\f]*\d\d*$', ' 111') # fails >>> re.match(r'

Re: How to write match nth grouped subexpression?

2014-07-10 Thread Cameron Simpson
On 10Jul2014 01:57, rxjw...@gmail.com wrote: It says that: match checks for a match only at the beginning of the string. Then, it also says that: \1...\9Matches nth grouped subexpression. I don't know how to write a script to include grouped subexpression in match? A grouped subexpres

Re: abrt: detected unhandled Python exception

2014-07-10 Thread shivagunwant
On Monday, 30 December 2013 01:05:32 UTC+5:30, smileso...@gmail.com wrote: > Hi all, > > I am facing a script issue whenever i run my script in /var/log/messages > and it gives error something as below: > > > > > > abrt: detected unhandled Python exception in x.py. > > > > Can anyb

How to write match nth grouped subexpression?

2014-07-10 Thread rxjwg98
Hi, It says that: match checks for a match only at the beginning of the string. Then, it also says that: \1...\9Matches nth grouped subexpression. I don't know how to write a script to include grouped subexpression in match? Thanks, -- https://mail.python.org/mailman/listinfo/python-l

Re: NaN comparisons - Call For Anecdotes

2014-07-10 Thread alister
On Wed, 09 Jul 2014 23:09:36 +0200, Anders J. Munch wrote: > Ethan Furman: >> I would suggest you ask for this on the numerical mailing lists instead >> of here -- and you may not want to offer a beer to everyone that has an >> anecdote for NaN behavior being useful. > I don't have time to start t