Re: Function returns old value

2020-12-17 Thread Cameron Simpson
On 17Dec2020 14:22, Michael F. Stemper wrote: >On 17/12/2020 03.57, Peter J. Holzer wrote: >>On 2020-12-17 03:06:32 -, Bischoop wrote: >>>pasting from my IDE to vim/slrn was messing syntax, >> >>You can >> >>:set paste >> >>in vim to prevent it from messing with pasted content (don't forget to

Re: Lambda in parameters

2020-12-17 Thread Cameron Simpson
On 17Dec2020 23:52, Abdur-Rahmaan Janhangeer wrote: >Here is a famous question's solution These look like implementations of Lisp operators, which I've never found easy to remember. So I'll do this from first principles, but looking at the (uncommented) code. This is some gratuitiously tricky

Re: Review, suggestion etc?

2020-12-17 Thread Grant Edwards
On 2020-12-18, Joe Pfeiffer wrote: > Recursion has very limited application, but where it's the right > tool it's invaluable (top-down parsers, some graph algorithms...). > We teach it primarily because by the time a student has a good > handle on how to write a recursive function they understand

Re: Review, suggestion etc?

2020-12-17 Thread Joe Pfeiffer
Bischoop writes: > On 2020-12-17, Dennis Lee Bieber wrote: >>> >> >> The main concern is that you are using a RECURSIVE call. It is much >> better for such input checking to use an ITERATIVE (loop) scheme. >> >> def marriage(): >> #loop forever >> while True:

RE: setuptools issue

2020-12-17 Thread Joseph L. Casale
> Installed on this Slackware-14.2/x86_64 workstation with python-3.9.1 are: > python-setuptools-22.0.5-x86_64-1 I just ran into this recently, I don't recall the actual source but it was the version of setuptools having been so old. Your version is from Jun 3, 2016... Update it, that was what w

Re: Review, suggestion etc?

2020-12-17 Thread Bischoop
On 2020-12-17, Bischoop wrote: > On 2020-12-17, Dennis Lee Bieber wrote: >>> >> >> The main concern is that you are using a RECURSIVE call. It is much >> better for such input checking to use an ITERATIVE (loop) scheme. >> >> def marriage(): >> #loop forever >>

Re: Review, suggestion etc?

2020-12-17 Thread Bischoop
On 2020-12-17, Dennis Lee Bieber wrote: >> > > The main concern is that you are using a RECURSIVE call. It is much > better for such input checking to use an ITERATIVE (loop) scheme. > > def marriage(): > #loop forever > while True: > #

setuptools issue

2020-12-17 Thread Rich Shepard
I want to use tkcalendar and dateentry in my application but have problems with tkcalendar's dependency on babel and setuptools. When I try to build babel it fails: Traceback (most recent call last): File "/tmp/SBo/babel-2.8.1/setup.py", line 7, in from setuptools import setup ModuleNotFou

Re: Function returns old value

2020-12-17 Thread Michael F. Stemper
On 17/12/2020 03.57, Peter J. Holzer wrote: On 2020-12-17 03:06:32 -, Bischoop wrote: pasting from my IDE to vim/slrn was messing syntax, You can :set paste in vim to prevent it from messing with pasted content (don't forget to set nopaste afterwards). What's the difference between tha

Lambda in parameters

2020-12-17 Thread Abdur-Rahmaan Janhangeer
Greetings list, Here is a famous question's solution def cons(a, b): def pair(f): return f(a, b) return pair def car(c): return c(lambda a, b: a) print(cons(1, 2)(lambda a, b: a)) print(car(cons(1, 2))) The aim of car is to return 1 but i don't understand how lambda achie

Re: Function returns old value

2020-12-17 Thread Bischoop
On 2020-12-17, Peter J. Holzer wrote: > > --EVF5PPMfhYS0aIcm > Content-Type: text/plain; charset=us-ascii > Content-Disposition: inline > Content-Transfer-Encoding: quoted-printable > > On 2020-12-17 03:06:32 -, Bischoop wrote: >> pasting from my IDE to vim/slrn was messing syntax, > > You can

Re: Function returns old value

2020-12-17 Thread Bischoop
On 2020-12-17, dn wrote: >> After expiry, any posts 'here' with links to 'there', will be useless. >> >> I do mind that however I thoght it better if paste a whole code to see >> and pasting from my IDE to vim/slrn was messing syntax, I'll do better >> next time. > > > Yes, it can be difficult to

Re: Review, suggestion etc?

2020-12-17 Thread Bischoop
On 2020-12-17, Michał Jaworski wrote: > > Exactly. I would go even further and make it a reusable function. Eg. > > def prompt_choices(prompt, choices): > choices = set(c.lower() for c in choices) > while value := input(f"{prompt} {choices}:").lower() not in choices: > pass > r

Re: Review, suggestion etc?

2020-12-17 Thread Michał Jaworski
> I think he's hinting at using a loop instead. > > while maritals != 'Yes' and maritals != 'No': >maritals = input('Married: Yes/No ?: ').title() Exactly. I would go even further and make it a reusable function. Eg. def prompt_choices(prompt, choices): choices = set(c.lower() for c in ch

Re: Review, suggestion etc?

2020-12-17 Thread Bischoop
On 2020-12-17, Michael Torrie wrote: > On 12/17/20 9:10 AM, Bischoop wrote: >> Could you expand here, I rather don't know how I could do it different >> way apart from if maritals == 'Yes' or maritals == 'No' or is it what >> you meant? > > I think he's hinting at using a loop instead. > > while m

Re: Messed up syntax in Vim when pasting python code to post to the groups.

2020-12-17 Thread Bischoop
On 2020-12-17, 2qdxy4rzwzuui...@potatochowder.com <2qdxy4rzwzuui...@potatochowder.com> wrote: > > I'm not a vim user, but it just came up to look into the paste and > nopaste commands. I've googled the matter and found pressing F2 toogles 'paste' mode and then after pasting F2 again to switch off

Re: Messed up syntax in Vim when pasting python code to post to the groups.

2020-12-17 Thread Bischoop
On 2020-12-17, Bischoop wrote: > > I've being asked not to use external links for code sharing to the > groups but when I paste the code in to my vim editor I do use with slrn > client the code is just messed up. > How dear people people using vim solved this? Solved, partialy. Paste mode F2, ho

Re: Review, suggestion etc?

2020-12-17 Thread Michael Torrie
On 12/17/20 9:10 AM, Bischoop wrote: > Could you expand here, I rather don't know how I could do it different > way apart from if maritals == 'Yes' or maritals == 'No' or is it what > you meant? I think he's hinting at using a loop instead. while maritals != 'Yes' and maritals != 'No': marita

Re: Messed up syntax in Vim when pasting python code to post to the groups.

2020-12-17 Thread 2QdxY4RzWzUUiLuE
On 2020-12-17 at 16:20:16 -, Bischoop wrote: > I've being asked not to use external links for code sharing to the > groups but when I paste the code in to my vim editor I do use with > slrn client the code is just messed up. > How dear people people using vim solved this? I'm not a vim user

Messed up syntax in Vim when pasting python code to post to the groups.

2020-12-17 Thread Bischoop
I've being asked not to use external links for code sharing to the groups but when I paste the code in to my vim editor I do use with slrn client the code is just messed up. How dear people people using vim solved this? -- https://mail.python.org/mailman/listinfo/python-list

Re: Review, suggestion etc?

2020-12-17 Thread Bischoop
On 2020-12-17, Michał Jaworski wrote: Thanks for feedback and useful tips. I couldn't use any OOP here because have not a clue about it, just going to go toward it. > I've made a quick look at the code and even executed it. It looks pretty > clear and is easy to understand, although it has som

Re: dict.get(key, default) evaluates default even if key exists

2020-12-17 Thread jak
Il 17/12/2020 13:33, Chris Angelico ha scritto: On Thu, Dec 17, 2020 at 11:16 PM jak wrote: Il 17/12/2020 12:40, Peter J. Holzer ha scritto: On 2020-12-17 12:16:29 +0100, jak wrote: print(_ if d.get('a', None) is not None else get_default()) That doesn't work: print(_ if d.get('a', None)

Re: sudo python PermissionError [Errno 13] Permission denied

2020-12-17 Thread Pascal
you are right ! the "sticky bit" set to /tmp/ prevents the root user from altering the file belonging to the simple user ! $ ls -ld /tmp/ drwxrwxrwt 13 root root 320 Dec 17 13:22 /tmp/ $ ls -l /tmp/test -rw-r--r-- 1 user 0 Dec 17 13:24 /tmp/test $ echo test | sudo tee -a /tmp/test tee: /tmp/tes

Re: dict.get(key, default) evaluates default even if key exists

2020-12-17 Thread jak
Il 17/12/2020 12:40, Peter J. Holzer ha scritto: On 2020-12-17 12:16:29 +0100, jak wrote: print(_ if d.get('a', None) is not None else get_default()) That doesn't work: print(_ if d.get('a', None) is not None else get_default()) Traceback (most recent call last): File "", line 1, in Nam

Re: dict.get(key, default) evaluates default even if key exists

2020-12-17 Thread Chris Angelico
On Thu, Dec 17, 2020 at 11:16 PM jak wrote: > > Il 17/12/2020 12:40, Peter J. Holzer ha scritto: > > On 2020-12-17 12:16:29 +0100, jak wrote: > >> print(_ if d.get('a', None) is not None else get_default()) > > > > That doesn't work: > > > print(_ if d.get('a', None) is not None else get_defa

Re: dict.get(key, default) evaluates default even if key exists

2020-12-17 Thread jak
Il 17/12/2020 12:40, Peter J. Holzer ha scritto: On 2020-12-17 12:16:29 +0100, jak wrote: print(_ if d.get('a', None) is not None else get_default()) That doesn't work: print(_ if d.get('a', None) is not None else get_default()) Traceback (most recent call last): File "", line 1, in Nam

Re: sudo python PermissionError [Errno 13] Permission denied

2020-12-17 Thread 2QdxY4RzWzUUiLuE
On 2020-12-17 at 11:17:37 +0100, Pascal wrote: > hi, > > here, I have this simple script that tests if the /tmp/test file can be > opened in write mode : > > $ cat /tmp/append > #!/usr/bin/python > with open('/tmp/test', 'a'): pass > > the file does not exist yet : > > $ chmod +x /tmp/append

Re: Review, suggestion etc?

2020-12-17 Thread Michał Jaworski
I've made a quick look at the code and even executed it. It looks pretty clear and is easy to understand, although it has some structural problems. I won't do a thorough review but highlight the most important problems. First, the recursive user input pattern you use: def marriage():

Re: dict.get(key, default) evaluates default even if key exists

2020-12-17 Thread Peter J. Holzer
On 2020-12-17 12:16:29 +0100, jak wrote: > print(_ if d.get('a', None) is not None else get_default()) That doesn't work: >>> print(_ if d.get('a', None) is not None else get_default()) Traceback (most recent call last): File "", line 1, in NameError: name '_' is not defined But this works:

Re: dict.get(key, default) evaluates default even if key exists

2020-12-17 Thread jak
Il 17/12/2020 12:16, jak ha scritto: Il 15/12/2020 18:07, Mark Polesky ha scritto: Hi. # Running this script D = {'a':1} def get_default(): print('Nobody expects this') return 0 print(D.get('a', get_default())) # ...generates this output: Nobody expects this 1 ### Since I'm b

Re: dict.get(key, default) evaluates default even if key exists

2020-12-17 Thread jak
Il 15/12/2020 18:07, Mark Polesky ha scritto: Hi. # Running this script D = {'a':1} def get_default():     print('Nobody expects this')     return 0 print(D.get('a', get_default())) # ...generates this output: Nobody expects this 1 ### Since I'm brand new to this community, I thought

sudo python PermissionError [Errno 13] Permission denied

2020-12-17 Thread Pascal
hi, here, I have this simple script that tests if the /tmp/test file can be opened in write mode : $ cat /tmp/append #!/usr/bin/python with open('/tmp/test', 'a'): pass the file does not exist yet : $ chmod +x /tmp/append $ ls -l /tmp/test ls: cannot access '/tmp/test': No such file or director

Re: Python 2 to Python 3 .so library incompatibility - need help

2020-12-17 Thread Michał Jaworski
I've looked into the details of the deb package that Cameron mentioned. It may be the one that you Chris uss because it does indeed include a pyscand.so file. Quick question to you Chris: the utilities you've mentioned are the code that you've written yourself or utilities from /usr/libexec/okimfpu

Re: Python 2 to Python 3 .so library incompatibility - need help

2020-12-17 Thread Chris Green
Cameron Simpson wrote: > >> Guessing from the library name, have you looked on the OKI.com site > >> for current software? Maybe here? What's your printer model? > >> > >> https://www.oki.com/au/printing/support/drivers-and-utilities/index.html > >> > >> > >It comes from OKI with the Linux u

Re: Function returns old value

2020-12-17 Thread Peter J. Holzer
On 2020-12-17 03:06:32 -, Bischoop wrote: > pasting from my IDE to vim/slrn was messing syntax, You can :set paste in vim to prevent it from messing with pasted content (don't forget to set nopaste afterwards). With newer vims that's rarely necessary though since they can distinguish betwe

Re: dict.get(key, default) evaluates default even if key exists

2020-12-17 Thread Greg Ewing
On 17/12/20 8:31 am, Grant Edwards wrote: On 2020-12-16, Dennis Lee Bieber wrote: https://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_name I vaguely recall some other old language I ran across in a survey course when in college that used it. IIRC it was Algol. Algol 60. Also, Lisp ma