Implementation of "is" and "yield"

50 views
Skip to first unread message

Pierre Quentel

unread,
Mar 6, 2013, 3:37:11 PM3/6/13
to bry...@googlegroups.com
Hi,

The keywords "is" and "yield" are now supported : "is" is converted to the Javascript === (probably not correct in 100% of the cases : needs more testing) ; "yield" also needs testing, but it works in simple cases like :

def foo(x):
  for z in range(x):
    yield z
gen = foo(15)
for k in gen:
  print(k)


I also added the "else" part of "try / except / else"

With these changes, there only remains 2 unsupported Python keywords : "nonlocal" and "with" (I never use them in CPython so I'll have to learn what they do first...)

Among the features still uncovered, the next on my to-do list are generator expressions and decorators. Hopefully in a few weeks some of the scripts in the Python 3.3 standard distribution will run in Brython !

- Pierre

Tad Vi

unread,
Mar 6, 2013, 4:30:38 PM3/6/13
to bry...@googlegroups.com
Great.
I do not use "nonlocal" and "with" and will go read about them... :-)

Question: Will HTML5 History API be supported as external library or as built-in functions/objects?

Francois Dion

unread,
Mar 6, 2013, 4:58:13 PM3/6/13
to bry...@googlegroups.com
with is quite often use with open:

with open('filename','r') as f:
dosomething

once out of with scope, file object is closed.

In general, it is usable with an object that has a __enter__ and
__exit__ method.

Francois
> --
> You received this message because you are subscribed to the Google Groups
> "brython" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to brython+u...@googlegroups.com.
> To post to this group, send email to bry...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/brython/-/3LpEW2uaRXoJ.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Tad Vi

unread,
Mar 6, 2013, 5:04:34 PM3/6/13
to bry...@googlegroups.com
Damn, I do use Python's "with"... but last 10 days I have spent doing mostly JavaScript. That was brain-fart caused by overexposure to JavaScript.
Well, hopefully with fast improving Brython I will not have to spend my days in JavaScript that much.

Billy Earney

unread,
Mar 6, 2013, 6:27:14 PM3/6/13
to bry...@googlegroups.com
Awesome!!  Thanks for all your hard work.. :)



- Pierre

--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/brython/-/wPSsJhmP7HUJ.

Billy Earney

unread,
Mar 6, 2013, 6:28:13 PM3/6/13
to bry...@googlegroups.com
+1 for external library.

--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/brython/-/3LpEW2uaRXoJ.
Reply all
Reply to author
Forward
0 new messages