Re: How to wow someone new to Python

2015-01-22 Thread Grant Edwards
On 2015-01-22, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
 Mario Figueiredo wrote:

 But speaking about impressing more experient programmers, I personally
 don't think Python has a wow factor in any of its features and syntax. At
 least in the way I understand the word wow.

 Quote:

 I've seen Python criticized as ugly precisely because it doesn't 
 have a trick-based view of the world. In many ways, it's a dull
 language, borrowing solid old concepts from many other languages 
 styles: boring syntax, unsurprising semantics, few automatic 
 coercions, etc etc. But that's one of the things I like about it.
 - Tim Peters

Well, you know the ancient Chinese programmer's curse:

  May you program in an interesting language.

-- 
Grant Edwards   grant.b.edwardsYow! Pardon me, but do you
  at   know what it means to be
  gmail.comTRULY ONE with your BOOTH!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-21 Thread Steve Hayes
On Sat, 17 Jan 2015 02:03:57 +1100, Chris Angelico ros...@gmail.com wrote:

Scenario: You're introducing someone to Python for the first time.
S/he may have some previous programming experience, or may be new to
the whole idea of giving a computer instructions. You have a couple of
minutes to show off how awesome Python is. What do you do?

I was thinking along the lines of a simple demo in the REPL, showing
off some of Python's coolest features. But then I got stuck on the
specifics. What are Python's best coolnesses? What makes for a good
demo?

Ideally, this should be something that can be demo'd quickly and
easily, and it should be impressive without going into great details
of and see, this is how it works on the inside. So, how would you
brag about this language?

I can only say what made me sit up and take notice.

1. I found it already on my computer. 
2. It seemed to be used to run the Gramps genealogy program, which is quite
complex. I was impressed. 
3. When I started to look at it, I found that strings could be any length and
were not limited to swomething arbitrary, like 256 characters. 



-- 
Steve Hayes from Tshwane, South Africa
Web:  http://www.khanya.org.za/stevesig.htm
Blog: http://khanya.wordpress.com
E-mail - see web page, or parse: shayes at dunelm full stop org full stop uk
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-21 Thread Irmen de Jong
On 21-1-2015 18:59, Steve Hayes wrote:

 3. When I started to look at it, I found that strings could be any length and
 were not limited to swomething arbitrary, like 256 characters. 

Even more fun is that Python's primitive integer type (longs for older Python 
versions)
has no arbitrary limitation either.

That amazed me at the time I discovered python :)

Irmen

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-21 Thread André Roberge
On Friday, 16 January 2015 11:04:20 UTC-4, Chris Angelico  wrote:
 Scenario: You're introducing someone to Python for the first time.
 S/he may have some previous programming experience, or may be new to
 the whole idea of giving a computer instructions. You have a couple of
 minutes to show off how awesome Python is. What do you do?
 
 I was thinking along the lines of a simple demo in the REPL, showing
 off some of Python's coolest features. But then I got stuck on the
 specifics. What are Python's best coolnesses? What makes for a good
 demo?
 
 Ideally, this should be something that can be demo'd quickly and
 easily, and it should be impressive without going into great details
 of and see, this is how it works on the inside. So, how would you
 brag about this language?
 
 ChrisA
If you are willing to install an older version of Python (because the program I 
am going to mention has not been updated in years ... but it *should* work with 
2.6), I'm going to suggest an odd one:  Crunchy!  (ok, I'm biased :-).

The home page is at https://code.google.com/p/crunchy/ where you can find a 
link to some screencasts (based on an even older version ...)   So, before you 
install anything, just have a quick look at the screencast to see if it's 
worthwhile.

A demo using Crunchy seems to  be even more impressive if the person knows some 
programming.

(Here is what was said about an even older version of Crunchy by people at the 
Omaha Python group:  Jeff gave a presentation on Crunchy ([WWW]
http://crunchy.sourceforge.net/) Talk about a gee whiz app.  
[https://mail.python.org/pipermail/omaha/2007-July/65.html])

In a nutshell, I would open the official Python tutorial in my browser, showing 
the official Python tutorial.   (boring)

Then, I would open the exact same page using a browser tab served by Crunchy: 
magically some text-input boxes would have been inserted allowing you to try 
out the code in the REPL provided by Crunchy.  Then I'd use Crunchy to launch 
an external app (perhaps a tkinter program), etc.

As I said at the beginning, Crunchy has not been updated in *years* ... more or 
less since the IPython and Sage notebooks came along...

André
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-21 Thread André Roberge
On Wednesday, 21 January 2015 15:06:33 UTC-4, Chris Angelico  wrote:
 On Thu, Jan 22, 2015 at 5:20 AM, Irmen de Jong  wrote:
  On 21-1-2015 18:59, Steve Hayes wrote:
 
  3. When I started to look at it, I found that strings could be any length 
  and
  were not limited to swomething arbitrary, like 256 characters.
 
  Even more fun is that Python's primitive integer type (longs for older 
  Python versions)
  has no arbitrary limitation either.
 
  That amazed me at the time I discovered python :)
 
 I hadn't worked with length-limited strings in basically forever
 (technically BASIC has a length limit, but I never ran into it; and I
 never did much with Pascal), but you're right, arbitrary-precision
 integers would have impressed me a lot more if I hadn't first known
 REXX. So... is there a way to show that off efficiently? 

How about:

  def fac(n):
 ... ans = 1
 ... while n  1:
 ... ans *= n
 ... n -= 1
 ... return ans
 ...
  a = fac(100)
  a
 
9332621544394415268169923885626670049071596826438162146859296389521753229915608941463976156518286253697920827223758251185210916864
  b = fac(102)
  b
 
961446671503512660926865558697259548455355905059659464369444714048531715130254590603314961882364451384985595980362059157503710042865532928
  b//a
 10302
  b//a == 102 * 101
 True

André


Normally, any
 calculation that goes beyond 2**32 has already gone way beyond most
 humans' ability to hold the numbers in their heads.
 
 ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-21 Thread Mario Figueiredo

Chris,


Scenario: You're introducing someone to Python for the first time.
S/he may have some previous programming experience, or may be new to
the whole idea of giving a computer instructions. You have a couple of
minutes to show off how awesome Python is. What do you do?


Some ideas where given by others already. I especially liked the variable 
swap one liner by Emile van Sebille. That's a little simple gem that will 
impress any seasoned developer of other programming languages.


But speaking about impressing more experient programmers, I personally don't 
think Python has a wow factor in any of its features and syntax. At least 
in the way I understand the word wow. Python shares its own brand of idiosyncracies 
with any other programming languages. Little gotchas and caveats that have 
you scratch your head and sometimes annoy you slightly. Python is it too 
cropped here and there with things worth criticizing.


Meanwhile some of its interesting language features, like Comprehensions 
and Generators, aren't really that impressive to a seasoned developer of 
functional programming languages or programming languages like C# with its 
highly powerful and expressive LINQ.


This means that, alone, Python won't really standout. But this is ok. No 
language does it on the merits of its syntax or feature set.


What does make Python standout in my opinion -- what gave me the wow -- is 
its interoperability. Here we have a general purpose scripting language with 
more hooks to other systems that any other programming language in existence. 
With just Python, I can build a modern GUI interface on any of the most popular 
operating systems, use it on PostgreSQL to build stored procedures and move 
most of my business rules to the database server and attach dynamic behavior 
to a system developed in some other programming language.



I apologize if my post was to long, but I lacked the time to make it shorter.


--
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-21 Thread Chris Angelico
On Thu, Jan 22, 2015 at 5:20 AM, Irmen de Jong irmen.nos...@xs4all.nl wrote:
 On 21-1-2015 18:59, Steve Hayes wrote:

 3. When I started to look at it, I found that strings could be any length and
 were not limited to swomething arbitrary, like 256 characters.

 Even more fun is that Python's primitive integer type (longs for older Python 
 versions)
 has no arbitrary limitation either.

 That amazed me at the time I discovered python :)

I hadn't worked with length-limited strings in basically forever
(technically BASIC has a length limit, but I never ran into it; and I
never did much with Pascal), but you're right, arbitrary-precision
integers would have impressed me a lot more if I hadn't first known
REXX. So... is there a way to show that off efficiently? Normally, any
calculation that goes beyond 2**32 has already gone way beyond most
humans' ability to hold the numbers in their heads.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-21 Thread Matthew Ruffalo
On 01/21/2015 02:06 PM, Chris Angelico wrote:
 On Thu, Jan 22, 2015 at 5:20 AM, Irmen de Jong irmen.nos...@xs4all.nl wrote:
 On 21-1-2015 18:59, Steve Hayes wrote:

 3. When I started to look at it, I found that strings could be any length 
 and
 were not limited to swomething arbitrary, like 256 characters.
 Even more fun is that Python's primitive integer type (longs for older 
 Python versions)
 has no arbitrary limitation either.

 That amazed me at the time I discovered python :)
 I hadn't worked with length-limited strings in basically forever
 (technically BASIC has a length limit, but I never ran into it; and I
 never did much with Pascal), but you're right, arbitrary-precision
 integers would have impressed me a lot more if I hadn't first known
 REXX. So... is there a way to show that off efficiently? Normally, any
 calculation that goes beyond 2**32 has already gone way beyond most
 humans' ability to hold the numbers in their heads.

 ChrisA
Yes, length-unlimited strings are *extremely* useful in some
applications. I remember bitterly cursing Java's string length limit of
2 ** 31 (maybe - 1) on multiple occasions. Python's strings seem to
behave like integers in that their size is limited only by available memory.

MMR...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-21 Thread Alan Bawden
Chris Angelico ros...@gmail.com writes:
 ..., and I would guess a 64-bit Java would
 also raise the limit.

Even in a 64-bit Java, the _type_ returned by String.length() is 'int',
and is thus at most (2**31 - 1).  This isn't a problem for strings,
which never get that long in practice, but for some other Java datatypes
(e.g., Buffer) it is a real problem.  Score one for untyped languages.

-- 
Alan Bawden
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-21 Thread Mario Figueiredo
In article w2dsif33j2k@scooby-doo.csail.mit.edu, alan@scooby-
doo.csail.mit.edu says...
 Even in a 64-bit Java, the _type_ returned by String.length() is
 'int', and is thus at most (2**31 - 1).  This isn't a problem for
 strings, which never get that long in practice, but for some other
 Java datatypes (e.g., Buffer) it is a real problem.  Score one for
 untyped languages.

Still, assuming you have enough heap size, you can still create a 500 
million character string buffer. That's one of a heck large buffer. 
Nearly twice the online encyclopedia Britannica(1), and roughly 50 times 
the longest novel ever produced (2).

And considering you can always flush the buffer, I'm finding an hard 
time looking at unlimited string length in Python as wow factor. Even if 
we consider unicode strings. 


(1) 
http://en.wikipedia.org/wiki/Wikipedia:Size_comparisons#Comparison_of_en
cyclopedias

(2) http://en.wikipedia.org/wiki/List_of_longest_novels
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-21 Thread Alan Bawden
Alan Bawden a...@scooby-doo.csail.mit.edu writes:
 ...  Score one for untyped languages.

Drat.  I should have writted dynamically typed languages.

The language has changed.  When I was a novice Lisp hacker, we were
comfortable saying that Lisp was untyped.  But nowadays we always say
that Lisp is dynamically typed.  I could write an essay about why...

-- 
Alan Bawden
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-21 Thread Chris Angelico
On Thu, Jan 22, 2015 at 8:20 AM, Matthew Ruffalo mm...@case.edu wrote:
 Yes, length-unlimited strings are *extremely* useful in some
 applications. I remember bitterly cursing Java's string length limit of
 2 ** 31 (maybe - 1) on multiple occasions. Python's strings seem to
 behave like integers in that their size is limited only by available memory.

Hmm, I don't know that you'll get much beyond 2**31 characters (even
all-ASCII characters in PEP 393) on a 32-bit Python, simply because
available memory is capped at 2**32 bytes minus other stuff. You'd
need a 64-bit Python to do that, and I would guess a 64-bit Java would
also raise the limit.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-21 Thread Chris Angelico
On Thu, Jan 22, 2015 at 8:46 AM, Matthew Ruffalo mm...@case.edu wrote:
 No, Java's String.length returns an int and Strings are limited to ~2 **
 31 characters even in 64-bit Java.

Huh, annoying. In Python, the length of a string (in characters) is
stored in a Py_ssize_t (if I recall correctly), which is, I believe, a
pointer-sized integer. So it'd be 64-bit on a 64-bit build.

 I do seem to have encountered some strange behavior, though: creating
 very large strings with str.__mul__ seems to enter an allocation loop in
 Python 3.4. With a single-character string 's', I can create the
 following new strings quickly:

 s * 2 ** 33
 s * 2 ** 34
 s * 2 ** 35
 s * 2 ** 36

 but s * 2 ** 38 shows some odd memory usage. I'm watching the memory
 usage of a Python process steadily increase to 256GB, drop to a few MB,
 climb back to 256GB, drop to a few MB, and so on. It takes a half-dozen
 cycles of allocation and deallocation before the interactive interpreter
 gives me another prompt.

That sounds like you're blooping through your page file. The exact
behaviour will depend on how much physical memory you have, how your
page file is implemented (which depends on your OS), the phase of the
moon, and what you had for breakfast three weeks ago.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-21 Thread Paul Rubin
Alan Bawden a...@scooby-doo.csail.mit.edu writes:
 The language has changed.  When I was a novice Lisp hacker, we were
 comfortable saying that Lisp was untyped.  But nowadays we always say
 that Lisp is dynamically typed.  I could write an essay about why...

I'd be interested in seeing that.  Lisp of course descends from Church's
untyped lambda calculus but I didn't realize Lisp terminology about its
(runtime) type system had changed historically.  PL theorists sometimes
like to refer to runtime types as tags rather than types.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-21 Thread Irmen de Jong
On 21-1-2015 20:06, Chris Angelico wrote:
 On Thu, Jan 22, 2015 at 5:20 AM, Irmen de Jong irmen.nos...@xs4all.nl wrote:
 On 21-1-2015 18:59, Steve Hayes wrote:

 3. When I started to look at it, I found that strings could be any length 
 and
 were not limited to swomething arbitrary, like 256 characters.

 Even more fun is that Python's primitive integer type (longs for older 
 Python versions)
 has no arbitrary limitation either.

 That amazed me at the time I discovered python :)
 
 I hadn't worked with length-limited strings in basically forever
 (technically BASIC has a length limit, but I never ran into it; and I
 never did much with Pascal), but you're right, arbitrary-precision
 integers would have impressed me a lot more if I hadn't first known
 REXX. So... is there a way to show that off efficiently? Normally, any
 calculation that goes beyond 2**32 has already gone way beyond most
 humans' ability to hold the numbers in their heads.
 
 ChrisA
 

Something silly that I just thought about  (Python 3):


number = 2 * 3 * 5 * 103# okay.
number = number * 3120937 * 6977407 * 8431103# hmm...
number = number * 
70546381234168412430433268433712277793053956898109255590133639943
print(I know a huge number, it is:, number)
secret_message = number.to_bytes(37, big)
print(secret_message)


Or perhaps: (after pip install pyprimes)

 number = 1402811054100763300785480817886711606823329164566977593890  # wow?
 import pyprimes.factors
 print(pyprimes.factors.factorise(number))
[2, 3, 5, 557, 1559, 3413, 6991, 27799, 41333, 52999, 104681, 247001, 992441, 
211,
1299689]




Irmen


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-21 Thread Steven D'Aprano
Alan Bawden wrote:

 Alan Bawden a...@scooby-doo.csail.mit.edu writes:
 ...  Score one for untyped languages.
 
 Drat.  I should have writted dynamically typed languages.
 
 The language has changed.  When I was a novice Lisp hacker, we were
 comfortable saying that Lisp was untyped.  But nowadays we always say
 that Lisp is dynamically typed.  I could write an essay about why...

I've always understood that strictly speaking, untyped refers to low-level 
languages like assembly or Forth, where everything is a machine word.

In Forth, for example, all commands operate on single words on the stack, 
except for double variants which operate on two words at a time. E.g. you 
might have FOO to operate on the word at the top of the stack and FOOD to 
operate on the top two words. (Actually, given Forth's reputation for 
cryptic single-character line noise, it would probably be '^ and ''^ or 
something :-) In any case, there's a single stack, and double quantities 
aren't a separate data type, they're just two words.

(Some versions of Forth are arguably typed, in that they have a separate 
stack for floating point.)

I sometimes also use untyped to refer to languages like Hypertalk where 
everything is a string.



-- 
Steve

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-21 Thread Steven D'Aprano
Mario Figueiredo wrote:

 But speaking about impressing more experient programmers, I personally
 don't think Python has a wow factor in any of its features and syntax. At
 least in the way I understand the word wow.

Quote:

I've seen Python criticized as ugly precisely because it doesn't 
have a trick-based view of the world. In many ways, it's a dull
language, borrowing solid old concepts from many other languages 
styles: boring syntax, unsurprising semantics, few automatic 
coercions, etc etc. But that's one of the things I like about it.
- Tim Peters




-- 
Steve

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-21 Thread Matthew Ruffalo
On 01/21/2015 04:26 PM, Chris Angelico wrote:
 On Thu, Jan 22, 2015 at 8:20 AM, Matthew Ruffalo mm...@case.edu wrote:
 Yes, length-unlimited strings are *extremely* useful in some
 applications. I remember bitterly cursing Java's string length limit of
 2 ** 31 (maybe - 1) on multiple occasions. Python's strings seem to
 behave like integers in that their size is limited only by available memory.
 Hmm, I don't know that you'll get much beyond 2**31 characters (even
 all-ASCII characters in PEP 393) on a 32-bit Python, simply because
 available memory is capped at 2**32 bytes minus other stuff. You'd
 need a 64-bit Python to do that, and I would guess a 64-bit Java would
 also raise the limit.

 ChrisA
No, Java's String.length returns an int and Strings are limited to ~2 **
31 characters even in 64-bit Java.

I do seem to have encountered some strange behavior, though: creating
very large strings with str.__mul__ seems to enter an allocation loop in
Python 3.4. With a single-character string 's', I can create the
following new strings quickly:

s * 2 ** 33
s * 2 ** 34
s * 2 ** 35
s * 2 ** 36

but s * 2 ** 38 shows some odd memory usage. I'm watching the memory
usage of a Python process steadily increase to 256GB, drop to a few MB,
climb back to 256GB, drop to a few MB, and so on. It takes a half-dozen
cycles of allocation and deallocation before the interactive interpreter
gives me another prompt.

MMR...

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-19 Thread Ned Batchelder

On 1/16/15 10:03 AM, Chris Angelico wrote:

Scenario: You're introducing someone to Python for the first time.
S/he may have some previous programming experience, or may be new to
the whole idea of giving a computer instructions. You have a couple of
minutes to show off how awesome Python is. What do you do?

I was thinking along the lines of a simple demo in the REPL, showing
off some of Python's coolest features. But then I got stuck on the
specifics. What are Python's best coolnesses? What makes for a good
demo?

Ideally, this should be something that can be demo'd quickly and
easily, and it should be impressive without going into great details
of and see, this is how it works on the inside. So, how would you
brag about this language?

ChrisA



Peter Norvig's spell corrector is a compact example of a lot of Python 
power: http://norvig.com/spell-correct.html


I used it as a walk-through example for a presentation about Python at 
the DevDays conference: http://nedbatchelder.com/text/devdays.html


The second half of the presentation is a 25-line nano-templating engine 
which shows off some other good characteristics of the language.


--
Ned Batchelder, http://nedbatchelder.com

--
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-18 Thread alex23

On 17/01/2015 1:03 AM, Chris Angelico wrote:

Scenario: You're introducing someone to Python for the first time.
S/he may have some previous programming experience, or may be new to
the whole idea of giving a computer instructions. You have a couple of
minutes to show off how awesome Python is. What do you do?


When demoing to people with a reasonable amount of experience, I've 
found they're often impressed by showing them list comprehensions, then 
generators, then chained generators.


--
https://mail.python.org/mailman/listinfo/python-list


How to wow someone new to Python

2015-01-16 Thread Chris Angelico
Scenario: You're introducing someone to Python for the first time.
S/he may have some previous programming experience, or may be new to
the whole idea of giving a computer instructions. You have a couple of
minutes to show off how awesome Python is. What do you do?

I was thinking along the lines of a simple demo in the REPL, showing
off some of Python's coolest features. But then I got stuck on the
specifics. What are Python's best coolnesses? What makes for a good
demo?

Ideally, this should be something that can be demo'd quickly and
easily, and it should be impressive without going into great details
of and see, this is how it works on the inside. So, how would you
brag about this language?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-16 Thread Skip Montanaro
If you want to show off the REPL, I'd got for iPython and show them some
simple matplotlib examples (plotting sin waves, maybe dig up a CSV file on
the net with some data your friend is familiar with, etc)

Skip


On Fri, Jan 16, 2015 at 9:03 AM, Chris Angelico ros...@gmail.com wrote:

 Scenario: You're introducing someone to Python for the first time.
 S/he may have some previous programming experience, or may be new to
 the whole idea of giving a computer instructions. You have a couple of
 minutes to show off how awesome Python is. What do you do?

 I was thinking along the lines of a simple demo in the REPL, showing
 off some of Python's coolest features. But then I got stuck on the
 specifics. What are Python's best coolnesses? What makes for a good
 demo?

 Ideally, this should be something that can be demo'd quickly and
 easily, and it should be impressive without going into great details
 of and see, this is how it works on the inside. So, how would you
 brag about this language?

 ChrisA
 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-16 Thread Andrew Berg
On 2015.01.16 09:03, Chris Angelico wrote:
 Scenario: You're introducing someone to Python for the first time.
 S/he may have some previous programming experience, or may be new to
 the whole idea of giving a computer instructions. You have a couple of
 minutes to show off how awesome Python is. What do you do?
 
 I was thinking along the lines of a simple demo in the REPL, showing
 off some of Python's coolest features. But then I got stuck on the
 specifics. What are Python's best coolnesses? What makes for a good
 demo?
 
 Ideally, this should be something that can be demo'd quickly and
 easily, and it should be impressive without going into great details
 of and see, this is how it works on the inside. So, how would you
 brag about this language?
If the person is already familiar with programming, you could show off how
Python doesn't do a best effort guess at what to do when you make a mistake
(explicit is better than implicit). Many other languages will, for example,
make an undefined variable into a variable defined as an empty string or allow
silly things like 5 + cheese, whereas Python will let you know that you made
a mistake somewhere instead of letting garbage propagate. This behavior can be
frustrating for newbies to Python, but with someone there to explain why it
works that way, they can learn to appreciate it instead of giving up in anger
after Python keeps throwing exceptions at them.

If the person is not familiar with programming, show them how easy it is to get
something useful written quickly, even with only the stdlib. Low-level details
are handled so that you can focus on what you want the program to do, and there
is a ton of stuff in the stdlib so that it's likely you don't need to go
searching for a bunch of different libraries so that again, you can focus what
you want the program to do. For this, chances are, that person has some things
in mind already that are not difficult to get started with using Python. Also,
using the REPL for this makes it an even better demo. You can probably have the
basic functionality of whatever cool thing they want right there in the REPL.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-16 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com:

 Scenario: You're introducing someone to Python for the first time.
 S/he may have some previous programming experience, or may be new to
 the whole idea of giving a computer instructions. You have a couple of
 minutes to show off how awesome Python is. What do you do?

My experience is that if you have your customer try their hand on
programming and complete a simple challenge, they'll be extremely
impressed. Did I manage that?

On the other hand, if you want to demo your greatest achievements at the
screen, they will be left unmoved. Even my favorite Zynga game looks
cooler than that.

 I was thinking along the lines of a simple demo in the REPL, showing
 off some of Python's coolest features. But then I got stuck on the
 specifics. What are Python's best coolnesses? What makes for a good
 demo?

I would advise steering clear of the REPL and go directly to writing a
program and executing it. Maybe the classic ASCII graphics presentation
of the sine wave:


#!/usr/bin/env python3

import time
import math

def main():
for angle in range(0, 10, 5):
print(int((1 + math.sin(math.radians(angle))) * 35) * *)
time.sleep(0.1)

if __name__ == __main__:
main()


 Ideally, this should be something that can be demo'd quickly and
 easily, and it should be impressive without going into great details
 of and see, this is how it works on the inside. So, how would you
 brag about this language?

I'd recommend not skipping the traditional boilerplate (see my example).
Be professional from the start.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-16 Thread Marco Buttu

On 16/01/2015 16:03, Chris Angelico wrote:

Scenario: You're introducing someone to Python for the first time.
S/he may have some previous programming experience, or may be new to
the whole idea of giving a computer instructions. You have a couple of
minutes to show off how awesome Python is. What do you do?


The batteries included: some useful and simple examples with only core 
data type objects, built-in functions and standard library


--
Marco Buttu

INAF-Osservatorio Astronomico di Cagliari
Via della Scienza n. 5, 09047 Selargius (CA)
Phone: 070 711 80 217
Email: mbu...@oa-cagliari.inaf.it

--
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-16 Thread Rustom Mody
On Friday, January 16, 2015 at 8:34:20 PM UTC+5:30, Chris Angelico wrote:
 Scenario: You're introducing someone to Python for the first time.
 S/he may have some previous programming experience, or may be new to
 the whole idea of giving a computer instructions. You have a couple of
 minutes to show off how awesome Python is. What do you do?

There is this story -- maybe apocryphal -- that the tendency to vote
democratic or republican runs so deep it can be detected from 
genetic markers.

Similar things apply to programming:
Some people are drawn to a mathematical style; some are not
Some people love cute little scripts; some are left cold
Some love graphics; some dislike
etc etc
All corollary to:
Some people can think like programmers; most cant
[Who does the last quote? Steve Jobs?]

So to start with, you need to 'fingerprint' (is that the word?)
your subject.

 
 I was thinking along the lines of a simple demo in the REPL, showing
 off some of Python's coolest features. But then I got stuck on the
 specifics. What are Python's best coolnesses? What makes for a good
 demo?

The reason I find the REPL particularly cool for such demos
[I am surprised that Marko doesn't]
is that at least to some extent you can straddle some of the
divides above.

How about a little web-scrape with beautiful-soup?
Followed by maybe a throw the results into a csv-file
and open in the local spreadsheet?

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-16 Thread Mirage Web Studio

On 01/16/2015 08:33 PM, Chris Angelico wrote:
 Scenario: You're introducing someone to Python for the first time.
 S/he may have some previous programming experience, or may be new to
 the whole idea of giving a computer instructions. You have a couple of
 minutes to show off how awesome Python is. What do you do?

 I was thinking along the lines of a simple demo in the REPL, showing
 off some of Python's coolest features. But then I got stuck on the
 specifics. What are Python's best coolnesses? What makes for a good
 demo?

 Ideally, this should be something that can be demo'd quickly and
 easily, and it should be impressive without going into great details
 of and see, this is how it works on the inside. So, how would you
 brag about this language?

 ChrisA

hello,

I am a newbie to python, I have dwelled in c,qt none in java. php a lot,
though I don't make money with any of those.

The best thing I find is python is very easy, the best part maybe
because of my inexperience with other languages are the List and Dict
data types that just solved problems I had in real life made solvable
with python very easily. when I had to worry about memory and pointers
to memory in those other languages, python just made me focus on the
solution I want. also the way I can read python program just like they
are written in plain eglish :)

a personal problem I tried to solve is that how many characters  exist
in  a sequence statistically (with 2 or more characters in len)  in any
given file and then their count.  For a 100kb file I used practially all
programming knowledge in from the other languages but failed miserably
as the computation were taking more time with each bigger chunck of
file. I would have to do a lot of memery management with python using
those style like deleting list and dict before adding another. but when
I tried to solve the problem natively with python it just took a blink
of an eye for them to solve upto 50kb file. but for larger files
although instant it is just memory consuming since I was limit with 2 gb
I ddin't poke further.

this was my exp and I find programming fun in python like ironman
talking to jarvis

keep computing!!!

GCM
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-16 Thread Albert-Jan Roskam


On Fri, Jan 16, 2015 4:24 PM CET Andrew Berg wrote:

On 2015.01.16 09:03, Chris Angelico wrote:
 Scenario: You're introducing someone to Python for the first time.
 S/he may have some previous programming experience, or may be new to
 the whole idea of giving a computer instructions. You have a couple of
 minutes to show off how awesome Python is. What do you do?
 
 I was thinking along the lines of a simple demo in the REPL, showing
 off some of Python's coolest features. But then I got stuck on the
 specifics. What are Python's best coolnesses? What makes for a good
 demo?
 
 Ideally, this should be something that can be demo'd quickly and
 easily, and it should be impressive without going into great details
 of and see, this is how it works on the inside. So, how would you
 brag about this language?
If the person is already familiar with programming, you could show off how
Python doesn't do a best effort guess at what to do when you make a mistake
(explicit is better than implicit). Many other languages will, for example,
make an undefined variable into a variable defined as an empty string or allow
silly things like 5 + cheese, whereas Python will let you know that you made
a mistake somewhere instead of letting garbage propagate. This behavior can be
frustrating for newbies to Python, but with someone there to explain why it
works that way, they can learn to appreciate it instead of giving up in anger
after Python keeps throwing exceptions at them.

If the person is not familiar with programming, show them how easy it is to get
something useful written quickly, even with only the stdlib

Completely agree! Find out that person's itch and make a scratch.py that shows 
how problem-oriented the language is, with code that somewhat reads like 
regular English. REPL will also work, if you prepare it well enough. Ipython 
Notebook!


Low-level details
are handled so that you can focus on what you want the program to do, and there
is a ton of stuff in the stdlib so that it's likely you don't need to go
searching for a bunch of different libraries so that again, you can focus what
you want the program to do. For this, chances are, that person has some things
in mind already that are not difficult to get started with using Python. Also,
using the REPL for this makes it an even better demo. You can probably have the
basic functionality of whatever cool thing they want right there in the REPL.
-- 
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-16 Thread Rustom Mody
On Friday, January 16, 2015 at 10:51:52 PM UTC+5:30, Mirage Web Studio wrote:
 On 01/16/2015 08:33 PM, Chris Angelico wrote:
  Scenario: You're introducing someone to Python for the first time.
  S/he may have some previous programming experience, or may be new to
  the whole idea of giving a computer instructions. You have a couple of
  minutes to show off how awesome Python is. What do you do?
 
  I was thinking along the lines of a simple demo in the REPL, showing
  off some of Python's coolest features. But then I got stuck on the
  specifics. What are Python's best coolnesses? What makes for a good
  demo?
 
  Ideally, this should be something that can be demo'd quickly and
  easily, and it should be impressive without going into great details
  of and see, this is how it works on the inside. So, how would you
  brag about this language?
 
  ChrisA
 
 hello,
 
 I am a newbie to python, I have dwelled in c,qt none in java. php a lot,
 though I don't make money with any of those.
 
 The best thing I find is python is very easy, the best part maybe
 because of my inexperience with other languages are the List and Dict
 data types that just solved problems I had in real life made solvable
 with python very easily. when I had to worry about memory and pointers
 to memory in those other languages, python just made me focus on the
 solution I want. 

Nice point!
First class concrete data structures is a blessing especially for
a C programmer.

Here is an old Guido workout of dicts
https://www.python.org/doc/essays/graphs/

Probably can be improved to use comprehensions
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-16 Thread Chris Angelico
On Sat, Jan 17, 2015 at 4:31 AM, Rustom Mody rustompm...@gmail.com wrote:
 Nice point!
 First class concrete data structures is a blessing especially for
 a C programmer.

Definitely! Worth noting.

There've been some nice concepts mentioned; concrete suggestions would
be good too. Some specific feature or exact line of code that would
show off Python's awesomeness.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-16 Thread Tim Chase
On 2015-01-17 02:03, Chris Angelico wrote:
 Ideally, this should be something that can be demo'd quickly and
 easily, and it should be impressive without going into great details
 of and see, this is how it works on the inside. So, how would you
 brag about this language?

First, I agree with Andrew Berg's suggestion about the breadth of the
stdlib.  This always irks me when I have to return to the C/C++
world where there's no standard library for things like networking
(and thus no stock libraries for IMAP, SMTP, HTTP, FTP, etc or
email-message handling), CSV processing, regular expressions,
zip/tar/zlib files, SHA1/MD5, command-line option processing,
threading, and no available-everywhere GUI.  In the Java world, it
feels like much of this is available, but that the glommed-on
standards have multiple ways to do them (the old way(s) and the
new/improved way).  In PHP, well...that's just PHP (difficult-to-grok
equality testing, inconsistent naming conventions and parameter
ordering, lack of namespacing, easy-to-screw-up string interpolation,
hacky OOP, etc).

My fast-introduction go-to items are dir() and help() within the REPL
interface.  Nothing speeds up my development like being able to
drop to a PDB prompt and inspect an object, ask what properties it
supports, dump them, get help on them, etc.

There's also the bigint stuff that means I don't have to worry about
over/underflow errors.

I'm sure there are more great ideas, but how you market might depend
on your audience's background in programming (what language did they
use and what pain-points did they experience).

-tkc


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to wow someone new to Python

2015-01-16 Thread Emile van Sebille

On 1/16/2015 9:44 AM, Chris Angelico wrote:
snip
 exact line of code that would

show off Python's awesomeness.



a,b = b,a


Emile


--
https://mail.python.org/mailman/listinfo/python-list