Re: [ANN] Free Python tutorial with exercises, cscx.org

2021-04-13 Thread Russell via Python-list
Jach Feng  wrote:
 
> Is there any reason a student/beginner learn Python now start from Python2?
> 
> --Jach

Only if you want a job porting python2 to python3. Python 2.x is
officially End Of Life.

-- 
rust
0x68caecc97f6a90122e51c0692c88d9cb6b58a3dc
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [ANN] Free Python tutorial with exercises, cscx.org

2021-04-06 Thread Jach Feng
Rudy Matela 在 2021年4月1日 星期四下午11:13:03 [UTC+8] 的信中寫道:
> Hello python-list members, 
> 
> I would like to announce the following educational project: 
> 
> Computer Science by Example https://cscx.org/ is a collection of short 
> programming exercises. The site can automatically grade students' 
> solutions and it accepts submissions in Python. 
> 
> The exercises start simple, then increase in difficulty and complexity 
> gradually. Here are some examples: 
> 
> * Print "Hello, World!": https://cscx.org/hello 
> * Add two numbers: https://cscx.org/add1 
> * Compute the factorial of a number: https://cscx.org/factorial 
> * Compute the GCD of two numbers: https://cscx.org/gcd 
> * Solve the change-making problem: https://cscx.org/cash 
> 
> The website has a tutorial section covering Python's basics. 
> 
> I tried to make the content easy to use by instructors/lecturers, feel free 
> to use this with your students. The backend of the website is open source 
> and you can find it on 
> https://github.com/rudymatela/udge 
> 
> -- Rudy

Is there any reason a student/beginner learn Python now start from Python2?

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


Re: [ANN] Free Python tutorial with exercises, cscx.org

2021-04-06 Thread Rudy Matela
On Fri, Apr 02, 2021 at 05:00:40AM +1100, Chris Angelico wrote:
> On Fri, Apr 2, 2021 at 2:14 AM Rudy Matela  wrote:
> > Computer Science by Example https://cscx.org/ is a collection of short
> > programming exercises.  The site can automatically grade students'
> > solutions and it accepts submissions in Python.
> 
> What versions of Python does it support? The setup page is not clear.

It supports Python 2 and 3.  When you submit solutions to the exercises,
the system looks at the hashbang (#!) to check whether you are using
Python 2 or 3:

#!/usr/bin/env python2

or

#!/usr/bin/env python3

When none of these are present it defaults to Python 3.

The examples in the tutorial section (https://cscx.org/programming-basics)
are done so that they are compatible with both versions of the language.
So if you have either 2 or 3, you'll be able to follow the tutorial and
exercises.

I'll add this clarification in the setup section and the FAQ later this
week.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [ANN] Free Python tutorial with exercises, cscx.org

2021-04-01 Thread Chris Angelico
On Fri, Apr 2, 2021 at 2:14 AM Rudy Matela  wrote:
>
> Hello python-list members,
>
> I would like to announce the following educational project:
>
> Computer Science by Example https://cscx.org/ is a collection of short
> programming exercises.  The site can automatically grade students'
> solutions and it accepts submissions in Python.
>

What versions of Python does it support? The setup page is not clear.

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


[ANN] Free Python tutorial with exercises, cscx.org

2021-04-01 Thread Rudy Matela
Hello python-list members,

I would like to announce the following educational project:

Computer Science by Example https://cscx.org/ is a collection of short
programming exercises.  The site can automatically grade students'
solutions and it accepts submissions in Python.

The exercises start simple, then increase in difficulty and complexity
gradually.  Here are some examples:

* Print "Hello, World!": https://cscx.org/hello
* Add two numbers: https://cscx.org/add1
* Compute the factorial of a number: https://cscx.org/factorial
* Compute the GCD of two numbers: https://cscx.org/gcd
* Solve the change-making problem: https://cscx.org/cash

The website has a tutorial section covering Python's basics.

I tried to make the content easy to use by instructors/lecturers, feel free
to use this with your students.  The backend of the website is open source
and you can find it on
https://github.com/rudymatela/udge

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


Fwd: Reporting Documentation Bug in Documentation » The Python Tutorial »6.Modules

2018-04-27 Thread VijithNambiar
Hi
I think there is a bug in the section https://docs.python.org/3/
tutorial/modules.html#more-on-modules
where the outputs of the statements below is given as wrong as it is
starting with a '0'

>>> import fibo as fib>>> fib.fib(500)0 1 1 2 3 5 8 13 21 34 55 89 144 233 377

>>> import fibo as fib>>> fib.fib(500)0 1 1 2 3 5 8 13 21 34 55 89 144 233 377
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Your feedback on our free Advanced Python tutorial

2017-07-21 Thread Mario R. Osorio
It would be nice if you made it more 'readable' the light gray foreground color 
of the text makes it very uncomfortable to read, at least to me.

Take a look at: HOW THE WEB BECAME UNREADABLE 
https://www.wired.com/2016/10/how-the-web-became-unreadable/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Your feedback on our free Advanced Python tutorial

2017-07-20 Thread Noah
On 20 Jul 2017 3:03 p.m., "Aude Barral, CodinGame" 
wrote:

Hi everyone,

I am co-founder of a startup called CodinGame.

A few days ago we've launched a project: Tech.io . It's a
free knowledge-sharing platform that allows tech professionals to learn new
programming concepts through hands-on content crafted by volunteers in the
community.

Everything runs on our backend. Our system relies on Docker images so we
can play tutorials and demos of virtually any technology from the browser.

So why this project? Because as more and more resources over the Internet
now need to be paid for (Udacity, Udemy, etc), we want to foster free
online technology education thanks to peer learning. In a sense, we'd like
to become some kind of Wikipedia for tech.

One of the first tutorials our contributors published is about Advanced
Python Features (hope more will be published soon!): https://tech.io/play
grounds/500/advanced-python-features/advanced-python-features



Perfect and thanks for taking your time folks to put this together out
there for free.



I have 2 questions for you:

- Do you think this tutorial could be helpful to your Python user
community?


100% Yes


- Would you be willing to help us spread the word about Tech.io?



Yes yes yes...


Thanks a lot for checking,

Cheers!
Aude



Cheers,
Noah

-
Evolve or Extinct. Enable IPv6 now?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Your feedback on our free Advanced Python tutorial

2017-07-20 Thread Guido van Rossum
Hi Aude,

Unfortunately I don't have time to review or endorse your Python materials.

Good luck,

--Guido

On Wed, Jul 19, 2017 at 9:44 AM, Aude Barral, CodinGame 
wrote:

> Hi everyone,
>
> I am co-founder of a startup called CodinGame.
>
> A few days ago we've launched a project: Tech.io . It's
> a
> free knowledge-sharing platform that allows tech professionals to learn new
> programming concepts through hands-on content crafted by volunteers in the
> community.
>
> Everything runs on our backend. Our system relies on Docker images so we
> can play tutorials and demos of virtually any technology from the browser.
>
> So why this project? Because as more and more resources over the Internet
> now need to be paid for (Udacity, Udemy, etc), we want to foster free
> online technology education thanks to peer learning. In a sense, we'd like
> to become some kind of Wikipedia for tech.
>
> One of the first tutorials our contributors published is about Advanced
> Python Features (hope more will be published soon!): https://tech.io/play
> grounds/500/advanced-python-features/advanced-python-features
>
> I have 2 questions for you:
> - Do you think this tutorial could be helpful to your Python user
> community?
> - Would you be willing to help us spread the word about Tech.io?
>
> Thanks a lot for checking,
>
> Cheers!
> Aude
>
> 
> *Aude BARRAL*, Co-Founder
> +33 674 632 708
>
> [image: https://fr.linkedin.com/in/audebarral]
> 
> 
>   
> 
> --
> https://mail.python.org/mailman/listinfo/python-announce-list
>
> Support the Python Software Foundation:
> http://www.python.org/psf/donations/
>



-- 
--Guido van Rossum (python.org/~guido)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: perl + python tutorial available for download

2017-05-07 Thread retsithortmdk
On Monday, June 30, 2008 at 9:45:18 AM UTC-7, Xah wrote:
> my perl and python tutorial
> 
> http://xahlee.org/perl-python/index.html
> 
> is now available for download for offline reading.
> Download link at the bottom.
> 
>Xah
> ∑ http://xahlee.org/
> 
> ☄

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


RE: pdf version of python tutorial

2016-03-19 Thread Joaquin Alzola
Den 13-03-2016 kl. 14:45 skrev kamaraju kusumanchi:
> Is there a pdf version of the python tutorial
> https://docs.python.org/3/tutorial/index.html that I can download? The
> idea is to have everything in one file so I can search easily, be able
> to work offline.
>
> thanks
> raju
>

>Try here: https://docs.python.org/3.5/download.html.

>I found the tutorial in the zip-file "PDF(A4 paper size)", which contains a 
>lot of PDFs, amongst these many of howto-documents.

Download the HTML one.

--
Venlig hilsen / Best regards
Jesper K. Brogaard

(remove upper case letters in my e-mail address)
--
https://mail.python.org/mailman/listinfo/python-list
This email is confidential and may be subject to privilege. If you are not the 
intended recipient, please do not copy or disclose its content but contact the 
sender immediately upon receipt.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pdf version of python tutorial

2016-03-14 Thread Jesper K Brogaard

Den 13-03-2016 kl. 14:45 skrev kamaraju kusumanchi:

Is there a pdf version of the python tutorial
https://docs.python.org/3/tutorial/index.html that I can download? The
idea is to have everything in one file so I can search easily, be able
to work offline.

thanks
raju



Try here: https://docs.python.org/3.5/download.html.

I found the tutorial in the zip-file "PDF(A4 paper size)", which 
contains a lot of PDFs, amongst these many of howto-documents.



--
Venlig hilsen / Best regards
Jesper K. Brogaard

(remove upper case letters in my e-mail address)
--
https://mail.python.org/mailman/listinfo/python-list


Re: pdf version of python tutorial

2016-03-13 Thread kamaraju kusumanchi
On Sun, Mar 13, 2016 at 1:34 PM, Chris Warrick  wrote:
>
> There is a download link on the documentation index:
>
> https://docs.python.org/3/download.html
>

Exactly what I needed. Thanks.

raju
-- 
Kamaraju S Kusumanchi | http://raju.shoutwiki.com/wiki/Blog
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pdf version of python tutorial

2016-03-13 Thread Chris Warrick
On 13 March 2016 at 14:45, kamaraju kusumanchi
 wrote:
> Is there a pdf version of the python tutorial
> https://docs.python.org/3/tutorial/index.html that I can download? The
> idea is to have everything in one file so I can search easily, be able
> to work offline.
>
> thanks
> raju
> --
> Kamaraju S Kusumanchi | http://raju.shoutwiki.com/wiki/Blog
> --
> https://mail.python.org/mailman/listinfo/python-list

There is a download link on the documentation index:

https://docs.python.org/3/download.html

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


pdf version of python tutorial

2016-03-13 Thread kamaraju kusumanchi
Is there a pdf version of the python tutorial
https://docs.python.org/3/tutorial/index.html that I can download? The
idea is to have everything in one file so I can search easily, be able
to work offline.

thanks
raju
-- 
Kamaraju S Kusumanchi | http://raju.shoutwiki.com/wiki/Blog
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: good python tutorial

2016-02-23 Thread Aaron Christensen
Thanks for sharing!

On Tue, Feb 23, 2016 at 1:48 AM, Mike S via Python-list <
python-list@python.org> wrote:

> This site was recommended by a friend, it looks really well put together,
> I thought it might be of interest to people considering online tutorials.
>
> http://www.python-course.eu/index.php
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


good python tutorial

2016-02-22 Thread Mike S via Python-list
This site was recommended by a friend, it looks really well put 
together, I thought it might be of interest to people considering online 
tutorials.


http://www.python-course.eu/index.php
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python Tutorial

2014-06-16 Thread Zachary Ware
(Note, for those confused, context:
https://mail.python.org/pipermail/python-list/2010-August/584707.html)

On Mon, Jun 16, 2014 at 10:06 AM,   wrote:
> hello... pls how did ur tutorial creation go?
> Could i get it as i am starting to learn python
> thanks

Hi,

Please note that you've just posted to a mailing list in response to a
4-year-old post, providing no context whatsoever, which is likely to
cause many members of this list to ignore your question.  Google
Groups is only one of many ways in which people use this list, and is
the least polite-by-default -- through no fault of yours, but it means
you'll need to put extra effort into not raising ire.  See
https://wiki.python.org/moin/GoogleGroupsPython for some pointers on
how to use Google Groups politely on this list.

As for your actual question, I don't know if you will get an actual
answer; I don't recall seeing the author of the post you replied to
around here in quite some time.  However, there is a very nice
tutorial at http://docs.python.org/3/tutorial/ which should help you
get started.  Another good option is Alan Gauld's Learn to Program
website found at http://www.alan-g.me.uk/ and I'm sure a Google search
for "python tutorial" will turn up many options as well :).

You may also be interested in the Python 'tutor' mailing list, see
https://mail.python.org/mailman/listinfo/tutor

Regards,
-- 
Zach
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Tutorial

2014-06-16 Thread jonadina
hello... pls how did ur tutorial creation go?
Could i get it as i am starting to learn python
thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: mistake in python tutorial

2012-06-05 Thread MRAB

On 06/06/2012 03:00, Dave Angel wrote:

On 06/05/2012 09:43 PM, Miriam Gomez Rios wrote:

 Hello, I think that the example in section 4.4 in the tutorial for python 2.7X 
is wrong.

 http://docs.python.org/tutorial/controlflow.html



 It will end up printing this if you run the exact code listed in the tutorial.



 3 is a prime number

 4 equals 2*2

 5 is a prime number

 5 is a prime number

 5 is a prime number

 6 equals 2 * 3

 7 is a prime number

 7 is a prime number

 7 is a prime number

 7 is a prime number

 7 is a prime number

 8 equals 2*4

 9 is a prime number

 9 equals 3*3



 I believe it is because the is no break in " else print n is a prime number" 
and

 it never prints anything about number 2 because the second for is like 
range(2,2)

 which is empty so it does nothing.




Hate to tell you, but the example works as it exists on the website.  If
you got your output, you must have messed up the indentation, which is
VERY important in python.

In particular, the else clause has to line up with the for statement,
NOT with the if statement.

If it helps, this is the correct indentation.  Paste it into a file, and
run it.

for n in range(2, 10):
  for x in range(2, n):
  if n % x == 0:
  print n, 'equals', x, '*', n/x
  break
  else:
  # loop fell through without finding a factor
  print n, 'is a prime number'


I can confirm that the OP's output is what you get when the 'else' is
indented the same as the 'if'.
--
http://mail.python.org/mailman/listinfo/python-list


Re: mistake in python tutorial

2012-06-05 Thread Dave Angel
On 06/05/2012 09:43 PM, Miriam Gomez Rios wrote:
> Hello, I think that the example in section 4.4 in the tutorial for python 
> 2.7X is wrong.
>
> http://docs.python.org/tutorial/controlflow.html
>
>
>
> It will end up printing this if you run the exact code listed in the tutorial.
>
>
>
> 3 is a prime number
>
> 4 equals 2*2
>
> 5 is a prime number
>
> 5 is a prime number
>
> 5 is a prime number
>
> 6 equals 2 * 3
>
> 7 is a prime number
>
> 7 is a prime number
>
> 7 is a prime number
>
> 7 is a prime number
>
> 7 is a prime number
>
> 8 equals 2*4
>
> 9 is a prime number
>
> 9 equals 3*3
>
>
>
> I believe it is because the is no break in " else print n is a prime number" 
> and
>
> it never prints anything about number 2 because the second for is like 
> range(2,2)
>
> which is empty so it does nothing.
>
>

Hate to tell you, but the example works as it exists on the website.  If
you got your output, you must have messed up the indentation, which is
VERY important in python.

In particular, the else clause has to line up with the for statement,
NOT with the if statement.

If it helps, this is the correct indentation.  Paste it into a file, and
run it.

for n in range(2, 10):
 for x in range(2, n):
 if n % x == 0:
 print n, 'equals', x, '*', n/x
 break
 else:
 # loop fell through without finding a factor
 print n, 'is a prime number'

-- 
DaveA

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


mistake in python tutorial

2012-06-05 Thread Miriam Gomez Rios
Hello, I think that the example in section 4.4 in the tutorial for python 2.7X 
is wrong.

http://docs.python.org/tutorial/controlflow.html



It will end up printing this if you run the exact code listed in the tutorial.



3 is a prime number

4 equals 2*2

5 is a prime number

5 is a prime number

5 is a prime number

6 equals 2 * 3

7 is a prime number

7 is a prime number

7 is a prime number

7 is a prime number

7 is a prime number

8 equals 2*4

9 is a prime number

9 equals 3*3



I believe it is because the is no break in " else print n is a prime number" and

it never prints anything about number 2 because the second for is like 
range(2,2)

which is empty so it does nothing.




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


Re: generate and send mail with python: tutorial

2011-08-13 Thread aspineux
On Aug 13, 3:00 am, Ben Finney  wrote:
> Ben Finney  writes:
> > What is the process if the OP, or someone to whom the OP delegates
> > authority, wants to [contribute their work to the Python
> > documentation]?
>
> The answer is partly at http://docs.python.org/documenting/>:
>
>     If you’re interested in contributing to Python’s documentation […]
>     Send an e-mail to d...@python.org or open an issue on the tracker.
>
> One should, before doing so, follow the above document on the
> documentation style conventions for Python.

I'm using python for long now, and just discovered these HowTo today :-
(
I don't thing rewriting these articles  into another format
will improve the "message". I will not rewrite them.

You are free to do it, just keep my name as the original author.
I have no other original source than the HTML one you can have on my
blog.

I appreciate your interest for my work.

I think to put all the sources together to create a library.
I thing about the name of pyezmail for "python easy mail".
Any comment ?

Regards

>
> --
>  \      “Contentment is a pearl of great price, and whosoever procures |
>   `\        it at the expense of ten thousand desires makes a wise and |
> _o__)                                      happy purchase.” —J. Balguy |
> Ben Finney

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


Re: generate and send mail with python: tutorial

2011-08-12 Thread Ben Finney
Ben Finney  writes:

> What is the process if the OP, or someone to whom the OP delegates
> authority, wants to [contribute their work to the Python
> documentation]?

The answer is partly at http://docs.python.org/documenting/>:

If you’re interested in contributing to Python’s documentation […]
Send an e-mail to d...@python.org or open an issue on the tracker.

One should, before doing so, follow the above document on the
documentation style conventions for Python.

-- 
 \  “Contentment is a pearl of great price, and whosoever procures |
  `\it at the expense of ten thousand desires makes a wise and |
_o__)  happy purchase.” —J. Balguy |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: generate and send mail with python: tutorial

2011-08-12 Thread Ben Finney
Terry Reedy  writes:

> >> aspineux wrote:
> >>> Hi I have written a tutorial about how to generate and send emails
> >>> with python.

> Have you considered contributing a HOW-TO?

I think Terry is referring to http://docs.python.org/howto/>.

I agree that this should be submitted to that collection, and maintained
along with all the others.

What is the process if the OP, or someone to whom the OP delegates
authority, wants to do that?

-- 
 \“If you continue running Windows, your system may become |
  `\unstable.” —Microsoft, Windows 95 bluescreen error message |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: generate and send mail with python: tutorial

2011-08-12 Thread Terry Reedy

On 8/12/2011 2:17 PM, aspineux wrote:

On Aug 12, 3:38 pm, Steven D'Aprano  wrote:

aspineux wrote:

Hi I have written a tutorial about how to generate and send emails
with python.


[...]

Thank you, that is an extremely detailed tutorial.


Thanks,  It was my intention


Have you considered contributing a HOW-TO?

--
Terry Jan Reedy

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


Re: generate and send mail with python: tutorial

2011-08-12 Thread aspineux
On Aug 12, 3:38 pm, Steven D'Aprano  wrote:
> aspineux wrote:
> > Hi I have written a tutorial about how to generate and send emails
> > with python.
>
> [...]
>
> Thank you, that is an extremely detailed tutorial.

Thanks,  It was my intention

Alain

>
> --
> Steven

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


Re: generate and send mail with python: tutorial

2011-08-12 Thread Steven D'Aprano
aspineux wrote:

> Hi I have written a tutorial about how to generate and send emails
> with python.
[...]

Thank you, that is an extremely detailed tutorial.

-- 
Steven

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


Re: generate and send mail with python: tutorial

2011-08-12 Thread aspineux
On Aug 12, 8:51 am, Dennis Lee Bieber  wrote:
> On Thu, 11 Aug 2011 08:07:09 -0700 (PDT), aspineux 
> declaimed the following in gmane.comp.python.general:
>
> > Hi I have written a tutorial about how to generate and send emails
> > with python.
>
>         Is that really such a difficult task?

Yes it's difficult to make an _universal_ mail parser, able to handle
mails from different MUA, using different charsets.
Some emails that break RFC's requires at least some background
to know which rules can be missed by some MUA !

Handle mail from a unique source or similar sources is easy.
Using try and error method is fine for this kind of job, you don't
even need to care if the email you're parsing match the RFC's or not.

My "parser" functions have been tested over 20.000 mails from all
around the world using some human and automated verifications !

Generating emails is not easy, when mixing internationalized
addresses,
subject and content. Integrating text, html, attachment and embedded
images in one single email looks to me difficult enough to require
some explanations.

At least read carefully all my articles to get an idea about the
difficulty,
this is what I try to explain.

Regards.


>
>         Okay, I didn't really use Python for the entire creation of the
> message... But my first real Python program (using 1.4 or 1.5, whatever
> was included in the first "Programming Python" disk, for AmigaOS) was a
> rudimentary outgoing SMTPd which had to parse headers from  message
> files "queued" by an ARexx script from an Amiga version of ELM, then
> handshake with the ISP SMTPd to relay the message onward. It took less
> than a week after buying the book that I had this ARexx/Python hybrid
> working -- and it worked better than either C-language programs I'd
> downloaded (at that period of time, Amiga email programs ONLY read from
> local spool and queued to local spool; separate programs had to be used
> to read POP3 and send SMTP... My first SMTP utility presumed 1) direct
> connection to destination address, 2) created an email file for each
> address -- problem: if a destination did not have a receiving SMTPd [ie,
> one needed to do an MX lookup instead] it would hang trying to send that
> message, and never process others... The second program used ISP relay
> -- but it only parsed the "TO:" header, and thereby failed to handshake
> CC and BCC destinations)
> --
>         Wulfraed                 Dennis Lee Bieber         AF6VN
>         wlfr...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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


Re: generate and send mail with python: tutorial

2011-08-12 Thread maedox
On Friday, August 12, 2011 8:51:33 AM UTC+2, Dennis Lee Bieber wrote:
> On Thu, 11 Aug 2011 08:07:09 -0700 (PDT), aspineux 
> declaimed the following in gmane.comp.python.general:
> 
> > Hi I have written a tutorial about how to generate and send emails
> > with python.
> 
>   Is that really such a difficult task?
> 
>   Okay, I didn't really use Python for the entire creation of the
> message... But my first real Python program (using 1.4 or 1.5, whatever
> was included in the first "Programming Python" disk, for AmigaOS) was a
> rudimentary outgoing SMTPd which had to parse headers from  message
> files "queued" by an ARexx script from an Amiga version of ELM, then
> handshake with the ISP SMTPd to relay the message onward. It took less
> than a week after buying the book that I had this ARexx/Python hybrid
> working -- and it worked better than either C-language programs I'd
> downloaded (at that period of time, Amiga email programs ONLY read from
> local spool and queued to local spool; separate programs had to be used
> to read POP3 and send SMTP... My first SMTP utility presumed 1) direct
> connection to destination address, 2) created an email file for each
> address -- problem: if a destination did not have a receiving SMTPd [ie,
> one needed to do an MX lookup instead] it would hang trying to send that
> message, and never process others... The second program used ISP relay
> -- but it only parsed the "TO:" header, and thereby failed to handshake
> CC and BCC destinations)
> -- 
>   Wulfraed Dennis Lee Bieber AF6VN
> wlf...@ix.netcom.comHTTP://wlfraed.home.netcom.com/

Nice story bro...
-- 
http://mail.python.org/mailman/listinfo/python-list


generate and send mail with python: tutorial

2011-08-11 Thread aspineux
Hi I have written a tutorial about how to generate and send emails
with python.

You can find it here 
http://blog.magiksys.net/generate-and-send-mail-with-python-tutorial

And here is the content. Enjoy.

This article follows two other articles (1, 2) about how to parse
emails in Python.
These articles describe very well mail usages and rules and can be
helpful for non Python developer too.

The goal here is to generate a valid email including internationalized
content, attachments and even inline images, and send it to a SMTP
server.

The procedure can be achieved in 3 steps :

compose the body of the email.
compose the header of the email.
send the email to a SMTP server

At the end you will find the sources.

The first rule to keep in mind all the time, is that emails are 7bits
only, they can contains us-ascii characters only ! A lot of RFCs
define rules to encode non us-ascii characters when they are required:
RFC2047 to encode headers, RFC2045 for encoding body using the MIME
format or RFC2231 for MIME parameters like the attachment filename.
The mail header

The header is composed of lines having a name and a value. RFC2047 let
you use quoted or binary encoding to encode non us-ascii characters in
it.
For example:

Subject: Courrier électronique en Français

become using the quoted format

Subject: =?iso-8859-1?q?Courrier_=E8lectronique_en_Fran=E7ais?=

or using the binary one.

Subject: =?iso-8859-1?b?Q291cnJpZXIg6GxlY3Ryb25pcXVlIGVuIEZyYW7nYWlz?=

Here the quoted format is readable and shorter. Python
email.header.Header object generates user friendly header by choosing
the quoted format when the encoding shares characters with us-ascii,
and the binary one for encoding like the Chinese big5 that requires
the encoding of all characters.

>>> str(Header(u'Courrier \xe8lectronique en Fran\xe7ais', 'iso-8859-1'))
'=?iso-8859-1?q?Courrier_=E8lectronique_en_Fran=E7ais?='

Header values have different types (text, date, address, ...) that all
require different encoding rules. For example, in an address like :

Sender: Alain Spineux 

The email part  has to be in us-ascii and
cannot be encoded. The name part cannot contains some special
characters without quoting : []\()<>@,:;".
We can easily understand why "<>" are in the list, others have all
their own story.

For example, the use of the "Dr." prefix requires to quote the name
because of the '.':

Sender: "Dr. Alain Spineux" 

For a name with non us-ascii characters like (look at the "ï" in
Alaïn), the name must be encoded.

Sender: Dr. Alïan Spineux 

must be written :

Sender: =?iso-8859-1?q?Dr=2E_Ala=EFn_Spineux?=


Notice that the '.' in the prefix is replaced by "=2E", because Header
preventively encode all non alpha or digit characters to match the
most restrictive header rules.

The Python function email.utils.formataddr() quotes the special
characters but don't encode non us-ascii characters. On the other
hand, email.header.Header can encode non us-ascii characters but
ignore all specials rule about address encoding.
Let see how both work:

>>> email.Utils.formataddr(('Alain Spineux', 'alain.spin...@gmail.com'))
'Alain Spineux '

This is a valid header value for a To: field

>>> str(Header('Dr. Alain Spineux '))
'Dr. Alain Spineux '

Here the '.' should be escaped like these 13 characters: []\()<>@,:;".

>>> email.Utils.formataddr(('"Alain" Spineux', 'alain.spin...@gmail.com'))
'"\\"Alain\\" Spineux" '

Here '"' is escaped using '\', this is fine.

>>> email.Utils.formataddr((u'Ala\xefn Spineux', 'alain.spin...@gmail.com'))
u'Ala\xefn Spineux '

formataddr() don't handle non us-ascii string, this must be done by
Header object

>>> str(Header(email.Utils.formataddr((u'Ala\xefn Spineux', 
>>> 'alain.spin...@gmail.com'
'=?utf-8?q?Ala=C3=AFn_Spineux_=3Calain=2Espineux=40gmail=2Ecom=3E?='

This is not valid because the address is also encoded and an old or
some recent MUA will't handle this. The good form here is :

=?utf-8?q?Ala=C3=AFn_Spineux?= '

Function format_addresses(addresses, header_name=None, charset=None)
handle carefully the encoding of the addresses.

>>> str(format_addresses([ (u'Ala\xefn Spineux', 'alain.spin...@gmail.com'), 
>>> ('John', 'j...@smith.com'), ], 'to', 'iso-8859-1'))
'=?iso-8859-1?q?Ala=EFn_Spineux?=  ,\n John
'

Bytes and unicode string can be mixed. Addresses must always be us-
ascii. Byte string must be encoded using charset or be us-ascii.
Unicode strings that cannot be encoded

Re: learnpython.org - an online interactive Python tutorial

2011-04-25 Thread Gregory Ewing

harrismh777 wrote:
maybe the way 
to be really consistent (especially with the Zen of Python, explicit is 
better than implicit) that int --> float --> complex (imaginary) should 
not occur either !


Applying parts of the Zen selectively can be dangerous.
Practicality also beats purity. I've used a language
where there was no automatic promotion from ints to
floats, and it was a pain in the backside.

--
Greg
--
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-25 Thread Terry Reedy

On 4/25/2011 2:20 AM, harrismh777 wrote:

Steven D'Aprano wrote:

It seems to me that weak typing is a Do What I Mean function, and DWIM is
a notoriously bad anti-pattern that causes far more trouble than it is
worth. I'm even a little suspicious of numeric coercions between integer
and float. (But only a little.)


I'm wondering about that as well... (a little)... I mean, maybe the way
to be really consistent (especially with the Zen of Python, explicit is
better than implicit) that int --> float --> complex (imaginary) should
not occur either !

I think folks would baulk at that though... big-time. :)


Guido regards the number classes as subtypes of abstract number.
Given a==d, and b==e, he believes that after
c = a op b
f = d op e
then c == f should be true (in so far as possible).
This is why he wanted to change int division.

In other words, he wants Python math to pretty much imitate calculators,
on the basis that this is what most users expect and want.

This goes along with Python's general 
polymorphism/genericity/duck-typing philosophy. It is no different from 
the fact that one can write generic algorithms that give equivalent 
answers for equivalent inputs of ordered collections or indexable sequences.



So, bottom line here... if my students want to get numbers into their
programs in 3.x then the correct way to handle the imput() would be:

n = int(input("enter num > "))


Yes.


... and then let the interpreter throw an exception if the input cannot
be type cast to int?


Converted (not cast) to int or float or complex or anything else other 
than strl.


--
Terry Jan Reedy

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


Re: learnpython.org - an online interactive Python tutorial

2011-04-24 Thread harrismh777

Steven D'Aprano wrote:

It seems to me that weak typing is a Do What I Mean function, and DWIM is
a notoriously bad anti-pattern that causes far more trouble than it is
worth. I'm even a little suspicious of numeric coercions between integer
and float. (But only a little.)


I'm wondering about that as well... (a little)... I mean, maybe the way 
to be really consistent (especially with the Zen of Python, explicit is 
better than implicit) that int --> float --> complex (imaginary) should 
not occur either !


I think folks would baulk at that though... big-time.   :)


So, bottom line here... if my students want to get numbers into their 
programs in 3.x then the correct way to handle the imput() would be:


n = int(input("enter num > "))


... and then let the interpreter throw an exception if the input 
cannot be type cast to int?



kind regards,
m harris


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


Re: learnpython.org - an online interactive Python tutorial

2011-04-24 Thread harrismh777

Dave Angel wrote:

time echo "scale = 1010; 16 * a(1/5) - 4 * a(1/239)" |bc -lq




Wouldn't it be shorter to say:

time echo "scale = 1010;  4 * a(1)" |bc -lq


Well, you can check it out by doing the math... (its fun...)

...  you will notice that 'time' is called first, which on *nix systems 
clocks the processing, breaking out the system and user times... right?


... so try these 10,000 comparisons on your *nix system:

time echo "scale = 10010; 16 * a(1/5) - 4 * a(1/239)" |bc -lq

time echo "scale = 10010;  4 * a(1)" |bc -lq

(those will take a few minutes, if your processor is running 2-3Ghz...)

... then try these 100,000 runs:

time echo "scale = 100010; 16 * a(1/5) - 4 * a(1/239)" |bc -lq

time echo "scale = 100010;  4 * a(1)" |bc -lq

(Those will take some time, probably less than 20 - 30 minutes... )


After your time comparisons, tell me whether you want to use a(1)*4 ??

Leonard Euler came up with the formula I'm using here... and used it 
himself for paper 'n pencil arithmetic... because the arctan(n) infinite 
series converges much quicker (by orders of magnitude) for values of (n) 
< 0.  (the smaller the (n) the better)


We can make the entire function run even faster by using smp and 
splitting the  'a(1/5)' and  'a(1/239)' across two cores, having the 
arctan series' running in parallel. This is important if your 'big num' 
is going to be hundreds of thousands or millions of places. On my baby 
Beowulf cluster I have played a bit with running this on two separate 
systems and then bringing the result together in the end... fun for 
playtime... interesting to see how many digits (in how much time) can be 
achieved *without* using a super-computer


You can also try these formula for comparison sake:

PI  =  20 * a(1/7) + 8 * a(3/79)
or
PI  =  8 * a(1/3) + 4 * a(1/7)
or
PI  =  24 * a(1/8) + 8 * a(1/57) + 4 * a(1/239)



Happy Easter,  and have a slice of pie on me   :)





kind regards,
m harris



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


Re: learnpython.org - an online interactive Python tutorial

2011-04-24 Thread jmfauth
On 24 avr, 05:10, harrismh777  wrote:
>
>     I've been giving this some more thought. From the keyboard, all I am
> able to enter are character strings (not numbers). Presumably these are
> UTF-8 strings in python3.  If I enter ...


In Python 3, input() returns a unicode, a sequence/table/array of
unicode code point(s). No more, no less.

Similar to Python 2 where raw_input() returns a sequence/table/array
of byte(s). No more, no less.

jmf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re: learnpython.org - an online interactive Python tutorial

2011-04-24 Thread Dave Angel

On 01/-10/-28163 02:59 PM, harrismh777 wrote:

Cameron Simpson wrote:

| folks are not aware that 'bc' also has arbitrary precision floating
| point math and a standard math library.

Floating point math? I thought, historically at least, that bc is built
on dc (arbitrary precision integer math, reverse polish syntax) and that
consequently bc uses fixed point math rather than floating point.


My bad... I don't mean under-the-covers... I mean that the user may
calculate arbitrary precision floating arithmetic ... bc keeps track of
the decimal point and displays the number of digits the user specifies;
arbitrary precision calculator. (loose language, sorry)

On a *nix system, Mac OSx, Linux, run this to get 1000+ digits of PI:

time echo "scale = 1010; 16 * a(1/5) - 4 * a(1/239)" |bc -lq



scale sets the precision, -lq loads the math library arctan() quiet.





Wouldn't it be shorter to say:

time echo "scale = 1010;  4 * a(1)" |bc -lq

DaveA
--
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-24 Thread Steven D'Aprano
On Sat, 23 Apr 2011 22:10:47 -0500, harrismh777 wrote:

> I've been giving this some more thought. From the keyboard, all I am
> able to enter are character strings (not numbers). Presumably these are
> UTF-8 strings in python3.  If I enter the character string  57  then
> python converts my character string input and returns an reference to
> object 57.

That depends on where you enter it. If you enter it in between a pair of 
quotation marks, no conversion is done.

But I'll grant you that there are many places where the user/programmer 
communicates to the Python interpreter, and can generally only do so via 
characters or bytes. But that's hardly unique to numbers -- a dict is a 
rich compound data structure, but you can only create dicts by entering 
them as characters too. That's what we call syntax.

But the point is, once you have entered such a dict into the Python 
virtual machine:

d = {'spam': lambda x: x**2 + 3*x - 5, 42: ['a', 'b', 23, object(), []],
 17: (35, 19, True), 'x': {'cheese': 'cheddar'}, 
 'y': {'animal': 'aardvark'}, 'z': None}

Python no longer needs to convert it or its components back and forth 
between a string and the in-memory data structure. Converting to or from 
strings tend to be used in only a very few places:

* compiling from source code, including eval and exec;
* the interactive interpreter;
* some, but not all, serialization formats (e.g. JSON and YAML);
* printing the object repr;
* explicitly converting to string;

which is a big win for both speed and memory. You'll note that every 
single one of those is a special case of Input/Output.


[...]
> My idea for consistency is this: since the interpreter converts int
> to float, and float to imaginary (when needed), then it does (at least
> in a limited way) type promoting.

You are conflating lexing/parsing/compiling code with executing code. 
Just because you need to have a plumber install your water pipes when 
building a house, doesn't make it either practical or desirable to call a 
plumber in every time you want to turn a tap on.

I will grant that there are situations where a more implicit type 
conversion may be useful, or at least convenient. Perl does what you 
want, promoting strings to ints (and visa versa?) depending on what you 
try to do with them. Hypertalk, part of Apple's long defunct but not 
forgotten Hypercard, was deliberately designed to help non-programmers 
program. And I've sometimes experimented with config file formats that do 
similar things. So it's not that I think that weak typing in the REXX/
Hypertalk/Perl sense is always wrong, only that it's wrong for Python.

On the other hand, both Flash and Javascript also do weak typing, and the 
results in practice can be confusing and fraught with problems:

http://nedbatchelder.com/blog/200708/two_weak_typing_problems.html

And I think this quote from Peter Wone is amusing:

"Weak typing such as is used in COM Variants was an early attempt to 
solve this problem, but it is fraught with peril and frankly causes more 
trouble than it's worth. Even Visual Basic programmers, who will put up 
with all sorts of rubbish, correctly pegged this as a bad idea and 
backronymed Microsoft's ETC (Extended Type Conversion) to Evil Type Cast."

http://stackoverflow.com/questions/597664/when-should-weak-types-be-discouraged


It seems to me that weak typing is a Do What I Mean function, and DWIM is 
a notoriously bad anti-pattern that causes far more trouble than it is 
worth. I'm even a little suspicious of numeric coercions between integer 
and float. (But only a little.)



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-24 Thread Chris Angelico
On Sun, Apr 24, 2011 at 6:13 PM, Steven D'Aprano
 wrote:
> suppose an implementation might choose to trade off memory for time,
> skipping string -> bignum conversations at the cost of doubling the
> memory requirements. But even if I grant you bignums, you have to do the
> same for floats. Re-implementing the entire floating point library is not
> a trivial task, especially if you want to support arbitrary precision
> floats.

Or just arbitrary precision decimal strings, which aren't "floats" at
all. But to be honest, I've never looked at any implementation of REXX
(and the open source implementations do seem to be inferior to IBM's
OS/2 implementation, I think - haven't done any empirical testing
though), so I can't say how it's done. But it seems to my small
understanding that it'd be simpler to just work with the base 10
string than to convert it to base 256 or base 2**32 or something, just
because you skip the conversions. Obviously this makes REXX a poor
choice for heavy HEAVY computation, but it's potentially faster for
things that involve a little computation and a lot of string
manipulation (which is where REXX does well).

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-24 Thread Steven D'Aprano
On Sun, 24 Apr 2011 11:35:28 +1000, Chris Angelico wrote:

> On Sun, Apr 24, 2011 at 10:42 AM, Steven D'Aprano
>  wrote:
>> This is much like my experience with Apple's Hypertalk, where the only
>> data structure is a string. I'm very fond of Hypertalk, but it is
>> hardly designed with machine efficiency in mind. If you think Python is
>> slow now, imagine how slow it would be if every expression had to be
>> converted from a number back into a string, and vice versa, after every
>> operation:
>>
>> x = str(int("1") + int("2"))
>> y = str(int("9")/int("3"))
>> z = str(int(x) - int(y))
>> flag = str(int(z) == int("0"))
>>
>> only implicitly, by the interpreter.
> 
> Except that it wouldn't bother with a native integer implementation,
> would it? With a string-is-bignum system, it could simply do the
> arithmetic on the string itself, with no conversions at all.

I can assure you that Hypertalk had no BigNum system. This was in the 
days of Apple Mac when a standard int was 16 bits, although Hypertalk 
used 32 bit signed long ints.

But a text-string based bignum would be quite inefficient. Consider the 
relatively small number 256**100. Written out in a string it requires 240 
digits, with one byte per digit that's 240 bytes. Python stores longints 
in base 256, which requires 100 bytes (plus some overhead because it's an 
object):

>>> sys.getsizeof(256**100)
122

I suppose an implementation might choose to trade off memory for time, 
skipping string -> bignum conversations at the cost of doubling the 
memory requirements. But even if I grant you bignums, you have to do the 
same for floats. Re-implementing the entire floating point library is not 
a trivial task, especially if you want to support arbitrary precision 
floats.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-23 Thread harrismh777

Steven D'Aprano wrote:

If that's a "serious" flaw, it's a flaw shared by the vast majority of
programming languages.


   Yes, agreed.


As for the question of "consistency", I would argue the opposite: that
auto-promoting strings to numbers arguably is useful, but that is what is
inconsistent, not the failure to do so.


   I see your point...  but I'll push back just a little, in a minute...



Consider...

"one" + 1

"[1, 2, 3]" + [4]

"[2, 40, 10, 3]".sort()


   Yes, maybe problems all. Again, I see the point of your argument, 
and I do not necessarily disagree...


   I've been giving this some more thought. From the keyboard, all I am 
able to enter are character strings (not numbers). Presumably these are 
UTF-8 strings in python3.  If I enter the character string  57  then 
python converts my character string input and returns an reference to 
object 57.  If I enter the keyboard character string 34567 then the 
python interpreter converts my character string input into an object 
(creates a new object) (34567) returning a reference to that object (a 
type int). If I enter the keyboard character string 3.14 the python 
interpreter creates a float object (converts my string into a float) and 
returns a reference to the object. In any event, keyboard character 
strings that just happen to be numbers, are converted into int or float 
objects by the interpreter, from the keyboard, automatically.
   My idea for consistency is this: since the interpreter converts int 
to float, and float to imaginary (when needed), then it does (at least 
in a limited way) type promoting. So, it is consistent with the input 
methods generally to promote numeric string input to int --> float --> 
imaginary, as needed, therefore it is also consistent to promote a 
numeric string (that which I used to call a REXX number) into an int --> 
float --> imaginary, as implied by the statement(s). I am not asking for 
weak typing generally... nor am I thinking that all promotions are a 
good thing... just numeric string to int --> float --> imaginary when it 
makes sense. In any event, the programmer should be able to overide the 
behavior explicitly. On the other hand, I do see your point regarding 
performance. Otherwise,...


   ... type promotions really would not cause any more confusion for 
programmers who now know that int will be converted to float and use 
that knowledge conveniently


   I do believe that explicit is better than implicit (generally)... 
but not in this case. I am noticing a pattern in some of the responses, 
and that pattern is that some folks would find this appealing if not 
overtly convenient. The question IS, which I am not able to answer at 
this point, whether the convenience would actually cause other 
difficulties that would be worse...?



kind regards,
m harris




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


Re: learnpython.org - an online interactive Python tutorial

2011-04-23 Thread harrismh777

Cameron Simpson wrote:

| folks are not aware that 'bc' also has arbitrary precision floating
| point math and a standard math library.

Floating point math? I thought, historically at least, that bc is built
on dc (arbitrary precision integer math, reverse polish syntax) and that
consequently bc uses fixed point math rather than floating point.


My bad... I don't mean under-the-covers... I mean that the user may 
calculate arbitrary precision floating arithmetic ... bc keeps track of 
the decimal point and displays the number of digits the user specifies; 
arbitrary precision calculator.  (loose language, sorry)


On a *nix system, Mac OSx, Linux, run this to get 1000+ digits of PI:

time echo "scale = 1010; 16 * a(1/5) - 4 * a(1/239)" |bc -lq



scale sets the precision,  -lq  loads the math library arctan() quiet.


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


Re: learnpython.org - an online interactive Python tutorial

2011-04-23 Thread Cameron Simpson
On 23Apr2011 19:37, harrismh777  wrote:
[...]
| Yes, my "big num" research stuff was initially done in REXX, on
| VM/CMS. I later ported my libraries over to OS/2 and continued with
| that well into the '90s, when I discovered Unix and 'bc'.  Many
| folks are not aware that 'bc' also has arbitrary precision floating
| point math and a standard math library.

Floating point math? I thought, historically at least, that bc is built
on dc (arbitrary precision integer math, reverse polish syntax) and that
consequently bc uses fixed point math rather than floating point.

Cheers,
-- 
Cameron Simpson  DoD#743
http://www.cskk.ezoshosting.com/cs/

>From sci.physics:
t...@mailzone.com:
  The only problem is, how do you send a message from Earth to Mars
  instantly?  Does anyone have any ideas about where we can start?
John Baez :
  Just use a coordinate system in which the point at which the message is
  received has the same t coordinate as the point at which the message was sent.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-23 Thread Chris Angelico
On Sun, Apr 24, 2011 at 10:42 AM, Steven D'Aprano
 wrote:
> This is much like my experience with Apple's Hypertalk, where the only
> data structure is a string. I'm very fond of Hypertalk, but it is hardly
> designed with machine efficiency in mind. If you think Python is slow
> now, imagine how slow it would be if every expression had to be converted
> from a number back into a string, and vice versa, after every operation:
>
> x = str(int("1") + int("2"))
> y = str(int("9")/int("3"))
> z = str(int(x) - int(y))
> flag = str(int(z) == int("0"))
>
> only implicitly, by the interpreter.

Except that it wouldn't bother with a native integer implementation,
would it? With a string-is-bignum system, it could simply do the
arithmetic on the string itself, with no conversions at all.

Re harrismh's code: For that sort of work, I used and still use the
REXXTry program that comes with OS/2 (written, I believe, by Mike
Cowlishaw), with a modified input routine that gives readline-style
capabilities. Dragging this vaguely back on topic, the end result is
rather similar in feel to IDLE or Hilfe (Pike's interactive
interpreter).

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-23 Thread Steven D'Aprano
On Fri, 22 Apr 2011 01:38:21 -0500, harrismh777 wrote:

> Heiko Wundram wrote:
>> The difference between strong typing and weak typing is best described
>> by:
>>
>> Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01) [GCC 4.3.4 20090804
>> (release) 1] on cygwin Type "help", "copyright", "credits" or "license"
>> for more information.
> >>>  1+'2'
>> Traceback (most recent call last):
>>File "", line 1, in
>> TypeError: unsupported operand type(s) for +: 'int' and 'str'
> >>>
> >>>
> Yes. And you have managed to point out a serious flaw in the overall
> logic and consistency of Python, IMHO.
> 
> Strings should auto-type-promote to numbers if appropriate.

If that's a "serious" flaw, it's a flaw shared by the vast majority of 
programming languages.

As for the question of "consistency", I would argue the opposite: that 
auto-promoting strings to numbers arguably is useful, but that is what is 
inconsistent, not the failure to do so.

Consider...

"one" + 1

Should this also promote "one" to integer 1? If so, what about "uno" and 
"un" and "ein" and "один"? 

If not, why privilege one *string* representation of the number 1 over 
other *string* representations of the number 1?

How about this?

"[1, 2, 3]" + [4]

Should that auto-promote to a list as well? If not, why not? Why does 
your argument in favour of auto-promotion to int also not apply to auto-
promotion to list?

What about this?

"[2, 40, 10, 3]".sort()

Should that auto-promote to list? Should the result of sorting be 
[2, 3, 10, 40] or ['10', '2', '3', '40']? 

What about:

"[2, 4, 1, 3]".index("[")

Should that call the *string* index method, or the *list* index method?


If you want to argue that auto-promoting of strings to numbers is 
convenient for lazy programmers who can't be bothered keeping the 
distinction between strings and numbers straight, or for those who can't 
base the extra typing required to call int() but don't mind the 
inefficiency of the language repeatedly converting numbers to and from 
strings in the background, then I'd agree that the "convenience" argument 
is an argument in favour of weak-typing. (Not necessarily a *good* 
argument, but it's an argument.)

But I hope it is clear that "consistency" is not an argument in favour of 
weak-typing. As far as I know, no language applies weak-typing broadly to 
all types, and if a language did, it would be fraught with problems and 
traps.


[...]
> My feelings about this are strongly influenced by my experiences with
> the REXX language on IBM's SAA systems--- OS/2 and VM/CMS. In REXX
> everything is a string... everything. 

This is much like my experience with Apple's Hypertalk, where the only 
data structure is a string. I'm very fond of Hypertalk, but it is hardly 
designed with machine efficiency in mind. If you think Python is slow 
now, imagine how slow it would be if every expression had to be converted 
from a number back into a string, and vice versa, after every operation:

x = str(int("1") + int("2"))
y = str(int("9")/int("3"))
z = str(int(x) - int(y))
flag = str(int(z) == int("0"))

only implicitly, by the interpreter.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-23 Thread harrismh777

Chris Angelico wrote:

Wow, someone else who knows REXX and OS/2! REXX was the first bignum
language I met, and it was really cool after working in BASIC and
80x86 assembly to suddenly be able to work with arbitrary-precision
numbers!


Yes, my "big num" research stuff was initially done in REXX, on VM/CMS. 
I later ported my libraries over to OS/2 and continued with that well 
into the '90s, when I discovered Unix and 'bc'.  Many folks are not 
aware that 'bc' also has arbitrary precision floating point math and a 
standard math library. It is much faster than REXX because the libraries 
are written in C, and unlike REXX they do not have to be implemented in 
the interpreter. The syntax of 'bc' is C-like, which is its only 
down-side for new students who have never had any language training. 
REXX was a great business language, particularly when CMS Pipelines was 
introduced.


Just for fun, and a trip down memory lane, you can take a look at some 
of my ancient REXX code... this code is a REXX math library designed to 
be used from the command line,  written in REXX. The primary scientific 
functions were implemented, as well as some code to calculate PI... 
most of the algorithms can be ported to 'bc' easily, but the 'bc' 
algorithms will run much faster, of course.


Back in the day, REXX was the 'new BASIC'

... now I use Python.


//
//
/** COMPUTE COMMAND LINE SCIENTIFIC CALCULATOR **/
//
//
/****/
/**   IBM Corporation  **/
/**   HARRISMH at RCHVMP2  **/
/**   EL8/663-1 B627   **/
/**   Rochester, MN  55901 **/
/****/
/**   AUTHOR:  Marcus Harris   **/
/** DATE:  93/10/22 ( port from VM/CMS )   **/
/**   UPDATE:  98/03/07**/
/**  VER:  2.0a**/
/****/
//
//
/**  syntax**/
/****/
/**  COMPUTE  expression<;expression><;expression><@digits>**/
/****/
/****/
/**  The expression(s) will be computed and displayed in terminal  **/
/**  line mode to arbitrary <@digits> of accuracy. **/
/****/
/**  The expression(s) may be any REXX math clause and may include **/
/**  a variable assignment, for use in a subsequent expression:**/
/**  ie.,  COMPUTE A=3;B=7;A/B;A*B@30  **/
/**(will compute both the quotient and product of A & B)   **/
/****/
//
//
/**  NOTES **/
/****/
/**  COMPUTE  expression<;expression><;expression><@digits>**/
/****/
/**  This program exploits Rexx  INTERPRET and NUMERIC DIGITS  **/
/****/
/**  This exec is portable to OS/2, NT and w95 Rexx/objectRexx **/
/**  without changes.  **/
/****/
//
//
/**  updates   **/
/** 93/10/21 mhh New Program  (port from VM/CMS)   **/
/** 98/03/07 mhh New Version 2.0a  **/
/**  This version includes trigonometric, logarithmic, **/
/**  exponential and combinatorial functions.  **/
/****/
/**  See the REXROOTS ABOUT file for a discussion  **/
/**  o

Re: learnpython.org - an online interactive Python tutorial

2011-04-23 Thread Westley Martínez
On Fri, Apr 22, 2011 at 04:48:39PM -0700, Dan Stromberg wrote:
> On Thu, Apr 21, 2011 at 11:38 PM, harrismh777 wrote:
> 
> >
> > Yes. And you have managed to point out a serious flaw in the overall logic
> > and consistency of Python, IMHO.
> >
> > Strings should auto-type-promote to numbers if appropriate.
> 
> 
> Please no.  It's a little more convenient sometimes when you're coding, but
> it adds bugs that aren't worth the small benefit.
> 
> Explicit is better than implicit.
> 
> http://www.python.org/dev/peps/pep-0020/

We have tcl for this anyways.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-23 Thread Tim Chase

On 04/23/2011 11:51 AM, Dotan Cohen wrote:

harrismh777  wrote:

If an operation like (+) is used to add  1 + '1' then the
string should be converted to int and the addition should
take place, returning a reference to object int (2).


No, the int 1 should be cast to a string, and the result
should be the string '11'.


Oh, come on...clearly if you're adding mixed types, there's 
significance to the difference, so the result should obviously be 
the complex number


  (1+1j)

Or maybe it should be the tuple

  (1,1)

Or did I mean the list

 [1,1]

It's all so obvious...  :)

I didn't mind the auto-promotion (as much) in VB6 when I had an 
explicit concat operator


  1 & "1"   ' returns "11"

vs

  1 + "1"   ' returns 2

-tkc




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


Re: learnpython.org - an online interactive Python tutorial

2011-04-23 Thread Dotan Cohen
On Fri, Apr 22, 2011 at 09:38, harrismh777  wrote:
> If an operation like (+) is used to add  1 + '1' then the string should be
> converted to int and the addition should take place, returning a reference
> to object int (2).
>

No, the int 1 should be cast to a string, and the result should be the
string '11'.

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-23 Thread rantingrick
On Apr 22, 1:38 am, harrismh777  wrote:

> Strings should auto-type-promote to numbers if appropriate.

No they should not! We do not want a language to "guess" our
intentions. We are big boys and girls and should be responsible for
own actions.

> This behavior should occur in input() as well. If a 'number' string is
> entered and can be converted to a Python number (whatever I mean by that
> at the moment) then the string should be converted to a number (int or
> float as appropriate) and the input() should return a reference to the
> number type  ( a value );  otherwise, input() should return the string
> entered, or throw a type error.

No, no, no! This is evil! That is what "eval" is for my friend.

> If an operation like (+) is used to add  1 + '1' then the string should
> be converted to int and the addition should take place, returning a
> reference to object int (2).

My god man,  have you gone completely insane? 8-O
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-23 Thread rantingrick
On Apr 23, 1:28 am, Dennis Lee Bieber  wrote:

> But what if /I/ want
>                 "A" + 1
> to return
>                 "B"


No problem! Python even allows you to create your own functions! I
know, amazing! 8-O

>>> def succ(s):
return chr(ord(s) + 1)

>>> succ('a')
'b'
>>> succ('B')
'C'
>>> succ('Z')
'['

PS: The cases of (s > 255) or (s < 0) will be for the advanced reader
to solve.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-23 Thread Dotan Cohen
On Wed, Apr 20, 2011 at 20:15, Ron  wrote:
> Hey everyone.
>
> I've written an online interactive Python tutorial atop Google App Engine: 
> http://www.learnpython.org.
>
> All you need to do is log in using your Google account and edit the wiki to 
> add your tutorials.
>
> Read more on the website.
>
> Thanks for your help, and I would appreciate if you help me spread the word, 
> and give me feedback on the website.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Nice work! I notice that the "Next Chapter" link does not work.

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-23 Thread flebber
On Apr 23, 4:28 pm, Dennis Lee Bieber  wrote:
> On Fri, 22 Apr 2011 17:08:53 +1000, Chris Angelico 
> declaimed the following in gmane.comp.python.general:
>
> > I'm not so sure that all strings should autopromote to integer (or
> > "numeric" generally). However, adding a string and a number _should_
> > (IMHO) promote the number to string.
>
> > print "Hello, "+name+", you have "+credit+" dollars of credit with us."
>
> > Okay, that one is probably better done with the % operator, but it
> > definitely makes logical sense to concatenate numbers and strings as
> > strings, not to add them as numbers.
>
>         But what if /I/ want
>                 "A" + 1
> to return
>                 "B"
>
> 
> --
>         Wulfraed                 Dennis Lee Bieber         AF6VN
>         wlfr...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

I like what you have done. Was it deliberate that your site teaches
python 2.x code rather than 3.x?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-22 Thread Dan Stromberg
On Thu, Apr 21, 2011 at 11:38 PM, harrismh777 wrote:

>
> Yes. And you have managed to point out a serious flaw in the overall logic
> and consistency of Python, IMHO.
>
> Strings should auto-type-promote to numbers if appropriate.


Please no.  It's a little more convenient sometimes when you're coding, but
it adds bugs that aren't worth the small benefit.

Explicit is better than implicit.

http://www.python.org/dev/peps/pep-0020/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-22 Thread Roy Smith
In article , Mel  
wrote:

> > Strings should auto-type-promote to numbers if appropriate.
> 
> "Appropriate" is the problem.  This is why Perl needs two completely 
> different kinds of comparison -- one that works as though its operands are 
> numbers, and one that works as though they're strings.  Surprises to the 
> programmer who picks the wrong one.

Ugh, tell me about it.

The project I'm currently working on used to use PHP (which has the same 
auto-promotion semantics as Perl) as the front end to a SQL database.  
The PHP code gleefully turned strings into numbers and back again all 
over the place, but it all got cleaned up at the database interface 
since SQL has strict typing.

We converted the back end database to MongoDB, which does not have 
strict typing.  We're still cleaning up the mess of inconsistent data 
(i.e. string vs integer) that creeps into the database through various 
paths.  Not to mention 0 vs. '' vs null vs false.

Implicit type conversion can be convenient.  But, then again, so can 
removing the safety guards from a chain saw.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-22 Thread Mel
harrismh777 wrote:

> Heiko Wundram wrote:
>> The difference between strong typing and weak typing is best described
>> by:
>>
>> Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01)
>> [GCC 4.3.4 20090804 (release) 1] on cygwin
>> Type "help", "copyright", "credits" or "license" for more information.
> >>>  1+'2'
>> Traceback (most recent call last):
>>File "", line 1, in
>> TypeError: unsupported operand type(s) for +: 'int' and 'str'
> >>>
> 
> Yes. And you have managed to point out a serious flaw in the overall
> logic and consistency of Python, IMHO.
> 
> Strings should auto-type-promote to numbers if appropriate.

"Appropriate" is the problem.  This is why Perl needs two completely 
different kinds of comparison -- one that works as though its operands are 
numbers, and one that works as though they're strings.  Surprises to the 
programmer who picks the wrong one.

Mel.

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


Re: learnpython.org - an online interactive Python tutorial

2011-04-22 Thread Chris Angelico
On Fri, Apr 22, 2011 at 4:38 PM, harrismh777  wrote:
> My feelings about this are strongly influenced by my experiences with the
> REXX language on IBM's SAA systems--- OS/2 and VM/CMS. In REXX everything is
> a string... everything. If a string just happens to be a REXX number, then
> it can be manipulated as you might expect for a number.

Wow, someone else who knows REXX and OS/2! REXX was the first bignum
language I met, and it was really cool after working in BASIC and
80x86 assembly to suddenly be able to work with arbitrary-precision
numbers!

The "everything is a string, but treat it as a number if you like"
system is rather handy in a few places. I wanted it for my automated
DNS editor - I wanted to concatenate several numbers (from the date,
and the constant "1"), and then, if the resulting number is not
greater than another number (the previous serial), increment. Ahh
well...

I'm not so sure that all strings should autopromote to integer (or
"numeric" generally). However, adding a string and a number _should_
(IMHO) promote the number to string.

print "Hello, "+name+", you have "+credit+" dollars of credit with us."

Okay, that one is probably better done with the % operator, but it
definitely makes logical sense to concatenate numbers and strings as
strings, not to add them as numbers.

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-21 Thread harrismh777

Heiko Wundram wrote:

The difference between strong typing and weak typing is best described by:

Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01)
[GCC 4.3.4 20090804 (release) 1] on cygwin
Type "help", "copyright", "credits" or "license" for more information.

>>>  1+'2'

Traceback (most recent call last):
   File "", line 1, in
TypeError: unsupported operand type(s) for +: 'int' and 'str'

>>>


Yes. And you have managed to point out a serious flaw in the overall 
logic and consistency of Python, IMHO.


Strings should auto-type-promote to numbers if appropriate.

This behavior should occur in input() as well. If a 'number' string is 
entered and can be converted to a Python number (whatever I mean by that 
at the moment) then the string should be converted to a number (int or 
float as appropriate) and the input() should return a reference to the 
number type  ( a value );  otherwise, input() should return the string 
entered, or throw a type error.


If an operation like (+) is used to add  1 + '1' then the string should 
be converted to int and the addition should take place, returning a 
reference to object int (2).



My feelings about this are strongly influenced by my experiences with 
the REXX language on IBM's SAA systems--- OS/2 and VM/CMS. In REXX 
everything is a string... everything. If a string just happens to be a 
REXX number, then it can be manipulated as you might expect for a 
number.  Neither here, nor there... just that I believe Python could 
take advantage of the "Python Number" concept and provide for auto-type 
casting of string to number (int or float) as appropriate if the string 
meets the Python Number requirements.


Just an idea... again, probably got beat up long before my time, I'm 
guessing...



kind regards,
m harris



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


Re: learnpython.org - an online interactive Python tutorial

2011-04-21 Thread Diego Arias
On Thu, Apr 21, 2011 at 8:20 PM, Dan Stromberg  wrote:

>
> On Thu, Apr 21, 2011 at 9:13 AM, MRAB  wrote:
>
>> On 21/04/2011 15:14, Westley Martínez wrote:
>>
>>> On Thu, Apr 21, 2011 at 05:19:29PM +1000, Chris Angelico wrote:
>>>
 On Thu, Apr 21, 2011 at 5:10 PM, Algis Kabaila
  wrote:

> False: Python IS strongly typed, without doubt (though the
> variables are not explicitly declared.)
>

 Strongly duck-typed though. If I create a class that has all the right
 members, it can simultaneously be a file, an iterable, a database, and
 probably even a web browser if it feels like it. Is that strong typing
 or not?

 Chris Angelico
 --
 http://mail.python.org/mailman/listinfo/python-list

>>>
>>> It's strong typing.  Python does not implicitly convert types.  Weak
>>> typing is
>>> when I can do 1 + "1" and get 2.
>>>
>>
>> It could be argued that it does implicit convert for some numeric
>> types, eg int to float when needed.
>
>
> Yes, it'll silently promote int to float, int to Decimal, and also almost
> anything can be used in a Boolean context.  No other exceptions to strong
> typing come to mind...
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
> Hi:

Really nice site, keep it going


-- 
Still Going Strong!!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-21 Thread Dan Stromberg
On Thu, Apr 21, 2011 at 9:13 AM, MRAB  wrote:

> On 21/04/2011 15:14, Westley Martínez wrote:
>
>> On Thu, Apr 21, 2011 at 05:19:29PM +1000, Chris Angelico wrote:
>>
>>> On Thu, Apr 21, 2011 at 5:10 PM, Algis Kabaila
>>>  wrote:
>>>
 False: Python IS strongly typed, without doubt (though the
 variables are not explicitly declared.)

>>>
>>> Strongly duck-typed though. If I create a class that has all the right
>>> members, it can simultaneously be a file, an iterable, a database, and
>>> probably even a web browser if it feels like it. Is that strong typing
>>> or not?
>>>
>>> Chris Angelico
>>> --
>>> http://mail.python.org/mailman/listinfo/python-list
>>>
>>
>> It's strong typing.  Python does not implicitly convert types.  Weak
>> typing is
>> when I can do 1 + "1" and get 2.
>>
>
> It could be argued that it does implicit convert for some numeric
> types, eg int to float when needed.


Yes, it'll silently promote int to float, int to Decimal, and also almost
anything can be used in a Boolean context.  No other exceptions to strong
typing come to mind...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-21 Thread MRAB

On 21/04/2011 15:14, Westley Martínez wrote:

On Thu, Apr 21, 2011 at 05:19:29PM +1000, Chris Angelico wrote:

On Thu, Apr 21, 2011 at 5:10 PM, Algis Kabaila  wrote:

False: Python IS strongly typed, without doubt (though the
variables are not explicitly declared.)


Strongly duck-typed though. If I create a class that has all the right
members, it can simultaneously be a file, an iterable, a database, and
probably even a web browser if it feels like it. Is that strong typing
or not?

Chris Angelico
--
http://mail.python.org/mailman/listinfo/python-list


It's strong typing.  Python does not implicitly convert types.  Weak typing is
when I can do 1 + "1" and get 2.


It could be argued that it does implicit convert for some numeric
types, eg int to float when needed.
--
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-21 Thread Westley Martínez
On Thu, Apr 21, 2011 at 05:19:29PM +1000, Chris Angelico wrote:
> On Thu, Apr 21, 2011 at 5:10 PM, Algis Kabaila  wrote:
> > False: Python IS strongly typed, without doubt (though the
> > variables are not explicitly declared.)
> 
> Strongly duck-typed though. If I create a class that has all the right
> members, it can simultaneously be a file, an iterable, a database, and
> probably even a web browser if it feels like it. Is that strong typing
> or not?
> 
> Chris Angelico
> -- 
> http://mail.python.org/mailman/listinfo/python-list

It's strong typing.  Python does not implicitly convert types.  Weak typing is
when I can do 1 + "1" and get 2.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-21 Thread Heiko Wundram
Am 21.04.2011 09:19, schrieb Chris Angelico:
> On Thu, Apr 21, 2011 at 5:10 PM, Algis Kabaila  wrote:
>> False: Python IS strongly typed, without doubt (though the
>> variables are not explicitly declared.)
> 
> Strongly duck-typed though. If I create a class that has all the right
> members, it can simultaneously be a file, an iterable, a database, and
> probably even a web browser if it feels like it. Is that strong typing
> or not?

Yes, that's strong typing, because your class only works in those
contexts that you "explicitly" allow it to work in (through implementing
an interface, be it an iterator, a file, etc.), independent of
"duck-typing" (which is pretty much described by the term
interface-based typing IMHO).

The difference between strong typing and weak typing is best described by:

Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01)
[GCC 4.3.4 20090804 (release) 1] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1+'2'
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>>

which means that the interface for implementing "+" on the input types
"int" and "str" isn't implemented (i.e., TypeError). Weakly typed
languages allow this to work:

modelnine@gj-celle ~ $ php

3
modelnine@gj-celle ~ $

through all kinds of type-casting magic, which isn't explicitly
specified as interfaces on the objects (PHP also has integer and string
objects) themselves.

-- 
--- Heiko.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-21 Thread harrismh777

Algis Kabaila wrote:

[quote]
Python is completely object oriented, and not "strongly typed"
[/quote]

False: Python IS strongly typed, without doubt (though the
variables are not explicitly declared.)




Playing the advocate for a moment here, this is something that I was 
confused about early on also... and frankly, you are both correct, but 
from different vantage points.


Python IS strongly typed in that operations may only be applied to 
objects that support 'that' operation... numbers support (+) and also 
strings support (+) ,  although, the (+) does 'different' things 
depending on the object type. You might look at this as STRONGLY typed 
and you would be correct...  however, you might look on this as weakly 
typed and you would still be correct... because why?


Because, the programmer doesn't have to worry about the 'types' she is 
using ... the object based nature of the language and polymorphism come 
together so that the 'right thing' happens with (+) regardless of 
type...   see?  weakly typed...


In C the programmer is always considering what 'type' is this thing... 
even testing for it... and C is considered by those programmers (yes, me 
) as STRONGLY typed. The types must be declared ahead of time for sure, 
but that's not the point...  the point is that the 'type' matters and 
must always be on the front lobes in thinking about logic.


In Python much of the thinking about types is not even necessary.. for 
the most part... and by design. In this way of thinking the language is 
weakly typed...  on the other hand, because the objects may be only 
manipulated by operations they support, this makes Python STRONGLY 
typed.   Confused yet???


How one thinks about this depends on programming background, what is 
meant by 'type' and how the programmer differentiates thinking about 
types as variables versus objects.


Having said all of that, I agree that Python should be classified as 
STRONGLY typed... and this classification should always come with an 
explanation ... especially to new advocates writing tutorials...


kind regards,
m harris
--
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-21 Thread Chris Angelico
On Thu, Apr 21, 2011 at 5:10 PM, Algis Kabaila  wrote:
> False: Python IS strongly typed, without doubt (though the
> variables are not explicitly declared.)

Strongly duck-typed though. If I create a class that has all the right
members, it can simultaneously be a file, an iterable, a database, and
probably even a web browser if it feels like it. Is that strong typing
or not?

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-21 Thread Algis Kabaila
On Thursday 21 April 2011 03:15:50 Ron wrote:
> Hey everyone.
> 
> I've written an online interactive Python tutorial atop
> Google App Engine: http://www.learnpython.org.
> 
> All you need to do is log in using your Google account and
> edit the wiki to add your tutorials.
> 
> Read more on the website.
> 
> Thanks for your help, and I would appreciate if you help me
> spread the word, and give me feedback on the website.

[quote]
Python is completely object oriented, and not "strongly typed"
[/quote]

False: Python IS strongly typed, without doubt (though the 
variables are not explicitly declared.)

Explicit declaration and strong typing are two completely 
differen things.  If you are going to teach (and that is what 
tutorials are for), it is obligatory to learn first...

OldAl.
-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-20 Thread Yico Gaga
 well ,i can't visit your website ,required time out ,maybe it's the GFW'S
problem ~

2011/4/21 Ron 

> Hey everyone.
>
> I've written an online interactive Python tutorial atop Google App Engine:
> http://www.learnpython.org.
>
> All you need to do is log in using your Google account and edit the wiki to
> add your tutorials.
>
> Read more on the website.
>
> Thanks for your help, and I would appreciate if you help me spread the
> word, and give me feedback on the website.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-20 Thread Chris Angelico
On Thu, Apr 21, 2011 at 3:15 AM, Ron  wrote:
> Hey everyone.
>
> I've written an online interactive Python tutorial atop Google App Engine: 
> http://www.learnpython.org.

That looks very handy! And I notice you've protected yourself by
running it in a sandbox:


import time
time.sleep(3)

Traceback (most recent call last):
  File "/base/data/home/apps/learnpythoneasy/1.349862757547785986/main.py",
line 93, in post
exec(cmd, safe_globals)
  File "<string>", line 1, in <module>
TypeError: 'NoneType' object is not callable

hehe

Quite a few people on Threshold RPG have spoken to me about learning
programming, and I usually point them to Python or Pike; I think this
site will be where I start pointing people. Looks good!

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


Re: learnpython.org - an online interactive Python tutorial

2011-04-20 Thread Terry Reedy

On 4/20/2011 1:15 PM, Ron wrote:


I've written an online interactive Python tutorial atop Google App Engine:


 http://www.learnpython.org.

Currently giving 500 server error. Hope something clears up.

--
Terry Jan Reedy

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


Re: learnpython.org - an online interactive Python tutorial

2011-04-20 Thread FELD Boris
Excellent idea,

I've some ideas on specific subjects misunderstood by beginners.

One idea for facilitating the contribution, create a mercurial repository (or a 
git), everyone has not a google account and your contributors will be 
developers so they should use a SCM.

Once again, it's an excellent idea and, when the tutorials were expanded 
enough, i should be good to integrate it with python.org website (but it's more 
a dream than something else...)

One question, if i want to write a tutorial about import mechanism, how can i 
manage the file system ?

Nice work !
-- 
FELD Boris
Sent with Sparrow
On mercredi 20 avril 2011 at 19:57, Matty Sarro wrote: 
> Awesome project, I really like it. I'll see if I can't help adding
> some material that's missing when I get on the train.
> Keep up the great work!
> 
> On Wed, Apr 20, 2011 at 1:15 PM, Ron  wrote:
> > Hey everyone.
> > 
> > I've written an online interactive Python tutorial atop Google App Engine: 
> > http://www.learnpython.org.
> > 
> > All you need to do is log in using your Google account and edit the wiki to 
> > add your tutorials.
> > 
> > Read more on the website.
> > 
> > Thanks for your help, and I would appreciate if you help me spread the 
> > word, and give me feedback on the website.
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-20 Thread Ron
Thanks! :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learnpython.org - an online interactive Python tutorial

2011-04-20 Thread Matty Sarro
Awesome project, I really like it. I'll see if I can't help adding
some material that's missing when I get on the train.
Keep up the great work!

On Wed, Apr 20, 2011 at 1:15 PM, Ron  wrote:
> Hey everyone.
>
> I've written an online interactive Python tutorial atop Google App Engine: 
> http://www.learnpython.org.
>
> All you need to do is log in using your Google account and edit the wiki to 
> add your tutorials.
>
> Read more on the website.
>
> Thanks for your help, and I would appreciate if you help me spread the word, 
> and give me feedback on the website.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


learnpython.org - an online interactive Python tutorial

2011-04-20 Thread Ron
Hey everyone.

I've written an online interactive Python tutorial atop Google App Engine: 
http://www.learnpython.org.

All you need to do is log in using your Google account and edit the wiki to add 
your tutorials.

Read more on the website.

Thanks for your help, and I would appreciate if you help me spread the word, 
and give me feedback on the website.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python Tutorial

2011-03-27 Thread Colin J. Williams

I have come across: http://www.java2s.com/Tutorial/Python/CatalogPython.htm

On a quick skim, the above seems to cover more ground
than the standard: http://docs.python.org/tutorial/

I spotted one bug in the former, but one of the Network
examples was helpful.

Colin W.

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


Re: Python Tutorial on Multithreading

2011-02-21 Thread Terry Reedy

On 2/21/2011 7:02 PM, KevinSimonson wrote:

On Feb 21, 4:04 pm, Alexander Kapps  wrote:


That tutorial seems to be wrong.

According to the official docs:

"If the subclass overrides the constructor, it must make sure to
invoke the base class constructor (Thread.__init__()) before doing
anything else to the thread."

http://docs.python.org/library/threading.html#thread-objects

So, change your __init__ to this:

class myThread (threading.Thread):
  def __init__(self, threadID, name, q):
  threading.Thread.__init__(self)
  self.threadID = threadID
  self.name = name
  self.q = q



Alexander, thanks!  Your suggestion fixed my problem.


Please report the problem and solution on the tracker so the tutorial 
can be fixed.


--
Terry Jan Reedy

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


Re: Python Tutorial on Multithreading

2011-02-21 Thread KevinSimonson
On Feb 21, 4:04 pm, Alexander Kapps  wrote:
>
> That tutorial seems to be wrong.
>
> According to the official docs:
>
> "If the subclass overrides the constructor, it must make sure to
> invoke the base class constructor (Thread.__init__()) before doing
> anything else to the thread."
>
> http://docs.python.org/library/threading.html#thread-objects
>
> So, change your __init__ to this:
>
> class myThread (threading.Thread):
>      def __init__(self, threadID, name, q):
>          threading.Thread.__init__(self)
>          self.threadID = threadID
>          self.name = name
>          self.q = q
>

Alexander, thanks!  Your suggestion fixed my problem.

Kevin S
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Tutorial on Multithreading

2011-02-21 Thread Alexander Kapps

On 21.02.2011 23:30, KevinSimonson wrote:

I've been teaching myself Python from the tutorial routed at "http://
www.tutorialspoint.com/python/index.htm".  It's worked out pretty
well, but when I copied its multithreading example from the bottom of
the page at "http://www.tutorialspoint.com/python/
python_multithreading.htm" and tried to run it I got the error
messages:

C:\Users\kvnsmnsn\Python>python mt.py
Traceback (most recent call last):
   File "mt.py", line 38, in
 thread = myThread(threadID, tName, workQueue)
   File "mt.py", line 10, in __init__
 self.name = name
   File "C:\Python27\lib\threading.py", line 667, in name
 assert self.__initialized, "Thread.__init__() not called"
AssertionError: Thread.__init__() not called

I don't really understand why it's giving me these messages.
<__initialized>  gets set to  when<__init__()>  gets called.
Granted my Python program calls<__init__()>  with only one parameter,
and the constructor in "threading.py" takes _seven_ parameters, but
all but one have default values, so a call with just one parameter
should be legal.  Why then is<__initialized>  getting set to?

My code follows.


That tutorial seems to be wrong.

According to the official docs:

"If the subclass overrides the constructor, it must make sure to 
invoke the base class constructor (Thread.__init__()) before doing 
anything else to the thread."


http://docs.python.org/library/threading.html#thread-objects

So, change your __init__ to this:

class myThread (threading.Thread):
def __init__(self, threadID, name, q):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self.q = q


HTH
--
http://mail.python.org/mailman/listinfo/python-list


Python Tutorial on Multithreading

2011-02-21 Thread KevinSimonson
I've been teaching myself Python from the tutorial routed at "http://
www.tutorialspoint.com/python/index.htm".  It's worked out pretty
well, but when I copied its multithreading example from the bottom of
the page at "http://www.tutorialspoint.com/python/
python_multithreading.htm" and tried to run it I got the error
messages:

C:\Users\kvnsmnsn\Python>python mt.py
Traceback (most recent call last):
  File "mt.py", line 38, in 
thread = myThread(threadID, tName, workQueue)
  File "mt.py", line 10, in __init__
self.name = name
  File "C:\Python27\lib\threading.py", line 667, in name
assert self.__initialized, "Thread.__init__() not called"
AssertionError: Thread.__init__() not called

I don't really understand why it's giving me these messages.
<__initialized> gets set to  when <__init__()> gets called.
Granted my Python program calls <__init__()> with only one parameter,
and the constructor in "threading.py" takes _seven_ parameters, but
all but one have default values, so a call with just one parameter
should be legal.  Why then is <__initialized> getting set to ?

My code follows.

Kevin Simonson

import Queue
import threading
import time

exitFlag = 0

class myThread (threading.Thread):
def __init__(self, threadID, name, q):
self.threadID = threadID
self.name = name
self.q = q
threading.Thread.__init__(self)
def run(self):
print "Starting " + self.name
process_data(self.name, self.q)
print "Exiting " + self.name

def process_data(threadName, q):
while not exitFlag:
queueLock.acquire()
if not workQueue.empty():
data = q.get()
queueLock.release()
print "%s processing %s" % (threadName, data)
else:
queueLock.release()
time.sleep(1)

threadList = ["Thread-1", "Thread-2", "Thread-3"]
nameList = ["One", "Two", "Three", "Four", "Five"]
queueLock = threading.Lock()
workQueue = Queue.Queue(10)
threads = []
threadID = 1

# Create new threads
for tName in threadList:
thread = myThread(threadID, tName, workQueue)
thread.start()
threads.append(thread)
threadID += 1

# Fill the queue
queueLock.acquire()
for word in nameList:
workQueue.put(word)
queueLock.release()

# Wait for queue to empty
while not workQueue.empty():
pass

# Notify threads it's time to exit
exitFlag = 1

# Wait for all threads to complete
for t in threads:
t.join()
print "Exiting Main Thread"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to read the Python tutorial?

2010-11-10 Thread Ian
On Nov 10, 8:13 am, Zeynel  wrote:
> But when I try
>
> datetime.datetime.mDATE.toordinal())
>
> I get AttributeError.

Others have already explained why "mDATE.seconds" does not work, but I
wanted to touch on this as well.  The above fails because "mDATE" is
not an attribute of the "datetime.datetime" class, which is to be
expected since you've merely defined it as a local variable.  If you
want to call the "toordinal" method of mDATE, just do this:

mDATE.toordinal()

or this:

datetime.datetime.toordinal(mDATE)

But in most cases the first version is preferred.

As an aside, your capitalization scheme would drive me insane.  I
suggest reading PEP 8, the Python style guide, and following the
recommendations there.  Also, it is not customary in Python to prefix
attribute names with the string "m" or "m_" as it is in C++.  Because
Python does not do implicit attribute lookup, it is always clear from
context whether a name refers to an attribute or not, and so the "m"
is superfluous.

Cheers,
Ian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to read the Python tutorial?

2010-11-10 Thread Terry Reedy

On 11/10/2010 10:13 AM, Zeynel wrote:

For instance, when the tutorial has 
http://docs.python.org/release/2.6/library/datetime.html

class datetime.datetime
A combination of a date and a time. Attributes: year, month, day,
hour, minute, second, microsecond, and tzinfo.


Note 'second' singular, as with other attributes.


td = mDATE.seconds


You added a 's' to 'second', so


in GAE development server I get
AttributeError: 'datetime.datetime' object has no attribute 'seconds'


--
Terry Jan Reedy

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


Re: How to read the Python tutorial?

2010-11-10 Thread MRAB

On 10/11/2010 15:13, Zeynel wrote:

For instance, when the tutorial has 
http://docs.python.org/release/2.6/library/datetime.html

class datetime.datetime
A combination of a date and a time. Attributes: year, month, day,
hour, minute, second, microsecond, and tzinfo.

What does this mean? How do I use it?

For instance, I have a DateTimeProperty mDate that I get from a query
in Google App Engine. This mDate has value

mDATE = 2010-11-10 14:35:22.863000

But when I try

datetime.datetime.mDATE.toordinal())

I get AttributeError.

If I try something like

td = mDATE.seconds

in GAE development server I get

AttributeError: 'datetime.datetime' object has no attribute 'seconds'

What am I doing wrong? And how to understand this stuff so that I can
start using the language instead of trying to figure out types. Thanks
for your help.


If you lookup 'datetime' in Python's documentation you'll find that the
attribute is called 'second'.
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to read the Python tutorial?

2010-11-10 Thread Emile van Sebille

On 11/10/2010 8:19 AM rantingrick said...

I would start at the loop and figure out what is going on from there
with some print statements and the functions i showed you. Debugging
is a large part of any programming project. We all do it everyday. So
the sooner you learn the better. If you have a specific question feel
free to ask, but general debug issues are better solved yourself.

A few more indispensable functions are dir() and help()


All good info -- I'd add that you should learn and become comfortable with:

import pdb; pdb.set_trace()

to test running code.

Emile




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


How to read the Python tutorial?

2010-11-10 Thread Zeynel
For instance, when the tutorial has 
http://docs.python.org/release/2.6/library/datetime.html

class datetime.datetime
A combination of a date and a time. Attributes: year, month, day,
hour, minute, second, microsecond, and tzinfo.

What does this mean? How do I use it?

For instance, I have a DateTimeProperty mDate that I get from a query
in Google App Engine. This mDate has value

mDATE = 2010-11-10 14:35:22.863000

But when I try

datetime.datetime.mDATE.toordinal())

I get AttributeError.

If I try something like

td = mDATE.seconds

in GAE development server I get

AttributeError: 'datetime.datetime' object has no attribute 'seconds'

What am I doing wrong? And how to understand this stuff so that I can
start using the language instead of trying to figure out types. Thanks
for your help.



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


Re: How to read the Python tutorial?

2010-11-10 Thread rantingrick
On Nov 10, 10:05 am, Zeynel  wrote:

> AttributeError: 'datetime.datetime' object has no attribute 'seconds'

First of all put some scaffolding in this code. What is scaffolding.
Basically some debug print statements so you can follow the trail of
errors. You need to learn how to debug code and be self reliant. A few
very important functions are.

>>> a = 's'
>>> b = 1
>>> a * b
's'
>>> a + b

Traceback (most recent call last):
  File "", line 1, in 
a + b
TypeError: cannot concatenate 'str' and 'int' objects

>>> type(a), type(b)
(, )

>>> id(a), id(b)
(26864768, 12844616)

>>> print a, b
s 1

>>> repr(a), repr(b)
("'s'", '1')

>>> isinstance(a, str)
True

I would start at the loop and figure out what is going on from there
with some print statements and the functions i showed you. Debugging
is a large part of any programming project. We all do it everyday. So
the sooner you learn the better. If you have a specific question feel
free to ask, but general debug issues are better solved yourself.

A few more indispensable functions are dir() and help()

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


Re: How to read the Python tutorial?

2010-11-10 Thread rantingrick
On Nov 10, 9:13 am, Zeynel  wrote:
> For instance, when the tutorial 
> hashttp://docs.python.org/release/2.6/library/datetime.html
>
> class datetime.datetime
> A combination of a date and a time. Attributes: year, month, day,
> hour, minute, second, microsecond, and tzinfo.
>
> What does this mean? How do I use it?
>
> For instance, I have a DateTimeProperty mDate that I get from a query
> in Google App Engine. This mDate has value
>
> mDATE = 2010-11-10 14:35:22.863000

Wait a minute i am confused...? Does Python have a "text" object that
magically turns into a datetime object?

>>> mDATE = 2010-11-10 14:35:22.863000
SyntaxError: invalid syntax

hmm, apparently not! Usually in order to use methods of an object, you
must create an object first or more specifically an instance.

>>> dateobj = datetime.date(2010,11,10)
>>> dir(dateobj)
['__add__', '__class__', '__delattr__', '__doc__', '__eq__',
'__format__', '__ge__', '__getattribute__', '__gt__', '__hash__',
'__init__', '__le__', '__lt__', '__ne__', '__new__', '__radd__',
'__reduce__', '__reduce_ex__', '__repr__', '__rsub__', '__setattr__',
'__sizeof__', '__str__', '__sub__', '__subclasshook__', 'ctime',
'day', 'fromordinal', 'fromtimestamp', 'isocalendar', 'isoformat',
'isoweekday', 'max', 'min', 'month', 'replace', 'resolution',
'strftime', 'timetuple', 'today', 'toordinal', 'weekday', 'year']
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to read the Python tutorial?

2010-11-10 Thread Zeynel
On Nov 10, 10:51 am, rantingrick  wrote:

> Wait a minute i am confused...? Does Python have a "text" object that
> magically turns into a datetime object?
>
> >>> mDATE = 2010-11-10 14:35:22.863000
>
> SyntaxError: invalid syntax

This is the reason I am asking the question. I am confused about what
mDATE is. It is defined as a DateTimeProperty in Google App Engine in
the following model:

class Rep(db.Model):
mAUTHOR = db.UserProperty(auto_current_user=True)
mUNIQUE = db.StringProperty()
mCOUNT = db.IntegerProperty()
mDATE = db.DateTimeProperty(auto_now=True)
mDATE0 = db.DateTimeProperty(auto_now_add=True)
mWEIGHT = db.IntegerProperty()


When I acces it with this query:

QUERY = Rep.all()
QUERY.filter("mAUTHOR =", user)
QUERY.order("-mCOUNT")
RESULTS = QUERY.fetch(10)

But when I try to use like this for instance:

for result in RESULTS:
WEIGHT = (datetime.datetime.result.mDATE.toordinal()) *
result.mCOUNT

I get AttributeError

or if I try to use it like this

dt = result.mDATE.seconds

I get

AttributeError: 'datetime.datetime' object has no attribute 'seconds'

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


Python Tutorial

2010-08-13 Thread AK

Hello,

I plan to make a new python tutorial and I'd like to collaborate with
someone on it. I'm thinking of a slightly different approach than
existing tutorials: the idea is that readers will learn from examples,
going from small but complete and useful scripts to larger programs,
similar to Django by Example:

http://lightbird.net/dbe/

If you are interested and have a few years of experience with Python,
drop me an email and we'll discuss this further...

-ak
--
http://mail.python.org/mailman/listinfo/python-list


Re: * operator in python tutorial

2010-01-22 Thread Terry Reedy

On 1/22/2010 12:57 PM, ben wrote:

On Jan 20, 8:30 pm, Gringo  wrote:



I am following through the python tutorial which gets to a line that
uses the * operator with zip().


All such questions are at least briefly answered in
my complete python3 symbol glossary (all syntax usages) at
http://code.google.com/p/xploro/downloads/list

Terry Jan Reedy

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


Re: * operator in python tutorial

2010-01-22 Thread ben
On Jan 20, 8:30 pm, Gringo  wrote:
> On 1/20/2010 12:38, ben wrote:
>
>
>
> > Hello,
>
> > I am following through the python tutorial which gets to a line that
> > uses the * operator with zip(). I searched and searched but could find
> > no information on the operator or how to use it in general. The
> > example from the tut is as follows:
> >>>> x = [1, 2, 3]
> >>>> y = [4, 5, 6]
> >>>> zipped = zip(x, y)
> >>>> zipped
> > [(1, 4), (2, 5), (3, 6)]
> >>>> x2, y2 = zip(*zipped)
> >>>> x == list(x2) and y == list(y2)
> > True
>
> > How would i apply the * operator in general?
> > Thanks.
>
> The * operator, when used in this context, unpacks the sequence and it's
> as if you passed each item to the function as a different parameter.
> For example, if you have a list x with 4 items, these two statements
> would be the same:
> f(x[0],x[1],x[2],x[3])
> f(*x)
>
> Hope this helps.

It does.
Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: * operator in python tutorial

2010-01-20 Thread Gringo
On 1/20/2010 12:38, ben wrote:
> Hello,
> 
> I am following through the python tutorial which gets to a line that
> uses the * operator with zip(). I searched and searched but could find
> no information on the operator or how to use it in general. The
> example from the tut is as follows:
>>>> x = [1, 2, 3]
>>>> y = [4, 5, 6]
>>>> zipped = zip(x, y)
>>>> zipped
> [(1, 4), (2, 5), (3, 6)]
>>>> x2, y2 = zip(*zipped)
>>>> x == list(x2) and y == list(y2)
> True
> 
> How would i apply the * operator in general?
> Thanks.

The * operator, when used in this context, unpacks the sequence and it's
as if you passed each item to the function as a different parameter.
For example, if you have a list x with 4 items, these two statements
would be the same:
f(x[0],x[1],x[2],x[3])
f(*x)

Hope this helps.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: * operator in python tutorial

2010-01-20 Thread ben
I missed it because I skipped to the explanation of zip. I hit the
back arrow and went on and saw the link to "Unpacking Argument Lists"
which explained what I needed to know.

Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


* operator in python tutorial

2010-01-20 Thread ben
Hello,

I am following through the python tutorial which gets to a line that
uses the * operator with zip(). I searched and searched but could find
no information on the operator or how to use it in general. The
example from the tut is as follows:
>>> x = [1, 2, 3]
>>> y = [4, 5, 6]
>>> zipped = zip(x, y)
>>> zipped
[(1, 4), (2, 5), (3, 6)]
>>> x2, y2 = zip(*zipped)
>>> x == list(x2) and y == list(y2)
True

How would i apply the * operator in general?
Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Usefull python tutorial

2009-08-26 Thread Simon Brunning
2009/8/26 gentlestone :
> Can somebody give me an advise where I can found a really good online
> tutorial? All I found are useless.

 is really good, as I remember, as
is .

 For example no tutorial I found
> explains this piece of code:
>
>    someList = [element for element in otherList if element is not
> None]


or 

> or this example:
>
>    a = a or []

Strangely not in the tutorial:
.

-- 
Cheers,
Simon B.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Usefull python tutorial

2009-08-26 Thread Chris Rebert
On Wed, Aug 26, 2009 at 4:44 AM, gentlestone wrote:
> Can somebody give me an advise where I can found a really good online
> tutorial? All I found are useless. For example no tutorial I found
> explains this piece of code:
>
>    someList = [element for element in otherList if element is not
> None]

See http://docs.python.org/tutorial/datastructures.html#list-comprehensions

> or this example:
>
>    a = a or []

That's a bit more obscure, and I'm not entirely surprised it's not in
a tutorial:
http://docs.python.org/reference/expressions.html#boolean-operations


You might want to try the official tutorial (unless it's the one
you're complaining about):
http://docs.python.org/tutorial/index.html

I've also heard good things about Dive Into Python:
http://diveintopython.org/

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Usefull python tutorial

2009-08-26 Thread gentlestone
Can somebody give me an advise where I can found a really good online
tutorial? All I found are useless. For example no tutorial I found
explains this piece of code:

someList = [element for element in otherList if element is not
None]

or this example:

a = a or []

There are only stupid elementary examples in the tutorials I found.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PDF version of Python Tutorial?

2009-07-17 Thread Gabriel Genellina

En Fri, 17 Jul 2009 22:12:31 -0300, Dr. Phillip M. Feldman
 escribió:


Does anyone know if there is a PDF version of the Python Tutorial (URL=
http://www.python.org/doc/current/tutorial/)?


 From that page, click on the top left corner to go up one level, and
you'll see a download link.
Or, starting on http://www.python.org/doc/ you can navigate to the desired
document.

--
Gabriel Genellina

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


Re: PDF version of Python Tutorial?

2009-07-17 Thread David Robinow
On Fri, Jul 17, 2009 at 9:12 PM, Dr. Phillip M.
Feldman wrote:
>
> Does anyone know if there is a PDF version of the Python Tutorial (URL=
> http://www.python.org/doc/current/tutorial/)?

http://docs.python.org/download.html
-- 
http://mail.python.org/mailman/listinfo/python-list


PDF version of Python Tutorial?

2009-07-17 Thread Dr. Phillip M. Feldman

Does anyone know if there is a PDF version of the Python Tutorial (URL=
http://www.python.org/doc/current/tutorial/)?
-- 
View this message in context: 
http://www.nabble.com/PDF-version-of-Python-Tutorial--tp24543817p24543817.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: python tutorial

2009-06-18 Thread Carl Banks
On Jun 17, 5:36 pm, "steve"  wrote:
> >"Carl Banks"  wrote in message
> >news:2f6271b1-5ffa-4cec-81f8->>0276ad647__begin_mask_n#9g02mg7!__...__end_mask_i?a63jfad$...@p5g2000pre.googlegroups.com...
> >On Jun 15, 7:56 pm, "steve"  wrote:
> >> I was just looking at the python tutorial, and I noticed these lines:
>
> >>http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-...
>
> >> "Windows makes a distinction between text and binary files;
> >> "the end-of-line characters in text files are automatically altered
> >> "slightly when data is read or written.
>
> >> I don't see any obvious way to at docs.python.org to get that corrected:
> >> Is
> >> there some standard procedure?
>
> >What's wrong with it?
>
> >Carl Banks
>
> 1) Windows does not make a distinction between text and binary files.
>
> 2) end-of-line characters in text files are not automatically altered by
> Windows.

I agree with Robert Kern, it isn't necessary to distinguish between
Windows OS and a particular Windows runtime library for the purposes
of a tutorial.

Carl Banks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python tutorial

2009-06-18 Thread Aahz
In article ,
D'Arcy J.M. Cain  wrote:
>
>I really loved CP/M in its day but isn't it time we let go?

+1 QOTW
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"as long as we like the same operating system, things are cool." --piranha
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   >