![]() |
Learning Python now coming from Perl
I'm planning to start learning Python now, using Python 3000.
I have no previous Python skills, but I now Perl pretty well. I'm also well experienced with JavaScript. Any pointers and tips how I should go about getting into Python? -- Bertilo Wennergren <http://bertilow.com> |
Re: Learning Python now coming from Perl
In article <ghdt15$6e7$1@news.motzarella.org>,
Bertilo Wennergren <bertilow@gmail.com> wrote: > I'm planning to start learning Python now, using Python 3000. > I have no previous Python skills, but I now Perl pretty well. > I'm also well experienced with JavaScript. > > Any pointers and tips how I should go about getting into > Python? I assume you use Perl to solve real problems in whatever job you do. My recommendation would be the next time some problem comes up that you would normally solve with Perl, try doing it in Python. Having a real task that you need to accomplish is a great way to focus the mind. For your first project, pick something that's small enough that you think you could tackle it in under 50 lines of Perl. One of the very first things you'll probably discover that's different between Perl and Python is how they handle string pattern matching. In Perl, it's a built in part of the language syntax. In Python, you use the re module. The regular expressions themselves are the same, but the mechanism you use to apply them to input text is quite different. |
Re: Learning Python now coming from Perl
Roy Smith wrote:
> Bertilo Wennergren <bertilow@gmail.com> wrote: >> I'm planning to start learning Python now, using Python 3000. >> I have no previous Python skills, but I now Perl pretty well. >> I'm also well experienced with JavaScript. >> >> Any pointers and tips how I should go about getting into >> Python? > I assume you use Perl to solve real problems in whatever job you do. My > recommendation would be the next time some problem comes up that you would > normally solve with Perl, try doing it in Python. Having a real task that > you need to accomplish is a great way to focus the mind. For your first > project, pick something that's small enough that you think you could tackle > it in under 50 lines of Perl. Good advice. > One of the very first things you'll probably discover that's different > between Perl and Python is how they handle string pattern matching. In > Perl, it's a built in part of the language syntax. In Python, you use the > re module. The regular expressions themselves are the same, but the > mechanism you use to apply them to input text is quite different. Thanks. I don't suppose there is any introductory material out there that is based on Python 3000 and that is also geared at people with a Perl background? Too early for that I guess.. -- Bertilo Wennergren <http://bertilow.com> |
Re: Learning Python now coming from Perl
Bertilo Wennergren wrote:
> Roy Smith wrote: > >> Bertilo Wennergren <bertilow@gmail.com> wrote: > >>> I'm planning to start learning Python now, using Python 3000. >>> I have no previous Python skills, but I now Perl pretty well. >>> I'm also well experienced with JavaScript. >>> >>> Any pointers and tips how I should go about getting into >>> Python? > >> I assume you use Perl to solve real problems in whatever job you do. >> My recommendation would be the next time some problem comes up that >> you would normally solve with Perl, try doing it in Python. Having a >> real task that you need to accomplish is a great way to focus the >> mind. For your first project, pick something that's small enough that >> you think you could tackle it in under 50 lines of Perl. > > Good advice. > >> One of the very first things you'll probably discover that's different >> between Perl and Python is how they handle string pattern matching. >> In Perl, it's a built in part of the language syntax. In Python, you >> use the re module. The regular expressions themselves are the same, >> but the mechanism you use to apply them to input text is quite different. > > Thanks. > > I don't suppose there is any introductory material out there > that is based on Python 3000 and that is also geared at people > with a Perl background? Too early for that I guess.. > This is from a post within the last few days: http://www.qtrac.eu/pyqtbook.html Colin W. |
Re: Learning Python now coming from Perl
On Sat, 06 Dec 2008 08:50:20 -0500, Roy Smith wrote:
> For your first > project, pick something that's small enough that you think you could > tackle it in under 50 lines of Perl. Is there anything which *can't* be written in under 50 lines of Perl? :-) > One of the very first things you'll probably discover that's different > between Perl and Python is how they handle string pattern matching. In > Perl, it's a built in part of the language syntax. In Python, you use > the re module. The regular expressions themselves are the same, but > the mechanism you use to apply them to input text is quite different. Also, Perl REs are faster than Python REs, or so I'm told. Between the speed and the convenience, Perl programmers tend to use RE's for everything they can. Python programmers tend to use REs only for problems that *should* be solved with REs rather than *can* be solved with a RE. Well, I say "tend", but in truth we get our fair share of questions like "Hi, how do I factorize a 20 digit number with a regular expression?" too. Probably the biggest difference is that in Python, you always refer to objects the same way, regardless of what sort of data they contain. Regardless of whether x is a scalar or a vector, you always call it just plain x. -- Steven |
Re: Learning Python now coming from Perl
In article <ghe0jo$3i1$1@news.motzarella.org>,
Bertilo Wennergren <bertilow@gmail.com> wrote: > >I don't suppose there is any introductory material out there that is >based on Python 3000 and that is also geared at people with a Perl >background? Too early for that I guess.. Honestly, the differences between 2.x and 3.0 are small enough that it doesn't much matter, as long as you're not the kind of person who gets put off by little problems. Because so much material is for 2.x, you may be better off just learning 2.x first and then moving to 3.x. -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan |
Re: Learning Python now coming from Perl
I fully agree with Roy's answer.
COding small tasks is a good starting point. For quite some time you'll be of course less efficient than with your previous language, but that's part of the learning curve, isn't it. I guess you'll learn the syntax rather quickly. What's more painful is to learn which functianilty is in which library and which library exists. There's of course a lot of online documentation, but often you find answers to trivial python questions fastest with Google: for example: search for something like "python string reverse example" And there's of course this newsgroup whenever you're stuck with a 'missing' feature, (though mostly the features aren't missing, but just a little different) bye N Roy Smith wrote: > In article <ghdt15$6e7$1@news.motzarella.org>, > Bertilo Wennergren <bertilow@gmail.com> wrote: > >> I'm planning to start learning Python now, using Python 3000. >> I have no previous Python skills, >> . . . > > I assume you use Perl to solve real problems in whatever job you do. My > recommendation would be the next time some problem comes up that you would > normally solve with Perl, try doing it in Python. Having a real task that > you need to accomplish is a great way to focus the mind. For your first > project, pick something that's small enough that you think you could tackle > it in under 50 lines of Perl. > > One of the very first things you'll probably discover that's different > between Perl and Python is how they handle string pattern matching. In > Perl, it's a built in part of the language syntax. In Python, you use the > re module. The regular expressions themselves are the same, but the > mechanism you use to apply them to input text is quite different. |
Re: Learning Python now coming from Perl
In article <ghecgk$81m$1@panix3.panix.com>, aahz@pythoncraft.com (Aahz)
wrote: > In article <ghe0jo$3i1$1@news.motzarella.org>, > Bertilo Wennergren <bertilow@gmail.com> wrote: > > > >I don't suppose there is any introductory material out there that is > >based on Python 3000 and that is also geared at people with a Perl > >background? Too early for that I guess.. > > Honestly, the differences between 2.x and 3.0 are small enough that it > doesn't much matter, as long as you're not the kind of person who gets > put off by little problems. Because so much material is for 2.x, you > may be better off just learning 2.x first and then moving to 3.x. I'm not sure I agree. If you're starting out, you might as well learn the new stuff. Then there's no need to unlearn the old way. Using material meant for 2.x is likely to lead to confusion. If you don't know either, you'll never know if something isn't working as described because you're doing it wrong or if it's just not the same as it used to be. When everything is new, what seem like little stumbling blocks to experts become total blockers to people starting from zero. |
Re: Learning Python now coming from Perl
News123 wrote:
> > What's more painful is to learn which functianilty is in which library > and which library exists. > <cut> Yes and one mistake I still often find myself doing is, when confronted with a particular problem, that I write some helper code to deal with it. Of course later on I discover that there is a standard module or built-in that does exactly what I want and better. :-) Somehow in the heat of the moment my mind is not thinking 'there must be something out there which does what I want' but rather 'hmmm I think I can do it this way, clicker-di-click'. In my opinion it is a positive attribute to the language that it makes solving problems so easy that you forget about searching for solutions. Maybe python should prompt every 10 lines of code a message saying 'Are you sure this can not be done with a built-in?' Most of the time it will be right anyway :-) -- mph |
Re: Learning Python now coming from Perl
In article <014a96e0$0$20670$c3e8da3@news.astraweb.com>,
Steven D'Aprano <steve@REMOVE-THIS-cybersource.com.au> wrote: > On Sat, 06 Dec 2008 08:50:20 -0500, Roy Smith wrote: > > > For your first > > project, pick something that's small enough that you think you could > > tackle it in under 50 lines of Perl. > > Is there anything which *can't* be written in under 50 lines of Perl? [...] > Also, Perl REs are faster than Python REs, or so I'm told. Between the > speed and the convenience, Perl programmers tend to use RE's for > everything they can. Python programmers tend to use REs only for problems > that *should* be solved with REs rather than *can* be solved with a RE. Well, as an old-time unix hacker (who learned REs long before Perl existed), my question to you would be, "Is there any problem which *shouldn't* be solved with an RE?" :-) It's easy to go nuts with REs, and create write-only code. On the other hand, they are an extremely powerful tool. If you are wise in the ways of RE-fu, they can not only be the most compact way to write something, but also the most efficient and even the most comprehensible. Unfortunately, REs seem to be regarded as some kind of monster these days and few people take the time to master them fully. Which is a shame. One really nice feature of REs in Python is the VERBOSE flag. It lets you write some way-complicated REs in a way which is still easy for somebody to read and understand. Python's raw strings, and triple-quoted strings, also help reduce the sea of backslashes which often make REs seem much worse than they really are. One of the reasons REs don't get used in Python as much as in Perl is because strings have useful methods like startswith(), endswith(), and split(), and also the "in" operator. These combine to give you easy ways to do many things you might otherwise do with REs. |
| All times are GMT. The time now is 11:37 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.