[issue31969] re.groups() is not checking the arguments

2017-11-07 Thread Narendra

New submission from Narendra :

Hi Team,

I have observed a bug in re.groups() function behavior in Python as below:

Issue:
re.groups() is not validating the arguments

Example:
>>> m = re.match(r'(\w+)@(\w+)\.(\w+)','usern...@hackerrank.com')
>>> m.groups()
('username', 'hackerrank', 'com')
>>> m.groups(1)
('username', 'hackerrank', 'com')
>>> m.groups(1000)
('username', 'hackerrank', 'com')
>>>

>From the above, its clear that re.groups() and re.groups() both are 
>same. I think re.groups() is not validating the arguments.

Please review the same and provide your comments whether my views are correct 
or wrong

--
components: Regular Expressions
messages: 305751
nosy: ezio.melotti, mrabarnett, narendrac
priority: normal
severity: normal
status: open
title: re.groups() is not checking the arguments
type: behavior
versions: Python 2.7

___
Python tracker 
<https://bugs.python.org/issue31969>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31969] re.groups() is not checking the arguments

2017-11-07 Thread Narendra

Narendra  added the comment:

Please look in to the following example:

>>> m.groups()
('narendra', 'happiestmidns', 'com')
>>> m.groups(1)
('narendra', 'happiestmidns', 'com')
>>> m.groups(34)
('narendra', 'happiestmidns', 'com')
>>> m.groups(1000)
('narendra', 'happiestmidns', 'com')
>>>

--
status: closed -> open

___
Python tracker 
<https://bugs.python.org/issue31969>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31969] re.groups() is not checking the arguments

2017-11-07 Thread Narendra

Narendra  added the comment:

Hi Storchaka,

As per re.groups(), its should work as below:

groups([default])
Return a tuple containing all the subgroups of the match, from 1 up to however 
many groups are in the pattern. The default argument is used for groups that 
did not participate in the match; it defaults to None. (Incompatibility note: 
in the original Python 1.5 release, if the tuple was one element long, a string 
would be returned instead. In later versions (from 1.5.1 on), a singleton tuple 
is returned in such cases.)

For example:

>>> m = re.match(r"(\d+)\.(\d+)", "24.1632")
>>> m.groups()
('24', '1632')
If we make the decimal place and everything after it optional, not all groups 
might participate in the match. These groups will default to None unless the 
default argument is given:

>>> m = re.match(r"(\d+)\.?(\d+)?", "24")
>>> m.groups()  # Second group defaults to None.
('24', None)
>>> m.groups('0')   # Now, the second group defaults to '0'.
('24', '0')

I tested some scenario as below:
Scenario: Suppose i have a match like 
m = re.match(r"(\d+)\.(\d+)", "24.1632")
Here if i pass m.groups(1), then it should check if there is optional match 
(optional match, pattern which is specified using ?), it should print 1 in 
that match and if not, it should throw error that there is no any optional 
match (didn't have any pattern with ?).

Expected Output:
>>> m.groups(1)
There is no any optional argument to use 1

Received Output:
>>> m.groups(1)
'24', '1632')

Please review the above and provide your comments?

--
resolution: not a bug -> 
status: closed -> open

___
Python tracker 
<https://bugs.python.org/issue31969>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45368] ~(True) and ~(False) gives incorrect result

2021-10-04 Thread Narendra Madurkar


New submission from Narendra Madurkar :

~(True) returns -2
~(False) returns -1

--
messages: 403190
nosy: nmadurkar
priority: normal
severity: normal
status: open
title: ~(True) and ~(False) gives incorrect result

___
Python tracker 
<https://bugs.python.org/issue45368>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45368] ~(True) and ~(False) gives incorrect result

2021-10-04 Thread Narendra Madurkar


Narendra Madurkar  added the comment:

True is a boolean so ~True should return False according to me.
True is not the same as 1

--

___
Python tracker 
<https://bugs.python.org/issue45368>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32772] lstrip not working when string has =e in it

2018-02-05 Thread Narendra L

New submission from Narendra L :

Lstrip not working as expected when the string has "=e" in it.

Python 2.7.11 (default, Jan 22 2016, 08:28:37)

>>> test = "Cookie:  test-Debug=edttrace=expires=1517828996"
>>> test.lstrip('Cookie:  test-Debug=')
'dttrace=expires=1517828996'

--
components: Library (Lib)
messages: 311659
nosy: Narendra L
priority: normal
severity: normal
status: open
title: lstrip not working when string has =e in it
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 
<https://bugs.python.org/issue32772>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32772] lstrip not working when string has =e in it

2018-02-05 Thread Narendra L

Narendra L  added the comment:

If you see output dttrace e is missing 

see working example
>>> test = "Cookie:  test-Debug=edttrace=expires=1517828996"
>>> test.lstrip('Cookie:  test-Debug=')
'dttrace=expires=1517828996'
# e missing here


>>> test = "Cookie:  test-Debug=adttrace=expires=1517828996"
>>> test.lstrip('Cookie:  test-Debug=')
'adttrace=expires=1517828996'
# Works correct here

--

___
Python tracker 
<https://bugs.python.org/issue32772>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com