More 'pythonic' Boo code?

View: New views
4 Messages — Rating Filter:   Alert me  

More 'pythonic' Boo code?

by TylerWilson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Good day,

First, I apologize if this topic may have been discussed to death. I
did a quick search, and did not find anything, so I thought I should
post in any case. I am new to Boo, having started using it in the
Unity3D trial. I normally use Python for all my prototyping and
development when possible.

The main thing that irks me slightly are the differences between the
methods on the differing container classes between languages. For
example, I can create a map/dict in both languages like so:

d = {}

And I can add key/item pairs with the following:

d["one"] = 1
d["two"] = 2.0
d["three"] = "three"

I can even do a simple enumeration like so:

for item in d:
    print(item)

But this is where we start to lose similarities. The item variable in
the example above in Python is an 'str'. In Boo, it is a
DictionaryItem. The other methods on dictionarites vary widely between
the two languages as well: 'keys()' vs. 'Keys', etc.

My opinion is that since you are going for the Python look-and-feel,
and that you create many of your own derived classes like
Boo.Lang.Hash, you can go the next step and create the Python-
compatible methods on at least the built-in types.

Hope that makes sense, and I look forward to the response.

Tyler Wilson

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: More 'pythonic' Boo code?

by Justin Chase-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

They underlying classes aren't part of the language, boo sits ontop of the .NET framework which has many familiar classes to .NET developers such as Dictionary<TKey, TValue>. Boo gives you a python like syntax for calling those members that's about as good as it gets. I could see having a python compatibility namespace though, where common python classes are re-implemented with similar member signatures, that's not a bad idea.

On Tue, Sep 22, 2009 at 4:11 PM, TylerWilson <google@...> wrote:

Good day,

First, I apologize if this topic may have been discussed to death. I
did a quick search, and did not find anything, so I thought I should
post in any case. I am new to Boo, having started using it in the
Unity3D trial. I normally use Python for all my prototyping and
development when possible.

The main thing that irks me slightly are the differences between the
methods on the differing container classes between languages. For
example, I can create a map/dict in both languages like so:

d = {}

And I can add key/item pairs with the following:

d["one"] = 1
d["two"] = 2.0
d["three"] = "three"

I can even do a simple enumeration like so:

for item in d:
   print(item)

But this is where we start to lose similarities. The item variable in
the example above in Python is an 'str'. In Boo, it is a
DictionaryItem. The other methods on dictionarites vary widely between
the two languages as well: 'keys()' vs. 'Keys', etc.

My opinion is that since you are going for the Python look-and-feel,
and that you create many of your own derived classes like
Boo.Lang.Hash, you can go the next step and create the Python-
compatible methods on at least the built-in types.

Hope that makes sense, and I look forward to the response.

Tyler Wilson





--
Justin Chase
http://www.justnbusiness.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: More 'pythonic' Boo code?

by Max Battcher-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sep 22, 6:34 pm, Justin Chase <justin.m.ch...@...> wrote:
> They underlying classes aren't part of the language, boo sits ontop of the
> .NET framework which has many familiar classes to .NET developers such as
> Dictionary<TKey, TValue>. Boo gives you a python like syntax for calling
> those members that's about as good as it gets. I could see having a python
> compatibility namespace though, where common python classes are
> re-implemented with similar member signatures, that's not a bad idea.

If you want something like that today, then you probably want to use
IronPython. I don't know if Unity supports IronPython, yet, but
IronPython takes great pains to be compatible with CPython, and yet
still run in the .NET environments.

--
--Max Battcher--
http://worldmaker.net
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: More 'pythonic' Boo code?

by TylerWilson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Unity3D does not (currently) support IronPython. If it did, I would
certainly be using that. And from understanding of the Unity3D system,
my belief is that it would not be able to support IronPython 'out of
the box' anyway. It seems to me that Unity3D requires the language to
be more static than dynamic. Hence the use of Boo instead of
IronPython in the first place.

As for wrapping .NET types to look more like Python types in Boo: if I
find some time I will likely do an experiment with this, assuming I
can download and build the Boo assembly myself.

Thank you,
Tyler

On Sep 23, 11:42 am, Max Battcher <max.battc...@...> wrote:

> On Sep 22, 6:34 pm, Justin Chase <justin.m.ch...@...> wrote:
>
> > They underlying classes aren't part of the language, boo sits ontop of the
> > .NET framework which has many familiar classes to .NET developers such as
> > Dictionary<TKey, TValue>. Boo gives you a python like syntax for calling
> > those members that's about as good as it gets. I could see having a python
> > compatibility namespace though, where common python classes are
> > re-implemented with similar member signatures, that's not a bad idea.
>
> If you want something like that today, then you probably want to use
> IronPython. I don't know if Unity supports IronPython, yet, but
> IronPython takes great pains to be compatible with CPython, and yet
> still run in the .NET environments.
>
> --
> --Max Battcher--http://worldmaker.net
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---