how to obtain the text for BeautifulSoup object

2018-03-19 Thread Nathan Zhu
Hi Team, could anyone help me? for webpage having source code like this: ... number name I only can use below sentence, since there are a lot of tag em and tag a in other area. output = bs4.BeautifulSoup(res.content,'lxml').findAll("span",{"class":"xst thread-name"}) how can I get

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-19 Thread Eryk Sun
Eryk Sun added the comment: > the way `python -m pip` searches for the module to execute is much > closer to the way Windows searches for a command like `pip` (i.e. > current directory first) That's classic Windows behavior. However, search paths for CreateProcess and the

Re: Thank you Python community!

2018-03-19 Thread Rick Johnson
On Monday, March 19, 2018 at 6:37:21 PM UTC-5, Ben Finney wrote: > -- > \ "Success is going from one failure to the next without a loss | > `\ of enthusiasm." -- Winston Churchill | > _o__) | >

[issue33089] Add multi-dimensional Euclidean distance function to the math module

2018-03-19 Thread Tim Peters
Tim Peters added the comment: Mark, how about writing a clever single-rounding dot product that merely _detects_ when it encounters troublesome cases? If so, it can fall back to a (presumably) much slower method. For example, like this for the latter: def srdp(xs, ys):

[issue33100] dataclasses and __slots__ - non-default argument (member_descriptor)

2018-03-19 Thread Eric V. Smith
Change by Eric V. Smith : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue33100] dataclasses and __slots__ - non-default argument (member_descriptor)

2018-03-19 Thread Eric V. Smith
Eric V. Smith added the comment: New changeset 3d41f482594b6aab12a316202b3c06757262109a by Eric V. Smith (Miss Islington (bot)) in branch '3.7': bpo-33100: Dataclasses now handles __slots__ and default values correctly. (GH-6152) (GH-6153)

[issue33094] dataclasses: ClassVar attributes are not working properly

2018-03-19 Thread Eric V. Smith
Eric V. Smith added the comment: Are there any remaining issues here? If not, I'm going to close this issue. -- status: open -> pending ___ Python tracker

[issue33105] os.path.isfile returns false on Windows when file path is longer than 260 characters

2018-03-19 Thread Eryk Sun
Eryk Sun added the comment: > If you use os.listdir() on the networked folder, the log file > will come up. Querying a file's parent directory (e.g. via os.scandir in Python 3) can provide a basic stat (i.e. attributes, reparse tag, size, and timestamps) when opening the

[issue33103] Syntax to get multiple arbitrary items from an iterable

2018-03-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: FWIW, there is already a way to do this but it involves the extra step of applying map() to a bound method: >>> my_list = ["John", "Richard", "Alice", 1, True, 2.1, "End"] >>> a, b, c = map(my_list.__getitem__, [1, 3, -1]) >>>

[issue1467929] %-formatting and dicts

2018-03-19 Thread Eric V. Smith
Change by Eric V. Smith : -- assignee: eric.smith -> ___ Python tracker ___ ___

[issue33100] dataclasses and __slots__ - non-default argument (member_descriptor)

2018-03-19 Thread Eric V. Smith
Eric V. Smith added the comment: New changeset 7389fd935c95b4b6f094312294e703ee0de18719 by Eric V. Smith in branch 'master': bpo-33100: Dataclasses now handles __slots__ and default values correctly. (GH-6152)

[issue33100] dataclasses and __slots__ - non-default argument (member_descriptor)

2018-03-19 Thread miss-islington
Change by miss-islington : -- pull_requests: +5911 ___ Python tracker ___

Re: {:2X} didn't output what I expected

2018-03-19 Thread Chris Angelico
On Tue, Mar 20, 2018 at 11:32 AM, wrote: > Chris Angelico於 2018年3月20日星期二 UTC+8上午8時06分05秒寫道: >> On Tue, Mar 20, 2018 at 10:46 AM, wrote: >> > D:\Temp>py >> > Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 >> > bit (Intel)] on

[issue33105] os.path.isfile returns false on Windows when file path is longer than 260 characters

2018-03-19 Thread Eryk Sun
Eryk Sun added the comment: Python 2.7 is all but set in stone. Changes to its behavior have to correct serious bugs, not work around limits in an OS. You can do that yourself. For example, use an extended local-device path, i.e. a path that's prefixed by u"?\\". This

[issue33100] dataclasses and __slots__ - non-default argument (member_descriptor)

2018-03-19 Thread Eric V. Smith
Change by Eric V. Smith : -- keywords: +patch pull_requests: +5910 stage: -> patch review ___ Python tracker ___

Re: {:2X} didn't output what I expected

2018-03-19 Thread jfong
Chris Angelico於 2018年3月20日星期二 UTC+8上午8時06分05秒寫道: > On Tue, Mar 20, 2018 at 10:46 AM, wrote: > > D:\Temp>py > > Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 > > bit (Intel)] on win32 > > Type "help", "copyright", "credits" or "license" for more

[issue33087] No reliable clean shutdown method

2018-03-19 Thread Brett Cannon
Change by Brett Cannon : -- type: behavior -> enhancement versions: +Python 3.8 -Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7 ___ Python tracker

Re: {:2X} didn't output what I expected

2018-03-19 Thread Chris Angelico
On Tue, Mar 20, 2018 at 10:46 AM, wrote: > D:\Temp>py > Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit > (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. '{:02X}'.format(256) > '100' > What I

Re: Thank you Python community!

2018-03-19 Thread Etienne Robillard
Le 2018-03-19 à 19:36, Ben Finney a écrit : Etienne Robillard writes: I would like to make such an experimental research/investigation on the effects of Python software programming on opioid addiction. :-) Okay. The wording of your message implied that you know this

{:2X} didn't output what I expected

2018-03-19 Thread jfong
D:\Temp>py Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> '{:02X}'.format(256) '100' >>> What I expected is '00'. Am I wrong? Best Regards, Jach Fong --

Re: Style Q: Instance variables defined outside of __init__

2018-03-19 Thread Steven D'Aprano
On Mon, 19 Mar 2018 10:04:53 -0700, Irv Kalb wrote: > Some people say > that this type of thing is fine and these warnings should just be > ignored. While others say that all instance variables should be defined > in the __init__ method. Whenever anyone says "you should do this", the question

Re: Thank you Python community!

2018-03-19 Thread Ben Finney
Etienne Robillard writes: > I would like to make such an experimental research/investigation on > the effects of Python software programming on opioid addiction. :-) Okay. The wording of your message implied that you know this already happens now, though. How did you come to

Re: Thank you Python community!

2018-03-19 Thread Etienne Robillard
Hi Ben, Thank you for your reply. I would like to make such an experimental research/investigation on the effects of Python software programming on opioid addiction. :-) Probably studying the learning of Python in people with cocaine and heroin addiction would be significant and

[issue3405] Add support for the new data option supported by event generate (Tk 8.5)

2018-03-19 Thread Matthias Kievernagel
Change by Matthias Kievernagel : -- nosy: +mkiever ___ Python tracker ___ ___

[issue33100] dataclasses and __slots__ - non-default argument (member_descriptor)

2018-03-19 Thread Eric V. Smith
Eric V. Smith added the comment: Thanks, but I'm already looking at this in the context of a different bug. -- ___ Python tracker

Re: Style Q: Instance variables defined outside of __init__

2018-03-19 Thread Ben Finney
Irv Kalb writes: > In this class, I get warnings on the single lines of the conceal and > reveal methods. This is good! It prompts the question: Why are those methods defined as they are? If those methods are only ever intended to set the value of an attribute: Why not

Re: Thank you Python community!

2018-03-19 Thread Ben Finney
Etienne Robillard writes: > I would like to thank you guys sincerely for helping a lot of people > to stay clean, and focus on programming high-level stuff in Python > instead of doing some really nasty drugs. Thank you for the kind words. I'd love to believe the Python

[issue33100] dataclasses and __slots__ - non-default argument (member_descriptor)

2018-03-19 Thread Adrian Stachlewski
Adrian Stachlewski added the comment: There's also another major problem. Because Base.x has value, __init__ is not prepared correctly (member_descriptor is passed as default). @dataclass class Base: __slots__ = ('x',) x: Any Base() # No TypeError

[issue33106] Deleting a key in a read-only gdbm results in KeyError, not gdbm.error

2018-03-19 Thread sds
sds added the comment: Same problem with 3.6.4, start with >>> from dbm import gnu as gdbm then the same incorrect behavior -- versions: +Python 3.6 -Python 2.7 ___ Python tracker

[issue33106] Deleting a key in a read-only gdbm results in KeyError, not gdbm.error

2018-03-19 Thread sds
New submission from sds : deleting a key from a read-only gdbm should be gdbm.error, not KeyError: >>> import gdbm >>> db = gdbm.open("foo","n") # create new >>> db["a"] = "b" >>> db.close() >>> db = gdbm.open("foo","r") # read only >>> db["x"] = "1" Traceback (most recent

Re: Missing python36.dll

2018-03-19 Thread Jerry Hill
On Mon, Mar 19, 2018 at 5:07 PM, MRAB wrote: > You didn't say which installer you used. > ​It might also be helpful to know: Did you install python for "Just Me" or "All Users" in the installer? Does the user you're logged in as have enough authority to install for

Re: Missing python36.dll

2018-03-19 Thread MRAB
On 2018-03-19 19:33, Adrian Ordona wrote: Hi - just downloaded the latest version of Python (3.6.4) but keep getting an error because of missing .dll file. i tried uninstalling and reinstalling it but still getting the same error. Search online for the file but to no avail. Can someone direct

Re: Thank you Python community!

2018-03-19 Thread Etienne Robillard
Le 2018-03-19 à 15:21, Larry Martell a écrit : On Mon, Mar 19, 2018 at 12:08 PM, Etienne Robillard wrote: You guys just made me realize something very obvious. :-) I'm in the process right now of watching the excellent documentary named "Drugs Inc." on Netflix and I'm

[issue31550] Inconsistent error message for TypeError with subscripting

2018-03-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: > it's different than python3 (for no good reason?) Python 3 has new style classes which were always different. > main concern here is ease in portability We've long stated that there should never be dependency on the exact

[issue25345] Unable to install Python 3.5 on Windows 10

2018-03-19 Thread Arran McCutcheon
Arran McCutcheon added the comment: Yes there have been various Cumulative Updates and Security Updates in the past few months, the most recent five days ago. Last features update was successfully installed in December. Update Status: Your device is up to date. Last

Re: Thank you Python community!

2018-03-19 Thread Rob Gaddi
On 03/19/2018 12:40 PM, Tim Daneliuk wrote: On 03/19/2018 02:05 PM, bartc wrote: I've often wondered what the guys who invented C (around 1970) must have been  smoking to have come up with some of those ideas. I dunno, but I do know that - if they were smoking something - it was rolled in

[issue31550] Inconsistent error message for TypeError with subscripting

2018-03-19 Thread Anthony Sottile
Anthony Sottile added the comment: I think the main concern here is ease in portability coupled with the incorrectness of the current message (pointed out in https://bugs.python.org/issue31550#msg302738) For instance it was consistent in 2.7.1, but not later on in the

Re: Thank you Python community!

2018-03-19 Thread Tim Daneliuk
On 03/19/2018 02:05 PM, bartc wrote: > I've often wondered what the guys who invented C (around 1970) must have been  > smoking to have come up with some of those ideas. I dunno, but I do know that - if they were smoking something - it was rolled in greenbar paper ... --

[issue31550] Inconsistent error message for TypeError with subscripting

2018-03-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: I would like to leave this as-is. Consistency between error message wording is one of our least important considerations. The __getitem__ message is somewhat useful -- it helps learners know which magic method is being called

Missing python36.dll

2018-03-19 Thread Adrian Ordona
Hi - just downloaded the latest version of Python (3.6.4) but keep getting an error because of missing .dll file. i tried uninstalling and reinstalling it but still getting the same error. Search online for the file but to no avail. Can someone direct me as to where to download the missing dll

Re: Thank you Python community!

2018-03-19 Thread Larry Martell
On Mon, Mar 19, 2018 at 12:08 PM, Etienne Robillard wrote: > You guys just made me realize something very obvious. :-) > > I'm in the process right now of watching the excellent documentary named > "Drugs Inc." on Netflix and I'm basically stunned and deeply concerned about >

Re: Thank you Python community!

2018-03-19 Thread bartc
On 19/03/2018 16:08, Etienne Robillard wrote: You guys just made me realize something very obvious. :-) I'm in the process right now of watching the excellent documentary named "Drugs Inc." on Netflix and I'm basically stunned and deeply concerned about the major opioid epidemic in the US.

[issue33105] os.isfile returns false on Windows when file path is longer than 260 characters

2018-03-19 Thread Steve Dower
Steve Dower added the comment: Given basically every other file operation on Windows XP will also break on this file, I don't think it's worth us fixing in 2.7. If it occurs on Python 3.6 on Windows 7, we can consider it. But considering how well known this limitation

[issue33089] Add multi-dimensional Euclidean distance function to the math module

2018-03-19 Thread Tim Peters
Tim Peters added the comment: Mark, thanks! I'm happy with that resolution: if any argument is infinite, return +inf; else if any argument is a NaN, return a NaN; else do something useful ;-) Serhiy, yes, the scaling that prevents catastrophic overflow/underflow due to

[issue25345] Unable to install Python 3.5 on Windows 10

2018-03-19 Thread Steve Dower
Steve Dower added the comment: Arran - I think you have something else going wrong with your machine. There is nothing we do to cause multiple installs to start at the same time, and if rebooting does not help then I have to assume you have some permanently corrupt

[issue33061] NoReturn missing from __all__ in typing.py

2018-03-19 Thread Ivan Levkivskyi
Ivan Levkivskyi added the comment: New changeset 4573820d2a9156346392838d455e89f33067e9dd by Ivan Levkivskyi (aetracht) in branch 'master': bpo-33061: Add missing 'NoReturn' to __all__ in typing.py (GH-6127)

[issue25345] Unable to install Python 3.5 on Windows 10

2018-03-19 Thread Arran McCutcheon
Arran McCutcheon added the comment: Hi Steve, thanks for the reply. I tried the download again and got the same error with a slightly different log file, hopefully that will help identify the problem. Apart from that, I don't know of any other Python log files, there's

[issue33105] os.isfile returns false on Windows when file path is longer than 260 characters

2018-03-19 Thread Ned Deily
Change by Ned Deily : -- nosy: +paul.moore, steve.dower, tim.golden, zach.ware ___ Python tracker ___

[issue33105] os.isfile returns false on Windows when file path is longer than 260 characters

2018-03-19 Thread Luis Conejo-Alpizar
New submission from Luis Conejo-Alpizar : Windows has a maximum path length limitation of 260 characters. This limitation, however, can be bypassed in the scenario described below. When this occurs, os.isfile() will return false, even when the affected file does exist.

[issue32968] Fraction modulo infinity should behave consistently with other numbers

2018-03-19 Thread Mark Dickinson
Mark Dickinson added the comment: > Mark, I tried `Fraction(10**23) // 1e22`, and I got 10. Sorry: that result was with your PR (as it was at the time I wrote that comment). On master, you do indeed get 10. > I think the fact that floating-point rounding error sometimes

[issue33104] Documentation for EXTENDED_ARG in dis module is incorrect for >=3.6

2018-03-19 Thread Eric Appelt
Eric Appelt added the comment: Yes, thanks. I failed to see the duplicate searching for open issues, closing. -- resolution: -> duplicate stage: -> resolved status: open -> closed ___ Python tracker

[issue32625] Update the dis module documentation to reflect switch to wordcode

2018-03-19 Thread Eric Appelt
Change by Eric Appelt : -- nosy: +Eric Appelt ___ Python tracker ___ ___

[issue25433] whitespace in strip()/lstrip()/rstrip()

2018-03-19 Thread Cheryl Sabella
Change by Cheryl Sabella : -- versions: +Python 3.7, Python 3.8 -Python 3.5, Python 3.6 ___ Python tracker ___

Re: Style Q: Instance variables defined outside of __init__

2018-03-19 Thread Chris Angelico
On Tue, Mar 20, 2018 at 4:25 AM, Ethan Furman wrote: > Define them in __init__; otherwise, you get an error if reveal() is called > before conceal() is. Also, a card is either revealed or concealed, it can't > be both and it can't be neither -- so set it in __init__.

[issue31550] Inconsistent error message for TypeError with subscripting

2018-03-19 Thread Anthony Sottile
Anthony Sottile added the comment: I made a new PR which instead *reverts* the python2.7 patch to restore consistency -- ___ Python tracker

[issue31550] Inconsistent error message for TypeError with subscripting

2018-03-19 Thread Anthony Sottile
Change by Anthony Sottile : -- pull_requests: +5909 ___ Python tracker ___ ___

Re: Style Q: Instance variables defined outside of __init__

2018-03-19 Thread Ethan Furman
On 03/19/2018 10:04 AM, Irv Kalb wrote: I am building some classes for use in future curriculum. I am using PyCharm for my development. On the right hand edge of the PyCharm editor window, you get some little bars indicating warnings or errors in your code. I like this feature and try to

Re: Style Q: Instance variables defined outside of __init__

2018-03-19 Thread Ned Batchelder
On 3/19/18 1:04 PM, Irv Kalb wrote: I am building some classes for use in future curriculum. I am using PyCharm for my development. On the right hand edge of the PyCharm editor window, you get some little bars indicating warnings or errors in your code. I like this feature and try to clean

[issue19417] Bdb: add a unittest file (test.test_bdb)

2018-03-19 Thread Mariatta Wijaya
Mariatta Wijaya added the comment: New changeset 424f3dafea16fbaee55a30903af2d6717f4d4a6b by Mariatta (xdegaye) in branch '3.6': bpo-19417: Add test_bdb.py (GH-5217) https://github.com/python/cpython/commit/424f3dafea16fbaee55a30903af2d6717f4d4a6b --

[issue32756] argparse: parse_known_args: raising exception on unknown arg following known one

2018-03-19 Thread paul j3
paul j3 added the comment: >From the documentation, 16.4.4.1. Option value syntax > For short options (options only one character long), the option and its value > can be concatenated: > Several short options can be joined together, using only a single - prefix, > as

Style Q: Instance variables defined outside of __init__

2018-03-19 Thread Irv Kalb
I am building some classes for use in future curriculum. I am using PyCharm for my development. On the right hand edge of the PyCharm editor window, you get some little bars indicating warnings or errors in your code. I like this feature and try to clean up as many of those as I can.

[issue33089] Add multi-dimensional Euclidean distance function to the math module

2018-03-19 Thread Mark Dickinson
Mark Dickinson added the comment: Okay, that cut and paste didn't work so well. Just imagine an infinity symbol in those missing spaces. Trying again: > For the hypot function, hypot(±0, ±0) is +0, hypot(±∞, qNaN) is +∞, and > hypot(qNaN, ±∞) is +∞. --

[issue33089] Add multi-dimensional Euclidean distance function to the math module

2018-03-19 Thread Mark Dickinson
Mark Dickinson added the comment: > By the same logic, if there's an infinite argument to hypot(), it doesn't > matter what any other argument is - the result is +inf regardless. Yep, that's what IEEE 754-2008 says for the two-argument case, so I think that's the logic

Re: how do I retry a command only for a specific exception / error

2018-03-19 Thread Ganesh Pal
On Fri, Mar 16, 2018 at 11:21 AM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > On Fri, 16 Mar 2018 11:04:22 +0530, Ganesh Pal wrote: > > > All that I am trying to do here is write a generic function that will > > re-retry > > the command few more times before failing the

Thank you Python community!

2018-03-19 Thread Etienne Robillard
You guys just made me realize something very obvious. :-) I'm in the process right now of watching the excellent documentary named "Drugs Inc." on Netflix and I'm basically stunned and deeply concerned about the major opioid epidemic in the US. I would like to thank you guys sincerely for

[issue26647] ceval: use Wordcode, 16-bit bytecode

2018-03-19 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- pull_requests: -1041 ___ Python tracker ___

[issue33104] Documentation for EXTENDED_ARG in dis module is incorrect for >=3.6

2018-03-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Isn't this a duplicate of issue32625? -- nosy: +serhiy.storchaka ___ Python tracker

[issue33104] Documentation for EXTENDED_ARG in dis module is incorrect for >=3.6

2018-03-19 Thread Eric Appelt
New submission from Eric Appelt : The documentation for the EXTENDED_ARG instruction in the dis module documentation refers to the way the opcode worked before 3.6: https://docs.python.org/3.6/library/dis.html#opcode-EXTENDED_ARG As I understand, since moving to 2-byte

[issue33089] Add multi-dimensional Euclidean distance function to the math module

2018-03-19 Thread Tim Peters
Tim Peters added the comment: Some notes on the hypot() code I pasted in: first, it has to special case infinities too - it works fine if there's only one of 'em, but returns a NaN if there's more than one (it ends up computing inf/inf, and the resulting NaN propagates).

[issue33103] Syntax to get multiple arbitrary items from an iterable

2018-03-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This syntax already is supported for dicts and NumPy arrays, but with different semantic. >>> d = {(1, 2): 'foo'} >>> d[1, 2] 'foo' >>> a = numpy.array([[1, 2], [3, 4]]) >>> a[1, 0] 3 -- nosy: +serhiy.storchaka

[issue33101] Possible name inversion in heapq implementation

2018-03-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: There isn't universal agreement on whether it should be sift up or sift down. One point of view for sift down is that the datum is moving downward. The other point of view is that the datum is stationary which the rest of the

[issue33102] get the nth folder of a given path

2018-03-19 Thread Eric V. Smith
Eric V. Smith added the comment: Path.parents will do what you want. I don't have a Windows box handy, but this is on MacOS: >>> from pathlib import Path >>> p = >>> Path("/Users/User/AppData/Local/Programs/Python/Python36/Lib/asyncio/__init__.py") >>> p.parents[1]

[issue33103] Syntax to get multiple arbitrary items from an iterable

2018-03-19 Thread amjad ben hedhili
Change by amjad ben hedhili : -- title: Syntax to get multiple items from an iterable -> Syntax to get multiple arbitrary items from an iterable ___ Python tracker

[issue33103] Syntax to get multiple items from an iterable

2018-03-19 Thread amjad ben hedhili
New submission from amjad ben hedhili : It will be much of improvement for readability to write: my_list = ["John", "Richard", "Alice", 1, True, 2.1, "End"] a, b, c = my_list[1, 3, -1] instead of: my_list = ["John", "Richard", "Alice", 1, True, 2.1, "End"] a, b, c =

[issue33102] get the nth folder of a given path

2018-03-19 Thread amjad ben hedhili
Change by amjad ben hedhili : -- title: get the nth folder -> get the nth folder of a given path ___ Python tracker ___

[issue33102] get the nth folder

2018-03-19 Thread amjad ben hedhili
New submission from amjad ben hedhili : It will be handy if there was an os or os.path function that returns the path to the nth directory in a given path for example: given path = "C:\Users\User\AppData\Local\Programs\Python\Python36\Lib\asyncio\__init__.py"

[issue33101] Possible name inversion in heapq implementation

2018-03-19 Thread Yomguithereal
New submission from Yomguithereal : Hello Python team, I might be hallucinating but I am under the impression that the `heapq` module uses reverse naming. What I mean is that it seems to me that the _siftup method should actually be named _siftdown and, the other

Re: Keys in dict and keys not in dict

2018-03-19 Thread Andrew Z
Beautiful. Thank you Chris, Ben, Peter and Inada. On Mar 19, 2018 3:14 AM, "INADA Naoki" wrote: > > expected = {"foo", "bar", "spam"} > > missing = expected - set(json.keys()) > > > > dict.keys() returns set-like object. > So `missing = expected - json.keys()`

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-19 Thread Nick Coghlan
Nick Coghlan added the comment: It occurs to me that there may be some additional unshared context here: the way `python -m pip` searches for the module to execute is much closer to the way Windows searches for a command like `pip` (i.e. current directory first) than it

[issue19417] Bdb: add a unittest file (test.test_bdb)

2018-03-19 Thread Xavier de Gaye
Change by Xavier de Gaye : -- pull_requests: +5908 ___ Python tracker ___ ___

Re: Is it possible to do something similar to gnome glib's GSource in asyncio?

2018-03-19 Thread Vitaly Krug
Mea culpa! It sounds like I should be able to create a specialized future to test for my loop exit condition and then use that future with asyncio loop's `run_until_complete()` method. On Sat, Mar 17, 2018 at 7:39 PM, Vitaly Krug wrote: > I am looking for a way to get a

Is it possible to do something similar to gnome glib's GSource in asyncio?

2018-03-19 Thread Vitaly Krug
I am looking for a way to get a callback each time before asyncio event loop goes back to waiting on I/O (select, epoll, etc.). Documentation and googling for the answer hasn't helped yet. I am looking for something similar to gnome glib's GSource interface (

PyCA cryptography 2.2 released

2018-03-19 Thread Paul Kehrer
PyCA cryptography 2.2 has been released to PyPI. cryptography includes both high level recipes and low level interfaces to common cryptographic algorithms such as symmetric ciphers, message digests, and key derivation functions. We support Python 2.7, Python 3.4+, and PyPy. Changelog

[issue33100] dataclasses and __slots__ - non-default argument (member_descriptor)

2018-03-19 Thread Eric V. Smith
Eric V. Smith added the comment: My point is that the problem is that after: @dataclass class Base: __slots__ = ('x',) x: Any Base.x has a value (it's the member_descriptor for x). That's what's causing the problem that when adding a field to the derived class, it

[issue33100] dataclasses and __slots__ - non-default argument (member_descriptor)

2018-03-19 Thread Adrian Stachlewski
Adrian Stachlewski added the comment: I don't really get your point. @dataclass class Base: __slots__ = ('x',) x: Any This case is described in PEP 557 as correct, so I don't understand why you want to generate error. Also inheritance without defining

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-19 Thread Nathaniel Smith
Nathaniel Smith added the comment: Ah, yeah, I see: ~/t$ echo 'print("hi")' > re.py ~/t$ pip --version pip 9.0.1 from /home/njs/.user-python3.5-64bit/local/lib/python3.5/site-packages (python 3.5) ~/t$ python -m pip --version hi Traceback (most recent call last): [...] But if

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-19 Thread Antti Haapala
Antti Haapala added the comment: Took 2 seconds. % sudo python3 -mpip --version hello world Traceback (most recent call last): File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File

[issue33100] dataclasses and __slots__ - non-default argument (member_descriptor)

2018-03-19 Thread Eric V. Smith
Eric V. Smith added the comment: This is the same reason that this fails: class Base: __slots__ = ('x',) x = 3 with: ValueError: 'x' in __slots__ conflicts with class variable In the dataclasses case, the error needs to be improved, and moved to when the base

[issue33094] dataclasses: ClassVar attributes are not working properly

2018-03-19 Thread Adrian Stachlewski
Adrian Stachlewski added the comment: Once more same mistake. 'x' should be declared as: - x: ClassVar[set] = set() - x: ClassVar[Set[Any]] = set() -- ___ Python tracker

[issue33083] math.factorial accepts non-integral Decimal instances

2018-03-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: "Special cases aren't special enough to break the rules." Supporting floats is a special case. After ending the period of deprecation the code can be simplified. -- ___ Python

[issue33083] math.factorial accepts non-integral Decimal instances

2018-03-19 Thread Mark Dickinson
Mark Dickinson added the comment: Raymond: what are your thoughts on deprecating the ability of `math.factorial` to accept a float (as in `math.factorial(5.0)` -> `120`)? For me, I'm not sure I see the value of the deprecation. It's the usual story: the answer to "Knowing

[issue33021] Some fstat() calls do not release the GIL, possibly hanging all threads

2018-03-19 Thread Robert Collins
Robert Collins added the comment: Re: backporting this. I think backporting to 3.6/3.7 makes a lot of sense - bugfix and prerelease respectively. For 2.7, this bug has been around for ages, the patch is small, and I have no objection - but the RM has already said

[issue33089] Add multi-dimensional Euclidean distance function to the math module

2018-03-19 Thread Mark Dickinson
Mark Dickinson added the comment: +1 for a single-rounded dot product. If we're allowed to assume IEEE 754, it's straightforward to code up something that's not too inefficient and gives correctly rounded results for "normal" cases, using a combination of Veltkamp

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-19 Thread Nathaniel Smith
Nathaniel Smith added the comment: @ncoghlan: The comparison I'm worried about is specifically this one: IIUC, right now it's safe to run 'pip --version' in an arbitrary directory, but it's not safe to run 'python -m pip --version' in an arbitrary directory. Am I wrong? (I

[issue33098] add implicit conversion for random.choice() on a dict

2018-03-19 Thread Aristide Grange
Aristide Grange added the comment: My bad... For my reference to Python 2, I relied on my memory only, which starts to vanish. Really sorry about that. Yes, `random.choice(d)` (mostly) fails in Python 2 too, with an error message that I better understand after

Re: Keys in dict and keys not in dict

2018-03-19 Thread INADA Naoki
> expected = {"foo", "bar", "spam"} > missing = expected - set(json.keys()) > dict.keys() returns set-like object. So `missing = expected - json.keys()` works fine, and it's more efficient. -- INADA Naoki -- https://mail.python.org/mailman/listinfo/python-list

Re: Keys in dict and keys not in dict

2018-03-19 Thread Peter Otten
Ben Finney wrote: > Chris Angelico writes: > >> Sounds like a set operation to me. >> >> expected = {"foo", "bar", "spam"} >> missing = expected - set(json) > > That works (because iterating a dict returns its keys). But it is less > immediately understandable, IMO, than

[issue33089] Add multi-dimensional Euclidean distance function to the math module

2018-03-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: [Uncle Timmy] > I doubt `fsum()` would add much value here: all the addends have the > same sign, so cancellation is impossible fsum() may be overkill for this problem. I mentioned it because the math module already had the

[issue33089] Add multi-dimensional Euclidean distance function to the math module

2018-03-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: With this implementation >>> hypot(*range(15), 3) 32.01 The exact result is 32. -- nosy: +serhiy.storchaka ___ Python tracker