472,370 Members | 2,449 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,370 software developers and data experts.

What Python looks like

iu2
Hi,

This is a little bit strange post, but I'm curious...

I learned Python from its tutorial step by step, and practicing
writing small scripts.
I haven't seen a Python program before knowing Python.

I'm curious, what did Python code look like to those of you who have
seen a bunch of Python code for the first time before knowing Python?

(I can tell, for example, that seeing perl for the first time looked
like C with many $$$, I could see "if" and "for" and "while" but they
were meaningless. Or Lisp for the first time looked like many words,
no operators, how could that make a program???)

Thanks
Aug 4 '08 #1
13 3557
iu2 wrote:
Hi,

This is a little bit strange post, but I'm curious...

I learned Python from its tutorial step by step, and practicing
writing small scripts.
I haven't seen a Python program before knowing Python.

I'm curious, what did Python code look like to those of you who have
seen a bunch of Python code for the first time before knowing Python?

(I can tell, for example, that seeing perl for the first time looked
like C with many $$$, I could see "if" and "for" and "while" but they
were meaningless. Or Lisp for the first time looked like many words,
no operators, how could that make a program???)

Thanks
Python looked like pseudo-code that people would write before actually coding.
I've always thought that Python was "Pseudo-code that runs".

-Larry
Aug 4 '08 #2
iu2 wrote:
Hi,

This is a little bit strange post, but I'm curious...

I learned Python from its tutorial step by step, and practicing
writing small scripts.
I haven't seen a Python program before knowing Python.

I'm curious, what did Python code look like to those of you who have
seen a bunch of Python code for the first time before knowing Python?

(I can tell, for example, that seeing perl for the first time looked
like C with many $$$, I could see "if" and "for" and "while" but they
were meaningless. Or Lisp for the first time looked like many words,
no operators, how could that make a program???)
My impression was (and still is):

A page of Python code looks *clean*, with not a lot of
punctuation/special symbols and (in particular) no useless lines
containing {/} or begin/end or do/done (or whatever).

Gary Herron

Thanks
--
http://mail.python.org/mailman/listinfo/python-list
Aug 4 '08 #3
On Aug 4, 2:06*pm, iu2 <isra...@elbit.co.ilwrote:
Hi,

This is a little bit strange post, but I'm curious...

I learned Python from its tutorial step by step, and practicing
writing small scripts.
I haven't seen a Python program before knowing Python.

I'm curious, what did Python code look like to those of you who have
seen a bunch of Python code for the first time before knowing Python?
To me, when I started transitioning from perl to Python, Python

Python from 2002
--------------------------------------------------------------
import sys
import string
# Python Collatz tester
j = string.atol(sys.argv[1])
i = 2**(6*j-1)-1
print i,"\n"
r1 = 0
r2 = 0
count = 0
while i>1:
z = divmod(i,2)
if z[1]==0:
i = z[0]
r1 = r1 + 1
if z[1]>0:
i = i*3 + 1
r2 = r2 + 1
print "[1]",r1
print "[2]",r2,"\n"
--------------------------------------------------------------

looked just like perl, but without the braces (which seemed a
lot more important than the $s).

Perl from 2002
--------------------------------------------------------------
use Math::BigInt ':constant';
$j = @ARGV[0];
$i = 2**(6*$j-1)-1;
print "$i\n";
$r1 = 0;
$r2 = 0;
while ($i>1) {
if ($i =~ /.*?[0,2,4,6,8]$/) {
$i = $i/2;
$r1++;
}
else {
$i = $i*3 + 1;
$r2++;
}
}
print "[1] ",$r1;
print " [2] ",$r2,"\n";
--------------------------------------------------------------

>
(I can tell, for example, that seeing perl for the first time looked
like C with many $$$,
I wouldn't say that, the $s are minor, big thing is the declarations
and pointers.

C from 2005 (not complete program)
--------------------------------------------------------------
long collatz (mpz_ptr r)
{
mpz_t result, twee, twoo, cee;
mpz_init (result);
mpz_init_set_ui (cee, 1);
mpz_init_set_ui (twee, 3);
mpz_init_set_ui (twoo, 2);
long rule1 = 0;
long rule2 = 0;
long f;
while (mpz_cmp (r, cee) 0)
{
f = mpz_scan1 (r, 0);
if (f>0) /* even */
{
mpz_tdiv_q_2exp (result, r, f);
rule1 = rule1 + f;
}
else /* odd */
{
mpz_set (result, cee);
mpz_addmul (result, r, twee);
rule2++;
}
mpz_swap (r, result);
}
printf ("\nRule1: %8d Rule2: %8d\n\n", rule1, rule2);
return rule1 + rule2;
}
--------------------------------------------------------------

I could see "if" and "for" and "while" but they
were meaningless.
Maybe you looked at a crappy example.
Or Lisp for the first time looked like many words,
no operators,
Aren't some of the words operators? I never used used Lisp,
but I did dabble in Scheme and have no trouble identifying the
operators (although not the overall program).

Scheme from 2004
--------------------------------------------------------------
(define n 1)
(define collatz
(lambda (n)
(if (even? n)
(/ n 2)
(+ 1 (* n 3))
)))
(define sequence
(lambda (n)
(do ((count 0 (+ count 1)))
((= n 1) (display "stopping: ") (display count))
(set! n (collatz n)) (display n) (display " ")
)))
--------------------------------------------------------------
how could that make a program???)
You have to think differently with functional languages.
The functional snobs say you'll never "get" it once your
mind has been poisoned by imperative languages.
>
Thanks
Aug 4 '08 #4
iu2 <is*****@elbit.co.ilwrites:
I'm curious, what did Python code look like to those of you who have
seen a bunch of Python code for the first time before knowing Python?
To me it looked like the pseudo-code used for describing algorithms,
allowing clear understanding and redesign of the algorithm before
adding all the cruft "necessary" to make a real program from it.

I was very impressed, therefore, that program code could be so clear
and readable, and yet require so little computer-friendly cruft.
(I can tell, for example, that seeing perl for the first time looked
like C with many $$$, I could see "if" and "for" and "while" but they
were meaningless.
Being already familiar with Bourne-style shell programs, Perl just
looked to me like an even-more-baroque version of Bourne shell syntax.
Not surprising, since that was one of its main inspirations.
Or Lisp for the first time looked like many words, no operators, how
could that make a program???)
I had no referent with which to compare Lisp when I first saw it. I
did wonder "if the program is so nicely indented anyway, why are all
these parentheses necessary?" That was many years before I encountered
Python :-)

--
\ “I see little commercial potential for the Internet for at |
`\ least ten years.” —Bill Gates, 1994 |
_o__) |
Ben Finney
Aug 4 '08 #5
Mel
Ben Finney wrote:
iu2 <is*****@elbit.co.ilwrites:
>Or Lisp for the first time looked like many words, no operators, how
could that make a program???)

I had no referent with which to compare Lisp when I first saw it. I
did wonder "if the program is so nicely indented anyway, why are all
these parentheses necessary?" That was many years before I encountered
Python :-)
Coming from assembly language "no operators" was not something that
registered. A big limitation of assembly language is that the instruction
operands have to be identifiable at assembly time.. linkedit time at the
latest. Lisp has no such restriction. Hence all the parens.

Mel.

Aug 4 '08 #6
I'm curious, what did Python code look like to those of you who have
seen a bunch of Python code for the first time before k
Clean and readable.
Aug 5 '08 #7
En Mon, 04 Aug 2008 19:20:18 -0300, Ben Finney
<bi****************@benfinney.id.auescribi�:
iu2 <is*****@elbit.co.ilwrites:
>I'm curious, what did Python code look like to those of you who have
seen a bunch of Python code for the first time before knowing Python?

To me it looked like the pseudo-code used for describing algorithms,
allowing clear understanding and redesign of the algorithm before
adding all the cruft "necessary" to make a real program from it.

I was very impressed, therefore, that program code could be so clear
and readable, and yet require so little computer-friendly cruft.
I got the same impression when I saw Python code for the first time.

--
Gabriel Genellina

Aug 5 '08 #8
Gary Herron wrote:
My impression was (and still is):

A page of Python code looks *clean*, with not a lot of
punctuation/special symbols and (in particular) no useless lines
containing {/} or begin/end or do/done (or whatever).
what about all those 'self' thingys? :)
Aug 5 '08 #9
On Aug 4, 12:06*pm, iu2 <isra...@elbit.co.ilwrote:
Hi,

This is a little bit strange post, but I'm curious...

I learned Python from its tutorial step by step, and practicing
writing small scripts.
I haven't seen a Python program before knowing Python.

I'm curious, what did Python code look like to those of you who have
seen a bunch of Python code for the first time before knowing Python?

(I can tell, for example, that seeing perl for the first time looked
like C with many $$$, I could see "if" and "for" and "while" but they
were meaningless. Or Lisp for the first time looked like many words,
no operators, how could that make a program???)

Thanks
I stumbled across Python in 2000 when I ran accross GNUe. I decided
to look into Python at that time, and was impressed that the code was
readable, and, understandable - even before I looked at the language
and library refs. I had been working in a subset of Basic and Delphi
at the time. I really don't like Pascal or C/C++ with all of the
BEGIN/END and braces. I don't work in Python full time, but do use it
for scripting, and "hobby" programming. One heck of a cool language!

RCB
Aug 5 '08 #10
On Aug 4, 3:43*pm, Gary Herron <gher...@islandtraining.comwrote:
A page of Python code looks *clean*, *with not a lot of
punctuation/special symbols and (in particular) no useless lines
I am actually going to buck the trend.

My first impression of Python was that it was visually hard to parse.

When seeing sample code from languages I don't know (.NET, Smalltalk,
etc) I can decipher the intent fairly easily (on simple code).
Python, on the other hand, used shorthand notation for everything.
Each word wasn't bad, but as a whole it tended to wash out informative
clues. The lack of "special symbols" likewise removed visual parsing
clues.

Put another way, imagine math went from:
2 + 2 = 4
to:
two plus two equals four
and then someone decided to abbreviate:
two pl two eq four

When I ran into list comprehensions (Aah! Now we have punctuation,
but it's not providing visual parsing clues, it's more like Lisp
parens!) or lambda definitions or "self" being added a lot, it grew
more dense.

This is NOT a rip on Python. Please put the flamethrowers away. I
appreciate that Python operates with a fairly dense use of information
and operations. (Believe me, having done enough Java, I can
appreciate not having excessive syntax). My point is that not
everyone new to Python is going to have a "clean and clear" first
impression, particularly based on their previous language experience.
Aug 5 '08 #11
brad <by*******@gmail.comwrites:
Gary Herron wrote:
A page of Python code looks *clean*, with not a lot of
punctuation/special symbols and (in particular) no useless lines
containing {/} or begin/end or do/done (or whatever).

what about all those 'self' thingys? :)
Nice, clear, explicit, readable. I loved explicit 'self' the first
time I saw it.

--
\ “I've always wanted to be somebody, but I see now that I should |
`\ have been more specific.” —Jane Wagner, via Lily Tomlin |
_o__) |
Ben Finney
Aug 6 '08 #12
On Aug 4, 8:06*pm, iu2 <isra...@elbit.co.ilwrote:
Hi,

This is a little bit strange post, but I'm curious...

I learned Python from its tutorial step by step, and practicing
writing small scripts.
I haven't seen a Python program before knowing Python.

I'm curious, what did Python code look like to those of you who have
seen a bunch of Python code for the first time before knowing Python?

(I can tell, for example, that seeing perl for the first time looked
like C with many $$$, I could see "if" and "for" and "while" but they
were meaningless. Or Lisp for the first time looked like many words,
no operators, how could that make a program???)

Thanks
Strange you should mention this. I am currently new to Rosetta Code
http://www.rosettacode.org/ where some pages I have been looking at
such as the page for Zig Zag, and a page I created called Spiral
have had very terse solutions, and long explanations in the talk
pages all written in the J language. I can read the lines between
the code samples enough to intrigue , (OK frustrate), me - but the
code is impenetrable.
I am not sure if J attracts good programmers or if learning J
forces you to think about solutions in different or useful ways.
I've learnt A LISP-like language, dabbled with forth & prolog &
constraints - maybe its time to learn J and find out if this
array programming malarky will bring new insight to my problem
solving - but it will never be readable :-)

- Paddy.
Aug 6 '08 #13
On 5 Aug, 16:08, Brett Ritter <swift...@swiftone.orgwrote:
On Aug 4, 3:43*pm, Gary Herron <gher...@islandtraining.comwrote:
A page of Python code looks *clean*, *with not a lot of
punctuation/special symbols and (in particular) no useless lines
My first impression of Python was that it was visually hard to parse.
<snip>>
Put another way, imagine math went from:
2 + 2 = 4
to:
two plus two equals four
and then someone decided to abbreviate:
two pl two eq four
That looks more like tcl than python to me.

My first reaction to python was a strong dislike
of indentation as a block delimeter and
the convention of using '__*__' names. I got over
my issue with indentation fairly quickly, but still
don't care for the excessive underscores. However,
overall I thought it was extremely clean and
easy to write. By the time I saw Python, I had
already essentially given up on Perl, but it
only took 20 minutes going through the tutorial to
completely nail down the lid on the coffin of
my Perl self.

To summarize the first impression: clean, simple,
powerful, and a lot of potential.

Aug 6 '08 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
34
by: Brandon J. Van Every | last post by:
What do you think of this Python logo? http://pythonology.org/logos Good, bad, indifferent, love it, hate it? -- Cheers, www.indiegamedesign.com Brandon Van Every ...
53
by: Paul Rubin | last post by:
I've been approached about writing a Windows app which will need a really professional looking GUI. Forget TKinter, this has to actually look good (real artists will be available to get the visual...
3
by: Chris Cioffi | last post by:
I started writing this list because I wanted to have definite points to base a comparison on and as the starting point of writing something myself. After looking around, I think it would be a...
37
by: Bengt Richter | last post by:
ISTM that @limited_expression_producing_function @another def func(): pass is syntactic sugar for creating a hidden list of functions. (Using '|' in place of '@' doesn't change the picture...
92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
28
by: john_sips_tea | last post by:
Just tried Ruby over the past two days. I won't bore you with the reasons I didn't like it, however one thing really struck me about it that I think we (the Python community) can learn from. ...
5
by: Karyn Williams | last post by:
I am new to Pyton. I am trying to modify and understand a script someone else wrote. I am trying to make sense of the following code snippet. I know line 7 would be best coded with regex. I first...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.