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

Cameron Simpson cs at zip.com.au
Fri Jan 29 18:48:47 EST 2016


On 29Jan2016 18:12, Steven D'Aprano <steve at 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 at zip.com.au>



More information about the Python-list mailing list