Re: code blocks in Python

2022-03-25 Thread MRAB
On 2022-03-25 10:12, jlfivn wrote: On Monday, 24 November 2003 at 23:54:49 UTC, John Roth wrote: "Hung Jung Lu" wrote in message news:8ef9bea6.03112...@posting.google.com... > Skip Montanaro wrote in message news:... > > > I come back again to repeat it one more time: the compile() function >

Re: code blocks in Python

2022-03-25 Thread jlfivn
On Monday, 24 November 2003 at 23:54:49 UTC, John Roth wrote: > "Hung Jung Lu" wrote in message > news:8ef9bea6.03112...@posting.google.com... > > Skip Montanaro wrote in message > news:... > > > > > I come back again to repeat it one more time: the compile() function > > already exists and works

Re: code blocks

2015-05-11 Thread Peter Otten
Chris Angelico wrote: > On Tue, May 12, 2015 at 2:01 AM, Peter Otten <__pete...@web.de> wrote: >> Though interestingly, my Py2 doesn't have any help >>> on exec: >>> >> help('exec') >>> no documentation found for 'exec' >>> >>> Not sure why that is. >> >> Path confusion? You may accidentally b

Re: code blocks

2015-05-11 Thread zipher
On Monday, May 11, 2015 at 11:08:14 AM UTC-5, Chris Angelico wrote: > On Tue, May 12, 2015 at 2:01 AM, Peter Otten <__pete...@web.de> wrote: > > Though interestingly, my Py2 doesn't have any help > >> on exec: > >> > > help('exec') > >> no documentation found for 'exec' > >> > >> Not sure why t

Re: code blocks

2015-05-11 Thread Chris Angelico
On Tue, May 12, 2015 at 2:01 AM, Peter Otten <__pete...@web.de> wrote: > Though interestingly, my Py2 doesn't have any help >> on exec: >> > help('exec') >> no documentation found for 'exec' >> >> Not sure why that is. > > Path confusion? You may accidentally be importing Python 3's topics. > T

Re: code blocks

2015-05-11 Thread Peter Otten
Chris Angelico wrote: > On Tue, May 12, 2015 at 1:22 AM, zipher wrote: >> Ah, yeah, I guess that does it. But (shame) it looks like you've gone >> past the BDFL. Try: >> > help(exec) >> ^ >> SyntaxError: invalid syntax >> > > That's because, in the version of Python you're usin

Re: code blocks

2015-05-11 Thread Chris Angelico
On Tue, May 12, 2015 at 1:22 AM, zipher wrote: > Ah, yeah, I guess that does it. But (shame) it looks like you've gone past > the BDFL. Try: > help(exec) > ^ > SyntaxError: invalid syntax > That's because, in the version of Python you're using, exec is a keyword. You could swi

Re: code blocks

2015-05-11 Thread zipher
On Monday, May 11, 2015 at 10:22:15 AM UTC-5, zipher wrote: > Ah, yeah, I guess that does it. But (shame) it looks like you've gone past > the BDFL. Try: > [...] > Better Oops, omit word "better". Sent before reading over it again... m -- https://mail.python.org/mailman/listinfo/python-list

Re: code blocks

2015-05-11 Thread zipher
On Sunday, May 10, 2015 at 10:32:07 PM UTC-5, Ian wrote: > On Sun, May 10, 2015 at 7:39 PM, zipher wrote: > > Similarly, you'd want: > > > encode(codestr) > > > > to instantiate all objects in the codestr. You can't do this with eval, > > because it doesn't allow assignment (eval(n=2) retur

Re: code blocks

2015-05-10 Thread Rustom Mody
On Monday, May 11, 2015 at 9:02:07 AM UTC+5:30, Ian wrote: > Is exec what you're looking for? Now Now Ian! In classical times, corrupting the youth would fetch you a cup of hemlock. Community service it is nowadays. -- https://mail.python.org/mailman/listinfo/python-list

Re: code blocks

2015-05-10 Thread Ian Kelly
On Sun, May 10, 2015 at 9:31 PM, Ian Kelly wrote: > On Sun, May 10, 2015 at 7:39 PM, zipher wrote: >> Similarly, you'd want: >> > encode(codestr) >> >> to instantiate all objects in the codestr. You can't do this with eval, >> because it doesn't allow assignment (eval(n=2) returns "InvalidS

Re: code blocks

2015-05-10 Thread Ian Kelly
On Sun, May 10, 2015 at 7:39 PM, zipher wrote: > Similarly, you'd want: > encode(codestr) > > to instantiate all objects in the codestr. You can't do this with eval, > because it doesn't allow assignment (eval(n=2) returns "InvalidSyntax"). Is exec what you're looking for? >>> exec('n = 2

Re: code blocks

2015-05-10 Thread zipher
> I'm thinking how interesting it would be to add code blocks to Python, so > that arbitrary strings of code can be passed around.   It would open up some > interesting possibilities for self-modifying code and generic programming. > > My suggestion would be to use triple double-quoted strings

Re: code blocks

2015-05-03 Thread Ben Bacarisse
"Dr. John Q. Hacker" writes: > I'm thinking how interesting it would be to add code blocks to Python, > so that arbitrary strings of code can be passed around. It would open > up some interesting possibilities for self-modifying code and generic > programming. > > Since Python has already a pleth