First noob questions about pythonect

18 views
Skip to first unread message

Guy Adini

unread,
Aug 29, 2012, 7:15:32 AM8/29/12
to pyth...@googlegroups.com
Hey,

I am reading the pythonect code (hoping to start contributing), and am starting to gather some assorted questions:

  1. Silly question: How do I write a pythonect script with multiple expressions?
    I expected to just write each of the in its own line - which doesn't work.
  2. Does it make sense to open a new thread for each subexpression? For example, in the 100 bottles example,
    we get 100 threads - so we couldn't count, say 10,000 bottles.
  3. Would you mind if I committed a version of eval.__run which is broken into multiple sub-functions? I am finding the logic of this 300-liner hard to follow. (BTW - why do you use this 'blank-every-other-line' format? I have never seen it before).
  4. A pedantic note: except Exception, e has been replaced with except Exception as e, since Python 2.5 if I am not mistaken. 

I am still reading and playing with it, but I think that I would like to send in some suggested revisions soon. Will changing things like Exception, e --> Exception as e be more helpful or annoying?

Thanks,

Guy

Itzik Kotler

unread,
Aug 29, 2012, 8:24:20 AM8/29/12
to pyth...@googlegroups.com
Hi Guy,

Please see inline.

On Wed, Aug 29, 2012 at 2:15 PM, Guy Adini <guya...@gmail.com> wrote:
Hey,

I am reading the pythonect code (hoping to start contributing), and am starting to gather some assorted questions:

  1. Silly question: How do I write a pythonect script with multiple expressions? 
 
I'm not sure what you mean by multiple expressions. I assume you mean having more than one "main" flow, if so, it's:

"Hello, world" -> print , "Goodbye, world" -> print

A Pythonect program can be expr_list or empty. expr_list can be a single expression, or multiple expressions separated by comma. (see: https://github.com/ikotler/pythonect/blob/master/pythonect/internal/parser.py)

  1. I expected to just write each of the in its own line - which doesn't work.
 
Right now the lexical scoping is done via comma (see example above) and brackets (i.e. [])

Having said that, Pythonect syntax is still a work in progress (see: https://github.com/ikotler/pythonect/wiki/Call-For-Syntax).

  1. Does it make sense to open a new thread for each subexpression? For example, in the 100 bottles example,
    we get 100 threads - so we couldn't count, say 10,000 bottles.
 
This is a question of definition (or design choice).

The 100 bottles example is synchronous, meaning, only one thread is created (at a time) and so there's no limitation to how many bottles you can count.

Having said that, I don't think it's a programming language job to put the "limits" to what you can do or can't do with your resources.

You are free to try and allocate 10,000 threads in any language, if at some point you will get an Exception - so be it.

  1. Would you mind if I committed a version of eval.__run which is broken into multiple sub-functions? I am finding the logic of this 300-liner hard to follow. (BTW - why do you use this 'blank-every-other-line' format? I have never seen it before).

Generally speaking I am always in favor of refactoring a code.

Make sure your eval.__run passes both https://github.com/ikotler/pythonect/blob/master/pythonect/test/run_unittest.sh and https://github.com/ikotler/pythonect/blob/master/pythonect/test/eval_test_gen.py before submitting.

And, that it's PEP8 formatted (see: http://pypi.python.org/pypi/pep8/), but feel free to ignore E501 warnings though.

Re the blank-every-other-line format, I just find code to be more read-able and aesthetic that way. I am not planning on enforcing it.

  1. A pedantic note: except Exception, e has been replaced with except Exception as e, since Python 2.5 if I am not mistaken. 
I didn't know that. I will happily accept a patch that changes every 'except Exception, e'  to the new format.

I am still reading and playing with it, but I think that I would like to send in some suggested revisions soon. Will changing things like Exception, e --> Exception as e be more helpful or annoying?

Thank you for your interest in Pythonect. I appreciate any help. I also suggest you see: https://github.com/ikotler/pythonect/wiki/Ideas and https://github.com/ikotler/pythonect/wiki/Roadmap. The latter is a bit out dated.

Thanks,

Guy

--
You received this message because you are subscribed to the Google Groups "pythonect" group.
To view this discussion on the web visit https://groups.google.com/d/msg/pythonect/-/wnmlUko6DJwJ.
To post to this group, send email to pyth...@googlegroups.com.
To unsubscribe from this group, send email to pythonect+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pythonect?hl=en.

Reply all
Reply to author
Forward
0 new messages