[issue38352] In typing docs, note explicit import needed for IO and Pattern/Match

2021-07-18 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests:  -25772

___
Python tracker 

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



[issue38352] In typing docs, note explicit import needed for IO and Pattern/Match

2021-07-18 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
nosy: +pablogsal
nosy_count: 8.0 -> 9.0
pull_requests: +25772
pull_request: https://github.com/python/cpython/pull/27228

___
Python tracker 

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



[issue38352] In typing docs, note explicit import needed for IO and Pattern/Match

2021-05-04 Thread Jelle Zijlstra

Jelle Zijlstra  added the comment:

@Łukasz thanks for your merging spree!

I'm actually not sure this should go into 3.9. Seems potentially dangerous that 
people upgrading from an earlier 3.9 patch release will now see new names 
injected into their namespace if they do `from typing import *`.

--

___
Python tracker 

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



[issue38352] In typing docs, note explicit import needed for IO and Pattern/Match

2021-05-04 Thread Łukasz Langa

Łukasz Langa  added the comment:

Fix merged to main (3.11), 3.10, and 3.9. Not applicable to older Pythons as 
they are security fixes only.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.6

___
Python tracker 

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



[issue38352] In typing docs, note explicit import needed for IO and Pattern/Match

2021-05-04 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 00726e51ade10c7e3535811eb700418725244230 by Miss Islington (bot) 
in branch '3.9':
bpo-38352: Add to typing.__all__ (GH-25821) (#25885)
https://github.com/python/cpython/commit/00726e51ade10c7e3535811eb700418725244230


--

___
Python tracker 

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



[issue38352] In typing docs, note explicit import needed for IO and Pattern/Match

2021-05-04 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset e1bcc88a502aa0239b6bcc4da3fe024307fd27f4 by Miss Islington (bot) 
in branch '3.10':
bpo-38352: Add to typing.__all__ (GH-25821) (#25884)
https://github.com/python/cpython/commit/e1bcc88a502aa0239b6bcc4da3fe024307fd27f4


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue38352] In typing docs, note explicit import needed for IO and Pattern/Match

2021-05-04 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24559
pull_request: https://github.com/python/cpython/pull/25885

___
Python tracker 

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



[issue38352] In typing docs, note explicit import needed for IO and Pattern/Match

2021-05-04 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 6.0 -> 7.0
pull_requests: +24558
pull_request: https://github.com/python/cpython/pull/25884

___
Python tracker 

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



[issue38352] In typing docs, note explicit import needed for IO and Pattern/Match

2021-05-02 Thread Jelle Zijlstra


Change by Jelle Zijlstra :


--
keywords: +patch
pull_requests: +24508
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/25821

___
Python tracker 

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



[issue38352] In typing docs, note explicit import needed for IO and Pattern/Match

2021-05-02 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

It turns out that IO, TextIO, BinaryIO, Match, and Pattern aren't in 
typing.__all__. As Walter points out above, there's no clear reason for this. I 
am submitting a PR to add them to __all__.

--
nosy: +Jelle Zijlstra

___
Python tracker 

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



[issue38352] In typing docs, note explicit import needed for IO and Pattern/Match

2020-12-04 Thread Guido van Rossum

Guido van Rossum  added the comment:

Wait, is the OP maybe that there’s a difference between typeshed an the stdlib 
typing.py?

--

___
Python tracker 

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



[issue38352] In typing docs, note explicit import needed for IO and Pattern/Match

2020-12-04 Thread Walter Dörwald

Walter Dörwald  added the comment:

Shadowing the real modules `re` and `io` by

   from typing import *

would indeed be bad, but that argument IMHO doesn't hold for the types `IO`, 
`TextIO` and `BinaryIO`, yet they are not listed in `typing.__all__`. Is there 
a reason for that? And if not, could `IO`, `TextIO` and `BinaryIO` be added to 
`typing.__all__`?

--
nosy: +doerwalter

___
Python tracker 

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



[issue38352] In typing docs, note explicit import needed for IO and Pattern/Match

2019-10-04 Thread Ivan Levkivskyi


Ivan Levkivskyi  added the comment:

> So, my request is: In the sections for the IO/TextIO/BinaryIO and 
> Pattern/Match classes, include text warning the user that these types are not 
> imported when you do `from typing import *`.

I don't think this should really be a warning, probably just a note, but 
otherwise I totally agree. Would you like to make a PR?

--

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



[issue38352] In typing docs, note explicit import needed for IO and Pattern/Match

2019-10-02 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +gvanrossum, levkivskyi

___
Python tracker 

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



[issue38352] In typing docs, note explicit import needed for IO and Pattern/Match

2019-10-02 Thread Karl Kornel


New submission from Karl Kornel :

Hello!

In https://github.com/python/cpython/blob/master/Lib/typing.py#L115-L117, there 
is a note about the io and re classes not being included in typing.__all__.  I 
am a relatively new user of typing, and I did `from typing import *` in my 
code.  I ran the code through mypy first, which reported no problems, but then 
running Python 3.6 failed with a NameError (name 'IO' is not defined).

Reading through the typing source, it's clear that this was an intentional 
decision.  So, instead of reporting a bug, I'd like to request a documentation 
enhancement!

The docs for typing make no mention of typing.io or typing.re.  So, my request 
is: In the sections for the IO/TextIO/BinaryIO and Pattern/Match classes, 
include text warning the user that these types are not imported when you do 
`from typing import *`.

--
assignee: docs@python
components: Documentation
messages: 353763
nosy: Karl Kornel, docs@python
priority: normal
severity: normal
status: open
title: In typing docs, note explicit import needed for IO and Pattern/Match
type: behavior
versions: Python 3.6

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



Pattern-match Replace - help required

2012-12-19 Thread AT
Hi,

I am new to python and web2py framework. Need urgent help to match a pattern in 
an string and replace the matched text.

I've this string (basically an sql statement):
stmnt = 'SELECT  taxpayer.id, 
 taxpayer.enc_name, 
 taxpayer.age,
 taxpayer.occupation
 FROM taxpayer WHERE (taxpayer.id IS NOT NULL);'

The requirement is to replace it with this one:
r_stmnt = 'SELECT  taxpayer.id, 
   decrypt(taxpayer.enc_name), 
   taxpayer.age,
   taxpayer.occupation
   FROM taxpayer WHERE (taxpayer.id IS NOT NULL);'

Can somebody please help?

Thanks  Regards
 

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pattern-match Replace - help required

2012-12-19 Thread Steven D'Aprano
On Wed, 19 Dec 2012 02:42:26 -0800, AT wrote:

 Hi,
 
 I am new to python and web2py framework. Need urgent help to match a
 pattern in an string and replace the matched text.
 
 I've this string (basically an sql statement): 

 stmnt = 'SELECT taxpayer.id,
  taxpayer.enc_name,
  taxpayer.age,
  taxpayer.occupation
  FROM taxpayer WHERE (taxpayer.id IS NOT NULL);'
 
 The requirement is to replace it with this one: 
 
 r_stmnt = 'SELECT taxpayer.id,
decrypt(taxpayer.enc_name),
taxpayer.age,
taxpayer.occupation
FROM taxpayer WHERE (taxpayer.id IS NOT NULL);'
 
 Can somebody please help?

Can you do this?

stmnt = r_stmnt

That should do what you are asking.

If that doesn't solve your problem, you will need to explain your problem 
in more detail.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pattern-match Replace - help required

2012-12-19 Thread AT

On Wednesday, 19 December 2012 15:51:22 UTC+5, Steven D'Aprano  wrote:
 On Wed, 19 Dec 2012 02:42:26 -0800, AT wrote:
 
 
 
  Hi,
 
  
 
  I am new to python and web2py framework. Need urgent help to match a
 
  pattern in an string and replace the matched text.
 
  
 
  I've this string (basically an sql statement): 
 
 
 
  stmnt = 'SELECT taxpayer.id,
 
   taxpayer.enc_name,
 
   taxpayer.age,
 
   taxpayer.occupation
 
   FROM taxpayer WHERE (taxpayer.id IS NOT NULL);'
 
  
 
  The requirement is to replace it with this one: 
 
  
 
  r_stmnt = 'SELECT taxpayer.id,
 
 decrypt(taxpayer.enc_name),
 
 taxpayer.age,
 
 taxpayer.occupation
 
 FROM taxpayer WHERE (taxpayer.id IS NOT NULL);'
 
  
 
  Can somebody please help?
 
 
 
 Can you do this?
 
 
 
 stmnt = r_stmnt
 
 
 
 That should do what you are asking.
 
 
 
 If that doesn't solve your problem, you will need to explain your problem 
 
 in more detail.
 
 
 
 
 
 
 
 -- 
 
 Steven


I just wanted to change taxpayer.enc_name in stmnt to decrypt(taxpayer.enc_name)

hope it clarifies?

thanks


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pattern-match Replace - help required

2012-12-19 Thread Steven D'Aprano
On Wed, 19 Dec 2012 03:01:32 -0800, AT wrote:

 I just wanted to change taxpayer.enc_name in stmnt to
 decrypt(taxpayer.enc_name)
 
 hope it clarifies?

Maybe. Does this help?

lunch = Bread, ham, cheese and tomato.
# replace ham with spam
offset = lunch.find('ham')
if offset != -1:
lunch = lunch[:offset] + 'spam' + lunch[offset + len('ham'):]
print(lunch)




-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pattern-match Replace - help required

2012-12-19 Thread Thomas Bach
On Wed, Dec 19, 2012 at 02:42:26AM -0800, AT wrote:
 Hi,
 
 I am new to python and web2py framework. Need urgent help to match a
 pattern in an string and replace the matched text.
 

Well, what about str.replace then?

 'egg, ham, tomato'.replace('ham', 'spam, ham, spam')
'egg, spam, ham, spam, tomato'


If the pattern you want to match is more complicated, have a look at
the re module!

Regards,
Thomas.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pattern-match Replace - help required

2012-12-19 Thread AT
On Wednesday, 19 December 2012 16:27:19 UTC+5, Thomas Bach  wrote:
 On Wed, Dec 19, 2012 at 02:42:26AM -0800, AT wrote:
 
  Hi,
 
  
 
  I am new to python and web2py framework. Need urgent help to match a
 
  pattern in an string and replace the matched text.
 
  
 
 
 
 Well, what about str.replace then?
 
 
 
  'egg, ham, tomato'.replace('ham', 'spam, ham, spam')
 
 'egg, spam, ham, spam, tomato'
 
 
 
 
 
 If the pattern you want to match is more complicated, have a look at
 
 the re module!
 
 
 
 Regards,
 
   Thomas.


The pattern is '%s.enc_%s', and after matching this pattern want to change it 
to 'decrypt(%s.enc_%s)' 

Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pattern-match Replace - help required

2012-12-19 Thread Peter Otten
AT wrote:

 I am new to python and web2py framework. Need urgent help to match a
 pattern in an string and replace the matched text.
 
 I've this string (basically an sql statement):
 stmnt = 'SELECT  taxpayer.id,
  taxpayer.enc_name,
  taxpayer.age,
  taxpayer.occupation
  FROM taxpayer WHERE (taxpayer.id IS NOT NULL);'
 
 The requirement is to replace it with this one:
 r_stmnt = 'SELECT  taxpayer.id,
decrypt(taxpayer.enc_name),
taxpayer.age,
taxpayer.occupation
FROM taxpayer WHERE (taxpayer.id IS NOT NULL);'
 
 Can somebody please help?

 The pattern is '%s.enc_%s', and after matching this pattern want to change
 it to 'decrypt(%s.enc_%s)'

after = re.compile(r(\w+[.]enc_\w+)).sub(rdecrypt(\1), before)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pattern-match Replace - help required

2012-12-19 Thread AT
On Wednesday, 19 December 2012 18:16:18 UTC+5, Peter Otten  wrote:
 AT wrote:
 
 
 
  I am new to python and web2py framework. Need urgent help to match a
 
  pattern in an string and replace the matched text.
 
  
 
  I've this string (basically an sql statement):
 
  stmnt = 'SELECT  taxpayer.id,
 
   taxpayer.enc_name,
 
   taxpayer.age,
 
   taxpayer.occupation
 
   FROM taxpayer WHERE (taxpayer.id IS NOT NULL);'
 
  
 
  The requirement is to replace it with this one:
 
  r_stmnt = 'SELECT  taxpayer.id,
 
 decrypt(taxpayer.enc_name),
 
 taxpayer.age,
 
 taxpayer.occupation
 
 FROM taxpayer WHERE (taxpayer.id IS NOT NULL);'
 
  
 
  Can somebody please help?
 
 
 
  The pattern is '%s.enc_%s', and after matching this pattern want to change
 
  it to 'decrypt(%s.enc_%s)'
 
 
 
 after = re.compile(r(\w+[.]enc_\w+)).sub(rdecrypt(\1), before)

Thanks a million
Can you recommend a good online book/tutorial on regular expr. in python?

Regards
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pattern-match Replace - help required

2012-12-19 Thread Alexander Blinne
Am 19.12.2012 14:41, schrieb AT:
 Thanks a million
 Can you recommend a good online book/tutorial on regular expr. in python?

http://docs.python.org/3/howto/regex.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pattern-match Replace - help required

2012-12-19 Thread MRAB

On 2012-12-19 14:11, Alexander Blinne wrote:

Am 19.12.2012 14:41, schrieb AT:

Thanks a million
Can you recommend a good online book/tutorial on regular expr. in python?


http://docs.python.org/3/howto/regex.html


Another good resource is:

http://www.regular-expressions.info/

--
http://mail.python.org/mailman/listinfo/python-list


Re: pattern match !

2007-07-15 Thread Asun Friere
On Jul 11, 9:29 pm, Helmut Jarausch [EMAIL PROTECTED]
wrote:
 import re
 P=re.compile(r'(\w+(?:[-.]\d+)+)-RHEL3-Linux\.RPM')
 S=hpsmh-1.1.1.2-0-RHEL3-Linux.RPM
 PO= P.match(S)
 if  PO :
print PO.group(1)

Isn't a regexp overkill here when this will do:

head = filename[:filename.index('-RHEL3')]

Of course if you need to make it more generic (as in Jay's solution
below), re is the way to go.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pattern match !

2007-07-14 Thread Jay Loden
[EMAIL PROTECTED] wrote:
 A slightly more generic match in case your package names turn out to be less 
 consistent than given in the test cases:

 #!/usr/bin/python

 import re
 pattern = re.compile(r'(\w+?-(\d+[\.-])+\d+?)-\D+.*RPM')
 pkgnames = [hpsmh-1.1.1.2-0-RHEL3-Linux.RPM, 
 hpsmh-1.1.1.2-RHEL3-Linux.RPM]
 for pkg in pkgnames:
   matchObj = pattern.search(pkg)
   if matchObj:
 print matchObj.group(1)

 Still assumes it will end in RPM (all caps), but if you add the flag re.I 
 to the re.compile() call, it will match case-insensitive.

 Hope that helps,

 -Jay
 
 How about if i had something like 1-3 words in the application name:
 websphere-pk543-1.1.4.2-1-RHEL3-i386.rpm (in this case are 2 words)?

Try this instead then:

#!/usr/bin/python

import re
pattern = re.compile(r'((\w+?-)+?(\d+[\.-])+\d+?)-\D+.*RPM', re.I)
pkgnames = [hpsmh-1.1.1.2-0-RHEL3-Linux.RPM, hpsmh-1.1.1.2-RHEL3-Linux.RPM, 
websphere-pk543-1.1.4.2-1-RHEL3-i386.rpm]
for pkg in pkgnames:
  matchObj = pattern.search(pkg)
  if matchObj:
print matchObj.group(1)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pattern match !

2007-07-11 Thread Helmut Jarausch
[EMAIL PROTECTED] wrote:
 Extract the application name with version from an RPM string like
 hpsmh-1.1.1.2-0-RHEL3-Linux.RPM, i require to extract hpsmh-1.1.1.2-0
 from above string. Sometimes the RPM string may be hpsmh-1.1.1.2-RHEL3-
 Linux.RPM.
 

Have a try with

import re
P=re.compile(r'(\w+(?:[-.]\d+)+)-RHEL3-Linux\.RPM')
S=hpsmh-1.1.1.2-0-RHEL3-Linux.RPM
PO= P.match(S)
if  PO :
   print PO.group(1)



-- 
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pattern match !

2007-07-11 Thread Jay Loden

Helmut Jarausch wrote:
 [EMAIL PROTECTED] wrote:
 Extract the application name with version from an RPM string like
 hpsmh-1.1.1.2-0-RHEL3-Linux.RPM, i require to extract hpsmh-1.1.1.2-0
 from above string. Sometimes the RPM string may be hpsmh-1.1.1.2-RHEL3-
 Linux.RPM.

 
 Have a try with
 
 import re
 P=re.compile(r'(\w+(?:[-.]\d+)+)-RHEL3-Linux\.RPM')
 S=hpsmh-1.1.1.2-0-RHEL3-Linux.RPM
 PO= P.match(S)
 if  PO :
print PO.group(1)


A slightly more generic match in case your package names turn out to be less 
consistent than given in the test cases:

#!/usr/bin/python

import re
pattern = re.compile(r'(\w+?-(\d+[\.-])+\d+?)-\D+.*RPM')
pkgnames = [hpsmh-1.1.1.2-0-RHEL3-Linux.RPM, hpsmh-1.1.1.2-RHEL3-Linux.RPM]
for pkg in pkgnames:
  matchObj = pattern.search(pkg)
  if matchObj:
print matchObj.group(1)

Still assumes it will end in RPM (all caps), but if you add the flag re.I to 
the re.compile() call, it will match case-insensitive. 

Hope that helps, 

-Jay
-- 
http://mail.python.org/mailman/listinfo/python-list


pattern match !

2007-07-10 Thread hari . siri74
Extract the application name with version from an RPM string like
hpsmh-1.1.1.2-0-RHEL3-Linux.RPM, i require to extract hpsmh-1.1.1.2-0
from above string. Sometimes the RPM string may be hpsmh-1.1.1.2-RHEL3-
Linux.RPM.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pattern match !

2007-07-10 Thread Steven D'Aprano
On Wed, 11 Jul 2007 03:40:06 +, hari.siri74 wrote:

 Extract the application name with version from an RPM string like
 hpsmh-1.1.1.2-0-RHEL3-Linux.RPM, i require to extract hpsmh-1.1.1.2-0
 from above string. Sometimes the RPM string may be hpsmh-1.1.1.2-RHEL3-
 Linux.RPM.

Thank you for sharing.

The answer to your problem is here: 
http://tinyurl.com/anel


-- 
Steven.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pattern match !

2007-07-10 Thread Asun Friere
On Jul 11, 1:40 pm, [EMAIL PROTECTED] wrote:
 Extract the application name with version from an RPM string like
 hpsmh-1.1.1.2-0-RHEL3-Linux.RPM, i require to extract hpsmh-1.1.1.2-0
 from above string. Sometimes the RPM string may be hpsmh-1.1.1.2-RHEL3-
 Linux.RPM.

Now that list-like splicing and indexing works on strings, why not
just splice the string, using .index to locate '-RHEL'?

-- 
http://mail.python.org/mailman/listinfo/python-list