Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102199 > unrolled thread

psss...I want to move from Perl to Python

Started byFillmore <fillmore_remove@hotmail.com>
First post2016-01-28 19:01 -0500
Last post2016-02-02 19:36 -0500
Articles 20 on this page of 74 — 27 participants

Back to article view | Back to comp.lang.python


Contents

  psss...I want to move from Perl to Python Fillmore <fillmore_remove@hotmail.com> - 2016-01-28 19:01 -0500
    Re: psss...I want to move from Perl to Python paul.hermeneutic@gmail.com - 2016-01-28 17:22 -0700
    Re: psss...I want to move from Perl to Python Nathan Hilterbrand <nhilterbrand@gmail.com> - 2016-01-28 19:21 -0500
      Re: psss...I want to move from Perl to Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-28 19:23 -0800
        Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-01-29 14:26 +1100
      Re: psss...I want to move from Perl to Python wxjmfauth@gmail.com - 2016-01-30 02:26 -0800
        Re: psss...I want to move from Perl to Python Fillmore <fillmore_remove@hotmail.com> - 2016-01-31 17:34 -0500
          Re: psss...I want to move from Perl to Python Michael Torrie <torriem@gmail.com> - 2016-01-31 16:45 -0700
          Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-02-01 10:48 +1100
          Re: psss...I want to move from Perl to Python Terry Reedy <tjreedy@udel.edu> - 2016-01-31 18:51 -0500
            Re: psss...I want to move from Perl to Python Rustom Mody <rustompmody@gmail.com> - 2016-01-31 18:59 -0800
              Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-02-01 14:15 +1100
                Re: psss...I want to move from Perl to Python Rustom Mody <rustompmody@gmail.com> - 2016-01-31 19:43 -0800
                Re: psss...I want to move from Perl to Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-02-02 14:53 -0800
    Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-01-29 11:25 +1100
      Re: psss...I want to move from Perl to Python Steven D'Aprano <steve@pearwood.info> - 2016-01-29 18:12 +1100
        Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-01-29 18:19 +1100
        Re: psss...I want to move from Perl to Python Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-01-29 09:12 +0000
          Re: psss...I want to move from Perl to Python James Harris <james.harris.1@gmail.com> - 2016-01-29 11:03 +0000
            Re: psss...I want to move from Perl to Python Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-01-29 12:21 +0000
              Re: psss...I want to move from Perl to Python Steven D'Aprano <steve@pearwood.info> - 2016-01-30 00:46 +1100
                Re: psss...I want to move from Perl to Python Ben Finney <ben+python@benfinney.id.au> - 2016-01-30 09:47 +1100
                  Re: psss...I want to move from Perl to Python Steven D'Aprano <steve@pearwood.info> - 2016-01-30 22:12 +1100
              Re: psss...I want to move from Perl to Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-29 13:30 -0800
                Re: psss...I want to move from Perl to Python Fillmore <fillmore_remove@hotmail.com> - 2016-01-29 19:57 -0500
                  Re: psss...I want to move from Perl to Python Ben Finney <ben+python@benfinney.id.au> - 2016-01-30 12:04 +1100
                Re: psss...I want to move from Perl to Python Rustom Mody <rustompmody@gmail.com> - 2016-01-29 19:38 -0800
                  Re: psss...I want to move from Perl to Python Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-01-31 11:18 +1300
                    Re: psss...I want to move from Perl to Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-01-31 12:56 +1100
                      Re: psss...I want to move from Perl to Python Rustom Mody <rustompmody@gmail.com> - 2016-01-30 19:22 -0800
                        Re: psss...I want to move from Perl to Python Cameron Simpson <cs@zip.com.au> - 2016-01-31 14:48 +1100
                          Re: psss...I want to move from Perl to Python Rustom Mody <rustompmody@gmail.com> - 2016-01-30 19:53 -0800
                            Re: psss...I want to move from Perl to Python Cameron Simpson <cs@zip.com.au> - 2016-01-31 20:56 +1100
                            Re: psss...I want to move from Perl to Python Paul Rubin <no.email@nospam.invalid> - 2016-01-31 09:45 -0800
                              Re: psss...I want to move from Perl to Python Rustom Mody <rustompmody@gmail.com> - 2016-01-31 18:08 -0800
                          Re: psss...I want to move from Perl to Python Steven D'Aprano <steve@pearwood.info> - 2016-01-31 20:23 +1100
                            Re: psss...I want to move from Perl to Python Cameron Simpson <cs@zip.com.au> - 2016-01-31 20:53 +1100
                              Re: psss...I want to move from Perl to Python Paul Rubin <no.email@nospam.invalid> - 2016-01-31 09:49 -0800
                                Re: psss...I want to move from Perl to Python Cameron Simpson <cs@zip.com.au> - 2016-02-01 08:16 +1100
                        Re: psss...I want to move from Perl to Python Terry Reedy <tjreedy@udel.edu> - 2016-01-31 07:28 -0500
                          Re: psss...I want to move from Perl to Python Rustom Mody <rustompmody@gmail.com> - 2016-01-31 05:12 -0800
                  Re: psss...I want to move from Perl to Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-30 14:25 -0800
                Re: psss...I want to move from Perl to Python Rustom Mody <rustompmody@gmail.com> - 2016-01-29 20:04 -0800
          Re: psss...I want to move from Perl to Python Random832 <random832@fastmail.com> - 2016-01-29 10:07 -0500
            Re: psss...I want to move from Perl to Python Fillmore <fillmore_remove@hotmail.com> - 2016-01-29 12:56 -0500
            Re: psss...I want to move from Perl to Python Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-01-30 11:21 +1300
          Re: psss...I want to move from Perl to Python sohcahtoa82@gmail.com - 2016-01-29 12:49 -0800
            Re: psss...I want to move from Perl to Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-29 14:29 -0800
        Re: psss...I want to move from Perl to Python Cameron Simpson <cs@zip.com.au> - 2016-01-30 10:48 +1100
    Re: psss...I want to move from Perl to Python Cameron Simpson <cs@zip.com.au> - 2016-01-29 12:20 +1100
    Re: psss...I want to move from Perl to Python Paul Rubin <no.email@nospam.invalid> - 2016-01-28 18:06 -0800
      Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-01-29 13:34 +1100
        Re: psss...I want to move from Perl to Python sohcahtoa82@gmail.com - 2016-01-29 12:41 -0800
          Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-01-30 07:54 +1100
          Re: psss...I want to move from Perl to Python Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-01-30 11:27 +1300
      Re: psss...I want to move from Perl to Python Michael Torrie <torriem@gmail.com> - 2016-01-28 21:42 -0700
      Re: psss...I want to move from Perl to Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-01-29 08:54 -0500
    Re: psss...I want to move from Perl to Python Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-01-29 08:24 +0200
    Re: psss...I want to move from Perl to Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-01-29 08:50 -0500
    Re: psss...I want to move from Perl to Python Fillmore <fillmore_remove@hotmail.com> - 2016-01-29 12:04 -0500
    Re: psss...I want to move from Perl to Python "Sven R. Kunze" <srkunze@mail.de> - 2016-01-29 18:39 +0100
    Re: psss...I want to move from Perl to Python Fillmore <fillmore_remove@hotmail.com> - 2016-01-29 15:42 -0500
      Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-01-30 07:51 +1100
      Re: psss...I want to move from Perl to Python Nathan Hilterbrand <nhilterbrand@gmail.com> - 2016-01-29 16:38 -0500
      Re: psss...I want to move from Perl to Python Cody Piersall <cody.piersall@gmail.com> - 2016-01-29 15:50 -0600
        Re: psss...I want to move from Perl to Python Josef Pktd <josef.pktd@gmail.com> - 2016-01-29 16:48 -0800
      Re: psss...I want to move from Perl to Python Terry Reedy <tjreedy@udel.edu> - 2016-01-29 22:08 -0500
      Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-01-30 14:12 +1100
    Re: psss...I want to move from Perl to Python Ben Finney <ben+python@benfinney.id.au> - 2016-01-30 09:49 +1100
    Re: psss...I want to move from Perl to Python Larry Hudson <orgnut@yahoo.com> - 2016-01-29 22:22 -0800
    Re: psss...I want to move from Perl to Python "Sven R. Kunze" <srkunze@mail.de> - 2016-01-30 13:43 +0100
    Re: psss...I want to move from Perl to Python <paul.hermeneutic@gmail.com> - 2016-02-02 10:00 -0700
    Re: psss...I want to move from Perl to Python "Martin A. Brown" <martin@linux-ip.net> - 2016-02-02 13:04 -0800
    Re: psss...I want to move from Perl to Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-02-02 19:36 -0500

Page 3 of 4 — ← Prev page 1 2 [3] 4  Next page →


#102355

FromRustom Mody <rustompmody@gmail.com>
Date2016-01-31 05:12 -0800
Message-ID<9d1f8fd3-53fb-45aa-94b9-b62fc30d5d34@googlegroups.com>
In reply to#102351
True...

$ python
Python 2.7.10 (default, Oct 14 2015, 16:09:02) 
[GCC 5.2.1 20151010] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re._MAXCACHE
100

But 100 is still large enough that for most normal users/uses re-compilation is pointless.

[toc] | [prev] | [next] | [standalone]


#102322

FromRick Johnson <rantingrickjohnson@gmail.com>
Date2016-01-30 14:25 -0800
Message-ID<00ca1b37-0a21-4a77-9c7e-0c4946ab25ad@googlegroups.com>
In reply to#102273
On Friday, January 29, 2016 at 9:38:23 PM UTC-6, Rustom Mody wrote:
> JustForTheRecord[1]: Rick is someone who I sometimes agree with...

Thanks for reacting in a rational, cool-headed manner. 

Many folks, especially the new members of this group, may
not understand *WHY* i react so passionately when someone
readily admits that they are unwilling to learn a specific
skill, in this case: the programming paradigm known as
Object Oriented Programming (or OOP)

 YOU'D THINK IT WAS *GIN-GI-VI-TIOUS* OR SOMETHING???

And they also may be unaware of the open hostilities that
exists against the OOP paradigm in this very group -- which
is odd, because, why should anyone *FEAR* a paradigm?

And although some may raise legitimate questions regarding
my unorthodox "stylistic mannerisms", my intention is never
to "rant for the sake of ranting", or to "rant for the sake
of disrupting", no, but to rant for the sake of *AWAKING*;
to rant for the sake of *JOLTING* my peers out of their
zombie-like religious trances!

The natural instinct of humans is for us to locate a social
group that we fit neatly into; become a member; adopt a
religious attitude of "my group is the best", and then fight
ferociously against those who are perceived as a threat to
"our little group".

There is no doubt that on a brisk cold morning, none of us
would enjoy having our "warm and cozy blanket" yanked
violently from our bodies so that we become exposed to the
"chilling *BITE* of conscious reality", but sometimes, this
"shock therapy" is only the method that will motivate us to
"rise from our intellectual slumbers".

 SOMETIMES WE ALL NEED A GOOD SMACK ON THE FACE!

And whilst this "motivational philosophy" may indeed be
easier to "preach than to practice", my job is to deliver
these "metaphorical smacks" without pride or prejudice, and
i freely admit, that i myself have benefited personally from
being a "shock therapy" patient. In fact, a very prominent
member of this fine community might even consider his
"smacking therapy" to be the impetus of the personality
otherwise known as Rick (rantingrick) Johnson!

  THOSE WHO SAY DON'T KNOW, AND THOSE WHO KNOW CAN'T SAY!
  
  BUT [CENSORED] KNOWS WHO [CENSORED] IS!!!
  
Therefore, i have become convinced that we can never allow
ourselves to become closed-minded to the many diverse
methods of solving problems, because, as programmers, or
more specifically, *AS ENGINEERS*, our primary and first
directive is to *SOLVE PROBLEMS*!

  INDEED!

And since every problem presents it's own unique challenges,
we must learn to wield the many unique perspectives, unique
techniques, and unique tools that are available to us to
*SOLVE* these *PROBLEMS* in the most *EFFICIENT* manner. A
manner that will *ENSURE* that we produce a high quality
product that requires very little maintenance, or at
minimum, is easy to maintain.

In conclusion, i implore the fine members of this group to
never allow themselves to become a "paradigm ideologue", or
*ANY* form of ideologue for that matter. We must
*CONSTANTLY* resist our natural instincts to religiously
identify ourselves with a "single selfish perspective", and
instead, discover the bits of truth, no matter how trivial,
that exist within in each unique perspective. By adopting
this "objective philosophy", we will not only become better
engineers, we will become better people.

This is the creed of those who are "liberated seekers of
knowledge", and who use that vast trove of knowledge to
enhance the collective, *NOT* slaves mired in the emotional
divisions that are a unfortunate aspect of our selfishly
subjective individual perspectives.

[1]: Acronym unpacking at no additional charge. ;-)

[toc] | [prev] | [next] | [standalone]


#102275

FromRustom Mody <rustompmody@gmail.com>
Date2016-01-29 20:04 -0800
Message-ID<bf433154-f613-4038-a35a-83906c107751@googlegroups.com>
In reply to#102250
On Saturday, January 30, 2016 at 3:01:09 AM UTC+5:30, Rick Johnson wrote:
> On Friday, January 29, 2016 at 6:21:21 AM UTC-6, Ulli Horlacher wrote:
> > I nearly gave up with Python at the very beginning before
> > I realised that OO-programming is optional in Python! :-)
> > Most tutorials I found so far makes OO mandatory.
> 
> Just more evidence that old dogs are incapable of learning
> new tricks. Either learn how to wield Neuroplasticity to
> your advantage, or go curl up into a ball and wait for death
> to come. 

Regarding neuroplasticity especially in programming you may find this useful:

http://blog.languager.org/2016/01/primacy.html

> People who are unwilling to "expanding their intellectual horizons" make me sick!!!

Yes!

And as functional programming becomes more mainstream, OO-fanboys
may need some urgent graft of plastic, see:

http://blog.languager.org/2015/06/functional-programming-moving-target.html

[toc] | [prev] | [next] | [standalone]


#102235

FromRandom832 <random832@fastmail.com>
Date2016-01-29 10:07 -0500
Message-ID<mailman.90.1454080086.2338.python-list@python.org>
In reply to#102224
On Fri, Jan 29, 2016, at 04:12, Ulli Horlacher wrote:
> Steven D'Aprano <steve@pearwood.info> wrote:
> 
> > Every time I make a half-hearted attempt to learn enough Perl syntax to get
> > started, I keep running into the differences between $foo, %foo and @foo
> > and dire warnings about what happens if you use the wrong sigil
...
> $foo is a scalar (number, string, reference, file handle)
> @foo is an array
> %foo is a hash (dictionary in Python slang)
> 
> and yes, you can use them all together in same code, they are different.

The main source of confusion is that $foo[5] is an element of @foo.
$foo{'x'} is an element of %foo. Both of these have absolutely nothing
to do with $foo.

[toc] | [prev] | [next] | [standalone]


#102242

FromFillmore <fillmore_remove@hotmail.com>
Date2016-01-29 12:56 -0500
Message-ID<n8g94j$1ji1$1@gioia.aioe.org>
In reply to#102235
+1

On 1/29/2016 10:07 AM, Random832 wrote:
>
> The main source of confusion is that $foo[5] is an element of @foo.
> $foo{'x'} is an element of %foo. Both of these have absolutely nothing
> to do with $foo.
>

[toc] | [prev] | [next] | [standalone]


#102255

FromGregory Ewing <greg.ewing@canterbury.ac.nz>
Date2016-01-30 11:21 +1300
Message-ID<dh26vdFtjk5U1@mid.individual.net>
In reply to#102235
Random832 wrote:
> The main source of confusion is that $foo[5] is an element of @foo.
> $foo{'x'} is an element of %foo. Both of these have absolutely nothing
> to do with $foo.

And this is where Perl seems totally insane to me. Obviously
it knows from the square brackets that foo[5] is referring
to the array called foo rather than the scalar called foo
or the hash called foo. So what purpose do the sigils serve,
other than provide you with the opportunity to use the
wrong one?

I know there's probably an answer to that question, but
the point is that it *looks* screwy to someone coming from
any other language on the planet.

I'm glad I learned Python first so I didn't have to
unlearn stuff like that. Was it Dijkstra who complained
about students whose minds had been damaged by BASIC?
Perl damage must be ten times worse...

-- 
Greg

[toc] | [prev] | [next] | [standalone]


#102247

Fromsohcahtoa82@gmail.com
Date2016-01-29 12:49 -0800
Message-ID<60b8e886-d6d1-4770-ab2a-0dd33b916f85@googlegroups.com>
In reply to#102224
On Friday, January 29, 2016 at 1:12:34 AM UTC-8, Ulli Horlacher wrote:
> Steven D'Aprano <steve@pearwood.info> wrote:
> 
> > Every time I make a half-hearted attempt to learn enough Perl syntax to get
> > started, I keep running into the differences between $foo, %foo and @foo
> > and dire warnings about what happens if you use the wrong sigil
> 
> I have started learning Python several times and surrendered because my
> brain was too Perl hardcoded after 30 years, but NOW I was successful :-)
> (I still find Perl syntax better...)
> 
> About the variables in short:
> 
> $foo is a scalar (number, string, reference, file handle)
> @foo is an array
> %foo is a hash (dictionary in Python slang)
> 
> and yes, you can use them all together in same code, they are different.
> 
> For more discussion about Perl syntax one should better go to
> comp.lang.perl
> 
> -- 
> Ullrich Horlacher              Server und Virtualisierung
> Rechenzentrum IZUS/TIK         E-Mail: horlacher@tik.uni-stuttgart.de
> Universitaet Stuttgart         Tel:    ++49-711-68565868
> Allmandring 30a                Fax:    ++49-711-682357
> 70550 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/

"(I still find Perl syntax better...)"

I'm convinced that anyone who actually prefers Perl's syntax over Python is suffering from Stockholm Syndrome.

People frequently joke about Perl being "write-only code" due to how frequently people will write code, not look at it for a week or so, then come back to it and not be able to understand what the code is doing without excessive comments.  Or they will say that Perl code is indistinguishable from line noise.

*These are not the hallmarks of a good syntax*

Readability counts.  I'd say readability is one of the most important features of a language, as you will read your code far more than you write it.  Perl is not readable.  I don't care how powerful your language is if you can't read it.

[toc] | [prev] | [next] | [standalone]


#102258

FromRick Johnson <rantingrickjohnson@gmail.com>
Date2016-01-29 14:29 -0800
Message-ID<eca97ef4-5507-4290-8256-926c237e7541@googlegroups.com>
In reply to#102247
On Friday, January 29, 2016 at 2:49:24 PM UTC-6, sohca...@gmail.com wrote:

> I'm convinced that anyone who actually prefers Perl's
> syntax over Python is suffering from Stockholm Syndrome.
>
> [...]
>
> Readability counts.  I'd say readability is one of the
> most important features of a language, as you will read
> your code far more than you write it.  Perl is not
> readable.  I don't care how powerful your language is if
> you can't read it.

EXACTLY!

Which is the same reason why natural language is bound by
many structural rules. For instance: we utilize "syntactical
structures" like sentences and paragraphs to create
"comprehensible groupings", and we *NEVER* want to
arbitrarily, or randomly, use more than one space between
words, or more than one line between paragraphs.

STRUCTURE IS IMPORTANT!

And the only thing more important than a "self-imposed
structure" is a steadfast adherence to the "collective style
guides" of written communication. When we *ALL* utilize a
familiar structure, we will *ALL* spend less time
*CONSCIOUSLY INTERPRETING* superficial structural details,
and more time *ABSORBING* the actual meaning of the content.

ABSORPTION IS THE GOAL, NOT ABERRATION!

The goal of written communication is no different than any
other technology. We should strive to abstract away as much
as possible to the sub-conscience processes of our mind as
we can, so that we can target our mental focus purely on the
comprehension of content, *NOT* comprehension of structure!
When faced with an unfamiliar "syntactical structure", our
high level focus becomes "mired in the minutiae of the
superficial".

EVEN WHEN NECESSARY, THE SUPERFICIAL IS NOT IMPORTANT!

The goal of communication should never be (either
intentional or not) to distract or impress our readers with
our capacity to create "self-aggrandizing ornateness of
structure", which will undoubtedly obfuscate the intended
message, no, but to *STRICTLY* follow the collective
standards and practices of "acceptable syntactical
structuring" that will *facilitate* a smooth transition
between: ideas that are codified into symbolic languages,
and the translation of those linguistic symbols into concepts
in the mind of the reader.

ABSTRACTIONS ARE VITAL TO OUR COMPREHENSION OF COMPLEX
COMMUNICATION MEDIUMS!

For communication to function (at it's most basic level)
these abstractions must exist simultaneously in our codified
symbolic languages *AND* in our mental processes that
interpret them. But whilst our mental abstractions are
mostly unconscious, they can become disturbed when
dissonance is injected into symbolic languages in the form
of "poor syntactical structure". Break either link in the
chain, and a "smooth transition of ideas" becomes untenable.

[toc] | [prev] | [next] | [standalone]


#102263

FromCameron Simpson <cs@zip.com.au>
Date2016-01-30 10:48 +1100
Message-ID<mailman.104.1454111331.2338.python-list@python.org>
In reply to#102214
On 29Jan2016 18:12, Steven D'Aprano <steve@pearwood.info> wrote:
>On Fri, 29 Jan 2016 11:25 am, Chris Angelico wrote:
>
>> Probably the biggest thing to take note of is the Python object model
>> - how names and objects and assignment work. It's pretty
>> straight-forward, but if it's not what you're used to, you'll need to
>> get your head around it. Here's a good talk on the subject:
>>
>> http://nedbatchelder.com/text/names1.html
>
>Every time I make a half-hearted attempt to learn enough Perl syntax to get
>started, I keep running into the differences between $foo, %foo and @foo
>and dire warnings about what happens if you use the wrong sigil, and then I
>get confused. Is there a good discussion of how names and references work
>in Perl, equivalent to Ned's discussion?

The prefices:

$ = scalar (numbers and strings)
@ = array (lists)
% = hashes (dicts/mappings)

They are distinct namespaces, so you can use $foo and %foo in the same code for 
different variables. No, I don't think that is a good idea.

Cheers,
Cameron Simpson <cs@zip.com.au>

[toc] | [prev] | [next] | [standalone]


#102204

FromCameron Simpson <cs@zip.com.au>
Date2016-01-29 12:20 +1100
Message-ID<mailman.71.1454030466.2338.python-list@python.org>
In reply to#102199
On 28Jan2016 19:01, Fillmore <fillmore_remove@hotmail.com> wrote:
>I learned myself Perl as a scripting language over two decades ago.  All 
>through this time, I would revert to it from time to time whenever I needed 
>some text manipulation and data analysis script.
>
>My problem? maybe I am stupid, but each time I have to go back and 
>re-learn the syntax, the gotchas, the references and the derefercing, 
>the different syntax between Perl 4 and Perl 5, that messy CPAN in 
>which every author seems to have a different ideas of how things 
>should be done....

Yes. CPAN always seemed a royal PITA to me too. Pip and Python virtualenvs are 
much cleaner IMO.

>I look and Python and it looks so much more clean....

Oh yes. I wasted quite a while with Perl before shifting, largely because I had 
a large base of personal Perl modules I used a lot and felt like the bootstrap 
process would be painful. I do wish I'd jumped in a few years earlier.

>Does Python have Regexps?

It has a regexp module named "re" and they're the same syntax as perl. It 
doesn't have regexp operations as part of the language itself (no "=~ /regexp/" 
stuff) - you compile a regexp and then use it. This does mean you use regexps 
more deliberately and less frequently than in Perl, but that is a Good Thing.  
Regexps are far far overused in Perl and elsewhere. They are cumbersome, 
cryptic and error prone. Python's strings have a bunch of fixed-string methods 
available which cover a surprisingly large number of cases before you need the 
complexity of a regexp.

>How was the Python 2.7 vs Python 3.X solved? which version should I go for?

Go for 3. While not everything has been ported, many many things have and you 
will mostly be fine. Python 3 has a much cleaner bytes vs text separation 
(which is also a Good Thing), some library cleanups, and all the new work goes 
to Python 3. Python 2 exists, but is essentially frozen. I try to write code 
which will work in both (easy most of the time), but some of my code will only 
work in Python 3 because it works with bytes and text, and going back to the 
ambiguity of Python 2 would be a disaster (in fact, the module I'm thinking of 
had many potential bugs which got cleaned up as a direct result of the move to 
3).

>Do you think that switching to Python from Perl is a good idea at 45?

Yes. Yes yes yes.

>Where do I get started moving from Perl to Python?

There are tutorials, if that kind of thing works for you. My approach was to 
just start writing small things in Python. And when those things got reused, 
start making them modules (== "packages" in Perl speak). You will end up with a 
little suite of tools.

Also, join the "tutor@python.org" list. That is where to go for new Pythoners 
seeking help.

>which gotchas need I be aware of?

Hard to say, I found it depended on what I was doing.

I think the biggest for all new users is probably the "default argument value" 
semantics. When you write a Python function:

  def foo(a, b):
    ...

you can specify default values. For example:

  def (a, b=3):
    ...

means you can call foo as foo(1) and it will be like calling it as foo(1, 3).  
The important point here is that the default values are computed at function 
definition time, _not_ at function call time. For constants like the above this 
doesn't matter, but consider this:

  def foo(a, b=[]):

so that "b" defaults to being an empty list. Because "[]" is computed when the 
function is defined, you will be reusing the _same_ list whenever you call the 
function without specifying "b"; it won't stay an empty list, becuase it is not 
a _new_ empty list of each call.

So if you had "b.append(4)" inside the function, the list would progressively 
accrue 4s, and so forth. For this reason the standard idiom for default 
arguments goes:

  def foo(a, b=None):
    if b is None:
      b = []

Since that test runs on each call (being inside the function), it does make a 
new empty list for "b" if it was not specified.

Cheers,
Cameron Simpson <cs@zip.com.au>

[toc] | [prev] | [next] | [standalone]


#102205

FromPaul Rubin <no.email@nospam.invalid>
Date2016-01-28 18:06 -0800
Message-ID<87si1hqguo.fsf@jester.gateway.pace.com>
In reply to#102199
Fillmore <fillmore_remove@hotmail.com> writes:
> I look and Python and it looks so much more clean....

Yes it is, I forgot everything I knew about Perl shortly after starting
to use Python.

> add to that that it is the language of choice of data miners...

There are a bunch of statistical libraries and that sort of thing but
you have to know what you're doing to use them.  It's not a matter of
the language itself, which is pretty simple.

> add to that that iNotebook looks powerful....

People seem to like it.  I don't use it myself (haven't felt the need).

> Does Python have Regexps?

Not built into the language the way Perl regexps are.  There's a regexp
library that's pretty capable, but you have to say things like
  re.search('foo.*bar', x)
instead of x ~ /foo.*bar/  or whatever.  Generally I'd say Perl has far
more built-in creature comforts where Python makes you call a library.
The capabilities end up being about the same but one could say Python
doesn't require you to remember as much stuff.

Perl 6 is another story, interesting but apparently monstrously
complicated.  I haven't looked at it closely but followed some of the
development history, which was amazing.

> How was the Python 2.7 vs Python 3.X solved? which version should I go for?

It hasn't really been solved and probably never will be.  It's probably
preferable to start with 3.x, but in practice the differences aren't
that large and you should be able to work with both.  Despite the
screams of this newsgroup, most professional projects that I've been
involved with are still using 2.x.

> Do you think that switching to Python from Perl is a good idea at 45?

Sure.

> Where do I get started moving from Perl to Python?

Read the tutorial ( https://docs.python.org/3/tutorial/ )
and hack some code.

> which gotchas need I be aware of?

There's lots of minor ones, just like with any other complicated system.
You'll run into them as you go along, and deal with them.  There's
nothing really horrible that I can think of.

[toc] | [prev] | [next] | [standalone]


#102206

FromChris Angelico <rosuav@gmail.com>
Date2016-01-29 13:34 +1100
Message-ID<mailman.72.1454034863.2338.python-list@python.org>
In reply to#102205
On Fri, Jan 29, 2016 at 1:06 PM, Paul Rubin <no.email@nospam.invalid> wrote:
> Fillmore <fillmore_remove@hotmail.com> writes:
>> I look and Python and it looks so much more clean....
>
> Yes it is, I forgot everything I knew about Perl shortly after starting
> to use Python.

https://xkcd.com/353/

Particularly the hover text. :)

ChrisA

[toc] | [prev] | [next] | [standalone]


#102245

Fromsohcahtoa82@gmail.com
Date2016-01-29 12:41 -0800
Message-ID<2c66d920-27cf-41ae-a19e-935c801964ee@googlegroups.com>
In reply to#102206
On Thursday, January 28, 2016 at 6:34:34 PM UTC-8, Chris Angelico wrote:
> On Fri, Jan 29, 2016 at 1:06 PM, Paul Rubin <no.email@nospam.invalid> wrote:
> > Fillmore <fillmore_remove@hotmail.com> writes:
> >> I look and Python and it looks so much more clean....
> >
> > Yes it is, I forgot everything I knew about Perl shortly after starting
> > to use Python.
> 
> https://xkcd.com/353/
> 
> Particularly the hover text. :)
> 
> ChrisA

I have this comic pinned to the outside wall of my cubicle at work, where I use Python for 98% of my work.

It's funny...when I first started using Python, I hated it because it held your hand and made everything too easy.  I was a major C, C++ and Java fanatic.  Now, I LOVE Python because it holds your hand and makes everything so easy.

I still like C and C++, but have basically learned that each language has it's place.  I wouldn't try to write a AAA-quality game in Python, just like I wouldn't write something that should be a simple 50-line Python script in C++.

[toc] | [prev] | [next] | [standalone]


#102249

FromChris Angelico <rosuav@gmail.com>
Date2016-01-30 07:54 +1100
Message-ID<mailman.97.1454100871.2338.python-list@python.org>
In reply to#102245
On Sat, Jan 30, 2016 at 7:41 AM,  <sohcahtoa82@gmail.com> wrote:
> It's funny...when I first started using Python, I hated it because it held your hand and made everything too easy.  I was a major C, C++ and Java fanatic.  Now, I LOVE Python because it holds your hand and makes everything so easy.
>

Exactly.

> I still like C and C++, but have basically learned that each language has it's place.  I wouldn't try to write a AAA-quality game in Python, just like I wouldn't write something that should be a simple 50-line Python script in C++.
>

And you'd be amazed at how many of the things people say "oh, you
can't do *that* in Python" can actually be done 99% in Python and 1%
in some other language - often with the 1% being a standard library.
Sure, Python's arithmetic operations aren't fast enough to do heavy
computational work in - but what if you just deploy numpy and let
Fortran do the heavy lifting? You can write your application logic in
Python, and get the performance of Fortran.

ChrisA

[toc] | [prev] | [next] | [standalone]


#102257

FromGregory Ewing <greg.ewing@canterbury.ac.nz>
Date2016-01-30 11:27 +1300
Message-ID<dh27b4FtmkkU1@mid.individual.net>
In reply to#102245
sohcahtoa82@gmail.com wrote:
> On Thursday, January 28, 2016 at 6:34:34 PM UTC-8, Chris Angelico wrote:
> 
>> https://xkcd.com/353/
> 
> I have this comic pinned to the outside wall of my cubicle at work, where I
> use Python for 98% of my work.

Another good thing to pin to your wall:

http://www.gentoogeek.org/files/choose_python.pdf

-- 
Greg

[toc] | [prev] | [next] | [standalone]


#102209

FromMichael Torrie <torriem@gmail.com>
Date2016-01-28 21:42 -0700
Message-ID<mailman.74.1454042585.2338.python-list@python.org>
In reply to#102205
On 01/28/2016 07:34 PM, Chris Angelico wrote:
> On Fri, Jan 29, 2016 at 1:06 PM, Paul Rubin <no.email@nospam.invalid> wrote:
>> Fillmore <fillmore_remove@hotmail.com> writes:
>>> I look and Python and it looks so much more clean....
>>
>> Yes it is, I forgot everything I knew about Perl shortly after starting
>> to use Python.
> 
> https://xkcd.com/353/
> 
> Particularly the hover text. :)

Another particularly appropriate xkcd comic, given the OP's experiencein
Perl is this one (and the hover text again!):
https://xkcd.com/224/

[toc] | [prev] | [next] | [standalone]


#102233

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2016-01-29 08:54 -0500
Message-ID<mailman.88.1454075715.2338.python-list@python.org>
In reply to#102205
On Fri, 29 Jan 2016 13:34:20 +1100, Chris Angelico <rosuav@gmail.com>
declaimed the following:

>On Fri, Jan 29, 2016 at 1:06 PM, Paul Rubin <no.email@nospam.invalid> wrote:
>> Fillmore <fillmore_remove@hotmail.com> writes:
>>> I look and Python and it looks so much more clean....
>>
>> Yes it is, I forgot everything I knew about Perl shortly after starting
>> to use Python.
>
>https://xkcd.com/353/
>
>Particularly the hover text. :)
>

	And another Easter egg... 
 
PythonWin 2.7.5 (default, Sep 16 2013, 23:11:01) [MSC v.1500 64 bit
(AMD64)] on win32.
Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for
further copyright information.
>>> import antigravity
>>> 

.... opens a tab in my browser for that particular xkcd entry!
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#102211

FromJussi Piitulainen <jussi.piitulainen@helsinki.fi>
Date2016-01-29 08:24 +0200
Message-ID<lf5a8no9a3k.fsf@ling.helsinki.fi>
In reply to#102199
Fillmore writes:

> Does Python have Regexps?

Start by importing the re module (as said). Find its documentation at
the following link (together with a list of many other modules that come
standard with Python). Also, once imported to the interactive session,
help(re), dir(re).

https://docs.python.org/3/library/index.html

But there's an alternative implementation, which should be easy to
install (worked for me when I needed it), called regex. Find it at the
following link and see for yourself.

https://pypi.python.org/pypi/regex

[toc] | [prev] | [next] | [standalone]


#102231

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2016-01-29 08:50 -0500
Message-ID<mailman.86.1454075384.2338.python-list@python.org>
In reply to#102199
On Thu, 28 Jan 2016 19:21:40 -0500, Nathan Hilterbrand
<nhilterbrand@gmail.com> declaimed the following:


>Gotchas?  If you are learning Python after years of perl use, the 
>"gotchas" would be another book just by themselves.  Be prepared to do a 

	Heh... Almost literally...

http://www.barnesandnoble.com/w/perl-to-python-migration-martin-c-brown/1004847881?ean=9780201734881
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#102240

FromFillmore <fillmore_remove@hotmail.com>
Date2016-01-29 12:04 -0500
Message-ID<n8g62p$1dot$2@gioia.aioe.org>
In reply to#102199
So many answers. So much wisdom...thank you everyone

On 01/28/2016 07:01 PM, Fillmore wrote:
>
>

[toc] | [prev] | [next] | [standalone]


Page 3 of 4 — ← Prev page 1 2 [3] 4  Next page →

Back to top | Article view | comp.lang.python


csiph-web