Sujet : Re: Extract lines from file, add to new files
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.pythonDate : 29. Jan 2024, 17:41:14
Autres entêtes
Organisation : Stefan Ram
Message-ID : <file-20240129174003@ram.dialup.fu-berlin.de>
References : 1
Rich Shepard <
rshepard@appl-ecosys.com> writes: how to specify a
variable in one file that has its values in another file.
In the first file, you can write
variable = eval( open( "otherfile" ).read() )
, and the value for "variable" will be taken from "otherfile".
$ echo 3.14 >otherfile
$ echo "v = eval( open( 'otherfile' ).read() ); print( v )" > thisfile
$ python3 thisfile
3.14
$