Re: Optional arguments in a class behave like class attributes.

2022-10-17 Thread Antoon Pardon
You can use the following decorator for what you probably want. def copy_defaults(func): """ This decorator makes that defaults values are copied on a call. """ signature = inspect.signature(func) parameter_items = list(signature.parameters.items()) @wraps(func) def

Re: Quick question about CPython interpreter

2022-10-17 Thread Chris Angelico
On Tue, 18 Oct 2022 at 03:51, Stefan Ram wrote: > > MRAB writes: > >It can't optimise that because, say, 'print' could've been bound to a > >function that rebinds 'str'. > > It would be possible to find out whether a call of a function > named "print" is to the standard function, but the

Re: Find the path of a shell command

2022-10-17 Thread Grant Edwards
On 2022-10-15, Andreas Eder wrote: > On Mi 12 Okt 2022 at 05:00, Paulo da Silva > wrote: > >> The simple question: How do I find the full path of a shell command >> (linux), i.e. how do I obtain the corresponding of, for example, >> "type rm" in command line? >> >> The reason: >> I have python

Re: Quick question about CPython interpreter

2022-10-17 Thread MRAB
On 2022-10-17 16:43, David Lowry-Duda wrote: One can use the `dis` module and investigate the generated python bytecode. For me, I get # file "dis1.py" thing = 123 for i in range(10): if "hi" == str(thing): print("found") break The bytecode is then 1 0

Re: Quick question about CPython interpreter

2022-10-17 Thread David Lowry-Duda
One can use the `dis` module and investigate the generated python bytecode. For me, I get # file "dis1.py" thing = 123 for i in range(10): if "hi" == str(thing): print("found") break The bytecode is then 1 0 LOAD_CONST 0 (123) 2

Re: Quick question about CPython interpreter

2022-10-17 Thread Michael Torrie
On 10/14/22 16:25, DFS wrote: > - > this does a str() conversion in the loop > - > for i in range(cells.count()): >if text == str(ID): > break > > >

Re: Optional arguments in a class behave like class attributes.

2022-10-17 Thread Chris Angelico
On Tue, 18 Oct 2022 at 01:39, Abderrahim Adrabi wrote: > So, these default values behave like class attributes, here is a demo: > > # Using a list - > class GameOne: > def __init__(self, games = []) -> None: > self.games = games > This makes the default be a

Re: for -- else: what was the motivation?

2022-10-17 Thread Robert Latest via Python-list
wrote: > I had another crazy thought that I AM NOT ASKING anyone to do. OK? > > I was wondering about a sort of catch method you could use that generates a > pseudo-signal only when the enclosed preceding loop exits normally as a > sort of way to handle the ELSE need without the use of a keyword

Re: Find the path of a shell command

2022-10-17 Thread Andreas Eder
On Mi 12 Okt 2022 at 05:00, Paulo da Silva wrote: > The simple question: How do I find the full path of a shell command > (linux), i.e. how do I obtain the corresponding of, for example, > "type rm" in command line? > > The reason: > I have python program that launches a detached rm. It works

Using Paramiko to submit job on SGE

2022-10-17 Thread Arshi Syed
Hi All, I am trying to run a script-1 on a Linux server using a Paramiko ssh connection and this script-1 calls script-2 which ultimately submits a job using a qsub command, job starts on SGE and I can see it through qstat but everything stops as soon as the script-1 stops. It seems the SSH

Quick question about CPython interpreter

2022-10-17 Thread DFS
- this does a str() conversion in the loop - for i in range(cells.count()): if text == str(ID): break

Re: for -- else: what was the motivation?

2022-10-17 Thread Dennis Lee Bieber
On Wed, 12 Oct 2022 23:19:39 +0100, Rob Cliffe declaimed the following: >I too have occasionally used for ... else.  It does have its uses. But >oh, how I wish it had been called something else more meaningful, >whether 'nobreak' or whatever.  It used to really confuse me.  Now I've

Optional arguments in a class behave like class attributes.

2022-10-17 Thread Abderrahim Adrabi
Hi all, I tried to create a class with some optional arguments as always, but this time I used the default values to be lists, dictionaries, and object references. So, these default values behave like class attributes, here is a demo: # Using a list - class GameOne:

Aw: Re: for -- else: what was the motivation?

2022-10-17 Thread Karsten Hilbert
> which had special combinations for all the BASIC keywords). And if you > go this way, why not go a step further and dissociate the program from > its linear text representation? Add footnotes, different views, > hyperlinks, format mathematical expressions like formulas, etc.

Re: for -- else: what was the motivation?

2022-10-17 Thread Chris Angelico
On Mon, 17 Oct 2022 at 16:36, Antoon Pardon wrote: > > > > Op 17/10/2022 om 04:01 schreef Chris Angelico: > > On Mon, 17 Oct 2022 at 10:46, wrote: > >> My point Chris was that you can have a conversation where you are exploring > >> and not proposing. Brainstorming, perhaps. > > And my point is