Moving from java to python.

2007-11-12 Thread [EMAIL PROTECTED]
Hi, I have recently been learning python, and coming from a java background there are many new ways of doing things that I am only just getting to grips with. I wondered if anyone could take a look at a few pieces of code I have written to see if there are any places where I am still using java-

Re: Moving from java to python.

2007-11-12 Thread Jarek Zgoda
[EMAIL PROTECTED] napisaƂ(a): def getConnected(self): return self._connected No need to use accessors. Just plain attribute lookup is sufficient. -- Jarek Zgoda Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101 We read Knuth so you don't have to. (Tim

Re: Moving from java to python.

2007-11-12 Thread Paul Hankin
On Nov 12, 3:25 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I have recently been learning python, and coming from a java background there are many new ways of doing things that I am only just getting to grips with. I wondered if anyone could take a look at a few pieces of code I have

Re: Moving from java to python.

2007-11-12 Thread Hrvoje Niksic
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: def __init__(self, connections = None, uid = None): You can use connections=(), so you don't need the if below. In fact, you can further write: for node, weight in connections: self._connected.append(node)

Re: Moving from java to python.

2007-11-12 Thread Tim Chase
def __init__(self, connections = None, uid = None): Args: [connections - a list of (connected node, weight) tuples. ] [uid - an identifier for comparisons.] self._connected = [] self._weights = [] if connections: for i in

Re: Moving from java to python.

2007-11-12 Thread Larry Bates
Paul Hankin wrote: On Nov 12, 3:25 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I have recently been learning python, and coming from a java background there are many new ways of doing things that I am only just getting to grips with. I wondered if anyone could take a look at a few