Migrating from PHP to Python...
rnd at onego.ru
Tue Sep 4 06:45:47 CEST 2001
On Tue, 4 Sep 2001, Joal Heagney wrote:
>Joal Heagney wrote:
>> Rick Shin wrote:
>> > > All variables in python are dynamic type. Is that what you were asking?
>> > Actually, I was referring to PHP's ability to assign names dynamically to
>> > variables. For example:
>> > $var = 'hello';
>> > $$var = 'world!';
>> > echo $var . ' ' . $$var; // prints 'hello world!'
>> > echo $var . ' ' . $hello; // prints 'hello world!' too
If I had a need to migrate from PHP, the abovementioned kind
of mess were my priority ;-)
I just can't think why it need to be transfered to Python.
>> You mean like this?
>>>> var = 'hello'
>>>> var2 = 'world'
>>>> exec("%s = '%s'" % (var, var2))
>>> var = 'hello'
>>> var2 = 'world'
>>> globals()[var] = var2
but then again, this is all tricks and IMHO the main reason to drop PHP in
favor of Python is more intensive separation of logic from presentation.
It makes web-sites more maintainable.
Sincerely yours, Roman Suzi
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Tuesday, September 04, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "Useless Invention: Fine glass-crystal castanets." _/
More information about the Python-list