Re: [Tutor] getting 'pwd' for XP ?
+++ Shantanoo Mahajan [28-09-06 21:12 +0530]: | +++ Dave S [28-09-06 16:10 +0100]: | | I currently running XP (like a fish out of water :) and I need to know the dir | | that the python script is executed from. a linux 'pwd' How can I achieve | | this - I have looked in sys os os.path but found nothing suitable | | | Python 2.4.3 (#2, Sep 26 2006, 15:27:42) | [GCC 3.4.4 [FreeBSD] 20050518] on freebsd6 | Type help, copyright, credits or license for more information. | import os | os.getcwd() | '/tmp' | | And I do not remember exactly whether it will work or not, but you may try 'cd' instead of 'pwd' on windows. I do not have windows machine to test, so cannot confirm whether it works or not. -- Research is what I'm doing when I don't know what I'm doing. ~Wernher von Braun ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] e-learning Python
Paulino paulino1 at sapo.pt writes: Yes I'm looking for something more interactive, but didn't find anything yet. Lerning by one's self has it's limitations... I don't know of any such course. Probably the closest thing to it is picking a tutorial, work through it on your own and ask on this list when you get stuck/confused - there are many fine tutorials for different knowledge levels, so self-study should get you quite far. People also regularly post small scripts they do while learning and ask for feedback, which is a lot like getting your homework reviewed by a teacher in a more classical approach. Yours, Andrei ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] what.built-in
from http://docs.python.org/lib/built-in-funcs.html some functions are always available--the built-in functions. (from elsewhere) everything in python is an object. hey, from abs() to zip() there's type() and super() and str() and setattr() and ... dir() and... they're the built-ins my question: what.abs() what.zip() etc.? I think there must be a base object, a la java or Nextstep, that supports these functions. what is it? maybe it's not practical, but it's driving me nuts anyway. thanks in advance. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] what.built-in
jim stockford wrote: from http://docs.python.org/lib/built-in-funcs.html some functions are always available--the built-in functions. (from elsewhere) everything in python is an object. hey, from abs() to zip() there's type() and super() and str() and setattr() and ... dir() and... they're the built-ins my question: what.abs() what.zip() etc.? I think there must be a base object, a la java or Nextstep, that supports these functions. what is it? maybe it's not practical, but it's driving me nuts anyway. thanks in advance. They are attributes of the __builtins__ module which is searched as the last element of the name search path (local scope, nested scope(s), global (module) scope, __builtins__). In [3]: __builtins__ Out[3]: module '__builtin__' ( In [4]: dir(__builtins__) Out[4]: ['ArithmeticError', 'AssertionError', ... 'ZeroDivisionError', ... '__debug__', '__doc__', '__import__', '__name__', '_ip', 'abs', 'all', 'any', 'apply', 'basestring', 'bool', ... 'zip'] Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] what.built-in
jim stockford wrote: from http://docs.python.org/lib/built-in-funcs.html some functions are always available--the built-in functions. (from elsewhere) everything in python is an object. hey, from abs() to zip() there's type() and super() and str() and setattr() and ... dir() and... they're the built-ins my question: what.abs() what.zip() etc.? I think there must be a base object, a la java or Nextstep, that supports these functions. what is it? maybe it's not practical, but it's driving me nuts anyway. thanks in advance. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Hi Jim, in Python function are objects also. def test_func(): ... return 1 abs.__class__.__name__ 'builtin_function_or_method' test_func.__class__.__name__ 'function' from types import FunctionType, BuiltinFunctionType isinstance(abs, BuiltinFunctionType) True isinstance(test_func, FunctionType) True Each function is an object. When you call foo() It's actually shorthand for foo.__call__() Try the dir() command - it lists all attributes of an object. For instance: dir(abs) ['__call__', '__class__', '__cmp__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__name__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__setattr__', '__str__'] dir(test_func) ['__call__', '__class__', '__delattr__', '__dict__', '__doc__', '__get__', '__getattribute__', '__hash__', '__init__', '__module__', '__name__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc', 'func_globals', 'func_name'] This means that unlike Java you can pass functions as arguments to other functions/methods - it also means you don't need to wrap everything in a class unnecessarily - in Python you only use a class when you need a class, not because Sun decided that classes were good. ;-) Regards, Liam Clarke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Looking for an edutainment-type introduction to programming book
Hi! I'm looking for a book to give to my younger brother as a birthday present. He is 13 years old, had some experience with logo (but not much, so he knows about simple instructions and loops, but not about, say, algorithms), and is fairly comfortable around computers. He sometimes mentions that he would like to learn programming, but so far my only attempt to teach him was an absolute failure, due mostly to my total lack of pedagogical skills. (I tried to start with the concept of abstract objects, with predictable effects...) What I am looking for is a book thats: 1) simple, and fun enough so that he can learn from it without my continous assistence. (Of course, I can answer questions, but the idea is that I don't want to walk him through all of it.) 2) doesn't look like it is teaching programming -- it should be more like playing with the computer, and having fun style, with the learning programming being a sort of side-effect. Ideally it would use python, but thats not that strict a requirement, squeak or logo might be acceptable, as well. (Although I'm prejudiced towards python, that being my favourite programming language.) Similarly, being a book isn't a requirement either, so a pdf, or an online tutorial would be fine as well, although a book would be better. I tried to search for such books, but I mostly found 'now we are going to learn programming' types, and I would like something more subtle, and more motivating than that. Any suggestions? -- Abel Daniel ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Looking for an edutainment-type introduction to programming book
If he is into games, you could try to look at Python Programming for the Absolute Beginner, from Michael Dawson. It teaches Python through programming a set of simple games. -- Tom, http://www.vscripts.net on Fri, 29 Sep 2006 15:54:32 +0200, you wrote: 1) simple, and fun enough so that he can learn from it without my continous assistence. (Of course, I can answer questions, but the idea is that I don't want to walk him through all of it.) 2) doesn't look like it is teaching programming -- it should be more like playing with the computer, and having fun style, with the learning programming being a sort of side-effect. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Looking for an edutainment-type introduction to programming book
Look here: www.ceebot.com Not a book, but it might be what you are looking for. --- Abel Daniel [EMAIL PROTECTED] wrote: Hi! I'm looking for a book to give to my younger brother as a birthday present. He is 13 years old, had some experience with logo (but not much, so he knows about simple instructions and loops, but not about, say, algorithms), and is fairly comfortable around computers. He sometimes mentions that he would like to learn programming, but so far my only attempt to teach him was an absolute failure, due mostly to my total lack of pedagogical skills. (I tried to start with the concept of abstract objects, with predictable effects...) What I am looking for is a book thats: 1) simple, and fun enough so that he can learn from it without my continous assistence. (Of course, I can answer questions, but the idea is that I don't want to walk him through all of it.) 2) doesn't look like it is teaching programming -- it should be more like playing with the computer, and having fun style, with the learning programming being a sort of side-effect. Ideally it would use python, but thats not that strict a requirement, squeak or logo might be acceptable, as well. (Although I'm prejudiced towards python, that being my favourite programming language.) Similarly, being a book isn't a requirement either, so a pdf, or an online tutorial would be fine as well, although a book would be better. I tried to search for such books, but I mostly found 'now we are going to learn programming' types, and I would like something more subtle, and more motivating than that. Any suggestions? -- Abel Daniel ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor __ 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] Looking for an edutainment-type introduction to programming book
Abel Daniel wrote: Hi! I'm looking for a book to give to my younger brother as a birthday present. He is 13 years old, had some experience with logo (but not much, so he knows about simple instructions and loops, but not about, say, algorithms), and is fairly comfortable around computers. He sometimes mentions that he would like to learn programming, but so far my only attempt to teach him was an absolute failure, due mostly to my total lack of pedagogical skills. (I tried to start with the concept of abstract objects, with predictable effects...) I second the suggestion of Python Programming for the absolute beginner, definitely worth a look. Also he might be interested in Guido van Robot: http://gvr.sourceforge.net/ Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] python text adventures question
I got a copy of Creating Adventure Games on Your Computer in the mail yesterday. Very fun! I set up a moodle class for the project. It seems like a good way to do such a thing. http://crackrabbit.com/moodle/ I realize that I am probably not anyone's idea of a programming howto writer, but hey! I had the space and it looks like a lot of fun. Code snippets will go under the WikiWiki and may be linked to from anywhere. Moodle is pretty neat, despite being written in PHP (WackaWacka). Anyway, sign up if you like the idea and I'll give you instructor ops. Thanks! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] python text adventures question
doug shawhan wrote: I got a copy of Creating Adventure Games on Your Computer in the mail yesterday. Very fun! I set up a moodle class for the project. It seems like a good way to do such a thing. http://crackrabbit.com/moodle/ I realize that I am probably not anyone's idea of a programming howto writer, but hey! I had the space and it looks like a lot of fun. Code snippets will go under the WikiWiki and may be linked to from anywhere. Moodle is pretty neat, despite being written in PHP (WackaWacka). Anyway, sign up if you like the idea and I'll give you instructor ops. I don't get it. What's the password? starts with a? password.startswith('a') == True? _ Can you private e-mail me the password so I can see this? Thanks! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] python text adventures question
Whoops, the password is 'ascii'. :-) Guess I could just take that off, couldn't I? On 9/29/06, Luke Paireepinart [EMAIL PROTECTED] wrote: doug shawhan wrote: I got a copy of Creating Adventure Games on Your Computer in the mail yesterday. Very fun! I set up a moodle class for the project. It seems like a good way to do such a thing. http://crackrabbit.com/moodle/ I realize that I am probably not anyone's idea of a programming howto writer, but hey! I had the space and it looks like a lot of fun. Code snippets will go under the WikiWiki and may be linked to from anywhere. Moodle is pretty neat, despite being written in PHP (WackaWacka). Anyway, sign up if you like the idea and I'll give you instructor ops.I don't get it.What's the password? starts with a?password.startswith('a') == True? _Can you private e-mail me the password so I can see this? Thanks! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Better way to substitute text?
Hi, Just learning Python, on chapter 6 of Learning Python 2nd Ed. So, on to the question. Is there a better way to implement the code below? It scans a saved html file and highlights certain keywords is a bold, red font. It works, but I suppose I'm wondering if it's the Pythonic way. Thanks, Will #!/usr/bin/env python in_put = open('test.html', 'r') out_put = open('test_highlight.html', 'a') for line in in_put: line = line.replace(TWY, bfont color='#FF'TWY/font/b) line = line.replace(RWY, bfont color='#FF'RWY/font/b) line = line.replace(WIP, bfont color='#FF'WIP/font/b) out_put.write(line) in_put.close() out_put.close() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor