From: Chad Perrin Date: 2011-08-10T04:53:23+09:00 Subject: Re: *WHY* does this not work? --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Aug 10, 2011 at 04:38:36AM +0900, serialhex wrote: > ok, many responses, all very good and reasonable, but i guess my point is > kinda missed so i'll explain deeper... >=20 > here is an awesome kludge of a program i wrote last night: > https://gist.github.com/1133359 >=20 > yes it's ugly, and yes it's horrible, but it's not meant to be used for > anything more than what it was used for (which is quickly converting pyth= on > to ruby, and give kinda workable results most of the time, and since it's > simply single file programs that i was going to edit & fix later, i'm not > worried as to how ugly the translator is, or the translation, it just did > 90% of my work for me) >=20 > look at the strip_python_loads method, that is the *best* way i can come = up > with at the moment. yes i know there are better ways (to write this and = the > entire program) but what are they? if i wanted to edit the contents of an > array while iterating through it how do it do it besides that? like i sa= id, > a method such as each! which will allow you to modify the receiver would = be > nice... def strip_python_loads @file_lines.map! do |line| line =3D '' if line.match(/\s*from[ A-Za-z0-9\_.]*import\s*\w*/]) line end end Warning: I have not tested this code. I may have made a boneheaded error. There may also be a better way to do this that would have occurred to me if I was not multitasking. =20 --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --yrj/dFKFPuw6o+aM Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk5BjBQACgkQ9mn/Pj01uKXdvACfeZ41VKeG9XZ36HXqFBOAwd/f AI4AoN5BnXbzpeL+yfLNJZipV5SiXp0J =YSGs -----END PGP SIGNATURE----- --yrj/dFKFPuw6o+aM--