[Tutor] Unpacking a Tuple - Can It Be Done with a CSV Line?
Kalle Svensson
kalle@gnupung.net
Tue, 30 Jan 2001 23:13:14 +0100
--zS7rBR6csb6tI2e1
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Sez Seelinger, Bruce:
> Hello,
>=20
> I am writing a script which opens a file which consists of comma separated
> entries similar to the example below:
>=20
> value1, value2, value3, value4, etc. etc.
[How to make unpack them to variables?]
import string
s =3D "value1, value2, value3, value4"
var1, var2, var3, var4 =3D map(string.strip, string.split(s, ","))
> I am relatively new to Python and the only other language I have extensive
> programming with is VMS's DCL.
I hope and believe you will find python enjoyable, although I know nothing
about DCL (or VMS).
HTH,
Kalle
--=20
Email: kalle@gnupung.net | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
--zS7rBR6csb6tI2e1
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE6dzx6dNeA1787sd0RAliKAKCps24O9wobdM3et0HA4G5QnzKAQgCgifvi
Zy5Q/9ibxN3Z72+1otYPODs=
=oSJL
-----END PGP SIGNATURE-----
--zS7rBR6csb6tI2e1--