Re: [Tutor] Any 'graphical' ways of learning Python

2018-12-11 Thread Matthew Polack
Hi Mike and everyone who replied to the tutor question re: GUI ideas for
Python.

Really value all the ideas and suggestions...that is very helpful! Thanks
for taking time to reply with so much great information.

We're just in wind down mode/rush for our close of school year ...but will
really enjoy looking through all the various links and ideas as I prepare
the coding course for 2019. Will use them, to upskill myself too.

Thanks so much!

- Matthew Polack



On Fri, Dec 7, 2018 at 6:05 AM Mike Barnett 
wrote:

> Oh, one more thing on this topic... there are tutorial videos available
> for PySimpleGUI, both basic and advanced.
>
> Basic 5 video series:
> https://www.youtube.com/playlist?list=PLl8dD0doyrvHMoJGTdMtgLuHymaqJVjzt
>
> Additional 9 in-depth videos:
> https://www.youtube.com/playlist?list=PLl8dD0doyrvHMoJGTdMtgLuHymaqJVjzt
>
>
> -mike
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>

-- 
**Disclaimer: *Whilst every attempt has been made to ensure that material 
contained in this email is free from computer viruses or other defects, the 
attached files are provided, and may only be used, on the basis that the 
user assumes all responsibility for use of the material transmitted. This 
email is intended only for the use of the individual or entity named above 
and may contain information that is confidential and privileged. If you are 
not the intended recipient, please note that any dissemination, 
distribution or copying of this email is strictly prohibited. If you have 
received this email in error, please notify us immediately by return email 
or telephone +61 3 5382 2529** and destroy the original message.*
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any 'graphical' ways of learning Python

2018-12-06 Thread Mike Barnett
Oh, one more thing on this topic... there are tutorial videos available for 
PySimpleGUI, both basic and advanced.

Basic 5 video series:
https://www.youtube.com/playlist?list=PLl8dD0doyrvHMoJGTdMtgLuHymaqJVjzt

Additional 9 in-depth videos:
https://www.youtube.com/playlist?list=PLl8dD0doyrvHMoJGTdMtgLuHymaqJVjzt


-mike

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Any 'graphical' ways of learning Python

2018-12-06 Thread Mike Barnett
I stumbled onto this mailing list when Google found a mention of PySimpleGUI in 
a thread titled: Any 'graphical' ways of learning Python.

I wanted to respond with information on PySimpleGUI and why it's ideal for 
students.

If you're teaching kids and they want to learn how to do GUIs so that their 
programs run and look like Windows programs, then the PySimpleGUI package is 
the right choice.  It runs on top of either tkinter or Qt.  With tkinter it's 
easy to also package up the program into an EXE file that they kids can give to 
friends.  There are instructions in the PySimpleGUI documentation located at 
http://www.PySimpleGUI.org.

The GitHub http://www.PySimpleGUI.com has over 130 demo programs and there is a 
Cookbook filled with Recipes that you can copy, pate and run. There is a 
section with a bunch of exercises that are part of a course that an Aussie 
teacher developed.  You'll find them posted here:
https://github.com/MikeTheWatchGuy/PySimpleGUI/tree/master/ProgrammingClassExamples

There is extensive documentation for the package http://www.PySimpleGUI.org

The experience for the first time user was designed to be a positive one, 
filled with success, with the goal of having a GUI up on the screen within FIVE 
MINUTES of starting the process of installing.

PySimpleGUI was written with students and beginners in mind.  The idea was to 
enable the creation of any GUI layout using the same full-featured GUI widgets 
that are available if you coded directly in tkinter or Qt, but done without the 
boilerplate code.  The package does all the messy work for you.  It also hides 
the concepts like callbacks that are confusing to beginners.

Take a look at a small sampling of the GUIs made.
https://github.com/MikeTheWatchGuy/PySimpleGUI/issues/1
The better ones are towards the bottom. It's a long list dating back to the 1.0 
release so the early stuff looks a little primitive.

The reviews from users have been extremely positive on Reddit and on the GitHub 
site.

Today this was posted by a user on Reddit:
I'm finding it so easy to add a quick GUI front-end to some of my Python 
scripts with PySimpleGUI. There's so much less "boilerplate" needed than with 
more traditional GUI frameworks that I find myself adding simple GUIs to 
scripts which I would just run in console mode otherwise.

There are currently two flavors of PySimpleGUI, one that uses tkinter and the 
other Qt.  The great thing about PySimpleGUI is that you can create the same 
layout that you would if you coded directly in tkinter or Qt.  All of the same 
widgets are available for use.  They are just presented in an easier to 
understand manner.  The source code created in PySimpleGUI will run on either 
tkinter or Qt platform.  The only thing you have to change is the import 
statement.

PySimpleGUI has plenty of depth of features.  The result is a powerful GIU 
framework capable of running a large variety of user interfaces including 
running in the system tray.

PySimpleGUI is actively developed and maintained.  Should you run into a 
problem, it's typically addressed the same day.

There was a clear, large gap in the GUI landscape for Python.  In order to 
write even the most primitive of GUIs, you are required to know and use skills 
that are advanced beginner / intermediate.  GUIs are often taught towards the 
end of the curriculum for this reason.

With PySimpleGUI GUIs can be taught from the beginning of the course.  Rather 
than using the command line for input/output, it's easy to use windows instead.

If you want to learn more about the overall architecture, this recent post will 
help:
https://www.reddit.com/r/Python/comments/a1mj0p/pysimplegui_under_the_hood/



@mike

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any 'graphical' ways of learning Python

2018-12-05 Thread Sarfraaz Ahmed
Hello Matthew,

Although, its not for Graphics, I have noticed that
http://www.pythontutor.com is a good place that can come in handy for
students who are new to programming.

It gives a graphical view of how memory is allocated for variables and how
functions are invoked in a program.

I have seen students strengthen their fundamental programming concepts
through the visual representation of code flow on this website.

You could try this as well.

On Wed, Dec 5, 2018 at 1:54 PM Matthew Polack <
matthew.pol...@htlc.vic.edu.au> wrote:

> Hi All,
>
> We're using Python with our Year 9 and 10 students to teach programming.
> I've started with basic console programming...doing simple games like a
> quiz game etc.
>
> Students always seem to like 'graphics'..one of the reasons things like
> 'Scratch' are so popular in schools is because of  the ready made GUI.
>
> My concern with things like 'Scratch' and 'Game Engines' is that perhaps
> kids can miss out on  learning core fundamentals...but can appreciate some
> visuals can be very motivating...
>
> Can anyone recommend any ways of integrating 'graphics' but in a simpler
> way.
>
> I've had some experience with TKinter...(which is still quite a jump for
> beginners)also can see that 'Pygame' might offer some of this...
>
> also have seen some tutorials on Udemy that encourages using the 'Turtle'.
>
> Does anything else come to find for helping kids stay engaged when they
> start to get tired of just text based console programming?
>
> Thanks for any suggestions.
>
>
> Matthew Polack | Teacher
>
> --
> **Disclaimer: *Whilst every attempt has been made to ensure that material
> contained in this email is free from computer viruses or other defects,
> the
> attached files are provided, and may only be used, on the basis that the
> user assumes all responsibility for use of the material transmitted. This
> email is intended only for the use of the individual or entity named above
> and may contain information that is confidential and privileged. If you
> are
> not the intended recipient, please note that any dissemination,
> distribution or copying of this email is strictly prohibited. If you have
> received this email in error, please notify us immediately by return email
> or telephone +61 3 5382 2529** and destroy the original message.*
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


-- 
Thanks
   -- Sarfraaz Ahmed
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any 'graphical' ways of learning Python

2018-12-05 Thread Adam Eyring
I've liked turtle and make my graphing more interesting by asking for user
input such as dimensions, then graph automatically.

One starter source for using pygame graphics is
https://inventwithpython.com/pygame/
It jumps into game writing very quickly, but provides explanations of
commands.

The one I'm working on now is using the arcade library developed by a
python college professor:
http://arcade.academy
Many many examples of code (including videos of student projects) are
provided to help you write games that resemble many of our favorites.


On Wed, Dec 5, 2018, 3:40 AM Alan Gauld via Tutor  wrote:

> On 05/12/2018 00:39, Matthew Polack wrote:
>
> > Can anyone recommend any ways of integrating 'graphics' but in a simpler
> > way.
> >
>
> Have you considered the turtle module.
>
> Its limited to drawing shapes but does give some immediate results.
> You can of course create functions to draw more sophisticated shapes
> etc. And you write the code in an ordinary IDE/editor so its a good
> transition from fully graphical scratch to fully text mode Python.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>

On Dec 5, 2018 3:40 AM, "Alan Gauld via Tutor"  wrote:

On 05/12/2018 00:39, Matthew Polack wrote:

> Can anyone recommend any ways of integrating 'graphics' but in a simpler
> way.
>

Have you considered the turtle module.

Its limited to drawing shapes but does give some immediate results.
You can of course create functions to draw more sophisticated shapes
etc. And you write the code in an ordinary IDE/editor so its a good
transition from fully graphical scratch to fully text mode Python.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any 'graphical' ways of learning Python

2018-12-05 Thread Steven D'Aprano
On Wed, Dec 05, 2018 at 11:39:49AM +1100, Matthew Polack wrote:
> Hi All,
> 
> We're using Python with our Year 9 and 10 students to teach programming.

Yay! And I see you're a fellow Aussie :-)


> I've started with basic console programming...doing simple games like a
> quiz game etc.
> 
> Students always seem to like 'graphics'..one of the reasons things like
> 'Scratch' are so popular in schools is because of  the ready made GUI.

Indeed.

Alas, graphics is one of Python's weaknesses, especially at the 
beginners' level.

The easiest to use will be the turtle module, although its fairly 
limited in what it does. Its basically a simulation of the turtle 
from the Logo programming language. Logo was cutting edge about half a 
century ago.

You might try PyGame, although I don't know how easy it will be for you 
to pre-install it for the students, or how difficult it is to use (I've 
never used it myself).

https://www.pygame.org/


Another option is PySimpleGUI:

https://pypi.org/project/PySimpleGUI/




-- 
Steve
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any 'graphical' ways of learning Python

2018-12-05 Thread Alan Gauld via Tutor
On 05/12/2018 00:39, Matthew Polack wrote:

> Can anyone recommend any ways of integrating 'graphics' but in a simpler
> way.
> 

Have you considered the turtle module.

Its limited to drawing shapes but does give some immediate results.
You can of course create functions to draw more sophisticated shapes
etc. And you write the code in an ordinary IDE/editor so its a good
transition from fully graphical scratch to fully text mode Python.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Any 'graphical' ways of learning Python

2018-12-05 Thread Matthew Polack
Hi All,

We're using Python with our Year 9 and 10 students to teach programming.
I've started with basic console programming...doing simple games like a
quiz game etc.

Students always seem to like 'graphics'..one of the reasons things like
'Scratch' are so popular in schools is because of  the ready made GUI.

My concern with things like 'Scratch' and 'Game Engines' is that perhaps
kids can miss out on  learning core fundamentals...but can appreciate some
visuals can be very motivating...

Can anyone recommend any ways of integrating 'graphics' but in a simpler
way.

I've had some experience with TKinter...(which is still quite a jump for
beginners)also can see that 'Pygame' might offer some of this...

also have seen some tutorials on Udemy that encourages using the 'Turtle'.

Does anything else come to find for helping kids stay engaged when they
start to get tired of just text based console programming?

Thanks for any suggestions.


Matthew Polack | Teacher

-- 
**Disclaimer: *Whilst every attempt has been made to ensure that material 
contained in this email is free from computer viruses or other defects, the 
attached files are provided, and may only be used, on the basis that the 
user assumes all responsibility for use of the material transmitted. This 
email is intended only for the use of the individual or entity named above 
and may contain information that is confidential and privileged. If you are 
not the intended recipient, please note that any dissemination, 
distribution or copying of this email is strictly prohibited. If you have 
received this email in error, please notify us immediately by return email 
or telephone +61 3 5382 2529** and destroy the original message.*
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any ideas why this woudn't work?

2018-08-01 Thread Alan Gauld via Tutor
On 01/08/18 14:17, Matthew Polack wrote:
>
> c:\Python>python crops3.py
> Traceback (most recent call last):
>   File "crops3.py", line 30, in 
>     filemenu.add_command(label="Show", command=self.showImg)
> NameError: name 'self' is not defined

The problem with cutting and pasting/copying code...

self is the name used for the first parameter in a
class method definition.  But you have not defined
any classes so self does not make sense.

In fact once you get past this error you will likely run into others
since self will have very strange values compared to the original
author's intent.

I suspect you might also run into other problems since you use
from tkinter import *

and

from PIL import Image...

But tkinter also has an Image class which your PIL one will
hide. If you intend to use the tkinter Image rather than the
PIL one you will be stuck.

If you use the

import tkinter as tk

approach you will avoid the ambiguity.



>
>
> I can't figure out why his works and mine doesn't
>
> Here is all my code so far...can either of you spot anything wrong?
>
> Thanks so much if you have a chance to look.

OK, But I've also CC'd it to the list since its good to keep the
discussion public so other people can benefit (and contribute)
too.

>
> Matt
>
>
>
> fromtkinter import*
> root =Tk("Crop Calculator")
> root.title("Crop Calculator")
> root.geometry("640x640+0+0")
> fromPIL importImage, ImageTk
> defdonothing():
> filewin =Toplevel(root)
> button =Button(filewin, text="Do nothing button")
> button.pack()
> defshowImg(self):
> load =Image.open('wheat.jpg')
> render =ImageTk.PhotoImage(load)
> img =Label(self, image=render)
> img.image =render
> img.place(x=0, y=0)
> defShowTxt(self):
> text =Label (self, text='Hey there')
> text.pack()
> menubar =Menu(root)
> filemenu =Menu(menubar, tearoff=0)
> filemenu.add_command(label="New", command=donothing)
> filemenu.add_command(label="Show", command=self.showImg)
> filemenu.add_command(label="Show Text", command=self.showTxt)
> filemenu.add_command(label="Save", command=donothing)
> filemenu.add_command(label="Save as...", command=donothing)
> filemenu.add_command(label="Close", command=donothing)
> filemenu.add_separator()
> filemenu.add_command(label="Exit", command=root.quit)
> menubar.add_cascade(label="File", menu=filemenu)
> editmenu =Menu(menubar, tearoff=0)
> editmenu.add_command(label="Undo", command=donothing)
> editmenu.add_separator()
> editmenu.add_command(label="Cut", command=donothing)
> editmenu.add_command(label="Copy", command=donothing)
> editmenu.add_command(label="Paste", command=donothing)
> editmenu.add_command(label="Delete", command=donothing)
> editmenu.add_command(label="Select All", command=donothing)
> menubar.add_cascade(label="Edit", menu=editmenu)
> helpmenu =Menu(menubar, tearoff=0)
> helpmenu.add_command(label="Help Index", command=donothing)
> helpmenu.add_command(label="About...", command=donothing)
> menubar.add_cascade(label="Help", menu=helpmenu)
> root.config(menu=menubar)
> # abutton = Button(root, text="Crop Prices in Australia")
> #Main Heading Labels
> #Answerlabel
> answerlabel=Label(root, text="wheatwords")
> # abutton.pack(side='left', fill='both', expand=True)
> '''
> instruction.grid(row=1, columnspan=12, sticky='ew')
> blanklabel.grid(row=2, columnspan=12, sticky='ew')
> blanklabel2.grid(row=11, columnspan=12, sticky='ew')
> '''
> wheatcost =("$5.23")
> peascost =("$3.23")
> lupenscost =("$8.23")
> barleycost =("$2.53")
> canolacost =("$9.72")
> sorghumcost =("$22.23")
> #List of Crops
> croplabel =Label(root, text="Crop Prices in Australia", fg="white",
> bg="green", font=("arial", 36, "bold"))
> instruction =Label(root, text="Please select from the following
> crops", fg="green", bg="white", font=("arial", 18, "bold"))
> wheatbutton =Button(root, text="Wheat", fg="black", bg="yellow")
> wheatprice =Label(root, text=wheatcost, fg="white", bg="black")
> peasbutton =Button(root, text="Peas", fg="white", bg="green")
> peasprice =Label(root, text=peascost, fg="white", bg="black")
> lupensbutton =Button(root, text="Lupens", fg="white", bg="brown")
> lupensprice =Label(root, text=lupenscost, fg="white", bg="black")
> barleybutton =Button(root, text="Barley", fg="white", bg="brown")
> barleyprice =Label(root, text=barleycost, fg="white", bg="black")
> canolabutton =Button(root, text="Canola", fg="white", bg="red")
> canolaprice =Label(root, text=canolacost, fg="white", bg="black")
> sorghumbutton =Button(root, text="Sorghum", fg="black", bg="ivory3")
> sorghumprice =Label(root, text=sorghumcost, fg="white", bg="black")
> blankline =Label(root, text="", bg="white")
> label_1 =Label(root, text="Type of Crop", fg="white", bg="black")
> label_2 =Label(root, text="Number of Metric Tonnes", fg="white",
> bg="black")
> entry1 =Entry(root)
> entry2 =Entry(root)
> blankline2 =Label(root, text="", bg="white")
> statusbar =Label(root, text="Copyright 2018", fg="white", bg="black",
> relief='sunken')
> wheat_image 

Re: [Tutor] Any ideas

2014-02-05 Thread Oscar Benjamin
On Mon, Feb 03, 2014 at 04:35:58PM -0800, josh Malone wrote:
 Hi, I'm very new to programming and python is my first language. I'm
 currently enrolled in a class at Oregon State University where we are
 taught to program in python. I'm stuck on one problem and i know what i
 want to do... i just have no idea how to write the program. The question is
 as follows
 
 Consider four missiles initially located at the four corners of a square
 with a side of 100m. Model their behavior if each missile moves with a
 speed of 5m/s in the direction pointing directly at the missile
 counter-clockwise from itself.
 
 I think i can do most of this, i'm just confused on how to make the spheres
 continually change their direction. I'm assuming it has something to do
 with a while loop or possibly an if statement. Any help you could give me
 would be great! thanks!

You need to give more description about what you're actually doing (or
expected to do) in your code here. I thought I was with you until you
mentioned the spheres.

Are you supposed to make an animation? Is it about numerical integration?

I would probably use numerical integration for this. The simplest way is to
use the Euler method:
http://en.wikipedia.org/wiki/Euler_method

It's common to use the Euler method as a demonstration of how to do dynamic
simulations (a more advanced tutorial might rightly scorn the method as being
inferior to proper integration techniques). Does this seem like what you need
to do?

If you're using scipy then it has a function called odeint that is a good
numerical integrator (better than the Euler method).


Oscar
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Any ideas

2014-02-04 Thread josh Malone
Hi, I'm very new to programming and python is my first language. I'm
currently enrolled in a class at Oregon State University where we are
taught to program in python. I'm stuck on one problem and i know what i
want to do... i just have no idea how to write the program. The question is
as follows

Consider four missiles initially located at the four corners of a square
with a side of 100m. Model their behavior if each missile moves with a
speed of 5m/s in the direction pointing directly at the missile
counter-clockwise from itself.

I think i can do most of this, i'm just confused on how to make the spheres
continually change their direction. I'm assuming it has something to do
with a while loop or possibly an if statement. Any help you could give me
would be great! thanks!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any ideas

2014-02-04 Thread Dave Angel
 josh Malone joshkmalon...@gmail.com Wrote in message:
 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 https://mail.python.org/mailman/listinfo/tutor
 

First thing is to figure your goal.  Model might mean anything
 from figure out how far they each go to plot the four
 trajectories in real time on a screen.  Or even make
four
 robots traverse the course till they crash into each
 other.

Next,  figure how you'd solve it by hand.  Probably that includes
 figuring how far each will go and where they'll end
 up.

Assuming the real assignment is to come up with four lists of
 coordinates, figure you'll need a loop. Python's loop constructs
 are for and while.  If you have already figured the formula for
 how long they'll take, a for loop is most reasonable,  with an
 increment of perhaps a tenth of a second.

Now please post some code, tell us what doesn't work, and make
 sure it's a text message, not html.
-- 
DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Any speech to text conversation python library for Linux and mac box

2013-06-12 Thread Ranjith Kumar
Hello all,
I'm looking for speech to text conversation python library for linux and
mac box, I found few libraries but non of them supports any of these
platform.
I found following libraries speech, dragonfly and pyspeech supports only
windows and sphinx for linux.

Any suggestion?

-- 
Cheers,
Ranjith Kumar K,
Chennai.

http://ranjithtenz.wordpress.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any book to study Python

2012-03-28 Thread Prasad, Ramit
 
  any of the tutors here can help you, not just me! :-)
 
 
  once you provide the server code and output, people may be able to
  help you better.

 Agreed. It depends on firewalls between the two IP addresses. Also, the
 Linux server may have IP tables installed which might prevent access to
 that port but allow ping.

Or (if I remember correctly) allow access to the port but not ping.

 Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Any book to study Python

2012-03-19 Thread Yan, Xianming
Hello all,

I'm a new learning to python and does not know python anything at all.

Anyone can recommend a book about python to read? I prefer a paper-based book, 
not online book. 

By the way, I'm from china, I hope the book is Chinese--:)--Reading in Chinese 
is quicker~:)

Thanks
Xianming
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any book to study Python

2012-03-19 Thread wesley chun
你好 Xianming,

I have a book --  *Python 核 心 编 程 (第二版)* -- that is for people who already
program but want to learn Python. It is available in China from at least 3
online stores:

http://www.china-pub.com/39969
http://www.amazon.cn/dp/bkbk835890
http://mall.sina.com.cn/product_1749023.htm

In the Amazon comments, it looks like there are critical replies about the
translator. Since I cannot read Chinese, I don't know about the book's
quality or translation accuracy because I write with American English, so
you should do some research to see if it is a good book. To compare, the
English one is at http://amzn.com/0132269937

Good luck!
--Wesley - 陈仲才 (陳仲才)


On Mon, Mar 19, 2012 at 12:38 AM, Yan, Xianming 
xianming@intercallapac.com wrote:

 Hello all,

 I'm a new learning to python and does not know python anything at all.

 Anyone can recommend a book about python to read? I prefer a paper-based
 book, not online book.

 By the way, I'm from china, I hope the book is Chinese--:)--Reading in
 Chinese is quicker~:)

 Thanks
 Xianming



-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Core Python, Prentice Hall, (c)2007,2001
Python Fundamentals, Prentice Hall, (c)2009
http://corepython.com

wesley.chun : wescpy-gmail.com : @wescpy/+wescpy
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any book to study Python

2012-03-19 Thread Alan Gauld

On 19/03/12 07:38, Yan, Xianming wrote:

Hello all,

I'm a new learning to python and does not know python anything at all.

Anyone can recommend a book about python to read? I prefer a paper-based book, 
not online book.

By the way, I'm from china, I hope the book is Chinese--:)--Reading in Chinese 
is quicker~:)



My book is aimed at complete beginners but is a little out of date now 
being based on Python v1.5. But it was available briefly in Chinese so 
you might be able to find a copy. It is still available in Japanese 
although that probably doesn't help much!


Here is the url:

http://www.alan-g.me.uk/book/index.htm

Or on Amazon:

http://www.amazon.com/Learn-Program-Using-Python-Self-Starters/dp/0201709384/ref=sr_1_1?ie=UTF8qid=1332145741sr=8-1

It is also available in a greatly expanded and up to date version online 
at the url below.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Any book to study Python

2012-03-19 Thread Yan, Xianming
I'm following http://docs.python.org/tutorial/interpreter.html to type in the 
first script into python.

According to the link, I typed below:

 the_world_is_flat = 1
 if the_world_is_flat:
... print Be careful not to fall off!

Then I get below output:
File stdin, line1
  Print dd
^
IndentationError:expected an indented block


This is incorrect. According to the book, I should get:
Be careful not to fall off!



Anyone can tell me where the problem is or any suggestion about it?



Thanks
Xianming
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any book to study Python

2012-03-19 Thread Brian van den Broek
On 19 Mar 2012 11:42, Yan, Xianming xianming@intercallapac.com
wrote:

 I'm following http://docs.python.org/tutorial/interpreter.html to type in
the first script into python.

 According to the link, I typed below:

  the_world_is_flat = 1
  if the_world_is_flat:
 ... print Be careful not to fall off!

 Then I get below output:
 File stdin, line1
  Print dd
^
 IndentationError:expected an indented block

Xianming,

I see you solved your problem; I am glad.

But, a comment for future messages:

Be sure to copy and paste (as in, do not retype) your code and any output
that *that* code produces. The code you show cannot have produced the
output you show. If you retype or mix and match code and output, you make
it harder to help!

Best wishes,

Brian vdB
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any book to study Python

2012-03-19 Thread Russel Winder
Xianming,

On Mon, 2012-03-19 at 18:38 +1100, Yan, Xianming wrote:
 Hello all,
 
 I'm a new learning to python and does not know python anything at all.
 
 Anyone can recommend a book about python to read? I prefer a paper-based 
 book, not online book. 
 
 By the way, I'm from china, I hope the book is Chinese--:)--Reading in 
 Chinese is quicker~:)
 
 Thanks
 Xianming

The book Sarah Mount, James Shuttleworth and I wrote Python for
Rookies is a book aimed to teach people who are not already programmers
programming using Python.  Not been translated to Chinese yet as far as
I know.  The book is Python 2.4/2.5, we are currently trying to work
with the publisher to get out a new edition that can be Python 2.7/3.2.

-- 
Russel.
=
Dr Russel Winder  t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Roadm: +44 7770 465 077   xmpp: rus...@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder



signature.asc
Description: This is a digitally signed message part
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] any cons to using a module of functions?

2012-02-03 Thread Peter Otten
Che M wrote:

 
 I have a bunch of functions that do various utility-type tasks in an
 application (such as prettifying date strings, etc.), and they are used in
 many modules.  Much of the time, I have just been lazily copying and
 pasting the functions into whichever modules need them.  I realize that is
 very bad form and I should refactor, and so I am beginning to put these
 functions in their own module so that I can import the module and its
 functions when I need it; they will all be in one place and only only
 place.
 
 My question is about resources.  Let's say I have the module, myUtils.py,
 and I import it into every other module that will need one or more of the
 functions within it.  Is this in any way costly in terms of memory? 
 (since each time I import myUtils.py I import *all* the functions, instead
 of in the cutpaste approach, where I just run the functions I need).

I hope by importing all functions you mean

import myutils

or

from myutils import foo, bar

The oh-so-convenient

from myutils import *

will sooner or later result in nasty name clashes.

 I'm fairly sure this is not at all an issue, but I just want to understand
 why it's not.

After entering the interactive interpreter (Python 2.7) I see

 import sys
 len(sys.modules)
39
 len(sys.builtin_module_names)
20

So there are already forty or sixty modules, depending on how you count; the 
memory and runtime impact of adding one more is likely negligable.

There is an effect on your processes. If you hammer up a quick and dirty 
script using your kitchen-sink myutils.py, then forget the script, and in a 
year or so need it again it's likely that myutils have evolved and your 
script will not work out of the box.
At that point it will start to pay off having unit tests in place that 
ensure a stable api and to put everything into version control.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] any cons to using a module of functions?

2012-02-03 Thread Alan Gauld

On 03/02/12 05:05, Che M wrote:


is very bad form and I should refactor, and so I am beginning to put
these functions in their own module so that I can import the module and
its functions when I need it; they will all be in one place and only
only place.


While that's tempting it is better if you use multiple modules such that 
the functions in them are related in some way. A single mixed bag of 
functions will eventually become messy to maintain. Even if some modules 
only contain a single function its a lot clearer than having a bag of bits



My question is about resources. Let's say I have the module, myUtils.py,
and I import it into every other module that will need one or more of
the functions within it. Is this in any way costly in terms of memory?


Not really, Python creates one instance of the module and all the 
importing modules refer to that instance. The only way it's wasteful is 
if you have 20 functions and only need two then you have 18 function 
objects that you don't need. (see the point above about multiple 
modules!) But even then the memory usage is unlikely to be a major issue 
since 18 function objects will generally consume minimal memory

on a modern PC.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] any cons to using a module of functions?

2012-02-02 Thread Che M

I have a bunch of functions that do various utility-type tasks in an 
application (such as prettifying date strings, etc.), and they are used in many 
modules.  Much of the time, I have just been lazily copying and pasting the 
functions into whichever modules need them.  I realize that is very bad form 
and I should refactor, and so I am beginning to put these functions in their 
own module so that I can import the module and its functions when I need it; 
they will all be in one place and only only place.

My question is about resources.  Let's say I have the module, myUtils.py, and I 
import it into every other module that will need one or more of the functions 
within it.  Is this in any way costly in terms of memory?  (since each time I 
import myUtils.py I import *all* the functions, instead of in the cutpaste 
approach, where I just run the functions I need).

I'm fairly sure this is not at all an issue, but I just want to understand why 
it's not.  

Thanks.



  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Any recommend of UML tool and UI design tool for python?

2010-12-12 Thread cajsdy
Either paid or free open source is fine.
I'm creating automation frame work. Idealy it includes:

test plan management,
test manager across windows, unix, linux, solaris and other os.
UML documentation for python scripts
IDE tool for python on windoes and linux
UI design tool for python(best is integrated with IDE)

Wonder any recommend?


On 12/11/10, David bouncingc...@gmail.com wrote:
 On 12 December 2010 03:25, John Russell t...@othala.us wrote:
 Last night I started working through a book (Beginning Python: Using
 Python
 2.6 and Python 3.1)  I bought to learn Python, and there is an example in
 it
 that doesn't make sense to me.

 I have that book too, and several others thankfully. I'm just writing
 to share my experience, in case another perspective from another
 relatively new python user is helpful to anyone.

 I found that book is written towards a friendly beginner level, but it
 omits many details and is not a comprehensive reference. It does
 include plenty of examples on many topics. I have read the opposite
 criticism of other books, so it is probably impossible for one book to
 fit all needs.

 Personally I became weary of the food/fridge/kitchen theme of the
 early examples as it did not engage my interest at all, and there is
 so much of it. However I have found that book valuable for its Part
 III where it covers useful applications. Although I have come to
 expect that its examples will often need typos corrected or other
 small modifications to get them to run properly on Python 2.6.

 So while working through Parts I and II, if your experience is
 anything like mine where I moved away from it fairly quickly, you will
 definitely need other resources. Fortunately they are abundantly
 available. In case you are unaware, a Tutorial and Reference are
 integrated with Python. On my Linux box the tutorial is
 file:///usr/share/doc/python-docs-x.x.x/html/tutorial/index.html and
 the Alphabetic Index to the Reference is
 file:///usr/share/doc/python-docs-x.x.x/html/genindex.html

 I find the Tutorial easily readable, whereas the Reference can be
 challenging, but it is comprehensive and likely contains the answer to
 most questions, somewhere.

 As an exercise I thought I'd try to find the answer to your question
 using these built-in docs. The keyword is slice which we know from
 the book. I couldn't find any coverage in the 2.6 tutorial so I looked
 up slice in the Alphabetic Index, and the first link took me to a
 section which includes the answer: The slicing now selects all items
 with index k such that i = k  j where i and j are the specified
 lower and upper bounds.

 In case you are not aware, the web has a vast amount of great material
 for learning Python, see for example:
 http://wiki.python.org/moin/BeginnersGuide/NonProgrammers
 As Python is an evolving language, one needs be mindful of the
 differences between Python 2.x and Python 3.x when using this
 material.

 My favourite Python book of my small beginners collection is Python 3
 Object Oriented Programming by Dusty Phillips. It claims:
 If you're new to object-oriented programming techniques, or if you
 have basic Python skills, and wish to learn in depth how and when to
 correctly apply object-oriented programming in Python, this is the
 book for you.
 I endorse that completely. Having learned the syntax basics elsewhere,
 for me this is a book like no other. I find its topic coverage and all
 its short examples consistently useful, powerful, and illuminating. I
 find it easy to read, well matched to my level and interest, and it
 has made a real difference to the code I write. I use classes with
 confidence now. For example, it gave me the background and confidence
 to design a custom sortable abstract class I needed, my first personal
 experience of the power of OOP.

 Tthe python and tutorial mailing lists are a wonderul resource as you
 are obviously aware. Thanks to all the contributors from whom I
 continue to learn.
 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor


-- 
Sent from my mobile device
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any recommend of UML tool and UI design tool for python?

2010-12-12 Thread Alan Gauld


cajsdy caj...@gmail.com wrote

 Either paid or free open source is fine.
I'm creating automation frame work. Idealy it includes:

test plan management,
test manager across windows, unix, linux, solaris and other os.
UML documentation for python scripts
IDE tool for python on windoes and linux
UI design tool for python(best is integrated with IDE)


Eclipse would be the logical choice and there are a few free
UML editor plug-ins. I've tried one (can't recall the name) and
although a bit clunky compared to commercoal versions it
worked fine for small class and sequence diagrams.

If you don't need full CASE modelling  facilities someting
like a drawing tool such as Dia, Visio or Smartdraw might
suffice.

If you want full CASE features (model validation, simulation,
code generation, reverse engineering fof diagrams from code, etc)
then I think you will need to pay - and probably quite a lot! I've
used both Borland Together and IBM RSA. I prefer Borland
although IBM produces prettier diagrams - but I found it a
lot less intuitive. to use. Both come as Eclipse plugins and
work with whatever version control tools Eclipse is using.

There are other standalone UML tools too but it depends how
much of UML you want to use. If it's only a few basic class diagrams,
sequence diagrams and state diagrams then prettty much
anything will do. If you need to get into the more structural
aspects of UML (deployment diagrams, components, nested states,
activity charts, use-cases etc) then you might want to look at
paying out some money.

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any recommend of UML tool and UI design tool for python?

2010-12-12 Thread Knacktus

Am 12.12.2010 19:16, schrieb Alan Gauld:


cajsdy caj...@gmail.com wrote

Either paid or free open source is fine.
I'm creating automation frame work. Idealy it includes:

test plan management,
test manager across windows, unix, linux, solaris and other os.
UML documentation for python scripts
IDE tool for python on windoes and linux
UI design tool for python(best is integrated with IDE)


Eclipse would be the logical choice and there are a few free
UML editor plug-ins. I've tried one (can't recall the name) and
although a bit clunky compared to commercoal versions it
worked fine for small class and sequence diagrams.

If you don't need full CASE modelling facilities someting
like a drawing tool such as Dia, Visio or Smartdraw might
suffice.

If you want full CASE features (model validation, simulation,
code generation, reverse engineering fof diagrams from code, etc)
then I think you will need to pay - and probably quite a lot! I've
used both Borland Together and IBM RSA. I prefer Borland
although IBM produces prettier diagrams - but I found it a
lot less intuitive. to use. Both come as Eclipse plugins and
work with whatever version control tools Eclipse is using.

There are other standalone UML tools too but it depends how
much of UML you want to use. If it's only a few basic class diagrams,
sequence diagrams and state diagrams then prettty much
anything will do. If you need to get into the more structural
aspects of UML (deployment diagrams, components, nested states,
activity charts, use-cases etc) then you might want to look at
paying out some money.



If you're willing to pay for a CASE tool then check out Enterprise 
Architect from http://sparxsystems.eu/
For the massive features I think it's reasonable priced (professional 
edition for 165 Euro + VAT).
UML-Source Code integration with Python ... I don't know if it really 
works. You would need to limit your code to pure OO-style. Such 
integration might work with Java and C# (Enterprise Architect can do 
this: Change code - update UML and vice versa). Nevertheless. 
Enterprise Architect supports Python for reverse engineering.


For designing UIs: You will need another tool. It depends on your GUI 
toolkit. If you're planning to use PyQt  as GUI toolkit (which I can 
only highly recommend) you're lucky. It has GUI designer, which is quite 
nice.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Any

2010-04-29 Thread Kevin Kirton
Hi all,

I was just wondering if anyone here can recommend any freeware program
that has been written in python and for which the source code is
available.

Basically I just want to see a program that does something relatively
simple and straightforward, but something that is real world, I mean
something that people actually use, hopefully something that comes
with it's own installer and GUI.

I'd like to try out using the program as an ordinary user and then I
want to look at the source code to see how it's been achieved.

Any ideas or suggestions?

Kevin Kirton
Australia
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any

2010-04-29 Thread Alan Gauld


Kevin Kirton kpkir...@gmail.com wrote 


I was just wondering if anyone here can recommend any freeware program
that has been written in python and for which the source code is
available.


IDLE? 
The IDE that comes with Python ias wtten in Python and the 
source comes as part of the standard library.


But if thats not enough try both sourceforge and the PyGame web sites.
On sourceforge search for projects using python... DIA is one that springs 
to mind(a Visio type drawing program)


PyGame has lots of Python games you can download, several with source.


Basically I just want to see a program that does something relatively
simple and straightforward, but something that is real world, I mean
something that people actually use, hopefully something that comes
with it's own installer and GUI.


You can use the python install tools or drive them with something 
higher level like Wize(?) or Installshield (or the free InstallMaker for 
Windows that I used to use... I don't know if its still extant however!)


HTH,


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any

2010-04-29 Thread Kevin Kirton
Christian Witts wrote:

 Maybe look through projects at Freshmeat [1].

 [1] http://freshmeat.net/tags/python

That's exactly what I was looking for. I've already selected a few
small programs and now I plan on installing them, seeing how they
operate from a user's perspective, then I'll take a look at the source
code and see what I can work out.

Thanks very much.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any

2010-04-29 Thread spir ☣
On Thu, 29 Apr 2010 13:04:20 +0100
Alan Gauld alan.ga...@btinternet.com wrote:

 IDLE? 
 The IDE that comes with Python ias wtten in Python and the 
 source comes as part of the standard library.

There's also a free software programming editor --editra, I guess-- written in 
and mainly for python. (But I would not recommend it for first tweaks, because 
it is great code but highly abstract.)

Denis


vit esse estrany ☣

spir.wikidot.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any

2010-04-29 Thread Kevin Kirton
Alan Gauld wrote:

 But if thats not enough try both sourceforge and the PyGame web sites.
 On sourceforge search for projects using python... DIA is one that springs
 to mind(a Visio type drawing program)

 PyGame has lots of Python games you can download, several with source.

PyGame looks promising (very distracting too). DIA in itself looks
quite useful and interesting, so I might learn that as a user then see
if I can look through its code.

Thanks for your help.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any

2010-04-29 Thread Steven D'Aprano
On Thu, 29 Apr 2010 08:06:30 pm Kevin Kirton wrote:
 Hi all,

 I was just wondering if anyone here can recommend any freeware
 program that has been written in python and for which the source code
 is available.

The Red Hat Package Manager (rpm) is written in Python.

The original BitTorrent application was written in Python.

The Roundup and Trac bug-trackers are both written in Python, as are the 
version-control systems Bazaar and Mercurial.

So are Mailman and Plone.

Most of these are fairly big applications though. Not huge, but big.

The Reddit website is written in Python, as is the EVE Online massive 
multiplayer game, although I doubt the source code for them are 
available.


 Basically I just want to see a program that does something relatively
 simple and straightforward, but something that is real world, I
 mean something that people actually use, hopefully something that
 comes with it's own installer and GUI.

Unfortunately, these days all the cool kids are programming web apps 
rather than desktop applications. So it's a bit hard to find 
interesting, useful desktop applications. However, you can check out 
Pygame, PythonCard and Dabo:

http://www.pygame.org/news.html
http://pythoncard.sourceforge.net/
http://dabodev.com/

Pygame is a framework for, well, programming games in Python.

Pythoncard is a desktop application based on Apple's much-loved and 
never forgotten Hypercard (may it rest in peace!).

And Dabo is based on Visual FoxPro.



-- 
Steven D'Aprano
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any

2010-04-29 Thread iamroot
 
 The Reddit website is written in Python, as is the EVE Online massive 
 multiplayer game, although I doubt the source code for them are 
 available.

Actually, Reddit has made it's source available and has included a HOWTO 
install Reddit on your webserver. There is a Google Group reddit-dev for
this purpose, as well.

See http://code.reddit.com for more...they actually use Trac for that site. ;).

--
Brie

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any

2010-04-29 Thread Alan Gauld


Steven D'Aprano st...@pearwood.info wrote

Pythoncard is a desktop application based on Apple's much-loved and 
never forgotten Hypercard (may it rest in peace!).


And Dabo is based on Visual FoxPro.


Just a caveat:

Both of these are really development tools rather than applications in 
the normal sense - although they are applications for developers of 
course! But they are much closer to Visual Studio than to MS Word...


HTH,


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-03-03 Thread Karim Liateni


Hello Alan, Steven,

I was narrow minded about this topic and did not see the benefits of 
these multiple Python

implementations. You opened my eyes.

Regards
Karim


Steven D'Aprano wrote:

On Tue, 2 Mar 2010 11:25:44 am Andreas Kostyrka wrote:
  

Furthermore I do not think that most of the core community has a
problem with the alternate implementations, as they provide very
useful functions (it helps on the architecture side, because it
limits somewhat what can be done, it helps on the personal side,
because it increases the value of Python skills, ...), ...



The Python development team values alternative implementations, as it 
gives Python the language a much wider user base.


It also allows other people to shoulder some of the development burden. 
For example, people who want Python without the limitations of the C 
call stack can use Stackless Python, instead of ordinary CPython. 
Google is sponsoring a highly optimized version of Python with a JIT 
compiler: Unladen Swallow. It looks likely that Unladen Swallow will 
end up being merged with CPython too, which will be a great benefit.



  


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-03-02 Thread Karim Liateni


Hello,

Thanks a lot for this state of the art of the language, very instructive.
I see now top of the iceberg  ;o)

Karim

Steven D'Aprano wrote:

On Tue, 2 Mar 2010 07:07:57 am Karim Liateni wrote:
  

Thanks for this precision!
I'm using standard python so this is ok!
Why people use proprietary python ?
To have more trouble ? To be different from the rest of community ?



Python is a language, but there can be many different implementations of 
that language, just like there are different C compilers or different 
Javascript engines.


CPython is the version which was made first, it is the most common 
version, but it is not the only one. It is called CPython because it is 
written in C.


Jython is a version of Python written in Java, and it was created by 
people wanting to use Python as a front-end to Java libraries, and to 
take advantage of Java's garbage collector.


IronPython is Microsoft's version of Python written for .Net and Mono.

PyPy is an experimental version of Python written in Python, used by 
people wanting to experiment with Python compilers.


Python for S60 is a version of Python written for Nokia's S60 devices.

CapPython is an experimental version of Python designed for security.

There are many others, they are all Python, but they have differences.
  


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-02-28 Thread Karim Liateni


Hello Tutor,

Since Friday I get no answers to my first post.
So I re-post it was missed by the numerous arriving email:

This is my first program in python.

I am doing electrical simulation in spectre (spice like).
I have a models file which holds many parameters and
include files of parameters. But in batch mode the automatic
construction (by the simulator) of this file is not correct.
It concatenates both parameters and include files with the same
parameters definitions. That trigs errors during simulation and
it complains about parameters double definition.

The program must removes includes files of already existing parameters 
in the models file.


The file format is shown below:

// --
// Mismatch Variations Selection
// --
parameters param1=0
parameters param2=0
parameters param3=0
parameters param4=0
// --
// Global Flags Definition
// --
parameters gflag_param = 0
// --
// Models Library Files References
// --
include /project/hvt.scs section=TT
include /project/lvt.scs section=TT
include /project/svt.scs section=TT
include /project/veriloga.scs  section=typ
include /project/switch_all.scs section=no
---

Now my code is shown below:
___

#!/usr/bin/env python
# File: correctCorners K.Liateni 2010-02-25

import re

# ---
#  Functions Declaration
# ---

def copy(infile, outfile):
  Copy of the content of an input file to an outputfile.
  fout = open(outfile, 'w')
  fout.writelines(getLines(infile))
  fout.close()

def cat(lines, outfile):
  Concat the content of a strings list to an outputfile.
  f = open(outfile, 'w')
  f.writelines(lines)
  f.close()

def getLines(file):
  Get the content of a file in a lines list form.
  f = open(file, 'r')
  lines = f.readlines()
  f.close()
  return lines

def isParamExist(file, pattern, parameters):
  Check if a particular regex pattern parameter is existing in a 
parameters file.

  lines = getLines(file)
  paramExpressions = [ e for e in lines if pattern.search(e) ]
  matchParam   = [ e for e in paramExpressions if 
pattern.search(e).group(1) in parameters ]

  if matchParam:
return True
  else:
return False

# ---
#  Main Start here
# ---

parRe = '^[ \t]*(parameters[ \t]+[^ \t]+)[ \t]*='
comRe = '^[ \t]*//'

include = re.compile(incRe)
param   = re.compile(parRe)
comment = re.compile(comRe)

lines = getLines(models.scs)

linesWithNoInclude = [ e for e in lines if not include.search(e) ]
linesWithNoParam   = [ e for e in lines if not param.search(e) and not 
comment.search(e) ]


parameters   = [ param.search(e).group(1)   for e in linesWithNoInclude 
if param.search(e) ]

includeFiles = [ include.search(e).group(1) for e in linesWithNoParam ]

includeFilesToWrite = [ e for e in includeFiles if not 
isParamExist(e, param, parameters) ]
includeFilesToWrite = [ e for e in linesWithNoParam if 
include.search(e).group(3) in includeFilesToWrite ]


cat(linesWithNoInclude+includeFilesToWrite, models_modified.scs)
copy(models_modified.scs, models.scs):

# --- end of file --- #

The code works well but I am not fully happy with it. 
includeFilesToWrite is computed in 2 steps.
I am pretty sure that it can be simplify by using a dictionnary with the 
full path file as the key
and the string 'include' nominal line expression as the value to 
construct the final file with filtered include.
I am using python 2.2 so I have not use latest feature I want my code to 
run on old Solaris too (linux user).


I use as much as possible list comprehension following your advices.

I don't like the part:
 if matchParam:
return True
  else:
return False
Is there an easy way to do the same behavior. I am not sure but I saw 
one time something like using
the int value of True (1) and False (0) to select return value in a list 
of 2 elements 'return [False,True](matchParam)'

Is it correct?

Thanks a lot
Karim


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-02-28 Thread Alan Gauld

Karim Liateni karim.liat...@free.fr wrote


It concatenates both parameters and include files with the same
parameters definitions. That trigs errors during simulation and
it complains about parameters double definition.


I'd suggest you construct a dictionary based on the param names
You can check before you add ca param if one already exists.
Or alternatively make a Set of param names and check that
for existence before adding a new one.


def copy(infile, outfile):
  Copy of the content of an input file to an outputfile.
  fout = open(outfile, 'w')
  fout.writelines(getLines(infile))
  fout.close()


Its probably easier tyo use shutil.copyfile()


def cat(lines, outfile):
  Concat the content of a strings list to an outputfile.
  f = open(outfile, 'w')
  f.writelines(lines)
  f.close()




def getLines(file):
  Get the content of a file in a lines list form.
  f = open(file, 'r')
  lines = f.readlines()
  f.close()
  return lines


I'm not sure these functions add enough value to ghave them. I';d probably 
just use


try: open(outfile,'w').writelines(lines)
except IOError: #handle error

try: lines = open(filename).readlines()
except IOError: #handle error

The close will be done automatically since you don't hold a reference to 
the file



def isParamExist(file, pattern, parameters):
  Check if a particular regex pattern parameter is existing in a 
parameters file.

  lines = getLines(file)
  paramExpressions = [ e for e in lines if pattern.search(e) ]
  matchParam   = [ e for e in paramExpressions if 
pattern.search(e).group(1) in parameters ]

  if matchParam:
return True
  else:
return False


return bool(matchParam) instead of the if/else


I am pretty sure that it can be simplify by using a dictionnary with the 
full path file as the key
and the string 'include' nominal line expression as the value to 
construct the final file with filtered include.


I think dictionaries or Sets could improve things


I don't like the part:
 if matchParam:
return True
  else:
return False


See the note above.

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-02-28 Thread Lie Ryan
On 03/01/10 01:12, Alan Gauld wrote:
 
 def getLines(file):
   Get the content of a file in a lines list form.
   f = open(file, 'r')
   lines = f.readlines()
   f.close()
   return lines
 
 I'm not sure these functions add enough value to ghave them. I';d
 probably just use
 
 try: open(outfile,'w').writelines(lines)
 except IOError: #handle error
 
 try: lines = open(filename).readlines()
 except IOError: #handle error
 
 The close will be done automatically since you don't hold a reference to
 the file

Remember why we have the new with-block? It's precisely because files
will be automagically closed only if we're running on CPython; Python
the language and thus alternative implementations doesn't guarantee
automatic closing. I'd agree with the function having minimal utility
value though:

with open(file) as f:
lines = f.readlines()
# f.close() will be called by the context manager

and if you're just copying to another file:

from contextlib import nested
with nested(open(infile), open(outfile, 'w')) as (fin, fout):
fout.write(fin.read())

or even better, as Alan suggested, using shutil.copyfile().

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-02-28 Thread Karim Liateni

Lie Ryan wrote:

On 03/01/10 01:12, Alan Gauld wrote:
  

def getLines(file):
  Get the content of a file in a lines list form.
  f = open(file, 'r')
  lines = f.readlines()
  f.close()
  return lines
  

I'm not sure these functions add enough value to ghave them. I';d
probably just use

try: open(outfile,'w').writelines(lines)
except IOError: #handle error

try: lines = open(filename).readlines()
except IOError: #handle error

The close will be done automatically since you don't hold a reference to
the file



Remember why we have the new with-block? It's precisely because files
will be automagically closed only if we're running on CPython; Python
the language and thus alternative implementations doesn't guarantee
automatic closing. I'd agree with the function having minimal utility
value though:

with open(file) as f:
lines = f.readlines()
# f.close() will be called by the context manager

and if you're just copying to another file:

from contextlib import nested
with nested(open(infile), open(outfile, 'w')) as (fin, fout):
fout.write(fin.read())

or even better, as Alan suggested, using shutil.copyfile().

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

  
Thank you Lie but I have a restriction on the python version I must use 
v2.2.

This feature is available only on later version 2.5 I believe.

Regards
Karim

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-02-28 Thread Lie Ryan
On 03/01/10 02:49, Karim Liateni wrote:
 Lie Ryan wrote:
 On 03/01/10 01:12, Alan Gauld wrote:
   
 def getLines(file):
   Get the content of a file in a lines list form.
   f = open(file, 'r')
   lines = f.readlines()
   f.close()
   return lines
   
 I'm not sure these functions add enough value to ghave them. I';d
 probably just use

 try: open(outfile,'w').writelines(lines)
 except IOError: #handle error

 try: lines = open(filename).readlines()
 except IOError: #handle error

 The close will be done automatically since you don't hold a reference to
 the file
 

 Remember why we have the new with-block? It's precisely because files
 will be automagically closed only if we're running on CPython; Python
 the language and thus alternative implementations doesn't guarantee
 automatic closing. I'd agree with the function having minimal utility
 value though:

 with open(file) as f:
 lines = f.readlines()
 # f.close() will be called by the context manager

 and if you're just copying to another file:

 from contextlib import nested
 with nested(open(infile), open(outfile, 'w')) as (fin, fout):
 fout.write(fin.read())

 or even better, as Alan suggested, using shutil.copyfile().

 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor

   
 Thank you Lie but I have a restriction on the python version I must use
 v2.2.
 This feature is available only on later version 2.5 I believe.

Then you should at the least use the try-finally block, I think that one
has been there since 2.2? If you didn't use try-finally, there is no
guarantee that f.close() would be called if an exception happened in the
middle of reading/writing (e.g. KeyboardInterrupt, or perhaps user
plugging off the thumbdrive, or bit more realistic having a full
harddisk or exceeded some disk quota)

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-02-28 Thread Karim Liateni

Lie Ryan wrote:

On 03/01/10 02:49, Karim Liateni wrote:
  

Lie Ryan wrote:


On 03/01/10 01:12, Alan Gauld wrote:
  
  

def getLines(file):
  Get the content of a file in a lines list form.
  f = open(file, 'r')
  lines = f.readlines()
  f.close()
  return lines
  
  

I'm not sure these functions add enough value to ghave them. I';d
probably just use

try: open(outfile,'w').writelines(lines)
except IOError: #handle error

try: lines = open(filename).readlines()
except IOError: #handle error

The close will be done automatically since you don't hold a reference to
the file



Remember why we have the new with-block? It's precisely because files
will be automagically closed only if we're running on CPython; Python
the language and thus alternative implementations doesn't guarantee
automatic closing. I'd agree with the function having minimal utility
value though:

with open(file) as f:
lines = f.readlines()
# f.close() will be called by the context manager

and if you're just copying to another file:

from contextlib import nested
with nested(open(infile), open(outfile, 'w')) as (fin, fout):
fout.write(fin.read())

or even better, as Alan suggested, using shutil.copyfile().

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

  
  

Thank you Lie but I have a restriction on the python version I must use
v2.2.
This feature is available only on later version 2.5 I believe.



Then you should at the least use the try-finally block, I think that one
has been there since 2.2? If you didn't use try-finally, there is no
guarantee that f.close() would be called if an exception happened in the
middle of reading/writing (e.g. KeyboardInterrupt, or perhaps user
plugging off the thumbdrive, or bit more realistic having a full
harddisk or exceeded some disk quota)

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

  

Thank you Lie.
Yes, in fact I did it all the time during my years of Java development.
In perl I used or open() or die( msg ) structure.
I bypassed it because I wanted to construct the blocs very quickly like 
a 'beginner'.
I was excited to make it work as fast as ossible to see if I can program 
something

decent in Python. (gaining confidence? haaa human nature!).

I definitely enjoy python (and not very far in spirit my loving Lisp).
I definitely HATE tcl, java.

Now I will improve quality and robustness.

Thanks a lot!

Karim

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-02-28 Thread Alan Gauld


Karim Liateni karim.liat...@free.fr wrote


def getLines(file):
  try: lines = open(filename).readlines() ; return lines
  except IOError: #handle error


but in the second 'lines = open(filename).readlines()'
I don't hold indirectly a reference to the file? Please, could you 
explain more this point?


Sure, the lines variable holds a reference to the list returned by 
readlines.

There is no variable referring to the file object so immediately after
readlines completes the file will be ready to be closed (at least in
CPython as already pointed out by Lie)

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Any one got any idea

2009-10-18 Thread nitin chandra
Hello Everyone,

i am compiling Python 2.6.2 from source and have successfully been
able to cross  at least that is what i am thinking .
./configure and make  but i am facing a peculiar problem in
installing it this time. (This is the second time i am installing on
the same system with as much as similar structure like before 
this was required as i had to install Tcl / Tk 8.5 + Tix 8.4.3
--with-threads... on FC10 ... which does not have Tcl/Tk 8.5 with
threads enabled in the default install.)

Compiling /opt/python262/lib/python2.6/xmllib.py ...
Compiling /opt/python262/lib/python2.6/xmlrpclib.py ...
Compiling /opt/python262/lib/python2.6/zipfile.py ...
[17894 refs]
make: *** [libinstall] Error 1
[r...@mi Python-2.6.2]#

This is enabled in Modules/Setup

# Andrew Kuchling's zlib module.
# This require zlib 1.1.3 (or later).
# See http://www.gzip.org/zlib/
zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz


'zipfile.py' also exist in in the source dir .../Python-2.6.2/Lib/


Thanks

Nitin
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any one got any idea

2009-10-18 Thread nitin chandra
On Mon, Oct 19, 2009 at 1:58 AM, nitin chandra nitinchand...@gmail.com wrote:
 Hello Everyone,

 i am compiling Python 2.6.2 from source and have successfully been
 able to cross  at least that is what i am thinking .
 ./configure and make  but i am facing a peculiar problem in
 installing it this time. (This is the second time i am installing on
 the same system with as much as similar structure like before 
 this was required as i had to install Tcl / Tk 8.5 + Tix 8.4.3
 --with-threads... on FC10 ... which does not have Tcl/Tk 8.5 with
 threads enabled in the default install.)
 On running 'make install' i am getting the following error :-

 Compiling /opt/python262/lib/python2.6/xmllib.py ...
 Compiling /opt/python262/lib/python2.6/xmlrpclib.py ...
 Compiling /opt/python262/lib/python2.6/zipfile.py ...
 [17894 refs]
 make: *** [libinstall] Error 1
 [r...@mi Python-2.6.2]#

 This is enabled in Modules/Setup

 # Andrew Kuchling's zlib module.
 # This require zlib 1.1.3 (or later).
 # See http://www.gzip.org/zlib/
 zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz


 'zipfile.py' also exist in in the source dir .../Python-2.6.2/Lib/


 Thanks

 Nitin

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any one got any idea

2009-10-18 Thread David

nitin chandra wrote:

On Mon, Oct 19, 2009 at 1:58 AM, nitin chandra nitinchand...@gmail.com wrote:

Hello Everyone,

i am compiling Python 2.6.2 from source and have successfully been
able to cross  at least that is what i am thinking .
./configure and make  but i am facing a peculiar problem in
installing it this time. (This is the second time i am installing on
the same system with as much as similar structure like before 
this was required as i had to install Tcl / Tk 8.5 + Tix 8.4.3
--with-threads... on FC10 ... which does not have Tcl/Tk 8.5 with
threads enabled in the default install.)
On running 'make install' i am getting the following error :-


You are on the wrong list, try the Fedora mail list [1] or irc [2]
[1] https://www.redhat.com/mailman/listinfo/fedora-list
[2] http://fedoraproject.org/wiki/Communicate#IRC
--
David Abbott (dabbott)


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] any best practice on how to glue tiny tools together

2009-02-06 Thread Daniel
Hi Tutors,

I want to use python to finish some routine data processing tasks
automatically (on Windows).

The main task could be split to sub small tasks. Each can be done by
executing some small tools like awk or by some other python scripts.
One example of such task is conducting a data processing job, including:

   1. use tool-A to produce some patterns.
   2. feed tool-B with these patterns to mine more related data
   3. repeat these tasks circularly until meeting some conditions.

The real task includes more tools which run in parallel or sequential
manner.

I know how to do this with modules like subprocess, but the final python
program looks somewhat messy and hard to adapt for changes.

Do you have any best practices on this?

Thanks a lot,
Danny
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] any best practice on how to glue tiny tools together

2009-02-06 Thread spir
Le Fri, 6 Feb 2009 06:44:11 -0500,
Kent Johnson ken...@tds.net a écrit :

 My first thought was, use shell pipelines and bash. Then I remembered,
 David Beazley shows how to use generators to implement a processing
 pipeline in Python:
 http://www.dabeaz.com/generators-uk/

see also
http://en.wikipedia.org/wiki/Python_Pipelines

--
la vida e estranya
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] any best practice on how to glue tiny tools together

2009-02-06 Thread Kent Johnson
On Fri, Feb 6, 2009 at 7:21 AM, spir denis.s...@free.fr wrote:

 see also
 http://en.wikipedia.org/wiki/Python_Pipelines

That looks pretty dead, or at least unpublished. The google code
project is almost two years old but it contains no code.

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] any best practice on how to glue tiny tools together

2009-02-06 Thread bob gailer

spir wrote:

Le Fri, 6 Feb 2009 06:44:11 -0500,
Kent Johnson ken...@tds.net a écrit :

  

My first thought was, use shell pipelines and bash. Then I remembered,
David Beazley shows how to use generators to implement a processing
pipeline in Python:
http://www.dabeaz.com/generators-uk/



see also
http://en.wikipedia.org/wiki/Python_Pipelines
  


Thank you for the plug! The code is currently in flux so not available. 
I hope to have an alpha version out soon.


--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] any best practice on how to glue tiny tools together

2009-02-06 Thread bob gailer

Kent Johnson wrote:

On Fri, Feb 6, 2009 at 7:21 AM, spir denis.s...@free.fr wrote:

  

see also
http://en.wikipedia.org/wiki/Python_Pipelines



That looks pretty dead, or at least unpublished. The google code
project is almost two years old but it contains no code.
  


It is sluggish but not dead. The code is on my PC - not ready to 
release. I started the google code to help establish the project. Since 
development is voluntary right now it is slow. Keep tuned...


FWIW I was on target for an alpha version when I got sidetracked by 
writing a universal parser which I am now finalizing.


Assistants are always welcome.

--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] any best practice on how to glue tiny tools together

2009-02-06 Thread Kent Johnson
On Fri, Feb 6, 2009 at 4:11 AM, Daniel daniel.chaow...@gmail.com wrote:
 Hi Tutors,

 I want to use python to finish some routine data processing tasks
 automatically (on Windows).

 The main task could be split to sub small tasks. Each can be done by
 executing some small tools like awk or by some other python scripts.
 One example of such task is conducting a data processing job, including:

 use tool-A to produce some patterns.
 feed tool-B with these patterns to mine more related data
 repeat these tasks circularly until meeting some conditions.

 The real task includes more tools which run in parallel or sequential
 manner.

 I know how to do this with modules like subprocess, but the final python
 program looks somewhat messy and hard to adapt for changes.

 Do you have any best practices on this?

My first thought was, use shell pipelines and bash. Then I remembered,
David Beazley shows how to use generators to implement a processing
pipeline in Python:
http://www.dabeaz.com/generators-uk/

It's a fascinating read, it might take a couple of times to get it but
it might fit your needs quite well. You would write a generator that
wraps a subprocess call and use that to access external tools; other
pieces and the control logic would be in Python.

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] any best practice on how to glue tiny tools together

2009-02-06 Thread Daniel
These are really valuable info. I will try.

Thanks a lot.

On Fri, Feb 6, 2009 at 7:44 PM, Kent Johnson ken...@tds.net wrote:

  On Fri, Feb 6, 2009 at 4:11 AM, Daniel daniel.chaow...@gmail.com wrote:
  Hi Tutors,
 
  I want to use python to finish some routine data processing tasks
  automatically (on Windows).
 
  The main task could be split to sub small tasks. Each can be done by
  executing some small tools like awk or by some other python scripts.
  One example of such task is conducting a data processing job, including:
 
  use tool-A to produce some patterns.
  feed tool-B with these patterns to mine more related data
  repeat these tasks circularly until meeting some conditions.
 
  The real task includes more tools which run in parallel or sequential
  manner.
 
  I know how to do this with modules like subprocess, but the final python
  program looks somewhat messy and hard to adapt for changes.
 
  Do you have any best practices on this?

 My first thought was, use shell pipelines and bash. Then I remembered,
 David Beazley shows how to use generators to implement a processing
 pipeline in Python:
 http://www.dabeaz.com/generators-uk/

 It's a fascinating read, it might take a couple of times to get it but
 it might fit your needs quite well. You would write a generator that
 wraps a subprocess call and use that to access external tools; other
 pieces and the control logic would be in Python.

 Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Any Windows users help reproing IDLE bug 3841?

2008-09-19 Thread Stephen McInerney

Can a couple of Vista and XP users please test this out?
Thanks - Stephen
_
 
Could anyone help reproing this minor IDLE 
bug?http://bugs.python.org/issue3841I found it on Windows Vista with Python 2.5 
/ IDLE 1.2.2.Other people have reported it does NOT occur with either:Win XP / 
Python 2.5 / Idle 1.2 Mac OS X 10.5.4 / Python 2.5.2 / IDLE 1.2.2Can anyone 
repro it on Vista on 2.5? Vista on 2.6?Please let me know if you can/cannot 
repro on a combination of each of these:OS: Windows XP (SP2?), Windows Vista 
(SP1?), LinuxPython version: 2.5, 2.6, 2.7, 3.0IDLE versions: ? Copy-and-paste 
the testcase, view it inside IDLE and see what if the issue occurs.Should only 
take 1 minute. Thanks in advance,Stephen
_
Stay up to date on your PC, the Web, and your mobile phone with Windows Live.
http://clk.atdmt.com/MRT/go/msnnkwxp1020093185mrt/direct/01/___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any Italian speakers?

2008-08-05 Thread simone

Alan Gauld ha scritto:


---
voglio chiderti solo 1 cosa ... ma secondo te qualle e il miglior 
programma X programmare???

grazie ...

da Cristian
-


Literally:

---
I want to ask you only one thing... what's in your opinion the best 
program to program?


from Cristian
---

--
Simone


Chiacchiera con i tuoi amici in tempo reale! 
http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com 


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any Italian speakers?

2008-08-04 Thread Hansen, Mike

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Alan Gauld
 Sent: Sunday, August 03, 2008 4:55 PM
 To: tutor@python.org
 Subject: [Tutor] Any Italian speakers?
 
 I received this message which Google tells me is Italian but then 
 only gives a partial translation...
 
 Can anyone help?
 
 ---
 voglio chiderti solo 1 cosa ... ma secondo te qualle e il 
 miglior programma X programmare???
 grazie ...
 
 da Cristian
 -
 
 Alan G.

Alan,

Unfortunately, I only speak and read/write English.

Did you find anyone to traslate? I plugged it into Bablefish and tried Italian 
to English and here's what I got.(Probably the same as you.).

I want chiderti only 1 thing... but according to you qualle and better program 
X to program? thanks 

I also tried Spanish, Potuguese, and Greek, but the Italian one came out the 
best.

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any Italian speakers?

2008-08-04 Thread Alan Gauld
Hansen, Mike [EMAIL PROTECTED] wrote 

Did you find anyone to traslate? 


Yes thanks, Daniele (sp?) replied with a translation.
There are some Italian idiomatic things there so it confused 
Google (and Babelfish!)


I want chiderti only 1 thing... but according to you qualle 
and better program X to program? thanks 


Exactly what Google said...

It seems the reader wants to know which is the best 
programming language...


Thanks anyway,

Alan G.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Any Italian speakers?

2008-08-03 Thread Alan Gauld
I received this message which Google tells me is Italian but then 
only gives a partial translation...


Can anyone help?

---
voglio chiderti solo 1 cosa ... ma secondo te qualle e il 
miglior programma X programmare???

grazie ...

da Cristian
-

Alan G.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any way of monitoring a python program's memory utilization?

2008-07-17 Thread Monika Jisswel

 I'm iterating through a vey large tarfile (uncompressed, it would be about
 2.4G, with about 2.5 million files in it) and I can see from some external
 monitors that its virtual storage usage just grows and grows, until my
 whole system finally grinds to a halt after about 1.2 million members have
 been processed.


Well, you can check whether your system has reached its limits or not, but
what for ? it will lead you no where as the only sthing you can do is stop
your program (while MEM_stat = 1G: parse(); else: break)  you don't get
anything done.  I believe installing more memroy in your system is the way
to go, you need to have at least 3G of Memory (memory is cheap these days),
then don't let python use it as you don't know how much memory it will need
for your program's internal routines, but create a virtual drive in memory
(RAM DRIVE) extract the tar file into it   parse its content as you wish
(ofcourse you can use harddrive too ut its gona be VERY slow (specialy on
Windows)).
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any way of monitoring a python program's memory utilization?

2008-07-17 Thread Terry Carroll
On Thu, 17 Jul 2008, Monika Jisswel wrote:

 Well, you can check whether your system has reached its limits or not, but
 what for ? 

So I can debug the problem.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any way of monitoring a python program's memory utilization?

2008-07-17 Thread Monika Jisswel
I see no problem, if you open very BIG files then your memory will get
filled up  your system will halt,
can you buy more food than your fridge can handle , and write to a list
asking to invistigate the problem ?

2008/7/17 Terry Carroll [EMAIL PROTECTED]:

 On Thu, 17 Jul 2008, Monika Jisswel wrote:

  Well, you can check whether your system has reached its limits or not,
 but
  what for ?

 So I can debug the problem.

 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any way of monitoring a python program's memoryutilization?

2008-07-17 Thread Alan Gauld

Monika Jisswel [EMAIL PROTECTED] wrote...
I see no problem, if you open very BIG files then your memory will 
get

filled up  your system will halt,


Only if you were to foolishly read the whole file into memory at once.
Early computers only had memories of a few kilobytes but could
process files much larger than that  - I recall using one with
only 16K RAM and no hard drive( a server not a home computer)
that was able to process data files of several megabytes. And
many PC databases are 10's of GB in size and a database is
no more than a few very big files. Given that many PCs have
a hardware upper memory limit of 2G and 32bit processors
a limit of 4G that would make life very difficult if we were 
restricted

in file size by the RAM available.

You just have to make sure you read the files in small chunks.
and process each chunk in turn. (A technique usually referred to
as paging.) In python the chunk size is usually a line... There is
only a problem if you try saving all of the lines into a collection
of some sort


So I can debug the problem.


The problem he is trying to debug is why the files are using up
his memory when he (presumably) was not expecting them to
fill it. To use the fridge analogy, why is the fridge still full after
I've eaten all the food?

Alan G. 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any way of monitoring a python program's memory utilization?

2008-07-17 Thread Terry Carroll
On Thu, 17 Jul 2008, Monika Jisswel wrote:

 I see no problem, if you open very BIG files then your memory will get
 filled up  your system will halt,

I'm going to disagree with you on this one.

First, in general, it is not the case that opening a very large file will 
cause memory to be filled up. In general, only the portion of the file 
that is being processed needs to actually be in memory.  A tarfile appears 
to be an exception to that general rule.  The question is, why?  Can that 
exception be avoided and a program that's processing a tar file be as 
well-behaved in terms of resource consumption as a program that processes 
other types of files?

Second, although most resource constraint problems can often be addressed 
by buying more resource, that's not usually a good approach.  Where, as 
here, the resource constraint surfaces only in rare cases (i.e., 
processing a tarfile), the better approach is to find out if something is 
out of whack with respect to that one case.  

Simply adding resources is a poor use of, um, resources, for a couple
reasons.  I'd rather spend my money on a nice dinner than on adding memory
to a computer system that is perfectly adequate in every other way, other
than in processing a single file.  And adding resources, whether memory, 
disk, or CPU, is a band-aid: it gets you over this hump, but not the next.  
If I add enough memory to process a 4-Gb file, great, I can now process a 
4-Gb file.  But if I get a 6-Gb file in a couple months, I have to pull 
out the checkbook again.

But managing the resource utilization is a scalable scheme.

 can you buy more food than your fridge can handle , and write to a list
 asking to invistigate the problem ?

This is such an off-the wall analogy that it's difficult to respond to, 
but what the heck.

First, I'm not writing to the list to ask it to investigate the problem.  
I'm writing to the list to find out what tools are available so that *I*
can investigate the problem.

Second, under this analogy, you're looking at a scenario where food is 
put into a refrigerator in containers, and when consumed, the containers 
are left in the refrigerator.  Now, your solution here might be to keep 
buying more or larger refrigerators.  Mine would be to see if I can get 
rid of all the empty containers that are uselessly occupying space in the 
refrigerator, so I can utilize the space for useful purposes 
(refrigerating food) rather than chilling empty containers for no reason.

Back to the real Python case: now that I can monitor my memory usage, I
can try various strategies to solve the problem, and I can do it with a
subset of data.  Instead of running the program on a 4Gb file and waiting
to see if it blows up or halts my system in 15 minutes after processing a
couple gig, I can run it with a much smaller 60 Mb file, and track its
effects.

For anyone who cares about the real issue: it seems that tarfile.py caches
every member it processes in an internal list.  The list isn't actually
used if accessing the file as an iterator, so by reinitializing it to [],
the memory consumption problem is avoided.  This breaks other methods of
the module, which are used to extract particular desired members, but in
my case, that's okay.  I'm currently experimenting to see if I can come up
with a patch that will either allow both means of accessing the members
(as an iterator and directly), or, as a less desirable alternative, if a
parameter like cache=False is specified, allow access as an iterator and
raise an exception if the other methods are used.

Thanks to a couple tarfile.py experts on comp.lang.python for their 
insight on this.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any way of monitoring a python program's memory utilization?

2008-07-17 Thread Monika Jisswel
I m really sorry if no one of you liked/agreed with the fridge analogy but
that's what my brain could come up with at the time, I have to say it's not
a very scientific argument. but I only meant to say that if you are piping
data into memory  this data is larger than that memory then there is no
problem with the code but with the data,  I think this paragraph actually
confirms some of it :

For anyone who cares about the real issue: it seems that tarfile.py caches
 every member it processes in an internal list.  The list isn't actually
 used if accessing the file as an iterator, so by reinitializing it to [],
 the memory consumption problem is avoided.  This breaks other methods of
 the module, which are used to extract particular desired members, but in
 my case, that's okay.


but I have to admit I was completely wrong and a new patch to the tarfile
module will soon see the light to fix this problem for the rest of ur lives
painlessly.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Any way of monitoring a python program's memory utilization?

2008-07-16 Thread Terry Carroll
Is there any way of having my program see how much memory it's using?

I'm iterating through a vey large tarfile (uncompressed, it would be about
2.4G, with about 2.5 million files in it) and I can see from some external
monitors that its virtual storage usage just grows and grows, until my
whole system finally grinds to a halt after about 1.2 million members have
been processed.

I'd like to try various strategies, but as I try them I'd like for it to 
monitor its own memory usage so I can assess the different strategies I 
use, and in any event, abort before it gets to the point of hanging my 
system.

Is there anything within Python (I'm on 2.5) that can check this?  Failing 
that, are there any Windows/XP line-oriented commands that I could invoke 
and parse the output of?  (I also have Cygwin installed, in case there are 
any gnu-based commands that woudl work, too.)

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any way of monitoring a python program's memory utilization?

2008-07-16 Thread Alan Gauld

Terry Carroll [EMAIL PROTECTED] wrote

Is there anything within Python (I'm on 2.5) that can check this? 
Failing
that, are there any Windows/XP line-oriented commands that I could 
invoke
and parse the output of?  (I also have Cygwin installed, in case 
there are

any gnu-based commands that woudl work, too.)


With cygwin you should have top, vmstat and of course ps.
All of these can monitor system status,. top being very similar to
XPs Task Manager process view but in a text window. vmstat will
not tell you process IDs, just report total usage. And ps is single
shot so you could run it (via subprocess, say) after processing each
100 files or somesuch

Take your pick...

Alan G 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any way of monitoring a python program's memory utilization?

2008-07-16 Thread Terry Carroll
On Wed, 16 Jul 2008, Terry Carroll wrote:

 The obvious thing to do is to also filter by PID, which is the second 
 element; Of course that opens a new question: how to find one's own PID 
 from within Python.  More googling awaits.

And, while searching for that, I found out hwo to find memory utilization.  
For those who care:

def memusage():
import win32process
current_process = win32process.GetCurrentProcess()
memory_info = win32process.GetProcessMemoryInfo(current_process)
return memory_info[WorkingSetSize]


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Any Good book for python

2007-01-04 Thread deepak shingan
Hi Folks, 

I am new in Python area and want to know Python concepts with more deatils. 
Please suggest some good books on python.


Thanks in Advance
-Deepak

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com ___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any Good book for python

2007-01-04 Thread Arun Kumar PG

Python in a nutshell is a good one. Also Python docs are the all time
favorite.

On 1/4/07, deepak shingan [EMAIL PROTECTED] wrote:


Hi Folks,

I am new in Python area and want to know Python concepts with more
deatils.
Please suggest some good books on python.


Thanks in Advance
-Deepak


  **




__
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any Good book for python

2007-01-04 Thread stv
 I am new in Python area and want to know Python concepts with more deatils.
 Please suggest some good books on python.

Beginning Python, by Hetland is excellent for almost any level (I
think someone who has really mastered one language, and is currently
working as a programmer, can simply read Guido's tutorial  use the
online docs).

Hetland doesn't talk down to beginner, non-programmer types, nor does
he hide hard stuff; he makes it accessible. It also talks about how to
program in general, how to attack problems, test, have fun.It's well
indexed and organized, so it's a good reference for the noob, but as
yo gain experience with Python you will migrate to the on-line docs. I
have to say, however, that in the first weeks I used the book as a
reference more than I used the on-line docs.

Diving into Python, by Pilgrim has a lot of respect. It's available on-line
  http://diveintopython.org/index.html

It is a Python book for experienced programmers. Which, I assume,
means experienced non-Python programmers.

I learn via immersion research  doing, I've read a lot of computer
books, and Hetland's is really quite good. I'll read Pilgrim's book in
the near future.

In general (with the notable exception of the Plone book) I've found
the Apress materials excellent. (Both books happen to be Apress, no
I'm not affiliated in any way).

--stv
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] any win32com experts out there?

2006-11-17 Thread Orri Ganel
Hello again.  As I've mentioned in the last couple of emails, I'm having 
trouble registering iTunes for events, and I don't know if it's a bug 
with iTunes or with win32com, or if there's something I'm doing wrong.  
So, if any win32com gurus out there know why the following doesn't work 
and how to change it so it does work, a tip would be much appreciated.

  import win32com.client
  class iTunesEvents:
def __init__(self):
print starting iTunesEvents
def OnPlayerPlayEvent(self, track):
print playing
def OnPlayerStopEvent(self, track):
print stopped
def OnDatabaseChangedEvent(self, deleted, changed):
print database changed
def OnPlayerPlayingTrackChangedEvent(self, track):
print info on current track changed
def OnCOMCallsDisabledEvent(self, reason):
print com calls disabled
def OnCOMCallsEnabledEvent(self):
print com calls enabled
def OnQuittingEvent(self):
print quitting
def OnAboutToPromptUserToQuitEvent(self):
print prompting user to quit
def OnSoundVolumeChangedEvent(self, newvolume):
print volume changed

   
  iTunes = win32com.client.gencache.EnsureDispatch(iTunes.Application)
  iTEvents = win32com.client.WithEvents(iTunes, iTunesEvents)
starting iTunesEvents
  iTunes.Play()
  iTunes.Pause()
  iTunes.Play()
  iTunes.Pause()

iTunes did, in fact, play and pause as expected, but as can be seen, no 
events were caught.

Stumped,
Orri


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] any win32com experts out there?

2006-11-17 Thread Alan Gauld
I'm no expert but I get the same response when I tried it.

I googled a bit and found this long chain of useful looking stuff:

http://www.velocityreviews.com/forums/t345123-how-to-receive-events-eg-user-mouse-clicks-from-ie.html

One possibility mentioned at the end is:


Adding win32gui.PumpWaitingMessages() to the wait loop
seems to allow both event hooks to run without blocking each other.

But it discusses IE not iTunes so it may not be relevant...

Alan G.

Orri Ganel [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hello again.  As I've mentioned in the last couple of emails, I'm 
 having
 trouble registering iTunes for events, and I don't know if it's a 
 bug
 with iTunes or with win32com, or if there's something I'm doing 
 wrong.
 So, if any win32com gurus out there know why the following doesn't 
 work
 and how to change it so it does work, a tip would be much 
 appreciated.

  import win32com.client
  class iTunesEvents:
def __init__(self):
print starting iTunesEvents
def OnPlayerPlayEvent(self, track):
print playing
def OnPlayerStopEvent(self, track):
print stopped
def OnDatabaseChangedEvent(self, deleted, changed):
print database changed
def OnPlayerPlayingTrackChangedEvent(self, track):
print info on current track changed
def OnCOMCallsDisabledEvent(self, reason):
print com calls disabled
def OnCOMCallsEnabledEvent(self):
print com calls enabled
def OnQuittingEvent(self):
print quitting
def OnAboutToPromptUserToQuitEvent(self):
print prompting user to quit
def OnSoundVolumeChangedEvent(self, newvolume):
print volume changed


  iTunes = 
  win32com.client.gencache.EnsureDispatch(iTunes.Application)
  iTEvents = win32com.client.WithEvents(iTunes, iTunesEvents)
 starting iTunesEvents
  iTunes.Play()
  iTunes.Pause()
  iTunes.Play()
  iTunes.Pause()

 iTunes did, in fact, play and pause as expected, but as can be seen, 
 no
 events were caught.

 Stumped,
 Orri


 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor
 


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Any stuff about python interpreter design ?

2006-03-09 Thread Bo Yang
Hello ,
I have learned and used python half a year , and I like this language
very much . I used it in my web server page , in my homework and
part-tiem job .
Recently , I feel very interested in the python interpreter .
So I take a look into the source code .But I get confused about
so many files and functions .
I want to ask that is there any stuff about the interpreter
design and coding ?

Thanks in advance !

Regards !
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any stuff about python interpreter design ?

2006-03-09 Thread Danny Yoo
 So I take a look into the source code .But I get confused about so many
 files and functions . I want to ask that is there any stuff about the
 interpreter design and coding ?

[meta: my reply is really about Scheme, not Python.  My apologies to the
list, but it's my honest answer.]

Hi Bo,

There are several books and online material about the writing of
interpreters.  The ones that I'm most aware aware of that are aimed at
beginner programmers, though, target the language 'Scheme'.  The core
Scheme language has a fairly minimal syntax and semantics, and it's simple
enough that it's not too bad for beginner to understand (and write!) a
usable Scheme interpreter.

So you may find it useful to learn about interpreters by looking at Scheme
interpreters.  And even though it's not Python, it's still very related
and applicable; if you have a model of how a Scheme interpreter works,
you'll be better equipped to understand in general how interpreters work.


For example, the textbook How to Design Programs:

http://www.htdp.org/

starts covering the evaluation of a programming language by about Chapter
14:

http://www.htdp.org/2003-09-26/Book/curriculum-Z-H-19.html#node_sec_14.4


Here are other Scheme resources about interpretation (the first two links
contain online books):

http://mitpress.mit.edu/sicp/
http://www.cs.brown.edu/~sk/Publications/Books/ProgLangs/
http://www.cs.indiana.edu/eopl/
http://www-spi.lip6.fr/~queinnec/WWW/LiSP.html

If you have more questions, please feel free to ask!

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any stuff about python interpreter design ?

2006-03-09 Thread Bo Yang
Danny Yoo said:
 So I take a look into the source code .But I get confused about so many
 files and functions . I want to ask that is there any stuff about the
 interpreter design and coding ?
 

 [meta: my reply is really about Scheme, not Python.  My apologies to the
 list, but it's my honest answer.]

 Hi Bo,

 There are several books and online material about the writing of
 interpreters.  The ones that I'm most aware aware of that are aimed at
 beginner programmers, though, target the language 'Scheme'.  The core
 Scheme language has a fairly minimal syntax and semantics, and it's simple
 enough that it's not too bad for beginner to understand (and write!) a
 usable Scheme interpreter.

 So you may find it useful to learn about interpreters by looking at Scheme
 interpreters.  And even though it's not Python, it's still very related
 and applicable; if you have a model of how a Scheme interpreter works,
 you'll be better equipped to understand in general how interpreters work.


 For example, the textbook How to Design Programs:

 http://www.htdp.org/

 starts covering the evaluation of a programming language by about Chapter
 14:

 http://www.htdp.org/2003-09-26/Book/curriculum-Z-H-19.html#node_sec_14.4


 Here are other Scheme resources about interpretation (the first two links
 contain online books):

 http://mitpress.mit.edu/sicp/
 http://www.cs.brown.edu/~sk/Publications/Books/ProgLangs/
 http://www.cs.indiana.edu/eopl/
 http://www-spi.lip6.fr/~queinnec/WWW/LiSP.html

 If you have more questions, please feel free to ask!


   
I  feeled the people in this mailing list are very really friendly , I 
will follow your links
and ask again if I have any questions !


Regards !
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Any TurboGears users out there?

2005-11-14 Thread Alan Gauld
I just stumbled across TurboGears:

http://www.macdevcenter.com/pub/a/mac/2005/11/08/turbogears.html

Its based on CheryPy which consistently gets good reviews but adds SQL 
access and XML templates. Sounds interesting, possibly even a Zope rival 
for the medium sized as opposed to massive site..

Is anyone on the list using it? Or even looked at it?

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any TurboGears users out there?

2005-11-14 Thread Kent Johnson
Alan Gauld wrote:
 I just stumbled across TurboGears:
 
 http://www.macdevcenter.com/pub/a/mac/2005/11/08/turbogears.html
 
 Its based on CheryPy which consistently gets good reviews but adds SQL 
 access and XML templates. Sounds interesting, possibly even a Zope rival 
 for the medium sized as opposed to massive site..
 
 Is anyone on the list using it? Or even looked at it?

I have looked at it to the extent of getting through the tutorial and a little 
more playing. It looks very promising to me. CherryPy, SQLObject and mochikit 
all have good reputations and TG seems to do a good job of gluing them 
together. Kid (the template engine) is not as mature as the others but it seems 
to work OK.

I used CherryPy 1 for a small work project. It was very easy to build the web 
site. I found the built-in webserver lacking in some of the basics like a 
usable request log but I think this has been fixed in CP 2.

Kent
-- 
http://www.kentsjohnson.com

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any TurboGears users out there?

2005-11-14 Thread Tim Johnson
* Alan Gauld [EMAIL PROTECTED] [051114 09:26]:
 I just stumbled across TurboGears:
 
 http://www.macdevcenter.com/pub/a/mac/2005/11/08/turbogears.html
 
 Its based on CheryPy which consistently gets good reviews but adds SQL 
 access and XML templates. Sounds interesting, possibly even a Zope rival 
 for the medium sized as opposed to massive site..
 
 Is anyone on the list using it? Or even looked at it?
 
  I have downloaded it, but have not yet done any testing.  I'm
  interested in investigating AJAX features, which I believe it
  supports.

  I hope to do some testing in the next couple of days, time
  permitting.

  tj

 Alan G
 Author of the learn to program web tutor
 http://www.freenetpages.co.uk/hp/alan.gauld
 
 
 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor

-- 
Tim Johnson [EMAIL PROTECTED]
  http://www.alaska-internet-solutions.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] any code to draw parabola or curve?

2005-11-08 Thread Shi Mu
any code to draw parabola or curve?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] any code to draw parabola or curve?

2005-11-08 Thread Alex Hunsley
Shi Mu wrote:

any code to draw parabola or curve?
  

That question is so general and vague it's either unanswerable, or very 
easy to answer.
I'll try the 'very easy' answer: yes, there is probably code somewhere 
to draw a parabola or curve. Have you tried making a start on this 
yourself? Did you run into a problem?
Or perhaps: did you try googling for 'draw parabola' or 'parabola equation'?

If you've not made a start on attempting this problem, and need help, 
try breaking down your help request into sub-requests. Like, you might 
be wondering what the algorithm or maths is for drawing a 
parabola/curve. Or you might be wondering about how to display a curve 
on screen. (Ascii output? Generating an image file like a gif? Output to 
a window using a GUI toolkit like wxPython?) Or are you just expecting 
someone to post fully functional code from a vague request?

The following is highly recommended reading. It's called How to ask 
questions the smart way:
http://www.catb.org/~esr/faqs/smart-questions.html

best of luck!
alex


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any good Glade and python tutorials?

2005-10-19 Thread Luis N
You might want to search for how it fits together with twisted's reactor

http://www.google.com/search?q=twisted+glade+reactor

Luis.

On 10/15/05, Adam [EMAIL PROTECTED] wrote:
 I'm making a Twisted app that needs a client side GUI and GTK seems like the
 best way to go about this. Can anybody point me in the direction of any
 decent tutorials on how to use Glade with python and pyGTK.
  Thanks.
  Adam.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Any good Glade and python tutorials?

2005-10-15 Thread Adam
I'm making a Twisted app that needs a client side GUI and GTK seems
like the best way to go about this. Can anybody point me in the
direction of any decent tutorials on how to use Glade with python and
pyGTK.
Thanks.
Adam.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Any suggestions for optimizing this code?

2005-09-18 Thread grouchy
Hello again!I've been playing with generating 1-D cellular automata, and this is the fastest solution I've come up with so far. In the makeArray() function below, I have a sliding window of three elements
starting at row[-1,0,1] and going to row[-2,-1,0], so that it wraps
around at either boundary. I use the results of 4*row[i-1] + row[i] +
row[i+1] to convert the three bits to an integer, and fetch a result
from rule[index]. The inner loop is simple, and executes a million times, so shaving any time off makes a big difference. The biggest speedup from things I tried came from making an empty matrix first, to put results into the next row by index, instead of
creating new rows on the fly with append. And binding the result[row]
and result[row+1] references before the loop. Those two things sped it up by a consistentt 40%. Thanks to Python in a Nutshell!Does anybody see a faster approach, or a way
to optimize the inner loop on makeArray() further? With the current approach, the
inner loop does the real work, as it steps over each cell one at a
time.For anybody not familiar with cellular automatas, there is a pretty java animation of how cells get calculated here: http://math.hws.edu/xJava/CA/CA.html

And this is what CAs they look like when you plot them, with 1s as black and 0s as white, and some additional info: 
http://mathworld.wolfram.com/Rule30.htmlI've just hardcoded rule 30 into this for testing. I make a blank matrix with makeMatrix(). Then makeArray(matrix) sets the middle element of the first row in the matrix to 1 to seed the CA, and loops through it two rows at a time, calculating the results of the first row, and putting them into the next row.
Right now I get: timeArray(5)Total time: 3.95693028I am uneasy with the algorithm getting each element one at a time, throwing them away, and getting two that overlap in the next step of the window, but I couldn't come up with a more elegant solution.  Also, it seems like a kludgey way to convert the 3 bits into a binary number, but it was the fastest way I stumbled on to.
w = 1000h = 1000rule = [0,1,1,1,1,0,0,0]def makeMatrix(w,h): result = [0]*h for i in range(h): result[i] = [0]*w return resultdef makeArray(matrix): result = matrix
 result[0][w/2] = 1 for row in range(h-1): last = result[row] next = result[row+1] for i in range(w-1): next[i] = rule[4*last[i-1]+2*last[i]+last[i+1]]


 next[i+1] = rule[4*last[i]+2*last[i+1]+last[0]] return resultdef timeArray(num): import time matrix = makeMatrix(w,h) t1 = time.clock() for i in range(num): makeArray(matrix)
 t2 = time.clock() print Total time:, t2 - t1timeArray(5)

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any suggestions for optimizing this code?

2005-09-18 Thread John Fouhy
On 19/09/05, grouchy [EMAIL PROTECTED] wrote:
 I've been playing with generating 1-D cellular automata, and this is the
 fastest solution I've come up with so far. 

I haven't dug deep into your code --- but, I wonder if the array
module might help?

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any suggestions for optimizing this code?

2005-09-18 Thread grouchy
Hi John,Thanks for that suggestion.I tried replacing my matrix with a numpy array, and it was about 20% slower, but I just substituted one for the other, so that really isn't surprising. I didn't try with the built-in array, but I'm guessing that swapping out another container for lists would only have a chance of speeding it up by a constant amount, I think, since setting and getting list elements is O(1).

Having said that, I forgot arrays existed. I will take a look right now, and look at their methods, see if there is anything in there I can dig up to help above and beyond a new container.I think, conceptually, I need to make the sliding window more efficient by not getting overlapping elements repeatedly, or maybe figuring out a way to skip the conversion from bits to integers. I tried storing as strings, and doing a join to get 
i.e. 110 and using that as a key to look up 1 or 0, but it was miserably slow :)The ~15x speedup from psyco makes me think if there was a built-in function that could handle everything in one fell swoop with tight C code, that would probably speed it up a -lot-. But I haven't found anything like that for a sliding window type situation.
On 9/18/05, John Fouhy [EMAIL PROTECTED] wrote:
On 19/09/05, grouchy [EMAIL PROTECTED] wrote: I've been playing with generating 1-D cellular automata, and this is the fastest solution I've come up with so far.
I haven't dug deep into your code --- but, I wonder if the arraymodule might help?--John.___Tutor maillist-
Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Any Python interface to USPTO web site?

2005-05-27 Thread Terry Carroll
I have the need to run periodic searches on the US Patent and Trademark 
Office website, www.uspto.gov.  Before I reinvent the wheel, I thought I'd 
check to see if anyone knew of such a beast.

For instance, It's like to be able to pass an argument like one of these:

  an/dis corporation
  in/newmar-julie

to http://patft.uspto.gov/netahtml/search-adv.htm and get a list of all 
the patents owned by Dis Corporation, or invented by the 1960s Catwoman 
actress; or pass a patent number like 4,150,505 to 
http://patft.uspto.gov/netahtml/srchnum.htm to bring up a particular 
patent.

Then I want to be able to parse out the patent metadata, e.g. inventor 
names, dates filed and issued, etc.

Has this already been done?

The closest my google searches have turned up is 
http://hacks.oreilly.com/pub/h/1724 , but that turns out to be Perl rather 
than Python, and not quite dead-on anyway.


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] any help with this piece of code

2005-05-12 Thread Richard gelling
import os

fileList = []
subDirectories = []
directories = []
directoryPath = raw_input( Type in the path you want to start at:  )

for directory,subDirectory, files in os.walk( directoryPath ):
directories.append( directory )
subDirectories.append( subDirectory )
fileList.append( files )

for Files in fileList:
print Files

# It works fine up until here

fileToSearchFor = raw_input( Type in the file name you want to search 
for: )

if fileToSearchFor in fileList:
print %s was found % fileToSearchFor
else:
print %s was not found % fileToSearchFor

Could someone explain to me why this pice of code doesn't work, in that 
it works fine up until where I have commented , but when I come to 
search the list for a file name, even though I know the filename is in 
that particular directory, and is present in the list returned by 
'fileList.append( files )' it always reports that the file is not found. 
Incidentally if you try this code out, when prompted for the path to 
start at, don't select a large directory as it takes sometime to run. It 
may not be very useful I am just curious as to why the file name cannot 
be found in the list, what am I missing?

Richard Gelling


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] any help with this piece of code

2005-05-12 Thread Danny Yoo


On Thu, 12 May 2005, Richard gelling wrote:

 fileToSearchFor = raw_input( Type in the file name you want to search
 for: )

 if fileToSearchFor in fileList:
 print %s was found % fileToSearchFor
 else:
 print %s was not found % fileToSearchFor

 Could someone explain to me why this pice of code doesn't work, in that
 it works fine up until where I have commented , but when I come to
 search the list for a file name, even though I know the filename is in
 that particular directory, and is present in the list returned by
 'fileList.append( files )' it always reports that the file is not found.

Hi Richard,


Ah.  TypeError.  *grin* At least, a conceptual one.


The code above accumulates the fileList with the following:

fileList.append( files )


But the problem is that your fileList is a list of lists of file names.
What you really want to do is:

fileList.extend( files )

to hold a flat list of file names in fileList.  The extend() method of a
list allows the list to absorb the elements of the other input list.



Concretely, your fileList probably looks something like this:

[['hello.txt'], ['notes.txt', 'blah.txt']]

where you really want to have something like this instead:

['hello.txt', 'notes.txt', 'blah.txt']


Hope this helps!


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any easy way to invoke the default browser on a specified URL?

2005-05-10 Thread Roel Schroeven
Kent Johnson wrote:

 Terry Carroll wrote:
 
Is there any way, from within Python, to cause the default browser 
(Firefox, in my case) to be invoked with a specific URL?

I'd like to do something like (totally made-up name and syntax):

OpenBrowser(http://www.google.com/;)

and have a new browser window opened up pointing to Google.
 
 
import webbrowser
webbrowser.open(http://www.google.com/;)

Splendid! I've been looking for something like that too, but somehow 
that module escaped my attention. Thanks!

-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

Roel Schroeven

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any easy way to invoke the default browser on a specified URL?

2005-05-09 Thread Kent Johnson
Terry Carroll wrote:
 Is there any way, from within Python, to cause the default browser 
 (Firefox, in my case) to be invoked with a specific URL?
 
 I'd like to do something like (totally made-up name and syntax):
 
 OpenBrowser(http://www.google.com/;)
 
 and have a new browser window opened up pointing to Google.

   import webbrowser
   webbrowser.open(http://www.google.com/;)

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any easy way to invoke the default browser on a specified URL?

2005-05-09 Thread jfouhy
Quoting Terry Carroll [EMAIL PROTECTED]:

 Is there any way, from within Python, to cause the default browser 
 (Firefox, in my case) to be invoked with a specific URL?

If you're on Win32, try:

 import win32api
 win32api.ShellExecute(0, 'open', 'http://www.google.com/', None, '', 1)

Parameters in order: 
 - Handle to the parent window (0 for no parent)
 - Operation to perform (you can also use 'print', and maybe others?)
 - Name of the file/shortcut to execute
 - Optional parameters for the new process
 - Initial directory for the new process
 - Flag indicating if the new window should be shown or not.

[information from Mark Hammond's book]

Basically, this does the same thing as double-clicking on the file/shortcut in
Windows Explorer.

If you're on Linux, I'm not sure.  I think different distros / window managers
may have different ways of defining things like a default browser, or different
ways of getting at them.

And I don't know anything about Mac OS X :-)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any easy way to invoke the default browser on a specified URL?

2005-05-09 Thread Terry Carroll
On Mon, 9 May 2005, Kent Johnson wrote:

import webbrowser
webbrowser.open(http://www.google.com/;)

Beautiful; just what I needed.  Thanks.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor