Re: [Tutor] PyCon anyone?
Kent Johnson wrote: Hi all, I'm going to PyCon this year for the first time (yeah!) and I would love to meet other regular contributors to the tutor list. Is anyone else going to be there? Any interest in a "Meet the tutors" Open Space or dinner? Kent Hi Kent, I'm not a very regular contributor here, but we'd love have you (and anyone else who's on the tutor list) join the edu-sig group for dinner and open space, if you're so inclined... Our open space page is at http://us.pycon.org/2010/openspace/edu-sig/ Cheers, Vern Ceder ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- This time for sure! -Bullwinkle J. Moose - Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] PyCon anyone?
Kent Johnson wrote: On Tue, Feb 16, 2010 at 10:09 AM, Vern Ceder I'm not a very regular contributor here, but we'd love have you (and anyone else who's on the tutor list) join the edu-sig group for dinner and open space, if you're so inclined... Our open space page is at http://us.pycon.org/2010/openspace/edu-sig/ Thanks, that sounds good. I'll add myself to that page with a note. Any idea when the open space or dinner will be? Kent I believe we're aiming for Friday evening for dinner, but we're still working on where... The open space might be either after dinner on Friday or on Saturday evening... depending on interest. So go ahead and add your preferences. Vern -- This time for sure! -Bullwinkle J. Moose - Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Bowing out
Kent, Thanks for all of the work you've done over the years to help make this one of the best/most useful lists around. Enjoy the new challenges ahead! It was great to finally meet you at PyCon! Cheers, Vern Kent Johnson wrote: Hi all, After six years of tutor posts my interest and energy have waned and I'm ready to move on to something new. I'm planning to stop reading and contributing to the list. I have handed over list moderation duties to Alan Gauld and Wesley Chun. Thanks to everyone who contributes questions and answers. I learned a lot from my participation here. So long and keep coding! Kent ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- This time for sure! -Bullwinkle J. Moose ----- Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Problem with turtle
It looks like the indentation of n = n + 1 is wrong - it will be outside of the while loop and so n will never increment and the loop will never end. Instead of a while loop I would suggest a for loop: for n in range(10: HTH, Vern Marco Rompré wrote: I wanted turtle to draw alternatively a square and a triangle with a space between them each with a specific color, angle(orientation as you said), size. Instead, turtle was drawing a yellow square then it was drawing a triangle on the sqare but with no lines whatsovever like it was just going over it and the last problem was that it was never stopping and i had to rstart the shell to make it stop. I hope I am more precis with my explanations. Thanks for helping me learn On Thu, Mar 11, 2010 at 1:26 PM, Alan Gauld <mailto:alan.ga...@btinternet.com>> wrote: "Marco Rompré" mailto:marcodrom...@gmail.com>> wrote Hi! I am relatively new to python and turtle and I really need your help. Thats what we are hee for but Here's my code: ignore my comments n=0 while n < 10 : down() # abaisser le crayon carre(25, 'yellow', 0) # tracer un carré up() forward(30) triangle(90, 'blue',0) n = n + 1 If I am to vague I wanted to do successfully exercise 7.6 in Gérard Swinnen tutorial for Python It was supposed to look like this So what happens? Is there an error message or does it just draw the wrong thing? Don't make us guess... -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org <mailto:Tutor@python.org> To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Marc-O. Rompré ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- This time for sure! -Bullwinkle J. Moose - Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Problem with turtle
Ooops... missed a closing parenthese... that should be: for n in range(10): Vern Ceder wrote: It looks like the indentation of n = n + 1 is wrong - it will be outside of the while loop and so n will never increment and the loop will never end. Instead of a while loop I would suggest a for loop: for n in range(10: HTH, Vern Marco Rompré wrote: I wanted turtle to draw alternatively a square and a triangle with a space between them each with a specific color, angle(orientation as you said), size. Instead, turtle was drawing a yellow square then it was drawing a triangle on the sqare but with no lines whatsovever like it was just going over it and the last problem was that it was never stopping and i had to rstart the shell to make it stop. I hope I am more precis with my explanations. Thanks for helping me learn On Thu, Mar 11, 2010 at 1:26 PM, Alan Gauld <mailto:alan.ga...@btinternet.com>> wrote: "Marco Rompré" mailto:marcodrom...@gmail.com>> wrote Hi! I am relatively new to python and turtle and I really need your help. Thats what we are hee for but Here's my code: ignore my comments n=0 while n < 10 : down() # abaisser le crayon carre(25, 'yellow', 0) # tracer un carré up() forward(30) triangle(90, 'blue',0) n = n + 1 If I am to vague I wanted to do successfully exercise 7.6 in Gérard Swinnen tutorial for Python It was supposed to look like this So what happens? Is there an error message or does it just draw the wrong thing? Don't make us guess... -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org <mailto:Tutor@python.org> To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Marc-O. Rompré ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- This time for sure! -Bullwinkle J. Moose - Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] what is wrong with this syntax?
Dipo Elegbede wrote: ples help me figure out what is wrong with this syntax? print('Here are the numbers from 0 to 9') for i in the range(10): print(i) Remove the word "the" print('Here are the numbers from 0 to 9') for i in range(10): print(i) Cheers, Vern thank you. i am currently reading a byte of a python. thanks. -- Elegbede Muhammed Oladipupo OCA +2348077682428 +2347042171716 www.dudupay.com <http://www.dudupay.com> Mobile Banking Solutions | Transaction Processing | Enterprise Application Development ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- This time for sure! -Bullwinkle J. Moose - Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] 2to3 conversion
Zubin Mithra wrote: Hey everyone, I was running 2to3 on a particular file and I got the following traceback(http://paste.pocoo.org/show/223468/). The file which I was attempting to convert can be viewed here(http://paste.pocoo.org/show/223469/). Any pointers on what needs to be done? The traceback indicates that the utf-8 codec doesn't know how to decode the values at bytes 232-234, yet when I saved the file just now, 2to3 ran without giving that error. In fact it only flagged the exception handling as needing mofications. I wonder if the version served by the pastebin is *exactly* the same as the one you are using on your machine? Cheers, Vern Thanks in advance, Zubin ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- This time for sure! -Bullwinkle J. Moose - Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Creating A Simple Blog System Using Python Programming
F C wrote: Hi there, - I have recently decided to learn Python. - It is my first programming language. - I am new to programming. - I know XHTML and CSS, and a few lines of PHP. - I only started learning a couple of days ago. What I want to do is create a simple blog system. Where I can - create posts, edit them and post them online Thus far, people have pointed me to frameworks. From what I see, the framework does the work for you... I want to code the blog from scratch...after all - I want to learn the language - I don't want something to do the work for me. Managing the details of a framework could distract you from the basics of learning Python, IMHO, but they do make a lot things much easier. As it happens, I use a similar example (a message wall) in my book, The Quick Python Book, 2nd ed. (see link in my sig). While I can't reproduce that chapter here, I can tell you that you want to use the wsgiref server included in the Python standard library, and you should read through the online docs and examples for the wsgiref module on the python.org site. Then for storage of your posts, you might just want to use text files at first, and then consider picking up sqlite3 or another database later on. Cheers, Vern I truly do not know where to start, because most of the tutorials are segmented, and I don't know how to structure the program, let alone what commands to include. I would appreciate it if someone could give me some structure advice on how to tackle this. Many thanks to the person(s) who can help. Australia's #1 job site If It Exists, You'll Find it on SEEK <http://clk.atdmt.com/NMN/go/157639755/direct/01/> ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- This time for sure! -Bullwinkle J. Moose ----- Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Scribbler Robot
We're using the scribblers in our intro to Python programming class, and I'm pretty happy with them so far. They're a little clunky in some ways, but they do have a ton of sensors, and it's relatively easy to get going with them. For what they do, they're the cheapest option I've found. Cheers, Vern On Fri, Sep 17, 2010 at 12:19 AM, Nick wrote: > http://www.georgiarobotics.com/roboteducation/robot-kit.html > > you can check the robot out at this link. is this a good buy you guys > think, or is there a better python compatible robot out there? I just want > something to keep me interested in programming and that gives me ideas of > programs to write. The benefit of the scribbler is also that free book > online learning with robotics... It has all kinds of sample code for > programs for the scribbler. > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > -- This time for sure! -Bullwinkle J. Moose - Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] new turtle module
On Thu, Oct 7, 2010 at 1:19 PM, roberto wrote: > hello, > i want to use the turtle module described in > http://docs.python.org/library/turtle.html > > since the module in my python2.5 is a little bit outdated; > > is it correct to overwrite the turtle.py and turtle.pyc files in my current > '/usr/lib/python2.5/lib-tk/' > directory with the ones holding the same names unzipped from > turtleDemo folder 'TurtleDemo-Python2.x' by author Gregor Lindl ? > > Yes, that should work with Python 2.5, but probably not with any earlier versions. Cheers, Vern Ceder > Thank you ! > -- > roberto > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- This time for sure! -Bullwinkle J. Moose - Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Convert a string of numbers to a list
Kyle Kwaiser wrote: x = ['[335, 180, 201, 241, 199]\r\n'] y = map( int, x[0].strip( '[]\r\n' ).split( ', ' ) ) #need an index here print y [335, 180, 201, 241, 199] I realize it's not totally secure, but if your string really is in that format (i.e., a representation of a list), you COULD just use eval(): >>> x = '[335, 180, 201, 241, 199]\r\n' >>> y = eval(x.strip()) >>> print y [335, 180, 201, 241, 199] >>> Regards, Vern Ceder ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] print problem python
In Python 3, you need to put ( ) around what you want to print, so it would be: print("hello world") Cheers, Vern mustafa akkoc wrote: i start learning pyton language i want to print some thing but when i type : print "hello world" but it give an error like this SyntaxError: invalid syntax (, line 1) i am using python shell version 3.0.1 -- Mustafa Akkoc ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- This time for sure! -Bullwinkle J. Moose ----- Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Printing Problem python 3
Dave Crouse wrote: I got the same thing with idle, but when running as a script, it's not the same, it errors. I tried it on Windows and Linux. --- [da...@arch64 Python]$ less test.py #/usr/bin/python3 print ('The \"This is a test \" {') [da...@arch64 Python]$ sh test.py test.py: line 3: syntax error near unexpected token `'The \"This is a test \" {'' test.py: line 3: `print ('The \"This is a test \" {')' Maybe I'm missing something, but this error is because you're running a Python script using the Linux shell, probably bash as the interpreter instead of Python. Also, if you're running it on its own as a script, you'd want to add a '!' after the '#' - otherwise it's just a comment, not setting the interpreter. To run a Python file as a script, you'd need to do: [da...@arch64 Python]$ python3 test.py (or just ./test.py if it's executable and the interpreter is set using '#!/usr/bin/python3') When I do that, it works for me just fine without doubling the '{' Cheers, Vern -- This time for sure! -Bullwinkle J. Moose - Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Trouble with a Recipe ...
At the top in the docstring it says, '"To", "Cc" and "Bcc" values must be *lists*'. That means instead of "To": "garry.bet...@gmail.com", you need "To": ["garry.bet...@gmail.com"] i.e. a list containing the destination address. That's so that you could send to, cc and bcc more than one address. HTH, Vern Garry Bettle wrote: Hi, Hope this email finds everyone well - roll on the weekend. I'm trying to run http://code.activestate.com/recipes/576824/ I'm in IDLE and I try: email_it_via_gmail( {"To": "garry.bet...@gmail.com", "Subject": "Testing", "From": "garry.bet...@gmail.com"}, text="Testing") but I get the following error: Traceback (most recent call last): File "", line 1, in email_it_via_gmail( {"To": "garry.bet...@gmail.com", "Subject": "Testing", "From": "garry.bet...@gmail.com"}, text="Testing") File "C:\Documents and Settings\Garry\Desktop\recipe-576824-1.py", line 50, in email_it_via_gmail + headers.get("Bcc", []) TypeError: cannot concatenate 'str' and 'list' objects Sorry, but I according to the recipe I don't need a Bcc. Sorry, again, for such a simple question! Cheers, Garry ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- This time for sure! -Bullwinkle J. Moose - Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] if n == 0 vs if not n
Hi Sander, PEP 8, the "Style Guide for Python Code" http://www.python.org/dev/peps/pep-0008/ is pretty clear that the shorter version is preferable: if s: if n: if b: if not b: and so on... Cheers, Vern Sander Sweers wrote: Hi Tutors, I am going through someone's python script and I am seeing a lot of the following boolean checks. if not s == "" if not n == 0 if b == True if not b == True etc.. All of these can be written without the == notation like "if n", "if s" etc. Now in this case where it is only used as boolean checks which would be the most pythonic way if writing these checks? Thanks Sander ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- This time for sure! -Bullwinkle J. Moose - Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] if n == 0 vs if not n
Dave Angel wrote: Now in this case where it is only used as boolean checks which would be the most pythonic way if writing these checks? The shorter version may be preferable, but it doesn't generally give the same results. Without knowing the possible data, these substitutions are not safe. For example, replacing "if not n == 0"with "if n" will give different results for values of "", [] and so on. It WILL work if you know that n is an int or float, however. DaveA True, I took the OP's statement that they were to be used "only as boolean checks" to mean that there was no type mixing going on. Personally, I would say that checking a list or string for equality (or lack thereof) with 0 is even less "preferable". ;) Otherwise, one would at least prefer "if n != 0" to "if not n == 0", I would think. Cheers, Vern -- This time for sure! -Bullwinkle J. Moose - Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] 2to3 Help?
"Marco Petersen" wrote > This was the line of code: > > $ 2to3 testscript.py But I suspect... this will run your default python interpreter which is likely to still be your 2.5 version. THe convertion scrpt is almost certainly 3.0. So I think you will need to explicitly call the interpreter: Right - 2to3 isn't part of Python 2.5, but it is a part of 2.6 and 3.0 $ some/path/to/python3 2to3 testscript.py Actually isn't 2to3 a .py file too? ie 2to3.py? It's a Python file, but it doesn't have the .py extension. On my system it explicitly references Python 3 as the interpreter on the she-bang line, though, so that may not be the problem. Just some guesses... I haven't got around to installing Python 3 yet. Alan G. Cheers, Vern Ceder -- This time for sure! -Bullwinkle J. Moose - Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] python3.0 and tkinter on ubuntu 8.10
Hi, I have Python 3.0/Tkinter/IDLE working fine on Ubuntu 8.10, but it takes a certain amount of fiddling. 1. Make sure the stock Ubuntu Python 3.0 package is not installed 2. download the Python 3.0 source from python.org 3. install the following packages: build-essential libsqlite3-dev libreadline5-dev libncurses5-dev zlib1g-dev libbz2-dev libssl-dev libgdbm-dev tk-dev 4. unpack the Python source and switch to that folder 5. build Python using the standard ./configure, make, make install sequence - if you want more detail/help on that process, just ask... I'd be happy to explain this process in more detail if anyone wants... Cheers, Vern Hi Tutors,I have downloaded Python3.0 and started playing with it. I like it because of the utf-8 default encoding, but I'm having trouble importing tkinter. I get the following: >>> import turtle Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.0/turtle.py", line 107, in import tkinter as TK File "/usr/local/lib/python3.0/tkinter/__init__.py", line 39, in import _tkinter # If this fails your Python may not be configured for Tk ImportError: No module named _tkinter >>> import tkinter Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.0/tkinter/__init__.py", line 39, in import _tkinter # If this fails your Python may not be configured for Tk ImportError: No module named _tkinter >>> Any idea how this can be solved on Ubuntu 8.10. I don't have this problem with the default Python installation (2.5.2) Thank you -- This time for sure! -Bullwinkle J. Moose - Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Python3.0 and Tkinter on ubuntu 8.10 HOWTO
Since there was some interest in the question of how to get a full Python 3.0, including Tkinter and IDLE, compiled on Ubuntu Intrepid 8.10, I've written up what I've done and posted it at http://learnpython.wordpress.com/2009/01/14/installing-python-30-on-ubuntu/ Cheers, Vern Ceder -- This time for sure! -Bullwinkle J. Moose - Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] eval and floating point
Mr Gerard Kelly wrote: Thanks very much I've noticed that the eval() function gives an integer, so eval("3/2") gives back 1. float(eval("3/2")) doesn't seem to work, any way to get a floating point number back with eval()? I know you can just do ("3./2."), but is there any way to do it with just ("3/2")? If you are using a current version of Python, the line: from __future__ import division will make division with the "/" return a float; you then use "//" for integer division >>> from __future__ import division >>> eval("3/2") 1.5 >>> eval("3//2") 1 >>> Cheers, Vern -- This time for sure! -Bullwinkle J. Moose - Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Best Python3000 Tutorial for Beginner
Swaroop's Byte of Python has both 2.x and 3.x versions: http://www.swaroopch.com/notes/Python_en:Table_of_Contents Cheers, Vern Ceder Ian Egland wrote: Hello all, I just joined this mailing list. I am a beginner to programming in general and would really appreciate a tutorial for Python3000 that at least covers the basics. I have tried reading the manual, but I think it was written for more experienced programmers wishing to switch to python rather than a beginner looking for where to start. Most of the other tutorials I have found were for earlier versions of Python, and because Python 3.0 was released on my birthday, I decided I was meant to learn that release. ;-) Anyway, any help would be appreciated. I will do my best to return the favor. -Ian ___ 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] Print question in IDLE
I just tried it in Python 3 (both at the interactive prompt and in idle) and both places I get: >>> "food is very nice" #lets eat 'food is very nice' >>> So it looks like it *should* work. You might copy and paste exactly what you get into a post, including the full error traceso that we can see if there is some other problem. From the error message I (like Alan) wonder if you are typing in the ">>>" or something like that. Cheers, Vern jims wrote: I apologize for asking such a dumb question but I have no prior programming experience and am trying to learn by following examples from a book. And also from the web. Simply put here is where I am stuck. (Python version 3.0) I type in the example using the comment command: (example) *>>> "food is very nice" #lets eat *(I am supposed to get) *food is very nice (*What I do get is) SyntaxError: invalid syntax (, line 1) I understand the comment part, no problem but no way can I get past what ever else I am doing wrong. I assume it's something fundamental but I can't get past this. Thanks for any help. Jim ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- This time for sure! -Bullwinkle J. Moose - Vern Ceder, Director of Technology Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804 vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Trying To Debug Code That Runs Arbitrary Function
Here's your hint... to execute a Python function, it must be followed by parentheses otherwise you are just referring to the function object. HTH, Vern On Thu, Dec 2, 2010 at 9:35 AM, Homme, James wrote: > Hi, > > If you can get away with not telling me the answer, but pointing me to > where to look for the answer, I'd be grateful. > > > > In my Python learning, I am just now starting to understand how to make > classes and extend them, so I have a very long way to go. > > > > I wrote this code because I wanted to avoid lots of if statements and > having to maintain a bunch of code like that. Eventually, my idea is to read > in strings from a file, look one up, and use it to execute a function. So I > created the following code. But nothing gets printed to the screen. How do I > go about figuring out why this isn't happening? Here's the code. > > > > myfuncs = [ "func1", > > "func2" ] > > > > def func1(): > > print "func 1" > > > > def func2(): > > print "func 2" > > > > eval (myfuncs[0]) > > > > raw_input("Press enter to quit") > > > > Thanks. > > > > Jim > > Jim Homme, > > Usability Services, > > Phone: 412-544-1810. Skype: jim.homme > > Internal recipients, Read my accessibility > blog<http://mysites.highmark.com/personal/lidikki/Blog/default.aspx>. > Discuss accessibility > here<http://collaborate.highmark.com/COP/technical/accessibility/default.aspx>. > Accessibility Wiki: Breaking news and accessibility > advice<http://collaborate.highmark.com/COP/technical/accessibility/Accessibility%20Wiki/Forms/AllPages.aspx> > > > > -- > This e-mail and any attachments to it are confidential and are intended > solely for use of the individual or entity to whom they are addressed. If > you have received this e-mail in error, please notify the sender immediately > and then delete it. If you are not the intended recipient, you must not > keep, use, disclose, copy or distribute this e-mail without the author's > prior permission. The views expressed in this e-mail message do not > necessarily represent the views of Highmark Inc., its subsidiaries, or > affiliates. > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > -- Vern Ceder vce...@gmail.com, vce...@dogsinmotion.com The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] subclass not inheriting attributes?
On Mon, Jan 3, 2011 at 7:47 PM, Alex Hall wrote: > Hi all, > I have a solitaire game in which I use a "Pile" class. This class is > meant to hold a bunch of cards, so I subclass it for the deck, the ace > stacks, and the seven main stacks, defining rules and methods for each > but also relying on the parent Pile class's methods and attributes. > However, I keep getting an error that an attribute in the parent does > not exist in the child. Below is a simplified example, but it gives me > the exact same error: child object has no attribute l. > > class parent(object): > def __init__(self, l=None): > if l is None: l=[] > > class child(parent): > def __init__(self, *args, **kwords): > super(parent, self).__init__(*args, **kwords) > I believe you need to pass the object both to super() and to the method itself, as in: super(parent, self).__init__(self, *args, **kwords) See the example at http://docs.python.org/library/functions.html?highlight=super#super HTH, Vern > self.l.append(5) > > c=child() > print c.l > > Again, I get an error saying that 'child' object has no attribute 'l'. > Python 2.7 on win7x64. Thanks. > > -- > Have a great day, > Alex (msg sent from GMail website) > mehg...@gmail.com; http://www.facebook.com/mehgcap > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Vern Ceder vce...@gmail.com, vce...@dogsinmotion.com The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] errors in "Python Programming for the Absolute Beginner"??
Bill, Try this: >>> print("hello", "Bill") ('Hello', 'Bill') >>> x = input("Your name?") Your name?Bill Traceback (most recent call last): File "", line 1, in File "", line 1, in NameError: name 'Bill' is not defined and see if those work (my results on 2.6 shown). In Python 3 the results are: >>> print ("Hello", "Bill") Hello Bill >>> x = input("Your name?") Your name?Bill >>> Cheers, Vern The two examples you show would work on any Python 2.x (or even 1.5) system. The parens around the single string won't cause an error nor will using input to get an integer. Cheers, Vern On Thu, Jan 13, 2011 at 11:18 PM, Bill Allen wrote: > I will agree that it seems odd, but here is a sample run from my system. I > promise I am not pulling anyone's leg! :-)) > > wallenpb@Ubuntu-D810:~$ python > Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) > [GCC 4.4.3] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> print("hello world") > hello world > >>> x = input("how many?") > how many?5 > >>> x > 5 > > On Thu, Jan 13, 2011 at 9:31 PM, Corey Richardson wrote: > >> On 01/13/2011 10:29 PM, Bill Allen wrote: >> > That is correct about the difference between Python 2 and Python 3 >> > syntax. However, I am surprised that with 2.7.1 these do not work. I >> > have found that on my Ubuntu system with Python 2.6.5 these Python 3 >> > syntax items do seem to work properly. I am assuming they were back >> > ported or something. I would have expected the same for 2.7.1. >> > >> > --Bill >> >> I'm using Python 2.6.6 and I have a feeling you are not using python >> 2.6.5 with Python3 syntax working. I could be very wrong, but just a >> hunch ;) >> >> ~Corey >> > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > -- Vern Ceder vce...@gmail.com, vce...@dogsinmotion.com The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] ArcGis 10 support materials for Python
I do know that ArgGIS and Python are used together a fair amount, but I'm not aware of a book. I'm assuming that you've already checked out pages like this? http://gisweb.apsu.edu/blogs/arcgis-10-and-python Cheers, Vern On Mon, Jan 24, 2011 at 4:28 AM, saxon piggott wrote: > Hello, > > I was wondering if there is any information anywhere on the use of Python > scripts (How to..) for ESRIs ArcGIS 10? or alternatively, if ESRI press or > perhaps some other publisher has released a book that details obect oriented > programming (presumably with Python scripting) for ArcGIS 10? > > A simialr book exists for VBA for ArcGIS 9 called Getting To Know ArcObjects > released by Robert Burke for ESRI. However I cannot find a dedicated Python > text or site for ArcGIS 9 or 10 anywhere. Its a bit of a problem as ArcGIS > is phasing out VBA which is no longer available in version 10. > > Any help locating a relevent publication would be greatly appreciated as I > can find very little information for this on the Esri site. > > Best regards, > Saxon Piggott > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > -- Vern Ceder vce...@gmail.com, vce...@dogsinmotion.com The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor