Python grammar extension via encoding (pyxl style) questions

2016-09-29 Thread Pavel Velikhov
Hi everybody! We’re building an experimental extension to Python, we’re extending Python’s comprehensions into a full-scale query language. And we’d love to use the trick that was done in pyxl, where a special encoding of the file will trigger the preprocessor to run and compile our extend

Re: Style questions

2008-10-23 Thread James Mills
David, Here's a "good" example (NB: subjective): http://hg.softcircuit.com.au/index.wsgi/circuits/file/251bce4b92fd/circuits/core.py On Fri, Oct 24, 2008 at 10:04 AM, David Di Biase <[EMAIL PROTECTED]> wrote: > I have a few simple questions regarding python style standards. I have a > class cont

Style questions

2008-10-23 Thread David Di Biase
I have a few simple questions regarding python style standards. I have a class contained in a module...I'm wondering if I should perform any imports that are relevant to the class within the constructor of the class or at the top of the module page. Also if I'm creating a docstring for the class I

Re: __init__ style questions

2006-10-02 Thread bearophileHUGS
Will McGugan: > I am writting a Vector3D class as a teaching aid (not for me, for > others), and I find myself pondering over the __init__ function. I want > it to be as easy to use as possible (speed is a secondary > consideration). If optimizations are less important, then don't use __slots__, i

Re: __init__ style questions

2006-10-02 Thread Gerard Flanagan
Will McGugan wrote: > I am writting a Vector3D class as a teaching aid (not for me, for > others), and I find myself pondering over the __init__ function. I want > it to be as easy to use as possible (speed is a secondary > consideration). > > Heres the __init__ function I have at the moment. > >

Re: __init__ style questions

2006-10-02 Thread Will McGugan
Duncan Booth wrote: > > Yes, it would, although since the implication is that your class expected > numbers and the file iterator returns strings I'm not sure how much it > matters: you are still going to have to write more code than in your > example above. e.g. > >v1 = Vector3D(float(n) for

Re: __init__ style questions

2006-10-02 Thread Duncan Booth
"Will McGugan" <[EMAIL PROTECTED]> wrote: > Duncan Booth wrote: > >> No it isn't Pythonic. Why not just require 3 values and move the >> responsibility onto the caller to pass them correctly? They can still >> use an iterator if they want: >> >> Vector3D(a, b, c) >> Vector3D(*some_iter) >

Re: __init__ style questions

2006-10-02 Thread Duncan Booth
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > Duncan Booth wrote: > >> No it isn't Pythonic. > > rubbish. using a single constructor that handles two common use cases is > perfectly Pythonic (especially if you're targeting casual programmers). > Yes, but I don't think that the specific case the

Re: __init__ style questions

2006-10-02 Thread Will McGugan
Duncan Booth wrote: > No it isn't Pythonic. Why not just require 3 values and move the > responsibility onto the caller to pass them correctly? They can still use > an iterator if they want: > > Vector3D(a, b, c) > Vector3D(*some_iter) I kind of liked the ability to partially use iterato

Re: __init__ style questions

2006-10-02 Thread Fredrik Lundh
Duncan Booth wrote: > No it isn't Pythonic. rubbish. using a single constructor that handles two common use cases is perfectly Pythonic (especially if you're targeting casual programmers). -- http://mail.python.org/mailman/listinfo/python-list

Re: __init__ style questions

2006-10-02 Thread Duncan Booth
"Will McGugan" <[EMAIL PROTECTED]> wrote: > A Vector3D can be constructed in 3 ways. If no parameters are given it > assumes a default of (0, 0, 0). If one parameter is given it is assumed > to be an iterable capable of giving 3 values. If 3 values are given > they are assumed to be the initial x,

__init__ style questions

2006-10-02 Thread Will McGugan
I am writting a Vector3D class as a teaching aid (not for me, for others), and I find myself pondering over the __init__ function. I want it to be as easy to use as possible (speed is a secondary consideration). Heres the __init__ function I have at the moment. class Vector3D(object): __slot