Re: Learning tkinter - a grid problem
Am 05.12.2020 um 19:56 schrieb Paulo da Silva:
Hi!
Why this example does not work?
--
from tkinter import *
root=Tk()
root.geometry("400x200")
S=Scrollbar(root)
T=Text(root)
...
mainloop()
-
Shouldn't that be
root.mainloop()
?
--
https://mail.python.org/mailman/listinfo/python-list
Re: Learning tkinter - a grid problem
On 2020-12-06 08:11, Sibylle Koczian wrote:
Am 05.12.2020 um 19:56 schrieb Paulo da Silva:
Hi!
Why this example does not work?
--
from tkinter import *
root=Tk()
root.geometry("400x200")
S=Scrollbar(root)
T=Text(root)
...
mainloop()
-
Shouldn't that be
root.mainloop()
?
The function 'mainloop' calls the 'mainloop' method of the root Tk
window created by Tk(), so it does work as-is.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Learning tkinter - a grid problem
Am 06.12.2020 um 15:19 schrieb MRAB:
On 2020-12-06 08:11, Sibylle Koczian wrote:
Am 05.12.2020 um 19:56 schrieb Paulo da Silva:
Hi!
Why this example does not work?
--
from tkinter import *
root=Tk()
root.geometry("400x200")
S=Scrollbar(root)
T=Text(root)
...
mainloop()
-
Shouldn't that be
root.mainloop()
?
The function 'mainloop' calls the 'mainloop' method of the root Tk
window created by Tk(), so it does work as-is.
Didn't know that, thank you!
--
https://mail.python.org/mailman/listinfo/python-list
Re: Learning tkinter - a grid problem
On 12/6/2020 3:11 AM, Sibylle Koczian wrote:
Am 05.12.2020 um 19:56 schrieb Paulo da Silva:
Why this example does not work?
--
from tkinter import *
root=Tk()
root.geometry("400x200")
S=Scrollbar(root)
T=Text(root)
...
mainloop()
Shouldn't that be
root.mainloop()
?
Yes. The * import does not turn method into module functions.
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list
Error
Good day," I purchased a book for my son and followed the directions to a T. (Coding Games in Python) Whenever I got to the point of of moving the "hello" file over to pgzrun is where my trouble began. Its not finding a path because I'm getting this "pgzrun is not recognized as an internal or external command". I've uninstall reinstall and tried to trouble shoot offline. I' believe its a "path" issue but that is a little over my head. At least this is what I've read. Yes I selected all users and the variables options on custom install. Any Suggestions? -- https://mail.python.org/mailman/listinfo/python-list
Re: Error
On 06/12/2020 07:41, Barry Fitzgerald via Python-list wrote: Good day," I purchased a book for my son and followed the directions to a T. (Coding Games in Python) Whenever I got to the point of of moving the "hello" file over to pgzrun is where my trouble began. Its not finding a path because I'm getting this "pgzrun is not recognized as an internal or external command". I've uninstall reinstall and tried to trouble shoot offline. I' believe its a "path" issue but that is a little over my head. At least this is what I've read. Yes I selected all users and the variables options on custom install. Any Suggestions? It would help to have some detail: OpSys, source of Python and pygame, editor/IDE in-use, how executing pygame zero, etc. - please copy-paste relevant code and/or error messages. else: https://duckduckgo.com/?q=pgzrun&ia=web -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Error
On 12/5/20 11:41 AM, Barry Fitzgerald via Python-list wrote: > Good day," > > I purchased a book for my son and followed the directions to a T. (Coding > Games in Python) > Whenever I got to the point of of moving the "hello" file over to pgzrun is > where my trouble began. > Its not finding a path because I'm getting this "pgzrun is not recognized as > an internal or external command". > > I've uninstall reinstall and tried to trouble shoot offline. I' believe its > a "path" issue but that is a little over my head. At least this is what I've > read. Yes I selected all users and the variables options on custom install. I think you're referring to PyGame Zero. Where did you download the installer from? -- https://mail.python.org/mailman/listinfo/python-list
Re: Regarding Regex timeout behavior to minimize CPU consumption
> On 5 Dec 2020, at 23:44, Peter J. Holzer wrote: > > On 2020-12-05 23:42:11 +0100, [email protected] wrote: >> Timeout: no idea. But check out re.compile and re.iterfind as they might >> speed things up. > > I doubt that compiling regular expressions helps the OP much. Compiled > regular expressions are cached, but more importantly, if a match takes > long enough that specifying a timeout is useful, the time is almost > certainly not spent compiling, but matching - most likely backtracking > from lots of promising but ultimately unsuccessful partial matches. > >> regex = r'data-stid="section-room-list"[\s\S]*?>\s*([\s\S]*?)\s*' \ >> >> >> r'(?:class\s*=\s*"\s*sticky-book-now\s*"|\s*|id\s*=\s*"Location")' >> rooms_blocks_to_be_replace = re.findall(regex, html_template) > > This part: > >\s*([\s\S]*?)\s*' > > looks dangerous from a performance point of view. If that can be > rewritten with less potential for backtracking, it might help. > > Generally, it should be possible to implement a timeout for any > operation by either scheduling an alarm with signal.alarm or by > executing the operation in a separate thread and killing the thread if > it takes too long. I think that python ignores signals until the coeval loop is entered. And since the re.match will block that is not going to happen. Killing threads is not safe and if your OS allows it then you end up with the internal state of python messed up. To implement this I think requires the re code to implement the timeout. Better is for the OP to fix the re to not back track so much or to work on the input string in chunks. Barry > >hp > > -- > _ | Peter J. Holzer| Story must make more sense than reality. > |_|_) || > | | | [email protected] |-- Charles Stross, "Creative writing > __/ | http://www.hjp.at/ | challenge!" > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Error
On 12/5/20 11:41 AM, Barry Fitzgerald via Python-list wrote: > Good day," > > I purchased a book for my son and followed the directions to a T. > (Coding Games in Python) Whenever I got to the point of of moving the > "hello" file over to pgzrun is where my trouble began. Its not > finding a path because I'm getting this "pgzrun is not recognized as > an internal or external command". > > I've uninstall reinstall and tried to trouble shoot offline. I' > believe its a "path" issue but that is a little over my head. At > least this is what I've read. Yes I selected all users and the > variables options on custom install. Looks to me like you have to do two things to get PyGame Zero going on Windows. First, install the latest stable Python 3 from python.org. Be sure to tell the installer to put Python in the system path so you can get to it from the command prompt. Second, from a command prompt, run: py -m pip install pgzero And then you must put the location pgzrun.exe in your path. See below. For example this is what you'd see: C:\Users\torriem>py -m pip install pgzero Collecting pgzero Using cached https://files.pythonhosted.org/packages/48/e5/e5f14292373cb5fc7539aa01307b184c1e3c954d68945d8c44778669dd82/pgzero-1.2-py3-none-any.whl Collecting numpy (from pgzero) Using cached https://files.pythonhosted.org/packages/40/db/5060f18b0116f00ee73f8365efc9c95bd5496946290b0e7c97b6ee89dffe/numpy-1.19.4-cp38-cp38-win_amd64.whl Collecting pygame<2.0,>=1.9.2 (from pgzero) Using cached https://files.pythonhosted.org/packages/a8/1e/5da797179ce046decc7d6d57a9b1977218103ccfb099b959b7736aff5f73/pygame-1.9.6-cp38-cp38-win_amd64.whl Installing collected packages: numpy, pygame, pgzero WARNING: The script f2py.exe is installed in 'C:\Users\torriem\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. WARNING: The script pgzrun.exe is installed in 'C:\Users\torriem\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed numpy-1.19.4 pgzero-1.2 pygame-1.9.6 WARNING: You are using pip version 19.2.3, however version 20.3.1 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command. Note the WARNINGs about the scripts and path. You'll want to take that directory (which will be different on your machine) and add that to the path. See https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/ for an example of how to do that. In my case, the path I need to add is C:\Users\torriem\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts After that, pgzrun should run as the book says it will. -- https://mail.python.org/mailman/listinfo/python-list
Re: Regarding Regex timeout behavior to minimize CPU consumption
On Sun, Dec 6, 2020 at 2:37 PM Barry wrote: > > On 5 Dec 2020, at 23:44, Peter J. Holzer wrote: > > > > On 2020-12-05 23:42:11 +0100, [email protected] wrote: > >> Timeout: no idea. But check out re.compile and re.iterfind as they > might > >> speed things up. > > > > I doubt that compiling regular expressions helps the OP much. Compiled > > regular expressions are cached, but more importantly, if a match takes > > long enough that specifying a timeout is useful, the time is almost > > certainly not spent compiling, but matching - most likely backtracking > > from lots of promising but ultimately unsuccessful partial matches. > > > >> regex = r'data-stid="section-room-list"[\s\S]*?>\s*([\s\S]*?)\s*' \ > >> > >> > > r'(?:class\s*=\s*"\s*sticky-book-now\s*"|\s*|id\s*=\s*"Location")' > >> rooms_blocks_to_be_replace = re.findall(regex, html_template) > > > > This part: > > > >\s*([\s\S]*?)\s*' > > > > looks dangerous from a performance point of view. If that can be > > rewritten with less potential for backtracking, it might help. > > > > Generally, it should be possible to implement a timeout for any > > operation by either scheduling an alarm with signal.alarm or by > > executing the operation in a separate thread and killing the thread if > > it takes too long. > > I think that python ignores signals until the coeval loop is entered. > And since the re.match will block that is not going to happen. > > Killing threads is not safe and if your OS allows it then you end up with > the internal state of python messed up. > > To implement this I think requires the re code to implement the timeout. > > Better is for the OP to fix the re to not back track so much or to work on > the > input string in chunks. > If the regex is expensive enough to warrant it, you could use a subprocess - they are killable. -- https://mail.python.org/mailman/listinfo/python-list
