Re: [RELEASE] Python 3.9.0a6 is now available for testing

2020-04-29 Thread Paul Moore
m[-1]!= '\n'and'\n'or' ' This is '\n' if m[-1] != '\n' else ' ' ... just written in a way that was common before the if-expression was invented, using and and or. In itself, it's fine. The problem is that the space in "and '\n'" is omitted (presumably for brevity for some reason?) leav

Re: pip UX Studies - help improve the usability of pip

2020-03-09 Thread Paul Moore
We've had some questions as to whether this survey is legitimate. I can confirm it is (speaking as a pip core developer). The link to a page describing this work is https://pyfound.blogspot.com/2019/12/moss-czi-support-pip.html, if anyone wants to find out more. Paul Moore On Sat, 7 Mar 20

Re: Possible Addition to Python Language: Marked Sub-condition

2020-03-08 Thread Paul Moore
On Sun, 8 Mar 2020 at 15:02, Shrinivas Kulkarni wrote: > > Hello Everyone > > While writing python code, I frequently come across the need to do > certain tasks based on combined conditions. > > Much of the task for all the sub-conditions are common but some are > specific to one or more of these

Re: Sandboxing eval() (was: Calculator)

2020-01-19 Thread Paul Moore
On Sun, 19 Jan 2020 at 17:45, wrote: > > Is it actually possible to build a "sandbox" around eval, permitting it > only to do some arithmetic and use some math functions, but no > filesystem acces or module imports? No. This has been tried before, and it simply isn't safe in the face of malicious

Re: Relative import cannot find .so submodule?

2020-01-13 Thread Paul Moore
Did you build the extension as a debug build, but you're trying to use it in a release build Python? That may not work (it may depend on the OS, I don't know the compatibility details on MacOS)... On Mon, 13 Jan 2020 at 16:02, Pieter van Oostrum wrote: > > Patrick Stinson writes: > > > I have a

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Paul Moore
On Tue, 10 Dec 2019 at 21:12, R.Wieser wrote: > And although you have been fighting me over when the __del__ method is > called, it /is/ called directly as a result of an "del instance" and the > refcount goes zero. There is /no/ delay.(with the only exception is > when a circular reference e

Re: keying by identity in dict and set

2019-10-28 Thread Paul Moore
On Mon, 28 Oct 2019 at 10:01, Steve White wrote: > > Hi Chris, > > I'm afraid you've missed my point. As I said in the initial post, I > have read the documentation. > > I think the documentation does not adequately explain how the > hashtable (or hashtables generally) work internally. As stated

Re: installation problem

2019-10-24 Thread Paul Moore
On Thu, 24 Oct 2019 at 00:50, fateme jbr wrote: > > Dear Python team > > I have installed Python 3.7.4 on windows 10. I have access to IDLE and I > can run simple programs, but when I type python in command window nothing > happens. I wanna install pip and afterward some libraries and it is when >

Re: Black

2019-10-21 Thread Paul Moore
IMO, if you care enough to not like black's formatting choices, you probably shouldn't use it. The point of black is to *not* care about formatting, but leave the decisions to the tool. If you're not doing that, then it's probably the wrong tool for you. There may be other code formatters that are

Re: Curious about library inclusion

2019-10-10 Thread Paul Moore
Probably low. There would need to be a clear justification as to why having the library in the stdlib (and hence tied to Python's release schedule for updates/bug fixes etc - which is typically a really severe limitation for a newish library) would be better than having it available as a 3rd party

Re: Python 3.6 on Windows - does a python3 alias get created by installation?

2019-10-09 Thread Paul Moore
No, the Windows builds do not provide versioned executables (python3.exe or python3.7.exe). Generally, the recommended way to launch Python on Windows is via the py.exe launcher (py -3.7, or just py for the default), but if you have Python on your PATH then python works. The reason pip has version

Re: Announcing config-path an OS independent configuration file paths

2019-09-30 Thread Paul Moore
On Mon, 30 Sep 2019 at 15:51, Barry Scott wrote: > > > On 30 Sep 2019, at 14:17, Paul Moore wrote: > > > > How does this compare to the existing appdirs module on PyPI? > > > > I did not know about appdirs. Fair enough ;-) > It does not seem to have separate

Re: Announcing config-path an OS independent configuration file paths

2019-09-30 Thread Paul Moore
How does this compare to the existing appdirs module on PyPI? On Mon, 30 Sep 2019 at 13:15, Barry Scott wrote: > > See https://pypi.org/project/config-path/ for documentation. > > Install using pip: > > python -m pip install config-path > > I write tools that run on macOS, Unix and Window

Re: ypeError: decoding str is not supported

2019-09-28 Thread Paul Moore
On Sat, 28 Sep 2019 at 10:53, Peter Otten <__pete...@web.de> wrote: > > Hongyi Zhao wrote: > > > Hi, > > > > I have some code comes from python 2 like the following: > > > > str('a', encoding='utf-8') > > This fails in Python 2 > > >>> str("a", encoding="utf-8") > Traceback (most recent call last):

Re: How to get only valid python package index

2019-09-23 Thread Paul Moore
On Mon, 23 Sep 2019 at 19:15, Vijay Kumar Kamannavar wrote: > > Hellom > > As per https://pypi.org/simple/ we have ~2,00,000 packages. i feel there > are lot of packages found to be dummy/Experimental. Where can we get the > properly maintained package list for python? There is no "properly maint

Re: For the code to generate `zen of python'.

2019-08-07 Thread Paul Moore
It's basically a decryption of the string s in the same module, that's encoded using the ROT13 algorithm - https://en.wikipedia.org/wiki/ROT13. This isn't meant to be secure, it's basically a little bit of fun obfuscating the actual text. The code creates a dictionary mapping encoded characters to

Re: installing of python

2019-06-17 Thread Paul Moore
(a) By default if you're using a user install, Python is installed to %LOCALAPPDATA%\Programs\Python. (b) This list is text-only, so the screenshot didn't appear - I'm therefore only guessing what your issue is here. (c) Does the command py -V work? That should run Python and give the version numbe

Re: Implementing C++'s getch() in Python

2019-05-25 Thread Paul Moore
On Sat, 25 May 2019 at 12:12, wrote: > > I'm working on Python 3.7 under Windows. I need a way to input characters > without echoing them on screen, something that getch() did effectively in > C++. I read about the unicurses, ncurses and curses modules, which I was not > able to install using p

Re: What does at 0x0402C7B0> mean?

2019-05-22 Thread Paul Moore
On Wed, 22 May 2019 at 02:45, Terry Reedy wrote: > > On 5/21/2019 9:11 PM, CrazyVideoGamez wrote: > > I tried doing a list comprehension. I typed: > > > > favorite_fruits = ['watermelon', 'blackberries'] > > print(fruit for fruit in favorite_fruits) > > > > And I got: > > at 0x0402C7B0> > > What

Re: Why Python has no equivalent of JDBC of Java?

2019-05-21 Thread Paul Moore
On Tue, 21 May 2019 at 13:50, Adriaan Renting wrote: > > > I think it's partially a design philosophy difference. > > Java was meant to be generic, run anywhere and abstract and hide > differences in its underlying infrastructure. This has led to the Java > VM, and also JDBC I guess. > > Python wa

Re: How to concatenate strings with iteration in a loop?

2019-05-21 Thread Paul Moore
On Tue, 21 May 2019 at 09:25, Frank Millman wrote: > > On 2019-05-21 9:42 AM, Madhavan Bomidi wrote: > > Hi, > > > > I need to create an array as below: > > > > tempStr = year+','+mon+','+day+','+str("{:6.4f}".format(UTCHrs[k]))+','+ \ > > str("{:9.7f}".format(AExt[k,0]))+','+str({:9.7f}".format(A

Re: Conway's game of Life, just because.

2019-05-08 Thread Paul Moore
t being used). Disclaimer: I've only made very light use of golly, most of the above is inferred from the manual and reports of how others have used it. Paul On Wed, 8 May 2019 at 12:38, Richard Damon wrote: > > On 5/8/19 4:26 AM, Paul Moore wrote: > > On Wed, 8 May 2019 at 03:39,

Re: Conway's game of Life, just because.

2019-05-08 Thread Paul Moore
On Wed, 8 May 2019 at 03:39, Richard Damon wrote: > My experience is that the wrap around is common, as otherwise the hard > edge causes a discontinuity in the rules at the edge, so any pattern > that reaches the edge no longer has a valid result. The torus effect > still perturbs the result, but

Re: Change in cache tag in Python 3.8 - pip confused

2019-05-07 Thread Paul Moore
On Tue, 7 May 2019 at 22:26, Chris Angelico wrote: > So the next question is: Is this actually a problem? If it's something > that can only ever happen to people who build prerelease Pythons, it's > probably not an issue. Is there any way that a regular installation of > Python could ever change i

Re: Change in cache tag in Python 3.8 - pip confused

2019-05-07 Thread Paul Moore
On Tue, 7 May 2019 at 21:53, Chris Angelico wrote: > > I've been building Python 3.8 pre-alphas and alphas for a while now, > and ran into a weird problem. Not sure if this is significant or not, > and hoping to get other people's views. > > It seems that the value of sys.implementation.cache_tag

Re: pip as an importable module?

2019-05-01 Thread Paul Moore
Pip doesn't have a programming API, so no, you can't do this. Having said that, it looks like pip-conflict-checker only uses `pip.get_installed_distributions`, and setuptools (pkg_resources, specifically) has an API that does this, so you could probably relatively easily fix the code to use that.

Re: pip unable to find an extension of a lib.

2019-04-12 Thread Paul Moore
>From https://pypi.org/project/PyQt5-sip/#files, it looks like the project only distributes wheels (no source archive). You don't say what platform you're using, but if it's Linux, the fact that you have a debug Python probably means you need a different ABI, so the standard wheels that they provid

Re: fs package question - cp -p semantics when copying files?

2019-04-03 Thread Paul Moore
On Wed, 3 Apr 2019 at 16:06, Skip Montanaro wrote: > > > From a brief look at the docs, there's an on_copy callback to copy_fs. > > Maybe you could use the getinfo/setinfo methods to copy over the > > timestamps and any other file metadata that you want in that callback? > > Yes, I had gotten to t

Re: fs package question - cp -p semantics when copying files?

2019-04-03 Thread Paul Moore
On Wed, 3 Apr 2019 at 14:55, Skip Montanaro wrote: > It's part of a larger application which needs to copy files from a number > of locations, not all of which are filesystems on local or remote hosts > (think zip archives, s3 buckets, tar files, etc). In that application, I am > using the fs pack

Re: Library for parsing binary structures

2019-03-30 Thread Paul Moore
On Fri, 29 Mar 2019 at 23:21, Cameron Simpson wrote: > > On 27Mar2019 18:41, Paul Moore wrote: > >I'm looking for a library that lets me parse binary data structures. > >The stdlib struct module is fine for simple structures, but when it > >gets to more complicated

Re: Library for parsing binary structures

2019-03-29 Thread Paul Moore
On Fri, 29 Mar 2019 at 16:16, Peter J. Holzer wrote: > Obviously you need some way to describe the specific binary format you > want to parse - in other words, a grammar. The library could then use > the grammar to parse the input - either by interpreting it directly, or > by generating (Python)

Re: Library for parsing binary structures

2019-03-28 Thread Paul Moore
On Thu, 28 Mar 2019 at 08:15, dieter wrote: > What you have is a generalized deserialization problem. > It can be solved with a set of deserializers. Yes, and thanks for the suggested code structure. As I say, I can certainly do the parsing "by hand", and the way you describe is very similar to h

Library for parsing binary structures

2019-03-27 Thread Paul Moore
I'm looking for a library that lets me parse binary data structures. The stdlib struct module is fine for simple structures, but when it gets to more complicated cases, you end up doing a lot of the work by hand (which isn't that hard, and is generally perfectly viable, but I'm feeling lazy ;-)) I

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-27 Thread Paul Moore
On Wed, 27 Mar 2019 at 12:27, Alexey Muranov wrote: > > On mer., mars 27, 2019 at 10:10 AM, Paul Moore > wrote: > > On Wed, 27 Mar 2019 at 08:25, Alexey Muranov > > wrote: > >> > >> Whey you need a simple function in Python, there is a choice > >

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-27 Thread Paul Moore
On Wed, 27 Mar 2019 at 08:25, Alexey Muranov wrote: > > Whey you need a simple function in Python, there is a choice between a > normal function declaration and an assignment of a anonymous function > (defined by a lambda-expression) to a variable: > > def f(x): return x*x > > or > > f = l

Re: Question about the @staticmethod decorator

2019-03-17 Thread Paul Moore
On Sun, 17 Mar 2019 at 18:18, Arup Rakshit wrote: > > I am reading a book where the author says that: > > In principle, it would also be possible to implement any @staticmethod > completely outside of the class at module scope without any loss of > functionality — so you may want to consider car

Re: Convert Windows paths to Linux style paths

2019-03-13 Thread Paul Moore
On Wed, 13 Mar 2019 at 08:13, eryk sun wrote: > > On 3/12/19, Paul Moore wrote: > > > > Do you care about case sensitivity (for example, is it important to you > > whether filenames "foo" and "FOO" map to the same file or not on > > Linux, give

Re: Convert Windows paths to Linux style paths

2019-03-12 Thread Paul Moore
On Tue, 12 Mar 2019 at 14:54, Malcolm Greene wrote: > > Looking for best practice technique for converting Windows style paths to > Linux paths. Is there an os function or pathlib method that I'm missing or is > it some combination of replacing Windows path separators with Linux path > separato

Re: dash/underscore on name of package uploaded on pypi

2019-02-28 Thread Paul Moore
On Thu, 28 Feb 2019 at 16:14, ast wrote: > > Hello > > I just uploaded a package on pypi, whose name is "arith_lib" > > The strange thing is that on pypi the package is renamed "arith-lib" > The underscore is substitued with a dash The version with a dash is the normalised form of the name - see

Re: Deletion of Environmental Variables

2019-01-06 Thread Paul Moore
On Mon, 7 Jan 2019 at 06:37, Terry Reedy wrote: > The pydev recommended way to run pip on windows is > > py -x.y pip > as this installs the package requested into the x.y site-packages > directory. py -3.7 -m pip ... Note the extra -m). Paul -- https://mail.python.org/mailman/listinfo/python

Re: Transparently treating tar files and zip archives as directories

2019-01-06 Thread Paul Moore
Pyfilesystem (https://pypi.org/project/fs/) does something like this - it might be what you're after, Paul On Sun, 6 Jan 2019 at 22:32, Skip Montanaro wrote: > > I find it useful in some of the work I do to treat Zip archives as if > they were directories. I don't think it would be too difficult

Re: Question about slight deviations when using integer division with large integers.

2018-12-31 Thread Paul Moore
On Mon, 31 Dec 2018 at 09:00, Christian Seberino wrote: > > Thanks. I didn’t post new code. I was just referring back to original > post. I need to duplicate the exact behavior of Java’s BigIntegers. > > I’m guessing difference between Java and Python is that Java BigIntegers do > not switch to

Re: Decoding a huge JSON file incrementally

2018-12-20 Thread Paul Moore
(Sorry, hit "Send" too soon on the last try!) On Thu, 20 Dec 2018 at 17:22, Chris Angelico wrote: > > On Fri, Dec 21, 2018 at 2:44 AM Paul Moore wrote: > > > > I'm looking for a way to incrementally decode a JSON file. I know this > > has come up be

Re: Decoding a huge JSON file incrementally

2018-12-20 Thread Paul Moore
On Thu, 20 Dec 2018 at 17:22, Chris Angelico wrote: > > On Fri, Dec 21, 2018 at 2:44 AM Paul Moore wrote: > > > > I'm looking for a way to incrementally decode a JSON file. I know this > > has come up before, and in general the problem is not soluble (because > &g

Decoding a huge JSON file incrementally

2018-12-20 Thread Paul Moore
I'm looking for a way to incrementally decode a JSON file. I know this has come up before, and in general the problem is not soluble (because in theory the JSON file could be a single object). In my particular situation, though, I have a 9GB file containing a top-level array object, with many eleme

Re: [OT] master/slave debate in Python

2018-09-26 Thread Paul Moore
On Wed, 26 Sep 2018 at 16:30, Ian Kelly wrote: > Also: a human slave is not "a person being treated like a computer" > and I find it highly disrespectful that you would move to trivialize > slavery like that. I have no idea what it must feel like to be a slave (other than the trite and obvious i

Re: Any SML coders able to translate this to Python?

2018-09-07 Thread Paul Moore
On Fri, 7 Sep 2018 at 15:10, Paul Moore wrote: > > On Fri, 7 Sep 2018 at 14:06, Steven D'Aprano > wrote: > > > > On Thu, 06 Sep 2018 13:48:54 +0300, Marko Rauhamaa wrote: > > > > > Chris Angelico : > > >> The request was to translate th

Re: Any SML coders able to translate this to Python?

2018-09-07 Thread Paul Moore
On Fri, 7 Sep 2018 at 14:06, Steven D'Aprano wrote: > > On Thu, 06 Sep 2018 13:48:54 +0300, Marko Rauhamaa wrote: > > > Chris Angelico : > >> The request was to translate this into Python, not to slavishly imitate > >> every possible semantic difference even if it won't actually affect > >> behavi

Re: Any SML coders able to translate this to Python?

2018-09-05 Thread Paul Moore
On Tue, 4 Sep 2018 at 13:31, Steven D'Aprano wrote: > > I have this snippet of SML code which I'm trying to translate to Python: > > fun isqrt n = if n=0 then 0 > else let val r = isqrt (n/4) > in > if n < (2*r+1)^2 then 2*r >

Re: Any SML coders able to translate this to Python?

2018-09-04 Thread Paul Moore
On Tue, 4 Sep 2018 at 13:31, Steven D'Aprano wrote: > > I have this snippet of SML code which I'm trying to translate to Python: > > fun isqrt n = if n=0 then 0 > else let val r = isqrt (n/4) > in > if n < (2*r+1)^2 then 2*r >

Re: Question about floating point

2018-09-01 Thread Paul Moore
On Sat, 1 Sep 2018 at 12:31, Frank Millman wrote: > > "Frank Millman" wrote in message news:pm3l2m$kv4$1...@blaine.gmane.org... > > > > I know about this gotcha - > > > > >>> x = 1.1 + 2.2 > > >>> x > > 3.3003 > > > [...] > > I have enjoyed the discussion, and I have learnt a lot abou

Re: __init__ patterns

2018-08-30 Thread Paul Moore
On Thu, 30 Aug 2018 at 14:07, Tim wrote: > > I saw a thread on reddit/python where just about everyone said they never put > code in their __init__ files. > > Here's a stackoverflow thread saying the same thing. > https://stackoverflow.com/questions/1944569/how-do-i-write-good-correct-package-ini

Re: Path-like objects in the standard library

2018-08-24 Thread Paul Moore
On Fri, 24 Aug 2018 at 09:57, Torsten Bronger wrote: > > Hallöchen! > > Path-like objects are accepted by all path-processing functions in > the standard library since Python 3.6. Unfortunately, this is not > made explicit everywhere. In particular, if I pass a Path in the > first argument of su

Re: Partitioning a list

2018-08-22 Thread Paul Moore
On Wed, 22 Aug 2018 at 17:33, Richard Damon wrote: > Paul, my understanding of the problem is that you want to create multiple > divisions of the larger group into smaller groups, such that if two people > are in the same group in 1 division, they never appear together in other > divisions. > >

Re: Partitioning a list

2018-08-22 Thread Paul Moore
On Wed, 22 Aug 2018 at 00:44, Poul Riis wrote: > > I would like to list all possible ways to put N students in groups of k > students (suppose that k divides N) with the restriction that no two students > should ever meet each other in more than one group. > I think this is a classical problem a

Re: RFC -- custom operators

2018-08-07 Thread Paul Moore
On Tue, 7 Aug 2018 at 09:03, Steven D'Aprano wrote: > I'll looking for comments on custom binary operators: would it be useful, > if so, what use-cases do you have? I've never found a need for custom binary operators. I can imagine some *theoretical* cases where they might be useful (but no act

Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-02 Thread Paul Moore
On Thu, 2 Aug 2018 at 20:58, wrote: > > Sorry, but there's no "simple" answer here for you (although you may > > well be able to get something that works well enough for your specific > > needs - but it's not obvious from your snippet of code what you're > > trying to achieve). > > To send and rec

Re: Dealing with errors in interactive subprocess running python interpreter that freeze the process

2018-08-02 Thread Paul Moore
On Wed, 1 Aug 2018 at 21:17, wrote: > > I can run python3 interactively in a subprocess w/ Popen but > if I sent it text, that throws an exception, the process freezes > instead of just printing the exception like the normal interpreter.. > why? how fix? Here is my code below. > > (I suspect when

Re: Are dicts supposed to raise comparison errors

2018-08-01 Thread Paul Moore
On Wed, 1 Aug 2018 at 18:43, Steven D'Aprano wrote: > > On Wed, 01 Aug 2018 16:22:16 +0100, Paul Moore wrote: > > > If they've reported to you that your code produces warnings under -b, > > your response can quite reasonably be "thanks for the information,

Re: Are dicts supposed to raise comparison errors

2018-08-01 Thread Paul Moore
On Wed, 1 Aug 2018 at 16:10, Robin Becker wrote: > > On 01/08/2018 14:38, Chris Angelico wrote: > > t's a warning designed to help people port code from Py2 to Py3. It's > > not meant to catch every possible comparison. Unless you are actually > > porting Py2 code and are worried that you'll be ac

Re: Are dicts supposed to raise comparison errors

2018-07-31 Thread Paul Moore
On 31 July 2018 at 09:32, Robin Becker wrote: > On 31/07/2018 09:16, Paul Moore wrote: >> >> On 31 July 2018 at 08:40, Robin Becker wrote: >>> >>> A bitbucket user complains that python 3.6.6 with -Wall -b prints >>> warnings >>> for som

Re: Are dicts supposed to raise comparison errors

2018-07-31 Thread Paul Moore
On 31 July 2018 at 08:40, Robin Becker wrote: > A bitbucket user complains that python 3.6.6 with -Wall -b prints warnings > for some reportlab code; the > example boils down to the following > > ## > C:\code\hg-repos\reportlab\tmp>cat tb.py > if __name__=='__main__': > d={'a':1} >

Re: Better way / regex to extract values form a dictionary

2018-07-21 Thread Paul Moore
def return_filename_test_case(filepath): filename = os.path.basename(filepath) testcase = filename.partition('_')[0] return filename, testcase On 21 July 2018 at 12:37, Ganesh Pal wrote: > I have one of the dictionary values in the below format > > '/usr/local/ABCD/EDF/ASASAS/GTH/HELL

Re: Reading EmailMessage from file

2018-07-16 Thread Paul Moore
On 16 July 2018 at 02:31, Skip Montanaro wrote: >> What are you actually trying to do? You're talking like you're trying >> to read an existing RFC822 email-with-headers from a file, but you're >> showing code that creates a new email with body content set from >> a file, which is a completely dif

Re: Python for beginners or not? [was Re: syntax difference]

2018-06-26 Thread Paul Moore
From: Paul Moore On 25 June 2018 at 11:53, Steven D'Aprano wrote: > And the specific line you reference is *especially* a joke, one which > flies past nearly everyone's head: > > There should be one-- and preferably only one --obvious way to do it. > > > No

Re: Quick survey: locals in comprehensions (Python 3 only)

2018-06-26 Thread Paul Moore
From: Paul Moore On 24 June 2018 at 06:03, Steven D'Aprano wrote: > I'd like to run a quick survey. There is no right or wrong answer, since > this is about your EXPECTATIONS, not what Python actually does. > > Given this function: > > > def test(): > a = 1

Re: Quick survey: locals in comprehensions (Python 3 only)

2018-06-26 Thread Paul Moore
On 26 June 2018 at 11:09, Chris Angelico wrote: > On Tue, Jun 26, 2018 at 8:04 PM, Antoon Pardon wrote: >> On 26-06-18 11:22, Steven D'Aprano wrote: >>> On Tue, 26 Jun 2018 10:20:38 +0200, Antoon Pardon wrote: >>> > def test(): > a = 1 > b = 2 > result = [value for key

Re: Python for beginners or not? [was Re: syntax difference]

2018-06-25 Thread Paul Moore
On 25 June 2018 at 11:53, Steven D'Aprano wrote: > And the specific line you reference is *especially* a joke, one which > flies past nearly everyone's head: > > There should be one-- and preferably only one --obvious way to do it. > > > Notice the dashes? There are *two* traditional ways to use

Re: Quick survey: locals in comprehensions (Python 3 only)

2018-06-24 Thread Paul Moore
On 24 June 2018 at 06:03, Steven D'Aprano wrote: > I'd like to run a quick survey. There is no right or wrong answer, since > this is about your EXPECTATIONS, not what Python actually does. > > Given this function: > > > def test(): > a = 1 > b = 2 > result = [value for key, value in l

Re: PEP8 compliance

2018-06-13 Thread Paul Moore
On 13 June 2018 at 17:35, T Berger wrote: > I did make the changes in IDLE, but I thought I must be in the wrong place. > The line of code I got in terminal was: > /Users/TamaraB/Desktop/mymodules/vsearch.py:1:25: E231 missing whitespace > after ':' > def search4vowels(phrase:str)->set: > > I t

Re: Why exception from os.path.exists()?

2018-06-04 Thread Paul Moore
On 4 June 2018 at 13:01, Steven D'Aprano wrote: >> Turns out that this is a limitation on Windows as well. The \0 is not >> allowed for Windows, macOS and Posix. > > We -- all of us, including myself -- have been terribly careless all > through this discussion. The fact is, this should not be an

Re: Why exception from os.path.exists()?

2018-06-02 Thread Paul Moore
On 2 June 2018 at 12:28, Chris Angelico wrote: > On Sat, Jun 2, 2018 at 9:13 PM, Steven D'Aprano > wrote: >> On Sat, 02 Jun 2018 20:58:43 +1000, Chris Angelico wrote: >> > Windows isn't POSIX compliant. Technically, Windows is POSIX compliant. You have to turn off a bunch of fe

Re: Sorting NaNs

2018-06-02 Thread Paul Moore
On 2 June 2018 at 08:32, Peter J. Holzer wrote: > Browsing through older messages I came upon a thread discussing the > treatment of NaNs by median(). Since you have to (partially) sort the > values to compute the median, I played around with sorted(): > > Python 3.5.3 (default, Jan 19 2017, 14:11

Re: version

2018-06-02 Thread Paul Moore
On 2 June 2018 at 02:34, Mike McClain wrote: > It looks like what I was wanting is something like 'C's #if, a > compiler conditional. > > Does python have anything like that to tell the interpreter to ignore > a line that is not a comment or a quoted string? No, it doesn't. Honestly, if you are

Re: Indented multi-line strings

2018-06-02 Thread Paul Moore
On 1 June 2018 at 22:57, Chris Angelico wrote: > How will a method be worse than a standalone function? Please explain > this. Because the standalone function already exists (in the textwrap module). There's nothing wrong with adding string methods, but where they don't add anything that can't b

Re: Indented multi-line strings

2018-06-01 Thread Paul Moore
On 1 June 2018 at 16:36, Chris Angelico wrote: > On Sat, Jun 2, 2018 at 12:57 AM, Paul Moore wrote: >> Why does this need to be a string method? Why can't it be a standalone >> function? Maybe you should publish an implementation on PyPI, collect >> some data on how

Re: Why exception from os.path.exists()?

2018-06-01 Thread Paul Moore
On 1 June 2018 at 15:38, Grant Edwards wrote: > On 2018-06-01, Paul Moore wrote: > >> Python allows strings with embedded \0 characters, so it's possible >> to express that question in Python - os.path.exists('a\0b'). What >> can be expressed in ter

Re: Indented multi-line strings

2018-06-01 Thread Paul Moore
On 1 June 2018 at 15:36, Dan Strohl via Python-list wrote: > So... how does one go about suggesting changes to the built in types? I > could take a whack at the code for it, but my C skills are no where near what > should probably be needed for something this close to the core of the > languag

Re: Why exception from os.path.exists()?

2018-06-01 Thread Paul Moore
On 1 June 2018 at 13:15, Barry Scott wrote: > I think the reason for the \0 check is that if the string is passed to the > operating system with the \0 you can get surprising results. > > If \0 was not checked for you would be able to get True from: > > os.file.exists('/home\0ignore me') >

Re: Why exception from os.path.exists()?

2018-05-31 Thread Paul Moore
On 31 May 2018 at 16:11, Steven D'Aprano wrote: > On Thu, 31 May 2018 22:46:35 +1000, Chris Angelico wrote: > [...] >>> Most other analogous reasons *don't* generate an exception, nor is that >>> possibility mentioned in the specification: >>> >>>https://docs.python.org/3/library/os.path.html?

Re: Why exception from os.path.exists()?

2018-05-31 Thread Paul Moore
On 31 May 2018 at 15:01, Chris Angelico wrote: > Can someone on Windows see if there are other path names that raise > ValueError there? Windows has a whole lot more invalid characters, and > invalid names as well. On Windows: >>> os.path.exists('\0') ValueError: stat: embedded null character in

Re: syntax oddities

2018-05-18 Thread Paul Moore
On 18 May 2018 at 12:08, Rhodri James wrote: > On 17/05/18 23:44, Paul wrote: >> >> I've been using email for thirty years, including thousands of group >> emails >> at many tech companies, and no one has ever suggested, let alone insisted >> on, bottom posting. > > I've been using email for thirt

Re: what does := means simply?

2018-05-17 Thread Paul Moore
On 17 May 2018 at 12:58, bartc wrote: > On 17/05/2018 04:54, Steven D'Aprano wrote: >> >> On Thu, 17 May 2018 05:33:38 +0400, Abdur-Rahmaan Janhangeer wrote: >> >>> what does := proposes to do? > >> A simple example (not necessarily a GOOD example, but a SIMPLE one): >> >> print(x := 100, x+1, x*2

Re: object types, mutable or not?

2018-05-16 Thread Paul Moore
On 16 May 2018 at 14:23, Ned Batchelder wrote: > I've also experimented with different ways to better say "everything is an > object". One possibility is, "any right-hand side of an assignment is an > object," though that is a bit tortured. C++ called that an "rvalue". And then went on to defin

Re: Python-list Digest, Vol 176, Issue 16

2018-05-14 Thread Paul Moore
On 14 May 2018 at 20:02, Paul wrote: > 1) I understand the added cost of verifying the sequence. However, this > appears to be a one-time cost. E.G., if I submit this, > > random.choices(lm,cum_weights=[25,26,36,46,136],k=400 > > then the code will do an O(n log n) operation 400 times. > > If ve

Re: random.choices() Suggest that the code confirm that cum_weights sequence is in ascending order

2018-05-14 Thread Paul Moore
On 14 May 2018 at 14:07, Steven D'Aprano wrote: > On Mon, 14 May 2018 12:59:28 +0100, Paul Moore wrote: > >> The problem is that supplying cum_weights allows the code to run in >> O(log n) by using bisection. This is significantly faster on large >> populations. Addi

Re: random.choices() Suggest that the code confirm that cum_weights sequence is in ascending order

2018-05-14 Thread Paul Moore
On 14 May 2018 at 13:53, Chris Angelico wrote: > On Mon, May 14, 2018 at 10:49 PM, Paul Moore wrote: >> On 14 May 2018 at 13:27, Chris Angelico wrote: >>> On Mon, May 14, 2018 at 9:59 PM, Paul Moore wrote: >>>> The problem is that supplying cum_weights allows t

Re: random.choices() Suggest that the code confirm that cum_weights sequence is in ascending order

2018-05-14 Thread Paul Moore
On 14 May 2018 at 13:27, Chris Angelico wrote: > On Mon, May 14, 2018 at 9:59 PM, Paul Moore wrote: >> The problem is that supplying cum_weights allows the code to run in >> O(log n) by using bisection. This is significantly faster on large >> populations. Adding a tes

Re: random.choices() Suggest that the code confirm that cum_weights sequence is in ascending order

2018-05-14 Thread Paul Moore
The problem is that supplying cum_weights allows the code to run in O(log n) by using bisection. This is significantly faster on large populations. Adding a test that the cumulative weights are nondecreasing would add an O(n) step to the code. So while I understand the OP's problem, I don't think

Re: Python 2.7.15 Windows MSI removes previous 2.7.x binaries?

2018-05-01 Thread Paul Moore
It's intended behaviour (to my knowledge). Or at least, we don't intend for people to install two different patch versions in parallel (at least not with the official installers). I thought this behaviour was always the case. It may be related to the installer technology involved, though, so it may

Re: venv: make installed modules visible

2018-05-01 Thread Paul Moore
On 1 May 2018 at 17:06, Rich Shepard wrote: > Activating venv and trying to run the project Python tells me it cannot > find the wxPython4 modules: > > Traceback (most recent call last): > File "./openEDMS.py", line 12, in > import wx > ModuleNotFoundError: No module named 'wx' > > I've

Re: www.python.org down

2018-04-30 Thread Paul Moore
It's working for me now. Paul On 30 April 2018 at 18:38, Jorge Gimeno wrote: > Not sure who to report to, but the site comes back with a 503. Anyone know > where I can direct this to? > > -Jorge L. Gimeno > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mail

Re: Installation of tensorflow via pip -- messages?

2018-04-26 Thread Paul Moore
On 26 April 2018 at 21:18, Terry Reedy wrote: >> If my memory is correct, this is the default for path directories. > > The Python entries do, as added by the Windows Installer written by a > Microsoft engineer, so this must at least be a correct alternative. It's definitely acceptable - there's

Re: Installation of tensorflow via pip -- messages?

2018-04-26 Thread Paul Moore
On 26 April 2018 at 20:04, Virgil Stokes wrote: > IMHO it would have been useful to have "warning" somewhere in these > messages. Ha, I'd never even noticed that it didn't... I think it's in a different colour, FWIW, but your point is good. Paul -- https://mail.python.org/mailman/listinfo/pytho

Re: Installation of tensorflow via pip -- messages?

2018-04-26 Thread Paul Moore
On 26 April 2018 at 19:33, Virgil Stokes wrote: > Why am I getting this message, that I need to consider adding this directory > to PATH when it is already in PATH? > Note, all of these *.exe files are in C:\Python36\Scripts. The PATH entry ends with a backslash, which is confusing the check done

Re: Determining whether a package or module should be installed globally using pip

2018-04-25 Thread Paul Moore
On 25 April 2018 at 16:32, Rodrigo Acosta wrote: > Is there a rule of thumb in deciding where to install a package? What makes a > package, other than security vulnerabilities, better to install globally e.g. > using sudo pip install, or by changing directory to tmp folder, or by using > virtua

Pip 10.0.1 has been released

2018-04-19 Thread Paul Moore
On behalf of the PyPA, I am pleased to announce that pip 10.0.1 has just been released. This release fixes a number of issues with the initial release of pip 10.0, notably: * A problem with running the "pip.exe" wrapper script on Windows from a directory with a space in the name. * A problem with

Re: The basics of the logging module mystify me

2018-04-19 Thread Paul Moore
On 19 April 2018 at 02:00, Skip Montanaro wrote: > I really don't like the logging module, but it looks like I'm stuck > with it. Why aren't simple/obvious things either simple or obvious? If you can use non-stdlib things there are alternatives. I've heard good things about logbok (https://logboo

Pip 10.0 has been released

2018-04-14 Thread Paul Moore
On behalf of the PyPA, I am pleased to announce that pip 10.0 has just been released. This release has been the culmination of many months of work by the community. To install pip 10.0, you can run python -m pip install --upgrade pip or use get-pip, as described in https://pip.pypa.io/en/lat

Re: Asynchronous processing is more efficient -- surely not?

2018-04-04 Thread Paul Moore
On 4 April 2018 at 08:27, Steven D'Aprano wrote: > "Asynchronous programming has been gaining a lot of traction in the past > few years, and for good reason. Although it can be more difficult than > the traditional linear style, it is also much more efficient." > > I can agree with the first part

  1   2   3   4   5   >