Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
n00b question
#1
I am in the process of learning Python3.x, with prior experience in Perl.

I am wondering if there is anything out there that teaches Python from a Perl users perspective, such as comparing similar scripts as examples. Or even better, a 'cookbook' with examples in both languages?

I find Perl to be excellent for my text processsing needs (copious amounts of $a s/x/y/ type statements) but it seems a bit ponderous for web and network functions which I wish to be getting into. I want to update a DBI script into Python, for example.

It would be nice to be able to do perl *within* Python - are there any extant wrapper modules for things like the magic of <>,@_, and $_? The only one I was able to find is now a 404.
Reply
#2
Are you familiar with Rosetta Code? It's several hundred programming tasks done in multiple languages. You could use that to compare Perl and Python code.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
Perl Phrase book
https://wiki.python.org/moin/PerlPhrasebook

I think this would be a good source coming from perl, however it looks to be using python2.x. But i would still use it as a lot of tutorials for python2.x can be easily converted to python3.x

python2.x statements like this
Quote:print s1
print s2

would be a function in python3.x like this
print(s1)
print(s2)
and...
and string expression (py2) compared to the format method (py3)
python2.x
print '%d = %s' % (i, member),
python3.x
print('{} = {}'.format(i, member))
python3.6+
print(f'{i} = {member}')
Scanning through that real quick, that seems to be the only major difference
Recommended Tutorials:
Reply
#4
Many thanks!

The Rosetta site and the Phrasebook sites were exactly what I've been looking for.

While I really like Perl, it does become a bit obtuse on more complex things like references/pointers and OOP. Ruby would be ideal, but it doesnt seem to have the power for large databases, or the sophistication of Python, whose scientific modules are awesome. And as much as I've tried, cannot develop any liking for Java - despite liking its H2 database!

Only other question that comes to mind is:
As even re is an external module, and I hate relying on the cloud, is there any way of mirroring Pypi? (I have my own repos of CPAN, Ruby, and Debian)
Reply
#5
millpond Wrote:As even re is an external module,
re is not an external module. It's part of the standard library shipped with python.

As to mirroring pypi, I've kept this link in my bookmarks for a long time but I've never tried it :)
Reply
#6
Indeed, I see that there is a diffeence in Python, with standards libs needing tobe called....

As to devpi: No joy.
Output:
stretch:~# devpi-server --version #System is actually Buster. Anaconda is also insstalled, but pip witing to /ur/lib Traceback (most recent call last): File "/usr/local/bin/devpi-server", line 6, in <module> from devpi_server.main import main File "/usr/local/lib/python3.7/dist-packages/devpi_server/main.py", line 17, in <module> from .views import apireturn File "/usr/local/lib/python3.7/dist-packages/devpi_server/views.py", line 16, in <module> from pyramid.httpexceptions import HTTPException, HTTPFound, HTTPSuccessful File "/usr/lib/python3/dist-packages/pyramid/httpexceptions.py", line 138, in <module> from webob.acceptparse import create_accept_header ImportError: cannot import name 'create_accept_header' from 'webob.acceptparse' (/usr/local/lib/python3.7/dist-packages/webob/acceptparse.py)
Webob is installed. And that error occurs on all calls.

Reechecked install without -q , and all looks OK.

Is there ftp access for PyPi?
Reply
#7
millpond Wrote:Webob is installed
I never used webob but you may have a wrong version of this module. There is a create_accept_header() function in the repository. It happens often that prepackaged python modules distributed by the OS are slightly outdated. You could perhaps uninstall webob and reinstall it with pip.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  n00b help with referencing files theturd 8 5,128 Jul-21-2017, 04:16 PM
Last Post: nilamo
  n00b needs help theturd 8 5,817 Jun-12-2017, 01:55 PM
Last Post: theturd
  serious n00b.. NLTK in python 2.7 and 3.5 pythlang 24 19,773 Oct-21-2016, 04:15 PM
Last Post: pythlang

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020