RE: [Tutor] What am I doing wrong...
The basic problem is you never told Python to DO anything except define what it would do if anyone asked it to. If you add the line "main()" to the bottom you'll get your message printed. I'm not sure if this is your code or my mail agent (outlook) but as you can see below there's a space between the function name (main) and the parenthesis. I don't believe that's supposed to be there. Good Luck. John Purser -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ken Stevens Sent: Thursday, December 23, 2004 09:33 To: tutor@python.org Subject: [Tutor] What am I doing wrong... I am a elative new comer to python. I wrote the following test snippet. #!/usr/bin/env python def main (): play_test() def play_test (): print "Hi! -- in play test" When I do "python test.py" absolutely nothing happens. I expect it to do the print statement. Thanks in advance for your help. Ken -- The horizon of many people is a circle with a radius of zero. They call this their point of view. -- Albert Einstein ___ 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] happy holidays!
I'm in on the Spaceship but off potatoes because of the carbs. And can we modify that to "reasonable honest communication" please? "No, you're not fat", "This is delicious", "No, I don't think you're mother is insane." all have their rightful place in a peaceful community! And I got my Christmas wish when UPS delivered my very own RS/6000! Happiness is being root on your very own 'nix box! Merry Solstice Season everybody! John Purser -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Israel C. Evans Sent: Friday, December 24, 2004 10:42 To: Bob Gailer Cc: tutor@python.org Subject: Re: [Tutor] happy holidays! 100 foot tall mashed potato sculptures representing the common roots to all belief systems is my holiday wish. That, and a really neat spaceship. Seriously though, I think the best part about "happy holidays" is the Happy. Spread Happy wherever you go. Make it the great plague of the new age. But plaguey in a... good way. Not the bad, everybody is afraid of it and dies from it sort of way.. that's not happy... not really. amusing in monty python flics, but not in real life.. no. ~Israel~ ps.. I'm all for honest communication too.. That kicks patooti! Bob Gailer wrote: > My holiday (and everyday) wish is that we be in touch with our deepest > needs (love, contribution, autonomy, creativity, recognition, etc). > > That we notice in what ways our holiday customs, habits, behaviors > meet or fail to meet these needs. > > That we communicate our needs honestly to those in our lives and ask > them the questions above. > > It might be that we discover that parties, gifts, cooking, decorating, > spending, etc. doesn't meet anyone's deepest needs. > > It might be that open honest communication will go much further to > satisfying our needs. > > Invite your friends and loved ones to debrief the holidays in this > light and to create next year's in a way that is more satisfying, > > Bob Gailer > [EMAIL PROTECTED] > 303 442 2625 home > 720 938 2625 cell > ___ > 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 maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] happy holidays!
sean dwyer wrote: On Fri, Dec 24, 2004 at 11:01:13AM -0800, John Purser wrote: And I got my Christmas wish when UPS delivered my very own RS/6000! Happiness is being root on your very own 'nix box! I've been lurking so long I almost forgot I could email, but I HAVE to ask, what the santa do you need an RS/6000 for?! The biggest python script ever??! The couriers won't let me have MY pressies till next week, bah humbug. Merry Solstice Season everybody! Ho ho ho! Working on my AIX certification so I picked up a cheap RS/6000 of ebay. Amazing what you can find there! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Environment Variables On Windows
Mark Kels wrote: Hello to all :-) I'm writing a CGI script (one of my first ever CGI programs and I'm using this tutor to learn CGI: http://www.oreilly.com/openbook/cgi/ This isn't a python tutor, but the introductions says that any language will be good for this tutor. Anyway, I got to the Using Environment Variables chapter that is in this page: http://www.oreilly.com/openbook/cgi/ch02_02.html. This is UNIX environment variables (as I understand), and I guess they will not work on Windows... So what are the Windows environment variables and how can I use them with python (like any other variable or in a special way?) ? Thanks! Morning Mark, Happy New Year, Merry Christmas, and a jolly Winter Solstice Season! Whenever you're talking about how to do something in Windows it REALLY helps when you include WHICH windows you're working with. I believe the following will allow you to manipulate windows environmental variables. If anyone sees I'm wrong I know they'll speak up. The "set" command when run in a command window without parameters lists your current environmental variables. You can also use it as: c:\> set hello=Hi there Mark which will set the variable "HELLO" to "Hi there Mark". c:\> echo %HELLO% or c:\> echo %hello% will now print "Hi there Mark" without the quotes. Note that quoting, case sensitivity, and white spaces can all react differently under windows than they do in Python. If you need to set an environmental variable to a value every time you start windows then you can either store the above set command (no spaces around that "=" remember) in the autoexec.bat file or on Windows 2000, XP and (I believe) NT you can right click on the desktop icon "My Computer" and select "Properties". Now you're looking for the "Advanced" tab and the environmental variables button in Windows 2000. I THINK it's under the "System Performance" tab and advanced button in XP and you'll have to dig in NT. I'm not sure you can do this here under the win 95/98/ME family. Sorry, right now the only windows product I'm running at home is 2000. You can also set Windows environmental variables from within your python script of course. FYI being a coward myself before I go changing my setup I like to document things. Say running "set > Environment-Before.txt" in a nice safe directory. This will output your current setup so if things get weird you can at least bring things back to you starting point. Have a good one, John Purser ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Environment Variables On Windows
script itself... I tried to do this: import os import cgitb; cgitb.enable() print "Content-type: text/html\n\n" print "Hi there, ",os.system("echo %USERNAME%") But I don't get anything in the browser (500 error - Internal Server Error) and when I run the script in IDLE I get: Hi there, 0 I guess its not the way to print them, but it's the only way I came up with. And I got another question: In my server program I have "User CGI Environment Variables" list that should have pares of Name:Value in it... Whats that? (I guess its the same in all server programs). Thanks! BTW, I'm running Windows XP and Abyss Web Server on my PC. Mark, What you're seeing there is the exit code of the command "echo %USERNAME%" and not the value in the variable our the output of the command. Try: print "Hi there, ",os.environ["USERNAME"] Sorry, haven't done any CGI stuff with any languages. Can't help you there. John Purser ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
RE: [Tutor] O.T.
Wow. An actual ASL post. I haven't seen one of these since I left AOL. I'm a 44 year old IT jack of all trades with a background in accounting. Right now I work for a company creating and automating management reports. I've programmed in a half dozen languages, done networking, have some certifications in Unix and Windows. I guess my status would be "involved". Nice to meet you Jacob. John Purser -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jacob S. Sent: Monday, December 27, 2004 13:31 To: tutor@python.org Subject: [Tutor] O.T. I hate to sound weird... But who are you all, what are you're ages, what do you do, marriage status, etc? You obviously don't have to answer, I'm just curious who I'm boldly sending emails to. Jacob Schmidt P.S. I'm a student. 14 years. Play the piano better than I write scripts. Single. etc. ___ 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] try here for tkinter lessons
Thanks. I've bounced off tkinter several times and have been looking for a new approach. I'll check it out as soon as I can. John Purser -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ron Alvarado Sent: Wednesday, December 29, 2004 13:52 To: tutor@python.org Subject: [Tutor] try here for tkinter lessons I've had problems getting started with tkinter, but since reading these lessons everything is beginning to make sense. If anyone is interested this is the link. http://bembry.org/tech/python/index.php Ron A ___ 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] here documents
I'd like to thank everyone who posted on this thread. I was reading a Korn shell manual the other day and could not figure out what a "here" document was. I'm going to take another run at it with this conversation in mind! Sometimes I can't see the path until I know where it goes. John Purser -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Powe Sent: Monday, January 03, 2005 14:55 To: tutor@python.org Subject: [Tutor] here documents Hello, In perl, I create variables of fairly involved text using here documents. For example, $msg = <<"EOF"; a bunch of text here. ... EOF Is there an equivalent method in python? I usually use this method when creating help messages for scripts -- put all the text into a variable and the 'print $msg' for the output. I find it an easy way to produce formatted text. Now, I'm trying to switch over to python and want to recreate or adapt my processes. Thanks. mp ___ 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] How to run a script file
Bernard, If you're new to Linux you might not be aware of an additional method to run python scripts. If the first line of your script is: #!/usr/bin/python And you've set your script permissions to be executable (chmod 700 myscript.py) then you can run your script just like any other program. You can double click on it in a GUI environment or run it from a command prompt by just typing the script name. Or depending on the value of $PATH variable you might need to type "./myscript.py". Those first characters have to be right though. I'm assuming your python is in /usr/bin. And that is a hash mark followed by an exclamation point. This is called "hash bang" in uningo. John Purser -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Patric Michael Sent: Tuesday, January 04, 2005 14:56 To: tutor@python.org Subject: Re: [Tutor] How to run a script file Hi Bernard... The most basic form is to type "python" followed by the script you want to run. If your script is not in the system path, you'll either need to cd to the directory, or give a full pathname: (the pythonpath doesn't come into play until the interperter is running. python /usr/local/share/filename.py Remember that the script will inherit whatever permissions you currently have, so either log in or su to the user that's expected to run the script. Oh, and in case python itself isnt in your system path, (it probably is) you can find it by typing "which python" at the shell prompt. Patric > Hi, > > Sorry if I missed something obvious, but how do I execute a python > script file in the interpreter? I have "Using the Python Interpreter" > in the Python tutorial but not much is said... > > (this might be a lame quesiton but so far I always used either the > PythonWin interpreter wich has the Import function, or I ran Python > code in an application. Now I'm on Linux so I have to learn the hard > way!) > > > Thanks > Bernard > > ___ > 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 maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
RE: [Tutor] How to run a script file
I'm not sure why it fails "of course". How do you know it's failing at the first slash? Also you might want to look at your .profile file in your home directory and modify your path there. John Purser -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bernard Lebel Sent: Tuesday, January 04, 2005 15:33 To: tutor@python.org Subject: Re: [Tutor] How to run a script file Okay sorry I meant once you're in Python. I'm in Bash console, type Python, enter the Python interpreter. Then I add my custom path to the sys.path list (because my user permissions do not allow my to put anything in the Lib directory) and then I try an import /home/bernardl/python/myScript.py but of course if fails as soon the first slash is read. Thanks Bernard John Purser wrote: > Bernard, > > If you're new to Linux you might not be aware of an additional method to run > python scripts. If the first line of your script is: > #!/usr/bin/python > > And you've set your script permissions to be executable (chmod 700 > myscript.py) then you can run your script just like any other program. You > can double click on it in a GUI environment or run it from a command prompt > by just typing the script name. Or depending on the value of $PATH variable > you might need to type "./myscript.py". Those first characters have to be > right though. I'm assuming your python is in /usr/bin. And that is a hash > mark followed by an exclamation point. This is called "hash bang" in > uningo. > > John Purser > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf > Of Patric Michael > Sent: Tuesday, January 04, 2005 14:56 > To: tutor@python.org > Subject: Re: [Tutor] How to run a script file > > Hi Bernard... > > The most basic form is to type "python" followed by the script you want > to run. If your script is not in the system path, you'll either need to cd > to > the directory, or give a full pathname: (the pythonpath doesn't come into > play until the interperter is running. > > python /usr/local/share/filename.py > > Remember that the script will inherit whatever permissions you currently > have, so either log in or su to the user that's expected to run the script. > > Oh, and in case python itself isnt in your system path, (it probably is) > you can find it by typing "which python" at the shell prompt. > > > Patric > > > > >>Hi, >> >>Sorry if I missed something obvious, but how do I execute a python >>script file in the interpreter? I have "Using the Python Interpreter" >>in the Python tutorial but not much is said... >> >>(this might be a lame quesiton but so far I always used either the >>PythonWin interpreter wich has the Import function, or I ran Python >>code in an application. Now I'm on Linux so I have to learn the hard >>way!) >> >> >>Thanks >>Bernard ___ 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] Python with MySQL ?
A year of so ago I had a major data conversion project to deal with and used python, mysql, and the resources listed below to "get 'er done" (my abject apologies to the non-American readers who will not get that reference). It was very quick to get real results with this toolset. John Purser -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Danny Yoo Sent: Tuesday, January 11, 2005 10:56 To: Mark Kels Cc: tutor@python.org Subject: Re: [Tutor] Python with MySQL ? On Tue, 11 Jan 2005, Mark Kels wrote: > How can I send SQL querys to a MySQL database with a python-CGI program ? Hi Mark, You'll want to grab a "Python DB API" module for MySQL. The best one I've seen for MySQL is 'MySQLdb': http://sourceforge.net/projects/mysql-python and you should probably grab that for your system. It should come with some examples to help you get started. Python.org has a section on Python's database support: http://www.python.org/topics/database/ with some documentation. There used to be a tutorial linked from Linux Journal there, but it's now restricted to subscribers! *g* Here's an example program just to see how the pieces fit together: ### import MySQLdb connection = MySQLdb.connect(db="magic", user="dyoo", password="abracadabra") cursor = connection.cursor() cursor.execute("""select name from cards where tournament_type = 'restricted'""") for (name,) in cursor.fetchall(): print name cursor.close() connection.close() ### I hope this helps you get started! ___ 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] Python with MySQL ?
Great Link. Thanks for the reference! -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Rock Sent: Tuesday, January 11, 2005 19:03 To: tutor@python.org Subject: Re: [Tutor] Python with MySQL ? * Danny Yoo <[EMAIL PROTECTED]> [2005-01-11 10:55]: > > On Tue, 11 Jan 2005, Mark Kels wrote: > > > How can I send SQL querys to a MySQL database with a python-CGI program ? > > Hi Mark, > > You'll want to grab a "Python DB API" module for MySQL. The best one I've You might want to check out sqlobject, too http://sqlobject.org/ It gives you a relatively simple way to "objectify" SQL statements. -- David Rock [EMAIL PROTECTED] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
RE: [Tutor] Ooer, OT Lisp
Very interesting sites. Thank you. John Purser -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alan Gauld Sent: Friday, January 21, 2005 14:33 To: Liam Clarke; Tutor Tutor Subject: Re: [Tutor] Ooer, OT Lisp > 1) Anyone here familiar with both? Yes at least two of us - DAnny has used Lisp/Scheme. > 2) If so, which would you rate as more powerful? Lisp by a long long way. Its more mature and has every bell and whistle going. Of course its much much harder to become an expert in Lisp for the same reason. > 3) What's with all those parentheses? Read my page on Functional Programming. Basically every Lisp program statement is an expression, and like most complex expressions you need parens... Basically a Lisp program is just a whole heap of nested expressions! It doesn't really need them of course but its one of the things that makes Lisp very regular in a math sense, very pure in approach, and why the academics say its the only "beautiful" language. > 4) Perhaps the powerful question's a bit vague, how about ease of > use? I like that the simplest Lisp expression is - , but those > brackets Its very easy to use once you learn it. But its initially different to traditional programming languages (although since it was invented in the early 60s - late 50's even??? - it is ttraditional in itself!) > 5) Are you able to point me towards a simplified explanation of how > the 'syntaxless' language can write programmes? Try the How To Design Programs (htdp.org) and Structure & Interpretation of Computer Programs (sicp.org) web sites. Both are excellent books published by MIT for free on the web. Both use Scheme which is a close relative of Common Lisp. I strongly recommend you check them out your programming in general will improve a lot from reading either book. The first is easier for non maths folks, SICP is a software engineering classic textbook. 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 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
RE: [Tutor] sorting a 2 gb file
I'll just "Me Too" on Alan's Advice. I had a similar sized project only it was binary data in an ISAM file instead of flat ASCII. I tried several "pure" python methods and all took forever. Finally I used Python to read-modify-input source data into a mysql database. Then I pulled the data out via python and wrote it to a new ISAM file. The whole thing took longer to code that way but boy it sure scaled MUCH better and was much quicker in the end. John Purser -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alan Gauld Sent: Tuesday, January 25, 2005 05:09 To: Scott Melnyk; tutor@python.org Subject: Re: [Tutor] sorting a 2 gb file > My data set the below is taken from is over 2.4 gb so speed and memory > considerations come into play. To be honest, if this were my problem, I'd proably dump all the data into a database and use SQL to extract what I needed. Thats a much more effective tool for this kind of thing. You can do it with Python, but I think we need more understanding of the problem. For example what the various fields represent, how much of a comparison (ie which fields, case sensitivity etc) leads to "equality" etc. Alan G. ___ 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] Are you allowed to shoot camels? [kinda OT]
Glad someone else thinks so. I tried getting into Perl. The rational made perfect sense and I had picked up several languages by then. Tried. Hated it. Bounced off it. It's like reading alphabet soup. IMHO they took what was wrong with Shell scripting, AWK, Sed and a few other languages and rolled them into one. That's when I came across Python. Never looked back. John Purser -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Liam Clarke Sent: Wednesday, February 02, 2005 15:18 To: Tutor Tutor Subject: [Tutor] Are you allowed to shoot camels? [kinda OT] Hi, Had the *ahem* joy of learning Perl last night. Egad. Wrote the script in Python to get it right, and then 'translated' it to Perl. Does the style of coding Python engenders suit the Perl environment in anyone's experienc? AFAI can see there is no real 'style' to Perl, apart from white noise of non alphanumeric characters. Just wondering if I should bite the bullet and code from scratch in Perl, or if my Python - Perl is Ok. Two codes are here - Python http://www.rafb.net/paste/results/BVaym940.html Perl http://www.rafb.net/paste/results/LromA876.html [OT begins] By the way, I'm only learning Perl because I need to script some routine HTML maintenance, and I can't be bothered applying to head office IT for an install of Python, as the justification involved is ludicrous, especially considering that my role as defined does not include scripting. First impressions of Perl - 1) I'll use Perl for the regex stuff from now on, Perl is obviously built for this. 2 ) There's More Than One Way To Do It makes debugging hard - i.e. close INFILE; & close (INFILE); are both valid. I like one syntax, cos it's easier to remember. 3) Some stuff is counter-intuitive - $lenOfModList = @moddirList is the Perl equivalent of lenofModList = len(moddirList) @someArray = (@someArray, $newValue) is the same as someArray.append(newValue) I couldn't figure this one out until I read that Perl automatically flattens lists. Also, why doesn't if ( not $d eq "a" && not $d eq "c") evaluate to true for $d = "b" when if (not $d eq "a") evals to true and if ($d ne "a" && $d ne "c") evals true also? What's with that? 4) WHAT IS WITH THE STUPID SYMBOLS EVERYWHERE LARRY??!! I'm not referring to the $ & @, I can see how they could be useful, although with a list - @dude = (1, 2, 3), to obtain the 2nd value I would expect $d = @dude[1], not $d = $dude[1], that's counterintuitive also. Oh, no, what I'm referring to is stuff like @_, and @!, and @indexFile = to read a whole file, and this - I hate Perl for this - open OUTFILE, ">c:/python23/j/index.htm" What's the difference between open OUTFILE, "c:/python23/j/index.htm" and open OUTFILE, ">c:/python23/j/index.htm" ? The first will open index.htm with the handle OUTFILE, to read... The second will open index.htm with the handle OUTFILE to write!. Of course, the documentation I had didn't mention that. It just said to open it and use print FILEHANDLE $value; to write. Oh no, I had to find a CGI Perl tutorial, which mentioned using &lst; to open and &gst; to write (or something), which I guessed as lesser/greater than. Why is the read/write modifier part of the filename??? Why is it a > ? In my opinion, there's only one place a > sign should be, in an inequality test. So, Perl in my opinion - great for regexes obviously based around *nix conventions. Big hodge-podge, oozing with inconsistency. I'd hate to work collaboratively on a Perl project. Two steps up from Brainf**k in parts. Obviously in need of a benevolent dictator a la Guido. But then, I've been spoilt by clean, smooth (usually) Python. Lovely, usually consistent Python. Aah, Pytho *dreamy look* [end OT rant] -- 'There is only one basic human right, and that is to do as you damn well please. And with it comes the only basic human duty, to take the consequences. ___ 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] Reading Tutor with gmail: monospace fonts
Thanks for the tip. John Purser -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Dunn Sent: Thursday, February 24, 2005 14:43 To: tutor@python.org Subject: [Tutor] Reading Tutor with gmail: monospace fonts Hi all, This is slightly off topic, but I've noticed a lot of people are using gmail accounts to post to tutor and I just wanted to share a useful trick I just learned for making gmail display and edit mail with a monospace rather than proportional font. I'm sure anyone who's tried it agrees that significant whitespace means that python and proportional fonts don't play well together... Basically, you need to get your browser to override the stylesheet of the page with the following snippet of css: div.msg div.mb, .cm, .tb { font-family: monospace !important; font-size: 12px !important; } In Firefox, you add it to the userContent.css file in your preferences (you'll probably have to create this, see http://www.mozilla.org/support/firefox/edit). With Safari on MacOSX you make a css file anywhere you like (I used ~/Library/Safari/MyPrefs.css), add this snippet, and then select the file from the "Advanced" tab in Safari's Preferences. I don't know about other browsers, but the same sort of thing is almost certainly possible. Cheers, Michael ___ 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] Acessing files in Windows 2000
Try c:\\my documents\\memo.txt John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dave S Sent: Tuesday, March 08, 2005 14:24 To: Python Tutor Subject: [Tutor] Acessing files in Windows 2000 I have a script that converts data relating to my work. It works great on my Linux system but some of my colleagues run windows. I am attempting to convert the file paths to windows but am having no luck. I need to access 'memo.txt' in 'my documents' on windows & am struggling. I have tried just about every combination of \ and / and \\ and // but to no avail. I need something like ... C:\My Documents\memo.txt Can anyone advise me ? Dave ___ 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] Acessing files in Windows 2000
I agree with a previous poster, check your path. I think either the path doesn't exist or you don't have permission to get to it. John -Original Message- From: Dave S [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 08, 2005 14:50 To: [EMAIL PROTECTED] Cc: 'Python Tutor' Subject: Re: [Tutor] Acessing files in Windows 2000 John Purser wrote: >Try c:\\my documents\\memo.txt > > >John > > Unfortunately thats a no go ... palm.py palm memo.txt to oocalc data.csv convertor, written by lentil ;) [EMAIL PROTECTED] - enter "palm software" in the title or it will be junked 09-03-2005 v1.02w Coded for Windows 07-03-2005 v1.02 Coded capitalization() + default to mon 03-03-2005 v1.01 Squished 1/9 decode bug 02-03-2005 v1.00 Coded for Linux Traceback (most recent call last): File "C:\Documents and Settings\Administrator\Desktop\palm.py", line 268, in ? palm_conv() File "C:\Documents and Settings\Administrator\Desktop\palm.py", line 54, in palm_conv memo = open(memo_file, 'r') IOError: [Errno 2] No such file or directory: 'c:\\my documents\\memo.txt' >>> If I try c:\\ or c:\ it always comes out as c:\\... and fails Dave ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Debian install problems.
David, If you don't get an answer here on tutor.python.org then you might want to try: http://www.debian.org/MailingLists/ - where you'll find a link to http://lists.debian.org/debian-python/ - the mailing list for debian-python. Don't forget to search the archives. John Purser -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Driver Sent: Wednesday, May 11, 2005 06:43 To: tutor@python.org Subject: [Tutor] Debian install problems. I don't know is this is the proper place to post this but I need some help. I am running Damn Small Linux at the moment. I enabled apt-get and adjusted the list file to use the testing branch so I could install python2.4. The apt-get went fine, I think. I didn't get and errors. When I went to install quixote from a distutils package I received the following error: [EMAIL PROTECTED]:~# cd /home/dsl/Quixote-2.0 [EMAIL PROTECTED]:~/Quixote-2.0# python2.4 setup.py install running install error: invalid Python installation: unable to open /usr/lib/python2.4/config/Makefile (No such file or directory) Does anyone have any Idea where I should go from here? I have tried other distutills installs with the same results. Any help is appreciated. Thanks! -- *** See there, that wasn't so bad. *** ___ 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] Python Resources
Greg, Thanks for taking one for the team! How about some OS specific resources like the Active State (I think I have that right. At work so I can't check) stuff for windows/com and the debian-python mailing list that came up the other day. I even ran across some AS-400 python stuff a while back. Python is cross platform but there are platform specific issues and communities that can help with them. Just a thought. Thanks for being out there and making us look good. John Purser -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Greg Lindstrom Sent: Friday, May 13, 2005 05:53 To: tutor@python.org Subject: [Tutor] Python Resources Hello- I have been asked to write an article for the IEEE "IT Pro" magazine dealing with using Python in the medical field. The editors asked for about half the article dealing with using Python and the other half giving a short tutorial. They also asked for three "sidebars"; I'm going with Tim Peter's "Zen of Python" for one, a comparison of "Hello, World", in C, C++, Perl, and Java in the second, and for the third I would like to list some resources. I have the Python home page, "Dive Into Python", the Python Gems" page, but would like to ask what resources would any of you suggest? I'd like between 5 and 10, with a short description of each. The article emphasizes the simple syntax of Python and the friendliness of our community. It encourages anyone interested in learning to subscribe to this mailing list and ask questions (though I do caution them not to submit their homework simply to get a solution). I have asked two people to review the paper from a "Python" perspective to make sure I have not mis-represented the language (I'm sorry about the delays, Steve, but the paper is coming!). If any of you would like to review it, I would be happy to send you a copy, too. I have about a week before submission. Thanks for your help, --greg ___ 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] question about programmers
If that's your only question about programmers then you aint been around them much. I'm 45. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Wednesday, June 22, 2005 14:38 To: tutor@python.org Subject: [Tutor] question about programmers What's the average age of a python user? This is my only question about programmers themselves. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Quickest way to find a folder on windows
Since the "My Documents" folder can be re-named you need to search the registry to see what the user's "my documents" folder is. I'm not sure what domain constraints might do to this setting. Perhaps the most efficient method if you were just interested in the current user's "My Documents" directory would be to determine the current value of the %HOME% variable. John Purser From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jorge Louis De Castro Sent: Tuesday, July 26, 2005 04:32 To: tutor@python.org Subject: [Tutor] Quickest way to find a folder on windows Hi all, What is the quickest way to find/search a folder on windows? Specifically, I want to find the 'My Documents' folder on different machines but since this one lies in different user-specific folders (the user account on XP) I'm being forced to traverse the whole drive looking for it (though I can start from 'Documents and Settings' to prune the search space) Is there a faster way? I know this is very reliant on the windows search API so maybe I'm stuck with my solution Any help is appreciated cheers j ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hello
In Python that's Guido.Hail('All') -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Eric Walker Sent: Wednesday, August 24, 2005 16:49 To: tutor@python.org Subject: [Tutor] Hello all, Hello... I just finished a class given by Mark Lutz and I love python. Now I need to find a project to hone my skills. I am sure I will be sending lots of questions to this list. I used to use perl but now Its gone. I am now a Python guy... Hail Guido __ 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] Hello
You know, I got that backwards and I can't tell you how much it's bugging me! All.Hail('Guido') Thanks. John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Purser Sent: Wednesday, August 24, 2005 16:52 To: 'Eric Walker'; tutor@python.org Subject: Re: [Tutor] Hello In Python that's Guido.Hail('All') -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Eric Walker Sent: Wednesday, August 24, 2005 16:49 To: tutor@python.org Subject: [Tutor] Hello all, Hello... I just finished a class given by Mark Lutz and I love python. Now I need to find a project to hone my skills. I am sure I will be sending lots of questions to this list. I used to use perl but now Its gone. I am now a Python guy... Hail Guido __ 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 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Handling binary file
Julie, I've had to work with some binary files with 3 byte data types. They were generated by an application coded in Business Basic. Like you I grabbed it as bytes and converted. For clarity's sake I used powers of 2 instead of hard coding the numbers. 2^8 makes it pretty obvious why you're multiplying by 256 IMHO. Look out for negative numbers though. May not be applicable to "number of seconds" but as a general rule watch for it. Incidentally when I had to read the same data with VBA I used the same technique to reverse the byte order from Unix to Windows. Worked just fine. John Purser From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Julie LaiSent: Wednesday, August 24, 2005 18:20To: tutor@python.orgSubject: [Tutor] Handling binary file I have opened a file in binary mode. The 9th, 10th and 11th bytes contain the time in seconds. In order to get this value in decimal I did the following: timeinsec = bytes[9] * 65536 + bytes[10] * 256 + bytes{11] Would someone please advise if there is a better way to do this? Thanks, Julie. ___想即時收到新 email 通知?下載 Yahoo! Messenger http://messenger.yahoo.com.hk ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Grepping a file for words in a list
Hello, I'm writing a system admin script in python that checks recently accessed files for keywords like "failed, denied, error,..." etc. I'm using popen to call grep -F but it's VERY slow. Can anyone suggest a faster method to do this? Thanks, John Purser Ubuntu Linux Python 2.4 -- Courage is your greatest present need. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Grepping a file for words in a list
On Fri, 24 Feb 2006 12:23:22 -0800 (PST) Danny Yoo <[EMAIL PROTECTED]> wrote: > > > On Fri, 24 Feb 2006, John Purser wrote: > > > I'm writing a system admin script in python that checks recently > > accessed files for keywords like "failed, denied, error,..." etc. > > I'm using popen to call grep -F but it's VERY > > slow. Can anyone suggest a faster method to do this? > > Hi John, > > This should not be slow, but we have to see what exactly is going on > here. Can you give us more details? How many keywords are you > typically passing in ? How large is the ? What do > you mean by "slow"? > -- What good is an obscenity trial except to popularize literature? -- Nero Wolfe, "The League of Frightened Men" Danny, "what exactly is going on" is that I'm a doofus who will spend hours figuring out exactly what command string will get grep to work but then won't bother to put it in his code!!! DOH!!! John ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hi All
On Sat, 2 Sep 2006 13:39:05 +0200 tomd <[EMAIL PROTECTED]> wrote: > > i have just started working on Python ... > > please let me know the books to refer to start > > learning > > I recommend Beginning Python from Magnus Lie Hetland, apart from being > comprehensive and targetted at beginners, it will take you through the > develoopment of 10 various projects, including game, file sharing > application, or discussion forum. > > -- > Tom, http://www.vscripts.net/ > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor What he said! John Purser -- Be careful! Is it classified? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] opening files
On Mon, 2006-09-25 at 12:55 -0600, max . wrote: > hello i cant understand how to open text files with python > i have tried tutorials and evrything i just cant get pleas help > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor Hello Max, my_file = open('c:\\path\to\file\file.txt', 'r') my_file.readlines() my_file.close() Really, it's so simple it's hard to come up with directions. Just do it. John Purser ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor