Re: typing: property/setter and lists? [RESOLVED ERRATA]

2022-11-04 Thread Paulo da Silva
Às 07:52 de 04/11/22, dn escreveu: On 04/11/2022 07.50, Chris Angelico wrote: On Fri, 4 Nov 2022 at 05:48, Paulo da Silva wrote: Às 05:32 de 03/11/22, Paulo da Silva escreveu: Às 03:24 de 03/11/22, Paulo da Silva escreveu: Hi! And a typing problem again

Re: typing: property/setter and lists?

2022-11-03 Thread Paulo da Silva
Às 07:55 de 03/11/22, dn escreveu: On 03/11/2022 16.24, Paulo da Silva wrote: class C:  def __init__(self): self.__foos=5*[0]  @property  def foos(self) -> list[int]: return self.__foos  @foos.setter  def foos(self,v: int): self.__foos=[v for

Re: typing: property/setter and lists? [RESOLVED]

2022-11-03 Thread Paulo da Silva
Às 18:16 de 03/11/22, Chris Angelico escreveu: On Fri, 4 Nov 2022 at 05:03, Paulo da Silva wrote: Changing def foos(self) -> list[int]: to def foos(self) -> Union[list[int]]: fixes the problem. Not so elegant, however! Wait, what?! Union[X, Y] means "X or Y" Union[X] mea

Re: typing: property/setter and lists? [RESOLVED ERRATA]

2022-11-03 Thread Paulo da Silva
Às 05:32 de 03/11/22, Paulo da Silva escreveu: Às 03:24 de 03/11/22, Paulo da Silva escreveu: Hi! And a typing problem again!!! ___ class C:  def __init__(self): self.__foos=5*[0]  @property  def foos(self) -> list[int]: ret

Re: typing: property/setter and lists? [RESOLVED]

2022-11-03 Thread Paulo da Silva
Às 03:24 de 03/11/22, Paulo da Silva escreveu: Hi! And a typing problem again!!! ___ class C: def __init__(self):     self.__foos=5*[0] @property def foos(self) -> list[int]:     return self.__foos @foos.setter def f

typing: property/setter and lists?

2022-11-02 Thread Paulo da Silva
Hi! And a typing problem again!!! ___ class C: def __init__(self): self.__foos=5*[0] @property def foos(self) -> list[int]: return self.__foos @foos.setter def foos(self,v: int):

Re: Fwd: A typing question

2022-11-01 Thread Paulo da Silva
Às 21:08 de 31/10/22, Peter J. Holzer escreveu: On 2022-10-30 11:26:56 +0100, Peter J. Holzer wrote: On 2022-10-29 23:59:44 +0100, Paulo da Silva wrote: The funny thing is that if I replace foos by Foos it works because it gets known by the initial initialization

Re: Fwd: A typing question

2022-10-30 Thread Paulo da Silva
Às 17:06 de 30/10/22, Stefan Ram escreveu: Paulo da Silva writes: Is there anything to do without loosing my script structure and usual practice? to lose (losing): to stop having something to loose (loosing): to let or make loose (see next line) loose (adj.): not firmly attached

Re: Fwd: A typing question

2022-10-30 Thread Paulo da Silva
Às 22:34 de 29/10/22, dn escreveu: Out of interest, tested snippet in PyCharm, cf native-mypy. It flags the original:     GLOBALS.foos: Optional[Foos]=Foos() but not the fall-back:     GLOBALS.foos=Foos() Must admit, the first query coming to mind was: why is the typing taking place at i

Re: Fwd: A typing question

2022-10-30 Thread Paulo da Silva
Às 10:26 de 30/10/22, Peter J. Holzer escreveu: On 2022-10-29 23:59:44 +0100, Paulo da Silva wrote: Às 22:34 de 29/10/22, dn escreveu: Solution (below) will not work if the mention of Foos in GLOBALS is a forward-reference. Either move GLOBALS to suit, or surround "Foos" w

Re: A typing question

2022-10-30 Thread Paulo da Silva
Às 01:14 de 30/10/22, Thomas Passin escreveu: On 10/29/2022 1:45 PM, Paulo da Silva wrote: Hi! Consider this simple script ... ___ from typing import List, Optional class GLOBALS: foos=None class Foo: def __init__(self): pass class Foos: Foos: List

Re: Fwd: A typing question

2022-10-30 Thread Paulo da Silva
Às 02:32 de 30/10/22, dn escreveu: On 30/10/2022 11.59, Paulo da Silva wrote: Solution (below) will not work if the mention of Foos in GLOBALS is a forward-reference. Either move GLOBALS to suit, or surround "Foos" with quotes. This is the problem for me. So far, without typing, I us

Re: Fwd: A typing question

2022-10-29 Thread Paulo da Silva
rote: Do you want the following? ``` from typing import List, Optional class GLOBALS: foos: Optional[Foos] = None class Foo: def __init__(self): pass class Foos: Foos: List[Foo] = [] def __init__(self): pass GLOBALS.foos = Foos() ``` Kind regards, Sam

A typing question

2022-10-29 Thread Paulo da Silva
Hi! Consider this simple script ... ___ from typing import List, Optional class GLOBALS: foos=None class Foo: def __init__(self): pass class Foos: Foos: List[Foo]=[] # SOME GLOBALS ARE USED HERE in a real script def __init__(self): pass G

Re: Typing: Is there a "cast operator"?

2022-10-23 Thread Paulo da Silva
Às 23:56 de 23/10/22, Cameron Simpson escreveu: On 23Oct2022 21:36, Paulo da Silva wrote: I am in the process of "typing" of some of my scripts. Using it should help a lot to avoid some errors. But this is new for me and I'm facing some problems. Let's I have the followin

Re: Typing: Is there a "cast operator"? [RESOLVED]

2022-10-23 Thread Paulo da Silva
Às 21:36 de 23/10/22, Paulo da Silva escreveu: Hello! I am in the process of "typing" of some of my scripts. Using it should help a lot to avoid some errors. But this is new for me and I'm facing some problems. Let's I have the following code (please don't look at the

Re: A trivial question that I don't know - document a function/method

2022-10-23 Thread Paulo da Silva
Às 21:58 de 22/10/22, Paulo da Silva escreveu: Hi all! What is the correct way, if any, of documenting a function/method? Thank you all for the, valuable as usual, suggestions. I am now able to make my choices. Paulo -- https://mail.python.org/mailman/listinfo/python-list

Typing: Is there a "cast operator"?

2022-10-23 Thread Paulo da Silva
Hello! I am in the process of "typing" of some of my scripts. Using it should help a lot to avoid some errors. But this is new for me and I'm facing some problems. Let's I have the following code (please don't look at the program content): f=None # mypy naturally assumes Optional(int) because

A trivial question that I don't know - document a function/method

2022-10-22 Thread Paulo da Silva
Hi all! What is the correct way, if any, of documenting a function/method? 1. def foo(a,b): """ A description. a: Whatever 1 b: Whatever 2 """ ... 2. def foo(a,b): """ A description. a -- Whatever 1 b -- Whatever 2 """

Re: Find the path of a shell command [POSTPONED]

2022-10-12 Thread Paulo da Silva
Às 05:00 de 12/10/22, Paulo da Silva escreveu: Hi! 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 wo

Re: Find the path of a shell command

2022-10-12 Thread Paulo da Silva
Às 22:38 de 12/10/22, Jon Ribbens escreveu: On 2022-10-12, Jon Ribbens wrote: On 2022-10-12, Paulo da Silva wrote: Às 19:14 de 12/10/22, Jon Ribbens escreveu: On 2022-10-12, Paulo da Silva wrote: Às 05:00 de 12/10/22, Paulo da Silva escreveu: Hi! The simple question: How do I find the

Re: Find the path of a shell command

2022-10-12 Thread Paulo da Silva
Às 20:09 de 12/10/22, Antoon Pardon escreveu: Op 12/10/2022 om 18:49 schreef Paulo da Silva: Às 05:00 de 12/10/22, Paulo da Silva escreveu: Hi! 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 r

Re: Find the path of a shell command

2022-10-12 Thread Paulo da Silva
Às 19:14 de 12/10/22, Jon Ribbens escreveu: On 2022-10-12, Paulo da Silva wrote: Às 05:00 de 12/10/22, Paulo da Silva escreveu: Hi! 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 co

Re: Find the path of a shell command

2022-10-12 Thread Paulo da Silva
Às 20:16 de 12/10/22, 2qdxy4rzwzuui...@potatochowder.com escreveu: On 2022-10-12 at 17:43:18 +0100, Paulo da Silva wrote: Às 17:22 de 12/10/22, Tilmann Hentze escreveu: Paulo da Silva schrieb: I have python program that launches a detached rm. It works pretty well until it is invoked by

Re: Find the path of a shell command

2022-10-12 Thread Paulo da Silva
Às 17:22 de 12/10/22, Tilmann Hentze escreveu: Paulo da Silva schrieb: I have python program that launches a detached rm. It works pretty well until it is invoked by cron! I suspect that for cron we need to specify the full path. Probably you could use os.unlink[1] with no problem. No

Re: Find the path of a shell command

2022-10-12 Thread Paulo da Silva
Às 05:00 de 12/10/22, Paulo da Silva escreveu: Hi! 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 wo

Find the path of a shell command

2022-10-12 Thread Paulo da Silva
Hi! 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 pretty well until it is invoked by cron! I suspect that f

Re: Subtract n months from datetime

2022-06-22 Thread Paulo da Silva
Às 19:47 de 22/06/22, Marco Sulla escreveu: The package arrow has a simple shift method for months, weeks etc https://arrow.readthedocs.io/en/latest/#replace-shift At first look it seems pretty good! I didn't know it. Thank you Marco. Paulo -- https://mail.python.org/mailman/listinfo/python-l

Re: Subtract n months from datetime [Why?]

2022-06-22 Thread Paulo da Silva
Às 20:25 de 22/06/22, Barry Scott escreveu: On 22 Jun 2022, at 17:59, Paulo da Silva wrote: Às 05:29 de 21/06/22, Paulo da Silva escreveu: As a general response to some comments ... Suppose we need to delete records from a database older than ... Today, it's usual to specify days

Re: Subtract n months from datetime [Why?]

2022-06-22 Thread Paulo da Silva
Às 05:29 de 21/06/22, Paulo da Silva escreveu: As a general response to some comments ... Suppose we need to delete records from a database older than ... Today, it's usual to specify days. For example you have to keep some gov papers for 90 days. This seems to come from computers era. I

Re: Subtract n months from datetime

2022-06-21 Thread Paulo da Silva
me(*dtnow_t) Any comments are welcome. Thank you. Paulo On Tue, 2022-06-21 at 05:29 +0100, Paulo da Silva wrote: Hi! I implemented a part of a script to subtract n months from datetime. Basically I subtracted n%12 from year and n//12 from the month adding 12 months when it goes<=0. Then used

Subtract n months from datetime

2022-06-20 Thread Paulo da Silva
Hi! I implemented a part of a script to subtract n months from datetime. Basically I subtracted n%12 from year and n//12 from the month adding 12 months when it goes<=0. Then used try when converting to datetime again. So, if the day is for example 31 for a 30 days month it raises a ValuError

Re: "CPython"

2022-06-20 Thread Paulo da Silva
Às 03:20 de 21/06/22, MRAB escreveu: On 2022-06-21 02:33, Chris Angelico wrote: On Tue, 21 Jun 2022 at 11:13, Paulo da Silva wrote: Às 20:01 de 20/06/22, Paulo da Silva escreveu: > Às 18:19 de 20/06/22, Stefan Ram escreveu: >>    The same personality traits that make people react

Re: "CPython"

2022-06-20 Thread Paulo da Silva
Às 02:33 de 21/06/22, Chris Angelico escreveu: On Tue, 21 Jun 2022 at 11:13, Paulo da Silva wrote: Às 20:01 de 20/06/22, Paulo da Silva escreveu: Às 18:19 de 20/06/22, Stefan Ram escreveu: The same personality traits that make people react to troll postings might make them spread

Re: "CPython"

2022-06-20 Thread Paulo da Silva
Às 20:01 de 20/06/22, Paulo da Silva escreveu: Às 18:19 de 20/06/22, Stefan Ram escreveu:    The same personality traits that make people react    to troll postings might make them spread unconfirmed    ideas about the meaning of "C" in "CPython".    The /core/ of CPy

Re: "CPython"

2022-06-20 Thread Paulo da Silva
Às 18:19 de 20/06/22, Stefan Ram escreveu: The same personality traits that make people react to troll postings might make them spread unconfirmed ideas about the meaning of "C" in "CPython". The /core/ of CPython is written in C. CPython is the /canonical/ implementation of Pyth

Re: What's up with modern Python programmers rewriting everything in Rust?

2022-06-20 Thread Paulo da Silva
Às 15:07 de 19/06/22, jan Anja escreveu: Dude, it's called CPython for a reason. IMHO CPython means Core Python, not C Python. -- https://mail.python.org/mailman/listinfo/python-list

Re: What's up with modern Python programmers rewriting everything in Rust?

2022-06-20 Thread Paulo da Silva
Às 16:40 de 20/06/22, Dennis Lee Bieber escreveu: On Mon, 20 Jun 2022 15:54:29 +0100, Paulo da Silva declaimed the following: Às 15:07 de 19/06/22, jan Anja escreveu: Dude, it's called CPython for a reason. IMHO CPython means Core Python, not C Python. It is, as I recall, a

pandas (in jupyter?) problem

2022-05-06 Thread Paulo da Silva
Hi all! I'm having the following problem. Consider the code (the commented or the not commented which I think do the same things): #for col in missing_cols: #df[col] = np.nan df=df.copy() df[missing_cols]=np.nan df has about 2 cols and len(missing_cols) is about 18000. I'm getting l

Re: Unpacking lists in a f string

2022-02-09 Thread Paulo da Silva
Às 02:17 de 09/02/22, Paulo da Silva escreveu: Hi! Let's say I have two lists of equal length but with a variable number of elements. For ex.: l1=['a','b','c'] l2=['j','k','l'] I want to build a string like this "foo a

Unpacking lists in a f string

2022-02-09 Thread Paulo da Silva
Hi! Let's say I have two lists of equal length but with a variable number of elements. For ex.: l1=['a','b','c'] l2=['j','k','l'] I want to build a string like this "foo a j, b k, c l bar" Is it possible to achieve this with f strings or any other simple/efficient way? Thanks for any help

Re: Writing a package

2022-02-04 Thread Paulo da Silva
Às 02:01 de 05/02/22, Cameron Simpson escreveu: On 05Feb2022 00:37, Paulo da Silva wrote: Let's say I have a dir src containing another dir named foo and a script test.py. So, I have src/foo (dir) src/test.py (script) test.py has the folloing code: import foo as f c=f.C() I am insid

Writing a package

2022-02-04 Thread Paulo da Silva
Hello! Let's say I have a dir src containing another dir named foo and a script test.py. So, I have src/foo (dir) src/test.py (script) test.py has the folloing code: import foo as f c=f.C() I am inside src and want to run python test.py. How can I create the class C inside src/foo dir if i

Re: Avoid nested SIGINT handling

2021-11-11 Thread Paulo da Silva
Às 06:22 de 11/11/21, Chris Angelico escreveu: > On Thu, Nov 11, 2021 at 5:01 PM Jon Ribbens via Python-list > wrote: >> >> On 2021-11-10, Paulo da Silva wrote: >>> Hi! >>> >>> How do I handle a SIGINT (or any other signal) avoid nesting? >>

Re: Avoid nested SIGINT handling

2021-11-10 Thread Paulo da Silva
Às 21:55 de 10/11/21, Jon Ribbens escreveu: > On 2021-11-10, Paulo da Silva wrote: >> Hi! >> >> How do I handle a SIGINT (or any other signal) avoid nesting? > > I don't think you need to. Python will only call signal handlers in > the main thread, so a hand

Avoid nested SIGINT handling

2021-11-10 Thread Paulo da Silva
Hi! How do I handle a SIGINT (or any other signal) avoid nesting? Does this work? class STATUS: InInt=False def SIGINT_handler(sn,f): if STATUS.InInt: return STATUS.InInt=True process_int() STATUS.InInt=False Thanks for any suggestions. Paulo -- https:/

Re: New assignmens ...

2021-10-22 Thread Paulo da Silva
Às 20:34 de 22/10/21, Chris Angelico escreveu: > On Sat, Oct 23, 2021 at 6:24 AM Jon Ribbens via Python-list > wrote: >> >> On 2021-10-22, Stefan Ram wrote: >>> Paulo da Silva writes: >>>> Why doesn't this work >>>> if (self.ctr:=self

New assignmens ...

2021-10-22 Thread Paulo da Silva
Hi! Why doesn't this work if (self.ctr:=self.ctr-1)<=0: while this works if (ctr:=ctr-1)<=0: Thanks -- https://mail.python.org/mailman/listinfo/python-list

Re: spyder does not work under root! [linux]

2021-10-14 Thread Paulo da Silva
Às 23:55 de 13/10/21, Michael Torrie escreveu: > On 10/13/21 12:09 PM, Paulo da Silva wrote: >> spyder and eric are both python editors/debuggers! Why are they related >> with web browsers?! > > Good point. I was going off of the chromium bug report. My bad. I > mis

Re: spyder does not work under root! [linux]

2021-10-14 Thread Paulo da Silva
Às 16:16 de 14/10/21, Mats Wichmann escreveu: > On 10/13/21 16:55, Michael Torrie wrote: >> On 10/13/21 12:09 PM, Paulo da Silva wrote: >>> spyder and eric are both python editors/debuggers! Why are they related >>> with web browsers?! >> >> Good point. I w

Re: spyder does not work under root! [linux]

2021-10-13 Thread Paulo da Silva
Às 02:08 de 12/10/21, Michael Torrie escreveu: > On 10/8/21 4:32 PM, Paulo da Silva wrote: >> Às 22:56 de 08/10/21, Paulo da Silva escreveu: >>> Hi! >>> >>> I need to debug a python3 script under root. I tried spyder but it does >>> not work. >&g

Re: spyder does not work under root! [linux]

2021-10-13 Thread Paulo da Silva
Às 22:54 de 11/10/21, Chris Angelico escreveu: > On Tue, Oct 12, 2021 at 8:52 AM Paulo da Silva > wrote: >> >> Hi! >> >> I need to debug a python3 script under root. I tried spyder but it does >> not work. >> >> Running as root without --no-sa

Re: Assign a value to a var content in an object

2021-10-11 Thread Paulo da Silva
Às 23:28 de 10/10/21, Stefan Ram escreveu: > Paulo da Silva writes: >> class C: >>def f(self,v): >>#setattr(self,n,v) >>self.__dict__['n']=v > >> Why didn't setattr (as commented) work? > > Because the name n has not

Assign a value to a var content in an object

2021-10-11 Thread Paulo da Silva
Hello! Is there a better way of doing this? Why didn't setattr (as commented) work? Thanks for an help/comments. class C: def f(self,v): #setattr(self,n,v) self.__dict__['n']=v c=C() c.f(3) print(c.n) -- https://mail.python.org/mailman/listinfo/python-list

Re: spyder does not work under root! [linux]

2021-10-11 Thread Paulo da Silva
Às 22:56 de 08/10/21, Paulo da Silva escreveu: > Hi! > > I need to debug a python3 script under root. I tried spyder but it does > not work. > > Running as root without --no-sandbox is not supported. See > https://crbug.com/638180. > > Thanks for any comments includi

spyder does not work under root! [linux]

2021-10-11 Thread Paulo da Silva
Hi! I need to debug a python3 script under root. I tried spyder but it does not work. Running as root without --no-sandbox is not supported. See https://crbug.com/638180. Thanks for any comments including alternative solutions to debug as root. Paulo -- https://mail.python.org/mailman/listinfo

Re: Class and tkinter problem

2021-01-07 Thread Paulo da Silva
Às 20:35 de 07/01/21, Terry Reedy escreveu: > On 1/7/2021 4:20 AM, Terry Reedy wrote: >> On 1/7/2021 2:42 AM, Christian Gollwitzer wrote: >>> Am 07.01.21 um 08:29 schrieb Paulo da Silva: >>> >>>> Does anybody know why cmd method isn't called when I chan

Re: Class and tkinter problem

2021-01-07 Thread Paulo da Silva
Às 07:29 de 07/01/21, Paulo da Silva escreveu: > Hi! > > Does anybody know why cmd method isn't called when I change the button > state (clicking on it) in this example? > I know that this seems a weird class use. But why doesn't it work? > Thanks. > >

Re: Class and tkinter problem

2021-01-07 Thread Paulo da Silva
Às 16:02 de 07/01/21, Peter Otten escreveu: > On 07/01/2021 08:42, Christian Gollwitzer wrote: >> Am 07.01.21 um 08:29 schrieb Paulo da Silva: >> ... > > I recommend that the OP use a more conventional stye and do the setup > outside the class or, better, in an instanc

Re: Class and tkinter problem

2021-01-07 Thread Paulo da Silva
Às 09:20 de 07/01/21, Terry Reedy escreveu: > On 1/7/2021 2:42 AM, Christian Gollwitzer wrote: >> Am 07.01.21 um 08:29 schrieb Paulo da Silva: >> >>> Does anybody know why cmd method isn't called when I change the button >>> state (clicking on it) in this

Re: Class and tkinter problem

2021-01-07 Thread Paulo da Silva
Às 07:42 de 07/01/21, Christian Gollwitzer escreveu: > Am 07.01.21 um 08:29 schrieb Paulo da Silva: > >> Does anybody know why cmd method isn't called when I change the button >> state (clicking on it) in this example? >> I know that this seems a weird class

Class and tkinter problem

2021-01-06 Thread Paulo da Silva
Hi! Does anybody know why cmd method isn't called when I change the button state (clicking on it) in this example? I know that this seems a weird class use. But why doesn't it work? Thanks. class C: from tkinter import Checkbutton import tkinter @staticmethod def cmd(): p

Re: numpy/python (image) problem

2020-12-09 Thread Paulo da Silva
Às 05:55 de 09/12/20, Paulo da Silva escreveu: > Hi! > > I am looking at some code, that I found somewhere in the internet, to > compute DCT for each 8x8 block in an gray (2D) image (512x512). > > This is the code: > > def dct2(a): > return > scipy.fft.dct(scip

numpy/python (image) problem

2020-12-08 Thread Paulo da Silva
Hi! I am looking at some code, that I found somewhere in the internet, to compute DCT for each 8x8 block in an gray (2D) image (512x512). This is the code: def dct2(a): return scipy.fft.dct(scipy.fft.dct(a,axis=0,norm='ortho'),axis=1,norm='ortho') imsize=im.shape dct=np.zeros(imsize) # Do

Re: Learning tkinter - a grid problem

2020-12-05 Thread Paulo da Silva
Às 20:20 de 05/12/20, MRAB escreveu: > On 2020-12-05 18:56, Paulo da Silva wrote: >> Hi! >> >> Why this example does not work? >> > There are a few bits of configuration missing: > >> -- >> from tkinter import * >>

Learning tkinter - a grid problem

2020-12-05 Thread Paulo da Silva
Hi! Why this example does not work? -- from tkinter import * root=Tk() root.geometry("400x200") S=Scrollbar(root) T=Text(root) T.grid(row=0,column=0) S.grid(row=0,column=1) S.config(command=T.yview) T.config(yscrollcommand=S.set) txt="""This is a very big text - - - - - - - - - -

Re: Problem exiting from a script using tkinter

2020-11-25 Thread Paulo da Silva
Às 22:44 de 21/11/20, Chris Angelico escreveu: > On Sun, Nov 22, 2020 at 9:36 AM Paulo da Silva > wrote: >> >> Às 22:18 de 21/11/20, Chris Angelico escreveu: >>> On Sun, Nov 22, 2020 at 9:16 AM Paulo da Silva >>> wrote: >>>> >>>> H

Re: Problem exiting from a script using tkinter

2020-11-21 Thread Paulo da Silva
Às 22:18 de 21/11/20, Chris Angelico escreveu: > On Sun, Nov 22, 2020 at 9:16 AM Paulo da Silva > wrote: >> >> Hi! >> >> Why this does not work?! >> >> from tkinter import * >> >> def terminate(root): >> root.quit >> > >

Problem exiting from a script using tkinter

2020-11-21 Thread Paulo da Silva
Hi! Why this does not work?! from tkinter import * def terminate(root): root.quit root=Tk() #b=Button(root,text="QUIT",command=root.quit) b=Button(root,text="QUIT",command=lambda: terminate(root)) b.pack() mainloop() Thanks -- https://mail.python.org/mailman/listinfo/python-list

Re: Like c enumeration in python3

2020-03-23 Thread Paulo da Silva
Thank you very much for all your responses! Now I have too much ideas :-) I'm saving your answers and I'll see what is more appropriate/comfortable in my case. Best regards. Paulo -- https://mail.python.org/mailman/listinfo/python-list

Re: Like c enumeration in python3 [ERRATA]

2020-03-22 Thread Paulo da Silva
Às 02:18 de 23/03/20, Paulo da Silva escreveu: > Hi! > > Suppose a class C. > I want something like this: > > class C: > KA=0 > KB=1 KC=2 > ... > Kn=n > > def __init__ ... > ... > > > These

Like c enumeration in python3

2020-03-22 Thread Paulo da Silva
Hi! Suppose a class C. I want something like this: class C: KA=0 KB=1 KC=1 ... Kn=n def __init__ ... ... These constants come from an enum in a .h (header of C file). They are many and may change from time to time. Is there a way

Re: super or not super?

2019-07-16 Thread Paulo da Silva
Às 02:11 de 15/07/19, Chris Angelico escreveu: > On Mon, Jul 15, 2019 at 10:51 AM Paulo da Silva > wrote: >> ... >> >> Thank you Jollans. I forgot multiple inheritance. I never needed it in >> python, so far. >> > > Something to consider is that sup

Re: super or not super?

2019-07-14 Thread Paulo da Silva
Às 16:20 de 12/07/19, Rhodri James escreveu: > On 12/07/2019 15:12, Paulo da Silva wrote: > ... > super() also has major advantages if you are stuck with multiple > inheritance.  Raymond Hettinger has an excellent article on this here: > https://rhettinger.wordpress.com/2

Re: super or not super?

2019-07-14 Thread Paulo da Silva
Às 15:30 de 12/07/19, Thomas Jollans escreveu: > On 12/07/2019 16.12, Paulo da Silva wrote: >> Hi all! >> >> Is there any difference between using the base class name or super to >> call __init__ from base class? > > There is, when multiple inheritance is invol

super or not super?

2019-07-12 Thread Paulo da Silva
Hi all! Is there any difference between using the base class name or super to call __init__ from base class? class C1: def __init__(self): ... class C2(C1): def __init__(self): C1.__init__(self) or super().__init__() ?? ... I have

Re: Dataframe with two groups of cols. [RESOLVED]

2019-06-14 Thread Paulo da Silva
Às 18:31 de 14/06/19, Paulo da Silva escreveu: > Às 04:56 de 14/06/19, Paulo da Silva escreveu: ... > > After digging a lot :-) , and for those who may be interested, I found > one way: > > In [21]: d1 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, > 9]]),col

Re: Dataframe with two groups of cols. [RESOLVED]

2019-06-14 Thread Paulo da Silva
Às 04:56 de 14/06/19, Paulo da Silva escreveu: > Hi! > > How do I create a pandas dataframe with two (or more) groups of cols.? > > Ex.: > > G1 G2 > C1 C2 C3 C1 C2 C3 > Rows of values ... > > I then should be able to access for example > df['G2&#x

Dataframe with two groups of cols.

2019-06-13 Thread Paulo da Silva
Hi! How do I create a pandas dataframe with two (or more) groups of cols.? Ex.: G1 G2 C1 C2 C3 C1 C2 C3 Rows of values ... I then should be able to access for example df['G2']['C3'][] Thanks. -- https://mail.python.org/mailman/listinfo/python-list

Re: Better ways for implementing two situations

2019-04-23 Thread Paulo da Silva
Às 22:21 de 21/04/19, Paul Rubin escreveu: > Paulo da Silva writes: >> splitter={} >> for f in Objs: >> splitter.setdefault(f.getId1,[]).append(f) >> groups=[gs for gs in splitter.values() if len(gs)>1] > > It's easiest if you can sort the input l

Re: Better ways for implementing two situations

2019-04-23 Thread Paulo da Silva
Às 20:41 de 21/04/19, DL Neil escreveu: > Olá Paulo, > ... > > Given that we're talking "big data", which Python Data Science tools are > you employing? eg NumPy. Sorry. I misused the term "big data". I should have said a big amount of data. It is all about objects built of text and some number

Re: Better ways for implementing two situations

2019-04-23 Thread Paulo da Silva
Às 20:10 de 21/04/19, MRAB escreveu: > On 2019-04-21 19:23, Paulo da Silva wrote: >> Hi all. >> ... > Have you compared the speed with an implementation that uses > defaultdict? Your code always creates an empty list for each item, even > though it might not be needed.

Re: Better ways for implementing two situations

2019-04-23 Thread Paulo da Silva
Às 19:42 de 21/04/19, Stefan Ram escreveu: > Paulo da Silva writes: >> I have a list of objects and want to split it in a list of groups. >> "equal objects" is based on an id we can get from the object. > > main.py > > input = [ 'abc', '

Better ways for implementing two situations

2019-04-21 Thread Paulo da Silva
Hi all. I am looking for improved solutions to these two problems. They are to be in a program that deals with big data. So, they need to be fast and save memory. Problem 1. I have a list of objects and want to split it in a list of groups. Each group must have all "equal objects" and have more

Re: Getting file extensions [linux fs]

2019-04-08 Thread Paulo da Silva
Às 01:35 de 06/04/19, Pablo Lucena escreveu: > Have you looked into eBPF? I'll take a look at that. Thanks Pablo. -- https://mail.python.org/mailman/listinfo/python-list

Re: Getting file extensions [linux fs]

2019-03-30 Thread Paulo da Silva
Às 22:18 de 28/03/19, Cameron Simpson escreveu: > On 28Mar2019 01:12, Paulo da Silva wrote: >> Às 23:09 de 27/03/19, Cameron Simpson escreveu: ... > > Oh, just tangential to this. > > If you were doing this ad hoc, yes calling the filefrag executable is > very expensiv

Re: Getting file extensions [linux fs]

2019-03-27 Thread Paulo da Silva
Às 23:09 de 27/03/19, Cameron Simpson escreveu: > On 27Mar2019 21:49, Paulo da Silva wrote: ... > The filefrag manual entry says it works by calling one of 2 ioctls. You > can do that from Python with the ioctl() function in the standard fcntl > module. I haven't tried to do this

Getting file extensions [linux fs]

2019-03-27 Thread Paulo da Silva
Hi! I don't know if this is the right group to ask ... sorry if it isn't. Is there a way to get the file extensions of a file in linux, the same way as "filefrag -e " does? The purpose is to see if two files are the same file, namely those copied with the --reflink option in btrfs. A solution f

Re: conda/anaconda and pip3 (pip)

2019-01-05 Thread Paulo da Silva
Às 17:39 de 03/12/18, Paulo da Silva escreveu: Well ... further clarification ... > Hi! > > I have an environment created with conda (anaconda3). > There is a package that is unavailable in conda. The package is sklearn (import sklearn). - Look below before comment pls. > Ins

Re: conda/anaconda and pip3 (pip)

2019-01-04 Thread Paulo da Silva
Às 19:39 de 02/01/19, Hartmut Goebel escreveu: > Am 03.12.18 um 18:39 schrieb Paulo da Silva: >> This also has a bad side effect! It reinstalls there some depedencies >> already installed in the conda created environment! >> >> Is there a way to avoid this situation

Re: conda/anaconda and pip3 (pip)

2019-01-04 Thread Paulo da Silva
Às 19:54 de 09/12/18, Tim Williams escreveu: > On Saturday, December 8, 2018 at 10:13:14 PM UTC-5, Monte Milanuk wrote: >> Did you find any solution(s)? > > I usually just lurk and read on this list. I don't reply since there's > usually more competent people that regularly post helpful answers.

Re: cython3: Cannot start!

2018-12-24 Thread Paulo da Silva
Às 14:07 de 24/12/18, Stefan Behnel escreveu: > Paulo da Silva schrieb am 22.12.18 um 19:26: ... > > Ubuntu 18.04 ships Cython 0.26, which has a funny bug that you hit above. > It switches the language-level too late, so that the first token (or word) > in the file is parsed with

Re: cython3: Cannot start! [RESOLVED]

2018-12-22 Thread Paulo da Silva
Às 19:48 de 22/12/18, MRAB escreveu: > On 2018-12-22 18:26, Paulo da Silva wrote: ... > Well, I've just tried this on Raspbian with the same files (for Python 3): > > python3 -m pip install cython > python3 setup.py build_ext --inplace > python3 -c 'import tp'

cython3: Cannot start!

2018-12-22 Thread Paulo da Silva
Hi! Sorry if this is OT. I decided to give cython a try and cannot run a very simple program! 1. I am using kubuntu 18.04 and installe cython3 (not cython). 2. My program tp.pyx: # cython: language_level=3 print("Test",2) 3. setup.py from distutils.core import setup from Cython.Build import cy

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread Paulo da Silva
Às 01:17 de 08/12/18, jf...@ms4.hinet.net escreveu: 00 > 0 03 > File "", line 1 > 03 > ^ > SyntaxError: invalid token > > Any particular reason? > Not sure but I think that after 0 it expects x for hexadecimal, o for octal, b for binary, ... may be others. 0xa 10 0o10

Re: tkinter resizable text with grid

2018-12-07 Thread Paulo da Silva
Às 07:11 de 07/12/18, Christian Gollwitzer escreveu: > Am 07.12.18 um 03:00 schrieb Paulo da Silva: >> Às 21:15 de 06/12/18, Rick Johnson escreveu:  ... > So instead of complaining about lacking support in Tk, the > Python community should do their homework and provide wrapper

Re: tkinter resizable text with grid

2018-12-06 Thread Paulo da Silva
Às 21:15 de 06/12/18, Rick Johnson escreveu: > Paulo da Silva wrote: > ... > > In Tkinter, if you have a "container"[1] that only has a > single widget stuffed inside, and, you want that single > widget to expand to fill the extents of its parent > container, the

Re: tkinter resizable text with grid

2018-12-06 Thread Paulo da Silva
Às 08:24 de 06/12/18, Peter Otten escreveu: > Paulo da Silva wrote: > ... > > You have to set the column/row weight of the /master/: > > master.grid_columnconfigure(1, weight=1) > master.grid_rowconfigure(1, weight=1) Ok. That works! > > Als

tkinter resizable text with grid

2018-12-05 Thread Paulo da Silva
Hi! Does anybody know why this code does not expand the text widget when I increase the window size (with mouse)? I want height and width but as minimum (or may be initial) size. import tkinter as tk class App: def __init__(self,master): self.tboard=tk.Text(master,height=

conda/anaconda and pip3 (pip)

2018-12-03 Thread Paulo da Silva
Hi! I have an environment created with conda (anaconda3). There is a package that is unavailable in conda. Installing it with pip3, with conda env activated, the installation goes to .local/bin and .local/lib in my home dir (BTW I'm running linux kubuntu 18.04). This also has a bad side effect! It

  1   2   3   >