Next Meeting: Tue 4th October

6 views
Skip to first unread message

Tibs

unread,
Sep 27, 2011, 2:55:53 PM9/27/11
to Cambridge and East Anglian Python Users Group
The next meeting should be a coding/dojo meeting, 7.30pm at RealVNC
(http://tinyurl.com/realvncoffices).

(Tom, please let us know if that didn't turn out to be OK)

(although depending on who comes along, it might also be a PyConUK
retrospective, since I think those of us who got to go went to a range
of different talks)

Meetings after that should be:

* Tuesday 1st November, talks again
* Tuesday 6th December, dojo/coding again (not the 1st as I appear to
have said last time)

Do people want the first meeting of 2012 to be Tuesday 3rd January, or
Tuesday 10th, given that Monday 2nd will presumably be a public
holiday? It's meant to be a tallks meeting.

Tibs

Tibs

unread,
Oct 23, 2011, 12:56:59 PM10/23/11
to Cambridge and East Anglian Python Users Group
So, the meeting happened, and I meant to do a report on it. Sorry for
the delay.

Present were Tom, Joe, Peter, Robin, Bryan and myself.

We started off by talking over the recent PyConUK - Joe and I had both
been there. Much of the talk had been on Larch, which Tom had also
been reading about elsewhere. There are interesting videos linked off
its homepage at https://sites.google.com/site/larchenv/. I recommend
looking - it's not really quite like anything else, and the talk at
the conference was one of the high points for me.

Tom did finally drag us back to the idea that we should do some
coding, and we revisited some of the ideas of the last coding session,
and how one goes about parsing binary formats in a simple, friendly
manner. His idea was that it would be interesting to look at what we
thought would be a simple way (so not much code) to describe (at
first) simple formats. We got a little way with this approach, but
might have gotten further if we'd been wiling to look at the
documentation (perhaps it was more fun to think of things from first
principle - this works better in Python than some other places).

I'll paste the small amount of code/text we developed below - I'm not
entirely sure if it will survive my hitting the "send" button...


class Field(object):
order = {}
names = {}
def __init__(self):
Field.order[self] = len(Field.order)

class UInt32(Field):
pass

class MetaStructure(type):
def __new__(klass, bases, attributes):
print 'm.__new__', bases, attributes
for k in attributes:
Field.name[attributes[k]] = k
return type.__new__(klass, bases, attributes)

def __init__(self, *args, **kwargs):
print 'm.__init__', args, kwargs

class Structure(object):
__metaclass__ = MetaStructure
def __new__(klass, *args, **kwargs):
print '__new__', args, kwargs
return object.__new__(klass)

def __init__(self, *args, **kwargs):
print '__init__', args, kwargs

class Spam(Structure):

file_length = UInt32()
x = UInt32()

spam = Spam(3, spam='beans')

print Field.order
print Field.names

# How to specify arrays?
# array_no1 = Array(UInt32, 4) # simple and explicit
# array_no2 = [UInt32() for _ in range(4)] # hard to make it do
what we want
# array_no3 = Uint32[4]() # Tom's suggestion
# array_no4 = Uint32()*4 # compare with numpy
# array_no5 = Uint32(repeat=4)

# name = NullTerminatedString()
# str_len = SByte()
# manifest = CountedString(size=str_len)

# vim: set tabstop=8 softtabstop=4 shiftwidth=4 expandtab:
Reply all
Reply to author
Forward
0 new messages