473,729 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3682
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

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

Similar topics

220
19101
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 any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it seems that Ruby has the potential to compete with and displace Python. I'm curious on what basis it...
54
6567
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 FRICKIN' COOL!!! ***MAN*** that would save me a buttload of work and make my life sooooo much easier!" As opposed to minor differences of this feature here, that feature there. Variations on style are of no interest to me. I'm coming at this from a...
34
5110
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 Seattle, WA Brandon's Law (after Godwin's Law): "As a Usenet discussion grows longer, the probability of
53
6446
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 stuff right). Assuming I write in Python, what's the best toolkit to use? Some cost in implementation pain is tolerable if the finished interface looks better as a result. It would be nice if the toolkit runs on multiple platforms rather than...
3
3001
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 waste of time to start writing yet another IDE and so am now thinking in terms of new features/plug-ins for existing systems. Right now I mostly use Komodo Personal and it's pretty close to being what I want. They don't currently support plug-ins,...
37
2600
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 much (except for people whose tools depend on '@' ;-)). I.e., (not having the source or time to delve) the apparent semantics of the above is something roughly like
92
6504
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? cheers, reed
28
3001
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. Ruby has ... an issue with docs. That is to say, there are almost none. Well, actually, there are some. For example, the "PickAxe" book (google it), and "Why's" Poignant Guide. But there's a disturbing lack of *built-in* docs for Ruby. Now, the...
5
2525
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 would like to understand what was coded originally. thelistOut looks like a hash to me (I'm more familiar with perl). Perhaps someone could translate from perl to python for me - not in code but just in concept. Here is the code. This script...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9281
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.