Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #35439

Re: Parsing files in python

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Parsing files in python
Date 2012-12-24 00:16 -0500
Organization > Bestiaria Support Staff <
References <20121223171955.GB32535@ifeobi.illom.net> <kb8c6k$kb7$1@ger.gmane.org> <CAPTjJmpUs46to1OdcGc_j76H=KrNHnzyS=-9i6B_2FNJGDywaw@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1238.1356326208.29569.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, 24 Dec 2012 15:05:48 +1100, Chris Angelico <rosuav@gmail.com>
declaimed the following in gmane.comp.python.general:


> 
> It would also require some smart footwork at the export end,
> recognizing that a tuple needs to be output with angle brackets.
> 
	That's the easy part... If you don't use raw tuples but define a
class for POV vectors...

>>> class Vector(object):
... 	def __init__(self, tpl):
... 		self.vct = tpl
... 	def __str__(self):
... 		itms = ", ".join([str(x) for x in self.vct])
... 		return "< " + itms + " >"
... 	
>>> x = Vector((1, 2, 3))
>>> print x
< 1, 2, 3 >
>>> 

{Extending that to handle a non-tuple initialization -- Vector(1, 2, 3)
-- and operations that return Vector objects... say "y = x * 2", is
left, as they say, as an exercise for the student <G>}
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Parsing files in python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-12-24 00:16 -0500

csiph-web