Re: [Tutor] function won't import from module

2005-08-08 Thread Javier Ruere
Dick Moores wrote: > I have a bunch of functions I've collected in one script, "mycalc.py", > which I use as a module, "mycalc". The last one I wrote, cmpSeq() is as > follows: > [code] > > In a script, cmpSeq() works fine. For example followed by > [example] > > The output is: > [output] > > c

[Tutor] function won't import from module

2005-08-08 Thread Dick Moores
I have a bunch of functions I've collected in one script, "mycalc.py", which I use as a module, "mycalc". The last one I wrote, cmpSeq() is as follows: ===begin code== def cmpSeq(seq1, seq2): """ find first index at which two sequences differ """ if seq1 =

Re: [Tutor] problem with Python Tutorial

2005-08-08 Thread Danny Yoo
On Mon, 8 Aug 2005, Dick Moores wrote: > Danny Yoo wrote at 16:57 8/8/2005: > > > Traceback (most recent call last): > > >File "", line 1, in -toplevel- > > > sys.ps2 > > > AttributeError: 'module' object has no attribute 'ps2' > > > > > > What's wrong? > > > > > >IDLE doesn't use sys.p

Re: [Tutor] problem with Python Tutorial

2005-08-08 Thread Dick Moores
Danny Yoo wrote at 16:57 8/8/2005: > > Traceback (most recent call last): > >File "", line 1, in -toplevel- > > sys.ps2 > > AttributeError: 'module' object has no attribute 'ps2' > > > > What's wrong? > > >IDLE doesn't use sys.ps2. See the thread starting at: > > http://mail.python.or

Re: [Tutor] NotebookSizer is no longer needed

2005-08-08 Thread _ Dan _
There is a good chance I got it all wrong... __ Renovamos el Correo Yahoo! Nuevos servicios, más seguridad http://correo.yahoo.es--- Begin Message --- Hi... Well, I'm working on Gui programs with wxglade. On MS Windows I'm getting t

Re: [Tutor] problem with Python Tutorial

2005-08-08 Thread Danny Yoo
> Traceback (most recent call last): >File "", line 1, in -toplevel- > sys.ps2 > AttributeError: 'module' object has no attribute 'ps2' > > What's wrong? IDLE doesn't use sys.ps2. See the thread starting at: http://mail.python.org/pipermail/idle-dev/2002-February/000862.html _

[Tutor] help

2005-08-08 Thread Dan Deternova
i am making a simple script to get the hang of Tkinter. i want to use the input of the user from a Entry and calcuate the area. i have tryied many way... as you can see in my script.   the Entry is under def area():  and the output i want is under def cal():  ... please help me fix my code and expl

[Tutor] problem with Python Tutorial

2005-08-08 Thread Dick Moores
Quoting from "6.2 Standard Modules", of the Python Tutorial (): == One particular module deserves some attention: sys, which is built into every Python interpreter. The variables sys.ps1 an

[Tutor] NotebookSizer is no longer needed

2005-08-08 Thread _ Dan _
Hi... Well, I'm working on Gui programs with wxglade. On MS Windows I'm getting the following message: "DeprecationWarning: NotebookSizer is no longer needed" No message on Linux... and, if I remove the notebook sizer, then I cannot put any notebook at all, so I'm kind of lost in here... Anybody kn

Re: [Tutor] Using urllib to retrieve info

2005-08-08 Thread Liam Clarke-Hutchinson
Hi all, David, are you able to send us a screen shot of what you're trying to get? >From your desired link I just get a bunch of ads with another ad telling me it's for sale. When I open http://support.mywork.co.uk it looks exactly the same as http://support.mywork.co.uk/index.php?node=2371&pa

Re: [Tutor] while loops

2005-08-08 Thread Will Harris
Thanks for the help guys. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] IP Address from Python module?

2005-08-08 Thread Joseph Quigley
Danny Yoo wrote: Hi Joe, That actually sounds right in a sense. Any internet address with '192.168.x.x' is a "local" IP address, and is commonly allocated to folks on an internal network. For the really dull details about this, see RFC 1918 on "Private Address Space": http://www.faqs

Re: [Tutor] Fetching dictionaries using MySQLdb

2005-08-08 Thread Jan Eden
Hi Danny, Danny Yoo wrote on 08.08.2005: >On Mon, 8 Aug 2005, Jan Eden wrote: > >>Is there a recommended way to receive the results of an SQL query >>in the form I need? Or do I have to create a dictionary of >>fieldname tuples which can be zipped with the query result tuple? > > >Hi Jan, > >MySQ

Re: [Tutor] What's the invalid syntax? Code supplied

2005-08-08 Thread Alan G
Nathan, > I'm no longer going to use this method. I thought up a more easier > idea for dealing cards. I was going to share it, but with all this > time and effort pointing out things that I should know, instead of > helping me, I don't think I will, because it will probably be ripped > to shr

Re: [Tutor] Shut up and deal!

2005-08-08 Thread Danny Yoo
On Mon, 8 Aug 2005, Greg Lindstrom wrote: > I found the conversation of dealing cards interesting, so I took a few > minutes (about 20 while I waited for a production run to finish) and > came up with the following Dealer class. [text cut] > What type of Pythonic changes would make this? What

Re: [Tutor] Using urllib to retrieve info

2005-08-08 Thread Alan G
> It runs fine but the file saved to disk is the > information at : 'http://support.mywork.co.uk' > not > 'http://support.mywork.co.uk/index.php?node=2371&pagetree=&fromid=20397&objectid=21897";' Could there be cookies involved? Just a thought, Alan G. _

Re: [Tutor] Curses example on Linux?

2005-08-08 Thread Danny Yoo
On Mon, 8 Aug 2005, Hossein Movahhedian wrote: >I have copied the following example from "Learning to Program by Alan > Gauld (section: Event Driven Programming)". To run it on Linux > (Redhat 8.0; Python 2.4) the tutorial says to replace 'msvcrt' > with 'curses.stdscr'. Hi Hossein, A

Re: [Tutor] deck dealing program

2005-08-08 Thread luke
Just offering my take on the problem. hope it helps someone. - Original Message - From: <[EMAIL PROTECTED]> To: Sent: Monday, August 08, 2005 2:02 AM Subject: Re: [Tutor] deck dealing program > Are you: > a.) Having trouble with the code and looking for help? > b.) Looking for sugges

Re: [Tutor] Fetching dictionaries using MySQLdb

2005-08-08 Thread Danny Yoo
On Mon, 8 Aug 2005, Jan Eden wrote: > Is there a recommended way to receive the results of an SQL query in the > form I need? Or do I have to create a dictionary of fieldname tuples > which can be zipped with the query result tuple? Hi Jan, MySQLdb supports the concept of customized cursor ty

Re: [Tutor] use of webbrowser.open_new()

2005-08-08 Thread Danny Yoo
> > http://www.faqs.org/rfcs/rfc1738.html > > > > shows the syntax of file URLs. > > Man, that Berners-Lee can sure write plain English, can he not? I didn't > find that reference much use at all, in truth. Hi Tom, [Note: when you're responding to a message on Python-tutor, please make su

Re: [Tutor] raw string - solution to open_new() problem

2005-08-08 Thread Alan G
> webbrowser.open_new(r"file://C:\__Library\folders\02394 Yale Style > Manual\02394 Yale_Style_Manual.htm") > > does. > > Thank you Ewald, for triggering the solution in my mind! > > Now, if anyone can explain why webbrowser.open_new() does the > character substitution thing it was doing (and th

Re: [Tutor] while loops

2005-08-08 Thread Jay Loden
> coin = random.randrange(2) That's the problem there...you've got coin assigned outside the while loop, so it is assigned 0 or 1 once, before the loop, and then you're running 100 checks on the same value. If you move > coin = random.randrange(2) to inside the while loop before the if state

Re: [Tutor] while loops

2005-08-08 Thread Kent Johnson
Will Harris wrote: > I am working my way through "python programming for the absolute > beginner" and one of the challenges is to create a program that will > flip a coin 100 times and tell you how many of each it did. Now I > have it flipping the coin, but when I try to do this 100 times I end > u

Re: [Tutor] Using urllib to retrieve info

2005-08-08 Thread Kent Johnson
David Holland wrote: > Kent, > > Sorry I should have put my code. > This is what I wrote > import urllib > import urllib2 > f = > urllib.urlopen("http://support.mywork.co.uk/index.php?node=2371&pagetree=&fromid=20397&objectid=21897";).read() > newfile = open("newfile.html",'w') > newfile.write(f)

[Tutor] while loops

2005-08-08 Thread Will Harris
I am working my way through "python programming for the absolute beginner" and one of the challenges is to create a program that will flip a coin 100 times and tell you how many of each it did. Now I have it flipping the coin, but when I try to do this 100 times I end up with it running through

Re: [Tutor] Shut up and deal!

2005-08-08 Thread Kent Johnson
Greg Lindstrom wrote: > I found the conversation of dealing cards interesting, so I took a few > minutes (about 20 while I waited for a production run to finish) and > came up with the following Dealer class. I come with a long history of > coding in C/C++ and have been told my code looks like

[Tutor] Using urllib to retrieve info

2005-08-08 Thread David Holland
Kent, Sorry I should have put my code. This is what I wrote import urllib import urllib2 f = urllib.urlopen("http://support.mywork.co.uk/index.php?node=2371&pagetree=&fromid=20397&objectid=21897";).read() newfile = open("newfile.html",'w') newfile.write(f) newfile.close() print 'finished' It runs

[Tutor] Shut up and deal!

2005-08-08 Thread Greg Lindstrom
I found the conversation of dealing cards interesting, so I took a few minutes (about 20 while I waited for a production run to finish) and came up with the following Dealer class.  I come with a long history of coding in C/C++ and have been told my code looks like it (notice, in particular the nes

Re: [Tutor] raw string - solution to open_new() problem

2005-08-08 Thread Terry Carroll
On Mon, 8 Aug 2005, Tom Cloyd wrote: > So, thie > > webbrowser.open_new("file://C:\__Library\folders\02394 Yale Style > Manual\02394 Yale_Style_Manual.htm") > > does not work, but this > > webbrowser.open_new(r"file://C:\__Library\folders\02394 Yale Style > Manual\02394 Yale_Style_Manual.ht

[Tutor] Curses example on Linux?

2005-08-08 Thread Hossein Movahhedian
Hi All, I have copied the following example from "Learning to Program by Alan Gauld (section: Event Driven Programming)". To run it on Linux (Redhat 8.0; Python 2.4) the tutorial says to replace 'msvcrt' with 'curses.stdscr'. But there is no stdscr method in curses. In fact with 'import

Re: [Tutor] Fetching dictionaries using MySQLdb

2005-08-08 Thread Jan Eden
Kent Johnson wrote on 08.08.2005: >Jan Eden wrote: >>The documentation for MySQLdb says that fetchoneDict() is >>deprecated and the usage of fetchone() is suggested. > >You could just use fetchoneDict(); deprecated isn't the same as >gone... I tend to avoid deprecated functions/methods - I would

Re: [Tutor] Fetching dictionaries using MySQLdb

2005-08-08 Thread Kent Johnson
Jan Eden wrote: > Hi, > > in Perl's DBI, I used fetchrow_hashref() to receive a database row as > a dictionary, with the field names being the dictionary keys. > > MySQLdb's fetchone() returns a tuple Unfortunately, I have a > dictionary of SQL queries which return rows of different lengths > (re

[Tutor] Fetching dictionaries using MySQLdb

2005-08-08 Thread Jan Eden
Hi, in Perl's DBI, I used fetchrow_hashref() to receive a database row as a dictionary, with the field names being the dictionary keys. MySQLdb's fetchone() returns a tuple Unfortunately, I have a dictionary of SQL queries which return rows of different lengths (read: with a varying number of

Re: [Tutor] Tutor Digest, Vol 18, Issue 41

2005-08-08 Thread Kent Johnson
David Holland wrote: > Looking at the slashdot url works fine, I think the problem is because I > am trying to download a page with an address of the form > url.php?node=5924&pagetree=&fromid=&objectid=25586 > And I only download url not url.phpetc. > Is there anyway that that can be done ? Plea

Re: [Tutor] use of webbrowser.open_new()

2005-08-08 Thread Kent Johnson
Tom Cloyd wrote: > Having just discovered the webbrowser module, I've confirmed that I can > indeed open a URL in my default browser using something like > > webbrowser.get_new("{URL}") > > What I want to do is open a web page stored on my local machine. I'm not > getting it to work - > > we

[Tutor] raw string - solution to open_new() problem

2005-08-08 Thread Tom Cloyd
Ewald Ertl's reply to Don Parris's question about "r" operator gave me the idea of trying that out to solve my problem with file name scrambling when trying to use webbrowser.open_new() to open a file on my computer in a browser. It worked! So, thie webbrowser.open_new("file://C:\__Library\

Re: [Tutor] Tutor Digest, Vol 18, Issue 41

2005-08-08 Thread David Holland
Looking at the slashdot url works fine, I think the problem is because I am trying to download a page with an address of the form url.php?node=5924&pagetree=&fromid=&objectid=25586 And I only download url not url.phpetc. Is there anyway that that can be done ?   David Message: 8Date: Mon, 8 Aug 20

Re: [Tutor] Get information from a web page

2005-08-08 Thread python-tutor
Not sure exactly what you have going wrong without the code or the exact url you are using. Does something like: import urllib page = urllib.urlopen("http://slashdot.org/article.pl?sid=05/08/08/043236&tid=126";).read() print page give you the correct results? Is the problem specific to o

[Tutor] Get information from a web page

2005-08-08 Thread David Holland
Hi All, I am trying to save to disk a webpage (so I can extract useful info) with a urlof type "http://xxx.co.uk/index.php?node=2371&pagetree=&fromid=20397".However the following :-urllib.urlopen, urllib._urlopener, urllib2.Request, urllib2.urlopen,urllib2.urlretrievejust retrieve this webpage :- h

Re: [Tutor] Question About chdir()

2005-08-08 Thread python-tutor
Let's see if I can get this right.as I am working on memory and not enough sleep. The 'r' means that using a raw string so the backslashes aren't escaped out The equivalent without using the 'r' would be: os.chdir('c:\\temp') --Todd On Monday 08 August 2005 03:07 am, Don Parris wrote:

Re: [Tutor] Question About chdir()

2005-08-08 Thread Ewald Ertl
Hi Don! Don Parris wrote: > The book, "Programming Python", shows an example of os.chdir() on the > Windows platform, as follows: > > os.chdir(r'c:\temp') r ... raw Strings. There will no substitution be processed. Otherwise the "\t" ( Tab ) will be inserted in the string: >>> print "a\tb" a

[Tutor] Question About chdir()

2005-08-08 Thread Don Parris
The book, "Programming Python", shows an example of os.chdir() on the Windows platform, as follows: os.chdir(r'c:\temp') What's the 'r' for? It didn't seem to make any difference in how Python works - at least not on the surface. Thanks, Don -- DC Parris GNU Evangelist http://matheteuo.org/ [E

Re: [Tutor] deck dealing program

2005-08-08 Thread python-tutor
Are you: a.) Having trouble with the code and looking for help? b.) Looking for suggestions on how to improve the code? c.) Offering the code as a demo for Nathan et al.? I was just doing stuff along the same lines and was having fun seeing the different approaches to the same problem. -