Re: Nonetype List
In my introductory programming course, I have drawn some attention to this
behavior regarding mutating lists. Indeed, Python is very consistent with its
behavior:
Any function that mutates a list parameter does not return that list as a
return value.
For one thing, there is
"Hen Hanna" asked:
> so... for a few days i've been revising this Code (in Gauche / Lisp /
> Scheme) to make it run faster.. and last night i could improve it enough
> to give me the result i wantedin 72 minutes or so (on my slow PC at
> home).
> ( Maybe... within a few months, i'll
On 27/10/2021 8:28, Anton Pardon wrote:
>>> Suppose I would like to write a loop as follows:
>>. >while ((a, b) := next_couple(a, b))[1]:
>> >do needed calculations
>>
>>
>>> What I can do is write it as follows:
>>> while [tmp := next_couple(a,b), a := tmp[0], b := tmp[1]][
On 27/10/2021 at 12:45 Antoon Pardon wrote:
> However with the introduction of the walrus operator there is a
> way to simulate a significant number of one and a half loops.
> Consider the following:
>do
> a = expr1
> b = expr2
> while 2 * a > b:
> more calculations
Message: 8
Date: Mon, 25 Oct 2021 11:20:52 +0200
From: Antoon Pardon
To: python-list@python.org
Subject: Re: New assignmens ...
Message-ID: <5761dd65-4e87-8b8c-1400-edb821204...@vub.be>
Content-Type: text/plain; charset=utf-8; format=flowed
On 25/10/2021 11:20, Anton Pardon wrote:
> Suppose I woul
On 30/09/2020, yonatan <53770...@gmail.com> proposed:
> instead of
> con = "some text here"
> con = con.replace("here", "there")
> we could do
> con = "some text here"
> con .= replace("here", "there")
That would require a major rewrite of the grammer
of the Python language, which would probab
I'll preface this by saying I am a programming instructor
who still teaches from the ivory tower, so may not necessarily
reflect actual practice in industry.
But I have a very simple rule of thumb for limiting parameters:
One should be able to summarize what a function does in one or two
sentences
Emending my own note from moments ago:
def any_as_dict(*args, **kwargs):
if len(args) == 0:
my_dict = kwargs
elif type(args[0]) == type(dict()):
my_dict = args[0]
else:
my_dict = dict(args[0])
print(type(my_dict),my_dict)
>>> any_as_dict(a=1,b=2)
{'a': 1, 'b': 2}
>>> any_as_dict({'a':1, 'b':2}
DL Neil asked:
> How does one code a function/method signature so that
> it will accept either a set of key-value pairs,
> or the same data enclosed as a dict, as part of
> a general-case and polymorphic solution?
Will this do for you?
def any_as_dict(*args, **kwargs):
if len(args) == 0:
my_dic
> On Tue, 25 Feb 2020 3:06 PM BlindAnagram wrote:
> My interest in this stems from wanting to keep the dictionary only
> available to the function that uses it and also a worry about being
> called from threaded code.
It seems like the simplest solution for this is to make
a completely new file
-Original Message-
From: Python-list On
Behalf Of DL Neil
Sent: Monday, February 4, 2019 11:29 PM
To: 'Python'
Subject: Loop with else clause
What is the pythonic way to handle the situation where if a condition exists
the loop should be executed, but if it does not something else shoul
On 13 Nov 2018, at 09:51, Bev in TX wrote:
> On Nov 12, 2018, at 5:50 PM, Terry Reedy wrote:
>
> For me, open (command-O) opens 'Documents'. I presume it should be easy
> enough to move into a 'py' subfolder.
The whole point is for Idle -> File -> Open (or comm
eryk sun responded:
On 11/12/18, Christman, Roger Graydon wrote:
>
> I looked in IDLE's own configuration menu, and didn't see anything there --
> and I fear that I might have to fight some Windows settings somewhere else
> instead. I th
Could anyone tell me how to set up IDLE's default working directory, so that it
would be in the same place for each startup? (Like C:\Users\myname\Python)
I teach a course that mounts a lot of file space across the network and the
default directory for all my students is a readonly directory,
14 matches
Mail list logo