Hatch - A modern project, package, and virtual env manager

2017-09-04 Thread ofekmeister
I just released the first version of https://github.com/ofek/hatch It basically makes what you do most in your dev workflow easier and more configurable. Please provide feedback! -- https://mail.python.org/mailman/listinfo/python-list

Re: Run Windows commands from Python console

2017-09-04 Thread Terry Reedy
On 9/4/2017 5:50 PM, Rick Johnson wrote: Terry Reedy wrote: [...] In IDLE, trackbacks *do* include source lines. >>> def f(): return 1/0 >>> f() Traceback (most recent call last): File "", line 1, in f() File "", line 2, in f return 1/0 ZeroDivisionError: div

Re: Please improve these comprehensions (was meaning of [ ])

2017-09-04 Thread Rustom Mody
On Tuesday, September 5, 2017 at 1:44:24 AM UTC+5:30, Ben Bacarisse wrote: > Rustom Mody writes: > > > Here is some code I (tried) to write in class the other day > > > > The basic problem is of generating combinations > > > Now thats neat as far as it goes but combinations are fundamentally set

tictactoe script - commented - may have pedagogical value

2017-09-04 Thread namenobodywants
""" this program makes an optimal tictactoe move by answering the following questions in their given order until it is told where to put its mark: 1) can you win the game? if so then do it 2) could your opponent win the game if it was his turn? if so then put your own mark where a mar

Re: Please improve these comprehensions (was meaning of [ ])

2017-09-04 Thread breamoreboy
On Monday, September 4, 2017 at 9:14:24 PM UTC+1, Ben Bacarisse wrote: > Rustom Mody writes: > > > Here is some code I (tried) to write in class the other day > > > > The basic problem is of generating combinations > > > Now thats neat as far as it goes but combinations are fundamentally sets >

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
Dennis, That's an excellent summary of a number of programming languages' calling conventions, thank you. Unfortunately you have the X-No-Archive header set, so it will be lost to prosperity. To prevent that, I'm taking the liberty of quoting you in full below (and top posting). A couple of comm

Re: Case-insensitive string equality

2017-09-04 Thread Rick Johnson
Steven D'Aprano wrote: [...] > (1) Add a new string method, which performs a case- > insensitive equality test. Here is a potential > implementation, written in pure Python: > > def equal(self, other): > if self is other: > return True > if not isinstance(other, str): > rai

a Boulder Dash clone with retro graphics and sound

2017-09-04 Thread Irmen de Jong
Hi, Yet another continuation of my graphics experiments with tkinter. In the previous project I've been using tkinter bitmaps to simulate a commodore-64 screen where I exploited the possibility to change the foreground and background color of the bitmap on the fly. This conveniently matches the wa

Re: Run Windows commands from Python console

2017-09-04 Thread Rick Johnson
Terry Reedy wrote: [...] > In IDLE, trackbacks *do* include source lines. > > >>> def f(): > return 1/0 > > >>> f() > Traceback (most recent call last): >File "", line 1, in > f() >File "", line 2, in f > return 1/0 > ZeroDivisionError: division by zero One of the few

Re: wrote a commodore-64 emulator using just Python

2017-09-04 Thread Irmen de Jong
On 08/13/2017 03:50 PM, Irmen de Jong wrote: > Hi, > > As another experiment with using just tkinter for graphics, this time I > created a > Commodore-64 emulator. You can find it here https://github.com/irmen/pyc64 [...] > There's also https://github.com/mnaberez/py65 so... possibilities? Wel

Re: Case-insensitive string equality

2017-09-04 Thread Tim Chase
On 2017-09-02 12:21, Steve D'Aprano wrote: > On Fri, 1 Sep 2017 01:29 am, Tim Chase wrote: > > I'd want to have an optional parameter to take locale into > > consideration. E.g. > > Does regular case-sensitive equality take the locale into > consideration? No. Python says that .casefold() ht

Re: Please improve these comprehensions (was meaning of [ ])

2017-09-04 Thread Ben Bacarisse
Rustom Mody writes: > Here is some code I (tried) to write in class the other day > > The basic problem is of generating combinations > Now thats neat as far as it goes but combinations are fundamentally sets > not lists > > So I thought python would do a better job > I tried translating it to p

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Chris Angelico
On Tue, Sep 5, 2017 at 1:36 AM, Dennis Lee Bieber wrote: > On Tue, 05 Sep 2017 00:20:25 +1000, Steve D'Aprano > declaimed the following: > >>(Of course this is silly. As all physicists know, there are no people, animals >>or cars in the world, there are only quarks and electrons.) > > Qua

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Antoon Pardon
On 04-09-17 16:30, Steve D'Aprano wrote: > On Tue, 5 Sep 2017 12:09 am, Antoon Pardon wrote: > >> Op 04-09-17 om 15:26 schreef Steve D'Aprano: >>> On Mon, 4 Sep 2017 08:52 pm, Antoon Pardon wrote: >>> Op 04-09-17 om 12:22 schreef Stefan Ram: > Rustom Mody writes: >>> Stefan Ram wrote

Re: meaning of [ ]

2017-09-04 Thread Steve D'Aprano
On Tue, 5 Sep 2017 03:37 am, Rustom Mody wrote: > My understanding is that the OP saw a 'for' inside a '[]' and wondered > "WTF is this?" Rustom, did you not notice that the OP seemed to understood the 'for' perfectly well, but asked what the meaning of the [ ] delimiters is? He explicitly says:

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Tue, 5 Sep 2017 02:51 am, Stefan Ram wrote: > Steve D'Aprano writes: >>Sorry Stefan, that is the same trap that many others fall into. You are >>assuming that there are exactly two evaluation conventions: >>- pass by reference >>- pass by value >>and so if a language doesn't do one, it must do

Please improve these comprehensions (was meaning of [ ])

2017-09-04 Thread Rustom Mody
Since these discussions are uselessly abstract and meta Here is some code I (tried) to write in class the other day The basic problem is of generating combinations Using the pascal-identity nCr + nC(r-1) = (n+1)Cr This can be written (Haskell) c :: Int -> Int -> Int c n 0 = 1 c 0 (r+1)

Re: Capital ß [was Re: Case-insensitive string equality]

2017-09-04 Thread MRAB
On 2017-09-04 03:28, Steve D'Aprano wrote: On Sat, 2 Sep 2017 01:48 pm, Stefan Ram wrote: Steve D'Aprano writes: [1] I believe that the German government has now officially recognised the uppercase form of ß. [skip to the last paragraph for some "ß" content, unless you want to read deta

Re: meaning of [ ]

2017-09-04 Thread Rustom Mody
On Monday, September 4, 2017 at 10:42:47 PM UTC+5:30, Rick Johnson wrote: > On Monday, September 4, 2017 at 9:27:23 AM UTC-5, Rustom Mody wrote: > > On Monday, September 4, 2017 at 6:36:11 PM UTC+5:30, Ben Bacarisse wrote: > > > Rustom Mody writes: > > > > > > > On Sunday, September 3, 2017 at 5:

Re: meaning of [ ]

2017-09-04 Thread Rick Johnson
On Monday, September 4, 2017 at 9:27:23 AM UTC-5, Rustom Mody wrote: > On Monday, September 4, 2017 at 6:36:11 PM UTC+5:30, Ben Bacarisse wrote: > > Rustom Mody writes: > > > > > On Sunday, September 3, 2017 at 5:10:13 PM UTC+5:30, Rick Johnson wrote: > > >> Andrej Viktorovich wrote: > > >> > I s

Re: Can I use functions while defining paths?

2017-09-04 Thread Rick Johnson
> Trying to import my made module to python with helper function: > > import os.path.join > ("D","pyth_nonsens","workspace_python","PyhonTutorial","reader") There are esoteric methods by which one can import a python module from a filepath, but doing so is not considered good practice, and the

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Rustom Mody
On Monday, September 4, 2017 at 9:13:43 PM UTC+5:30, Steve D'Aprano wrote: > On Tue, 5 Sep 2017 01:17 am, Rustom Mody wrote: > > > Anton gave a picture explaining why/how references are needed and to be > > understood > > Antoon gave a picture demonstrating one model of Python's semantics. > > I

Can some one give examples of how to use graph.label to get data values while dealing with N-Triples files?

2017-09-04 Thread David Shi via Python-list
How to used graph.label to get data values like 'Baddesley Clinton E04009816'? "Baddesley Clinton E04009816"@en .

Re: Have do_nothing as default action for dictionary?

2017-09-04 Thread Christopher Reimer via Python-list
Greetings, After reading everyone's comments and doing a little more research, I re-implemented my function as a callable class.     def __call__(self, key, value):     if key not in self._methods:     return value     return self._methods[key](value) This behaves like my prev

How best to search and get values of label in N-Triples

2017-09-04 Thread David Shi via Python-list
I have a parsed N-Triples file, having many items like the following. "Baddesley Clinton E04009816"@en .

Re: A question on modification of a list via a function invocation

2017-09-04 Thread breamoreboy
On Monday, September 4, 2017 at 3:20:22 AM UTC+1, Chris Angelico wrote: > On Mon, Sep 4, 2017 at 12:05 PM, Steve D'Aprano wrote: > > On Mon, 4 Sep 2017 04:15 am, Stephan Houben wrote: > > > >> Needless to say, according to the definition in Plotkin's paper, Python > >> is "call-by-value". > > > > A

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Tue, 5 Sep 2017 01:17 am, Rustom Mody wrote: > Anton gave a picture explaining why/how references are needed and to be > understood Antoon gave a picture demonstrating one model of Python's semantics. It's a nice model that has a lot going for it, in particular that it matches the most obviou

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Tue, 5 Sep 2017 12:59 am, Rustom Mody wrote: > On Monday, September 4, 2017 at 7:50:39 PM UTC+5:30, Steve D'Aprano wrote: >> On Mon, 4 Sep 2017 01:11 pm, Rustom Mody wrote: >> > Simply put: pythonistas have no coherent/consistent sense of what python >> > values are. And the endless parameter-p

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Rustom Mody
On Monday, September 4, 2017 at 8:37:45 PM UTC+5:30, Steve D'Aprano wrote: > On Tue, 5 Sep 2017 12:34 am, Rustom Mody wrote: > > > On Monday, September 4, 2017 at 5:58:18 PM UTC+5:30, ROGER GRAYDON CHRISTMAN > > wrote: > >> Or with just one function: >>> def baz(x,y): > >> x += y > >> >>> a = 10

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Tue, 5 Sep 2017 12:34 am, Rustom Mody wrote: > On Monday, September 4, 2017 at 5:58:18 PM UTC+5:30, ROGER GRAYDON CHRISTMAN > wrote: >> Or with just one function: >>> def baz(x,y): >> x += y >> >>> a = 10 >> >>> b = [10] >> >>> baz(a,a) >> >>> a >> 10 >> >>> baz(b,b) >> >>> b[10, 10] > > Ha H

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Rustom Mody
On Monday, September 4, 2017 at 7:50:39 PM UTC+5:30, Steve D'Aprano wrote: > On Mon, 4 Sep 2017 01:11 pm, Rustom Mody wrote: > > Simply put: pythonistas have no coherent/consistent sense of what python > > values are. And the endless parameter-passing-nomenclature arguments are > > just > > the fa

Re: meaning of [ ]

2017-09-04 Thread Rustom Mody
On Monday, September 4, 2017 at 7:57:23 PM UTC+5:30, Rustom Mody wrote: > On Monday, September 4, 2017 at 6:36:11 PM UTC+5:30, Ben Bacarisse wrote: > > But [p for p in sys.path] is a list and "set-builder" notation is used > > for sets. Order is crucial for sys.path. You say exactly that below so

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Mon, 4 Sep 2017 11:30 pm, Antoon Pardon wrote: > Op 04-09-17 om 15:24 schreef Steve D'Aprano: >> I accept that many people dislike, or do not understand, conceptual models >> where objects can be in more than one location at once. For many people, >> dropping into the implementation and talking

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Tue, 5 Sep 2017 12:09 am, Antoon Pardon wrote: > Op 04-09-17 om 15:26 schreef Steve D'Aprano: >> On Mon, 4 Sep 2017 08:52 pm, Antoon Pardon wrote: >> >>> Op 04-09-17 om 12:22 schreef Stefan Ram: Rustom Mody writes: >> Stefan Ram wrote: >>> JavaScript and Python do not have referen

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Rustom Mody
On Monday, September 4, 2017 at 5:58:18 PM UTC+5:30, ROGER GRAYDON CHRISTMAN wrote: > >Does a poor job AFAIAC of explaining the difference between foo and bar in > foll def foo(x): x += 2 > def bar(x): x.append(2) > a=10 > b=[10] > foo(a) > a > >10 > bar(b) >

Re: meaning of [ ]

2017-09-04 Thread Rustom Mody
On Monday, September 4, 2017 at 6:36:11 PM UTC+5:30, Ben Bacarisse wrote: > Rustom Mody writes: > > > On Sunday, September 3, 2017 at 5:10:13 PM UTC+5:30, Rick Johnson wrote: > >> Andrej Viktorovich wrote: > >> > I suppose p becomes array of strings but what [] means in this statement? > >> > >>

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Mon, 4 Sep 2017 01:11 pm, Rustom Mody wrote: > Earlier > Ben Bacarisse wrote: >> The core of the idea is actually what the value-set of Python programs is -- > > Yes! That!! Indeed. Given the assignment: x = 1 then I think we all agree that the value of x is 1. So far so good. But then,

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Antoon Pardon
Op 04-09-17 om 15:26 schreef Steve D'Aprano: > On Mon, 4 Sep 2017 08:52 pm, Antoon Pardon wrote: > >> Op 04-09-17 om 12:22 schreef Stefan Ram: >>> Rustom Mody writes: > Stefan Ram wrote: >> JavaScript and Python do not have references as values > Yes, they do. The difference is that th

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Mon, 4 Sep 2017 01:31 pm, Stefan Ram wrote: > Steve D'Aprano writes: >>That makes arrays (and strings) in C a bit of an odd corner case, and an >>exception to the usual rules, like unboxed machine types in Java. We should >>acknowledge them, but as exceptional cases, and we should note that Py

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Antoon Pardon
Op 04-09-17 om 15:24 schreef Steve D'Aprano: > I accept that many people dislike, or do not understand, conceptual models > where > objects can be in more than one location at once. For many people, dropping > into the implementation and talking about references is easier to understand. > But that

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Mon, 4 Sep 2017 08:52 pm, Antoon Pardon wrote: > Op 04-09-17 om 12:22 schreef Stefan Ram: >> Rustom Mody writes: Stefan Ram wrote: > JavaScript and Python do not have references as values Yes, they do. The difference is that they don't have any >> ... >>> Its because reference (o

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Mon, 4 Sep 2017 08:12 pm, Rustom Mody wrote: > Its because reference (or pointer or …) is central to python's semantics > that we need to use them to talk/explain/understand. References are central to understanding the implementation of Python interpreters. (Perhaps not *all* interpreters, but

Re: meaning of [ ]

2017-09-04 Thread Ben Bacarisse
Rustom Mody writes: > On Sunday, September 3, 2017 at 5:10:13 PM UTC+5:30, Rick Johnson wrote: >> Andrej Viktorovich wrote: >> > I suppose p becomes array of strings but what [] means in this statement? >> >> Generally, it's an inline form of writing a loop that returns a >> list. There are othe

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Mon, 4 Sep 2017 06:16 pm, Gregory Ewing wrote: > Stefan Ram wrote: >> JavaScript and Python do not have references as values > > Yes, they do. No they don't. Python has ints, floats, strings, lists, tuples, dicts, etc as values. It has no "reference" type, nor can you define your own. (You

Re: meaning of [ ]

2017-09-04 Thread Steve D'Aprano
On Mon, 4 Sep 2017 01:36 pm, Rustom Mody wrote: > Tsk tsk the confusioning continues Rustom, it is generally considered that we should do our best to *reduce* confusion, not increase it. *wink* > Rewrite > [p for p in sys.path] > as > [p | p ∈ sys.path] > > Is that clearer? No. What is "|" in

Re: A question on modification of a list via a function invocation

2017-09-04 Thread ROGER GRAYDON CHRISTMAN
>Does a poor job AFAIAC of explaining the difference between foo and bar in foll def foo(x): x += 2 def bar(x): x.append(2) a=10 b=[10] foo(a) a >10 bar(b) b >[10, 2] Or with just one function: >>> def baz(x,y): x += y >>> a = 10 >>> b = [10] >>> baz(a

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Antoon Pardon
Op 04-09-17 om 13:08 schreef Stefan Ram: > Antoon Pardon writes: >> Op 04-09-17 om 12:22 schreef Stefan Ram: >>> Rustom Mody writes: > Stefan Ram wrote: >> JavaScript and Python do not have references as values > Yes, they do. The difference is that they don't have any Its becaus

Re: Can I use functions while defining paths?

2017-09-04 Thread Ned Batchelder
On 9/4/17 4:08 AM, Andrej Viktorovich wrote: > Hello, > > Trying to import my made module to python with helper function: > > import os.path.join > ("D","pyth_nonsens","workspace_python","PyhonTutorial","reader") > > > import os.path.join ("D","pyth_nonsens","workspace_python","PyhonTut

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Antoon Pardon
Op 04-09-17 om 12:22 schreef Stefan Ram: > Rustom Mody writes: >>> Stefan Ram wrote: JavaScript and Python do not have references as values >>> Yes, they do. The difference is that they don't have any > ... >> Its because reference (or pointer or ?) is central to python's semantics > If the

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Chris Angelico
On Mon, Sep 4, 2017 at 8:27 PM, Rustom Mody wrote: > That's fine as far as it goes > But then you have people (Steven above) who feel that python passing has > no exceptions (in parameter passing) > Does a poor job AFAIAC of explaining the difference between foo and bar in > foll > def foo(x

Re: ANN: psutil 5.3.0 with full unicode support is out

2017-09-04 Thread Giampaolo Rodola'
Mmm thanks for pointing this out. I don't have a Windows machine to test this against right now but it seems you're right and there's something wrong in my example (which is what I recommend in the official doc BTW, so it needs to be fixed). That aside, do you think the rest of my reasoning makes

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Rustom Mody
On Monday, September 4, 2017 at 3:35:54 PM UTC+5:30, Antoon Pardon wrote: > Op 04-09-17 om 00:44 schreef Dennis Lee Bieber: > > And is a limited theoretical study, heavy in mathematics and light in > > implementation. > > > > Programming Languages: Design and Implementation (Terrence W Prat

Re: XML Parsing

2017-09-04 Thread Peter Otten
Sambit Samal wrote: > Hi , > > Need help in Python Script using xml.etree.ElementTree to update the > value of any element in below XML ( e.g SETNPI to be 5 ) based on some > constraint ( e.g ) . Something along the lines from xml.etree import ElementTree as ET tree = ET.parse("original.xml"

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Chris Angelico
On Mon, Sep 4, 2017 at 8:12 PM, Rustom Mody wrote: > On Monday, September 4, 2017 at 1:46:55 PM UTC+5:30, Gregory Ewing wrote: >> Stefan Ram wrote: >> > JavaScript and Python do not have references as values >> >> Yes, they do. The difference is that they don't have any >> way of *not* having re

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Rustom Mody
On Monday, September 4, 2017 at 1:46:55 PM UTC+5:30, Gregory Ewing wrote: > Stefan Ram wrote: > > JavaScript and Python do not have references as values > > Yes, they do. The difference is that they don't have any > way of *not* having references as values, so there's less > need to use the word

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Antoon Pardon
Op 04-09-17 om 00:44 schreef Dennis Lee Bieber: > And is a limited theoretical study, heavy in mathematics and light in > implementation. > > Programming Languages: Design and Implementation (Terrence W Pratt, > 1975, Prentice-Hall) has a whole section (6-9 Subprograms with Parameters:

Looking for Python examples for querying, selecting items in N-Triples

2017-09-04 Thread David Shi via Python-list
I found this is very confusing. I will appreciate if simple examples are given. Regards, David -- https://mail.python.org/mailman/listinfo/python-list

Re: Permissions issues with zipfile

2017-09-04 Thread Cameron Simpson
On 04Sep2017 00:30, loial wrote: I am getting a permission issue with the following code targetdirectory = '/data/upload' self.ZIPFileName = targetDirectory + os.sep + "MY.ZIP" zf = zipfile.ZipFile(self.ZIPFileName, mode='w') [Errno 13] Permission denied: '/dat

XML Parsing

2017-09-04 Thread Sambit Samal
Hi , Need help in Python Script using xml.etree.ElementTree to update the value of any element in below XML ( e.g SETNPI to be 5 ) based on some constraint ( e.g ) . DRATRN 1 1

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Chris Angelico
On Mon, Sep 4, 2017 at 6:16 PM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> This is another proof that you can't divide everything into "pass by >> value" vs "pass by reference" > > > True, but that doesn't mean you should deny that something > is pass-by-value when it actually is. > >> In

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Gregory Ewing
Stefan Ram wrote: JavaScript and Python do not have references as values Yes, they do. The difference is that they don't have any way of *not* having references as values, so there's less need to use the word explicitly in that way -- most of the time it's just understood. Nevertheless, terms

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Gregory Ewing
Chris Angelico wrote: This is another proof that you can't divide everything into "pass by value" vs "pass by reference" True, but that doesn't mean you should deny that something is pass-by-value when it actually is. In C, a string is not an entity; it's simply an array of characters. Arrays

permission issue with zipfile

2017-09-04 Thread loial
I am getting a permission issue with the following code targetDirectory = '/data/upload' self.ZIPFileName = targetDirectory + os.sep + "MY.ZIP" zf = zipfile.ZipFile(self.ZIPFileName, mode='w') [Errno 13] Permission denied: '/data/upload/MY.ZIP' The

Can I use functions while defining paths?

2017-09-04 Thread Andrej Viktorovich
Hello, Trying to import my made module to python with helper function: import os.path.join ("D","pyth_nonsens","workspace_python","PyhonTutorial","reader") >>> import os.path.join >>> ("D","pyth_nonsens","workspace_python","PyhonTutorial","reader") File "", line 1 import os.path.join

Permissions issues with zipfile

2017-09-04 Thread loial
I am getting a permission issue with the following code targetdirectory = '/data/upload' self.ZIPFileName = targetDirectory + os.sep + "MY.ZIP" zf = zipfile.ZipFile(self.ZIPFileName, mode='w') [Errno 13] Permission denied: '/data/upload/MY.ZIP' The t