Re: [Tutor] Creating folders
Toon Pieton wrote: Hey friendly users! My question is pretty simple. How can I create a folder with Python? Trying to make a program which will allow me to save my notes (txt files) quickly and cleanly. Having to create folder manually would really make it a bit obsolete. Thanks in advance! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor import os os.mkdir(name_of_directory, permissions) print os.mkdir.__doc__ Glenn -- Ketchup. For the good times... - Ketchup Advisory Board Glenn Norton Application Developer Nebraska.gov 1-402-471-2777 [EMAIL PROTECTED] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Writing a list in a text file
Mihai Iacob wrote: Hello def saveBugs(data): store = open(filename, 'w') for timeMark,aList in data.items(): store.write(timeMark + '\n') store.write(aList + '\n') store.close() data is a dictionary aList is a list After i run this part the following error pops up: Traceback (most recent call last): File C:\Python\Bugs.py, line 133, in module main() File C:\Python\Bugs.py, line 130, in main saveBugs(dataBugs) File C:\Python\Bugs.py, line 17, in saveBugs store.write(aList + '\n') TypeError: can only concatenate list (not str) to list Can anybody tell me how to make it work Yahoo! Music Unlimited Access over 1 million songs. http://music.yahoo.com/unlimited ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Hi Mihai, The error says it all. You cant concatenate a string to a list [1,2,3,4,5] + '\n', Try [1,2,3,4,5] + '\n' in the interpretor, you ll get the same error. write() doesn't know what to do with a list as [i think] it will only handle strings. If you wrap your list in str() for writing, that should do the trick Wouldn't hurt to wrap timeMark in str() also, unless your positive that the keys will always be strings store.write(str(timeMark) + '\n') store.write(str(aList) + '\n') HTH Good Luck, Glenn -- Ketchup. For the good times... - Ketchup Advisory Board Glenn Norton Application Developer Nebraska.gov 1-402-471-2777 [EMAIL PROTECTED] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Database Table Primary Keys
Tod Haren wrote: Using a DBAPI 2.0 module such as ADODBAPI, how can a I identify the primary key fields of a table. cursor.desctription doesn't hold this info, unless I'm missing something. I just don't see it in the documentation. Maybe there's an SQL statement I haven't found yet. Is this even possible? I'm sure I could get this info from ADOX and win32com, but that seems a little excessive at this stage. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Hi Tod, When I need any kind of table meta data, I use describe cursor.execute(DESCRIBE table) I'm sure there are many different ways, but that's what I use. Good Luck, Glenn -- Ketchup. For the good times... - Ketchup Advisory Board Glenn Norton Application Developer Nebraska.gov 1-402-471-2777 [EMAIL PROTECTED] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] One million and counting
Alan Gauld wrote: Hi folks, In just thought I'd mention that my web tutor has now passed the million visitors mark. Thanks to all those on the tutor list who have paid a visit. Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Congratulations Alan! I visited your site many times when first learning Python. Keep up the good work. Glenn -- Ketchup. For the good times... - Ketchup Advisory Board Glenn Norton Application Developer Nebraska.gov 1-402-471-2777 [EMAIL PROTECTED] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] basic question ...
Ravi Kondamuru wrote: Hi, How does one figure all the builtin libraries/ classes that python supports? For example if I want to sort a list of names, I would normally think of implementing the sorting routine in C. I am just beginning to learn python. It looks like there is a rich set available builtin libraries. So, is there one place where I can look to figure out I dont have to write afresh. thanks, Ravi. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor A good way to start is the dir() method which will show what is available to an object mylist = [] dir(mylist) ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__str__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'] myString = '' dir(myString) ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__str__', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'replace', 'rfind', 'rindex', 'rjust', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill'] also, try the builtin help in the interpreter help(mylist.sort) Help on built-in function sort: sort(...) L.sort(cmpfunc=None) -- stable sort *IN PLACE*; cmpfunc(x, y) - -1, 0, 1 Good Luck, Glenn -- Ketchup. For the good times... - Ketchup Advisory Board Glenn Norton Application Developer Nebraska.gov 1-402-471-2777 [EMAIL PROTECTED] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] CGIHTTPServer - redirect output to a log file
Paulino wrote: How can I redirect the output of an CGIHTTPServer from the console to a logfile? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor You can start it from a shell script #!/bin/sh ./MyWebServer.py 2/path/to/output.log Good Luck, Glenn -- Ketchup. For the good times... - Ketchup Advisory Board Glenn Norton Application Developer Nebraska.gov 1-402-471-2777 [EMAIL PROTECTED] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Equivalent to perl -e
Chris Lasher wrote: My professor and advisor has been inspired by me to give Python a try. He's an avid Perl user, and challenged me with the following: What is the Python equivalent to perl -e 'some oneliner'? Embarassingly, I had no answer, but I figure, someone on the list will know. His use of Python is at stake; he threatened that, since he's dependant enough on using perl -e within Emacs enough, if it can't be done in Python, he won't take the language seriously. Help me, Python Tutor, you're his only hope! Thanks in advance, Chris ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor How about... python -c for x in 'Tell them to jump on board and take the blue pill': print x Glenn -- Ketchup. For the good times... - Ketchup Advisory Board Glenn Norton Application Developer Nebraska.gov 1-402-471-2777 [EMAIL PROTECTED] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] A puzzle for you
John Fouhy wrote: From the python_dev LiveJournal community --- Predict the outcome of the following code: ## from random import * seed() [choice(dict((x+1,0) for x in range(1000))) for x in range(693)][0] ## random.choice( [ SyntaxError: invalid syntax, 42 the answer is young skywalker. always the answer is 42. ] ) -- Ketchup. For the good times... - Ketchup Advisory Board Glenn Norton Application Developer Nebraska.gov 1-402-471-2777 [EMAIL PROTECTED] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Magazine
Amadeo Bellotti wrote: I no im probally not the best pereson to go about this but maybe people in this community are. I was wondering if there was or maybe someone can start a Python maganize kinda like 3dCreative or 2d Artist. that is an PDF magazine with tutorials interviews, python news, and maybe a programming challenge or two. and free would be nice i might start this but does anyone want to help maybe? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor #1, make it so... http://www.pyzine.com/ -- Ketchup. For the good times... - Ketchup Advisory Board Glenn Norton Application Developer Nebraska.gov 1-402-471-2777 [EMAIL PROTECTED] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help
Kefka Palazzo wrote: OK, first of all, I just started learning python a few hours ago so deal with me here. I'm picking up quite fast on Python since I took a C++ class a year ago when i was 13. However, before I go deep into learning it, I want to know if Python will work for the purpouses I need. I am trying to learn a programming language good for programming entire games (core functions too) similar to both the Final Fantasy and Metroid series. From the book I'm learning from (Python Programming for the Absolute Beginner, by Michael Dawsom) it seems like within a week or two I'll have a basic grasp on most of the functions, but I want to know if it will be worth it for what I need it for or if I would be better off learning something different (and harder .) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor I'm not a game writer, but there a good quote on the home page from Firaxis Games http://www.python.org/about/quotes/ ( bottom of page ) Good Luck, Glenn -- What's an Ear? ... A Jar and with a War of course! Why Programmers are Lonely - Reason #14 Glenn Norton Application Developer Nebraska.gov 1-402-471-2777 [EMAIL PROTECTED] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor