On 2006-01-30, squash@peoriade signweb.com <squash@peoriad esignweb.com> wrote:
[color=blue]
> I am a little annoyed at why such a simple program in Perl is causing
> so much difficulty for python,[/color]
Ah, well, there's your problem. Python doesn't run Perl
programs. It runs Python programs. If you write your program
in Python instead of Perl, you'll not have such problems.
--
Grant Edwards grante Yow! If this was a SWEDISH
at MOVIE, I'd take off your
visi.com GO-GO BOOTS!!
On Monday 30 January 2006 17:52, squash@peoriade signweb.com wrote:[color=blue]
> I am a little annoyed at why such a simple program in Perl is causing
> so much difficulty for python, i.e:
>
> $a += 200000 * 140000;
>
> print $a;[/color]
a = 0
a += 200000 * 140000
print a
Seems to be more a problem for you than for Python.
Christoph
P.S.: Xah, is that you?
P.P.S.: You should have told what's going wrong.
P.P.P.S.: Variables are not automatically initialised in Python.
And you shouldn't even rely on that in Perl.
--
Never trust a system administrator who wears a tie and suit.
i was hoping one didnt have to initialize variables because perl
defaults their value to zero. Also I noticed if I initialize a variable
as 0 , then I can only do integer math not floating math. this just
seems kind of backward as I am used to php and perl which dont require
such strict rules.
squash@peoriade signweb.com wrote:[color=blue]
> I am a little annoyed at why such a simple program in Perl is causing
> so much difficulty for python, i.e:
>
> $a += 200000 * 140000;
>
> print $a;
>[/color]
Yes, an annoying feature of the Python interpreter is that it doesn't
always interpret Perl correctly.
You will find, though, that
print 200000 * 140000
works quite well in both languages (with or without the trailing
semi-colon).
Variables in Python don't need a $ or @ to indicate whether they are
scalar or structured - that depends on their value.
So
a = 0
a += 200000 * 140000
should also work quite well. Note the first assignment is needed because
while there's no need to declare variables, you cannot assume a value
until they have been assigned one (in Pythonic jargon "bound to a value").
What does "+=" mean in Perl, by the way? Does it just assume $a is zero
if it isn't currently existent?
happily-forgotten-perl-ly y'rs - steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/
squash@peoriade signweb.com wrote:[color=blue]
> Also I noticed if I initialize a variable
> as 0 , then I can only do integer math not floating math. this just
> seems kind of backward as I am used to php and perl which dont require
> such strict rules.
>[/color]
On 2006-01-30, squash@peoriade signweb.com <squash@peoriad esignweb.com> wrote:
[color=blue]
> i was hoping one didnt have to initialize variables because perl
> defaults their value to zero.[/color]
Repeat after me: "Python is not Perl. Python is not Perl.
Python is not Perl. Python is not Perl. Python is not Perl.
Python is not Perl. Python is not Perl.Python is not Perl.
Python is not Perl. Python is not Perl. Python is not
Perl.Python is not Perl. Python is not Perl."
[color=blue]
> Also I noticed if I initialize a variable
> as 0 , then I can only do integer math not floating math.[/color]
Python is a strictly typed language. Perl isn't -- Perl does
all sorts of stuff "automagica lly" by trying to guess what you
wanted". I perfer languages that do exactly what I tell them
to rather than what the language's author thought I might have
meant.
[color=blue]
> this just seems kind of backward as I am used to php and perl
> which dont require such strict rules.[/color]
Really, and Perl/PHP seemed so primitive and backward to me. I
guess it's all in the perspective.
--
Grant Edwards grante Yow! Darling, my ELBOW
at is FLYING over FRANKFURT,
visi.com Germany...
On Mon, 30 Jan 2006, Grant Edwards wrote:
[color=blue]
> On 2006-01-30, squash@peoriade signweb.com <squash@peoriad esignweb.com> wrote:
>[color=green]
>> i was hoping one didnt have to initialize variables because perl
>> defaults their value to zero. Also I noticed if I initialize a variable
>> as 0 , then I can only do integer math not floating math.[/color]
>
> Python is a strictly typed language. Perl isn't -- Perl does all sorts
> of stuff "automagica lly" by trying to guess what you wanted". I perfer
> languages that do exactly what I tell them to rather than what the
> language's author thought I might have meant.[/color]
Especially when that's Larry Wall ... :)
tom
--
Don't trust the laws of men. Trust the laws of mathematics.
squash@peoriade signweb.com a écrit :[color=blue]
> I am a little annoyed at why such a simple program in Perl is causing
> so much difficulty for python, i.e:
>
> $a += 200000 * 140000;
>
> print $a;
>[/color]
On Jan 31, 2006, at 8:28 AM, morris carre wrote:
[color=blue]
> squash@peoriade signweb.com a écrit :[color=green]
>>
>> $a += 200000 * 140000;
>> print $a;[/color]
>
> a = 200000 * 140000
> print a
>
> where's the problem ?[/color]
Not sure if you typo'd that, but that should read:
a += 200000 * 140000
print a
-dan
--
I am not a vegetarian because I love animals; I am a vegetarian because
I hate plants. -A. Whitney Brown
On Feb 1, 2006, at 7:59 AM, Tim Roberts wrote:
[color=blue]
> Dan Lowe <dan@tangledhel ix.com> wrote:[color=green]
>>
>> Not sure if you typo'd that, but that should read:
>>
>> a += 200000 * 140000
>> print a[/color]
>
> Did you try to run that?[/color]
Well, I did, but I had given 'a' a value first. And now I'm thinking
that I may have forgotten some of the earlier thread... where I
suppose the point was that this doesn't work when 'a' hasn't already
been set. I was focusing on = vs += ...
So in that case, please ignore me :-)
-dan
--
Black holes are where God divided by zero. -Steven Wright
Comment