Re: Python script accessing own source code
On 12/05/2021 20:17, Mirko via Python-list wrote: Am 12.05.2021 um 20:41 schrieb Robin Becker: ... ... since GvR has been shown to have time traveling abilities such a script could paradoxically appear acausally. -- yrs-not-too-seriously Robin Becker Not sure, if that's what you mean, but writing a self-replicating script is easy too: actually I was really joking about self creating scripts that do something useful like finding future lotto numbers. the artificial programmer servant is some way off import os import sys with open(os.path.abspath(__file__)) as myself: with open(sys.argv[1], "w") as yourself: yourself.write(myself.read()) Give it a filename as a command-line argument and it will write itself to that file. -- Robin Becker -- https://mail.python.org/mailman/listinfo/python-list
Re: Python script accessing own source code
On Thu, May 13, 2021 at 5:27 PM Robin Becker wrote: > > On 12/05/2021 20:17, Mirko via Python-list wrote: > > Am 12.05.2021 um 20:41 schrieb Robin Becker: > >> ... > >>> > >... > >> since GvR has been shown to have time traveling abilities such a > >> script could paradoxically appear acausally. > >> -- > >> yrs-not-too-seriously > >> Robin Becker > > > > > > Not sure, if that's what you mean, but writing a self-replicating > > script is easy too: > > actually I was really joking about self creating scripts that do something > useful like finding future lotto numbers. > > the artificial programmer servant is some way off > Perhaps not so far off as you might think. With import hooks, it's entirely possible to have a program that creates itself on demand - for instance, you might transpile your script from some variant form of the language (maybe you're trying out a proposed new syntax). It won't help you with the lotto, but it certainly is an AI assistant for a programmer that creates runnable code when called upon. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
STARTUP FAILURE
Hello, I have been facing this " startup failure" for a while now, I can open the IDLE from the programs that I have saved but I'm not able to open the IDLE directly. Hope you can help me with this issue as soon as possible. -- https://mail.python.org/mailman/listinfo/python-list
Re: STARTUP FAILURE
On 5/13/21 7:49 AM, Sumukh chakkirala wrote: Hello, I have been facing this " startup failure" for a while now, I can open the IDLE from the programs that I have saved but I'm not able to open the IDLE directly. Hope you can help me with this issue as soon as possible. if it's the standard "IDLE's subprocess didn't make the connection" message, did you read the page pointed to by the link in the dialog box? if it's not that, please provide some more details of your problem. -- https://mail.python.org/mailman/listinfo/python-list
Re: STARTUP FAILURE
Il 13/05/2021 15:49, Sumukh chakkirala ha scritto: Hello, I have been facing this " startup failure" for a while now, I can open the IDLE from the programs that I have saved but I'm not able to open the IDLE directly. Hope you can help me with this issue as soon as possible. for Windows cmd: C:\Python\pythonw.exe "C:\Python\Lib\idlelib\idle.pyw -- https://mail.python.org/mailman/listinfo/python-list
Re: STARTUP FAILURE
On 13/05/2021 14:49, Sumukh chakkirala wrote: > Hello, I have been facing this " startup failure" for a while now, I can > open the IDLE from the programs that I have saved but I'm not able to open > the IDLE directly. Hope you can help me with this issue as soon as possible. > Usual questions: Which OS? Which python version? How exactly are you trying to open IDLE? And what happens? Any errors? How are you opening it "from the programs that I have saved" What exactly does that meaN? Right click in a File explorer program maybe? Have you tried other ways, such as from the command line? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list
typing instance variable
Greetings, This snippet of code raises ValueError during execution: class MyClass: __slots__ = 'foo' foo: int = 0 mypy does not complain: mypy myclass.py Success: no issues found in 1 source file But python3 does: python3 myclass.py Traceback (most recent call last): File "myclass.py", line 1, in class MyClass: ValueError: 'foo' in __slots__ conflicts with class variable This is where the way of type declaration of instance variable comes from: https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html class MyClass: # You can optionally declare instance variables in the class body attr: int # This is an instance variable with a default value charge_percent: int = 100 Why Python believes foo is class variable? python3 -V Python 3.6.8 Kind regards, David -- https://mail.python.org/mailman/listinfo/python-list
