[Tutor] awk like functionality in python
Hello, this is my first post. I'm glad a place like this exists. I'm coming from primarily a shell scripting background and it was suggested I should learn python because the two are closely related. I've been studying python now for about a week and as of right now, I'm not really seeing many similarities. Anyway, to learn python as fast as I can, I thought I'd just dive in and try to write a program but I'm stuck on the first step. The program I'm writing comes from this website: http://www.meetup.com/NOVA-Python/events/232629865/ I am not a member of the group and have not been to any meetings yet but here's the homework assignment I'm working on... *1. Find the total number of births in each year. If you can, find the total for both male and female births. Plot your results. * I've downloaded the files and put them in a directory and here's the script I wrote to tackle the first part of the question, the total number of births in a year: -- #!/bin/bash FILE_DIR=/home/ronw/my_python_journey/names for i in `ls $FILE_DIR` do OUTPUT=`awk -F, 'BEGIN{OFS=" ";} {sum+=$3} END {print FILENAME, sum}' $FILE_DIR/$i | awk -F'[^0-9]*' '{print $2, $3}'` echo $OUTPUT done Question: How would I write a similar program and achieve awk like functionality in python? Thanks ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] legacy help
Help. We are upgrading our Win XP to Win7 (64bit) (intel) machines. We have a legacy Python program we need to still run. We were using ver 2.4 and we had a shortcut to C:\fileditor\main.py.I installed ver 2.7.9 "Windows x86-64 MSI installer". Is that what I wanted??? When I pick the shortcut, a black cmd window flashes and is gone. I can start the program from the Start Menu, so it's installed OK. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Hello Python Tutor - help please!
Hi, Cecilia: I came across your posts when catching up with my tutor-request digest emails. I did not see the Udacity site mentioned--if it was, my apologies for the repetition. Udacity.com, a free online education service, offers a number of high-quality courses. They include interactive quizzes using code sandboxes. The courses are 7 weeks long with online office hours and forums. If you do not want to wait for the next start date, you can take the courses online without getting instructor responses to students' posts. Free Interactive Computer Courses (interaction via online quizzes using code sandboxes): http://www.udacity.com/ Intro to Computer Science Python -- Beginner -- Project create functional search engine http://www.udacity.com/view#Course/cs101/CourseRev/apr2012/Unit/671001/Nugget/675002 Programming Languages Python, JavaScript -- Intermediate -- Project: Build a Functional Web Browser http://www.udacity.com/view#Course/cs262/CourseRev/apr2012/Unit/3001/Nugget/5001 Web Application Engineering Python -- Intermediate -- Project: Build a Functional Blog http://www.udacity.com/view#Course/cs253/CourseRev/apr2012/Unit/4001/Nugget/5002 Other courses available. Best regards, Ron Painter ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] learnpython.org - Free Interactive Python Tutorial
For those of you who didn't notice the title, here is the link: www.learnpython.org Also, please note that there is still not enough content to actually learn from the website yet. I am hoping people will help me with writing tutorials so the site will be useful as soon as possible. On Wed, Apr 20, 2011 at 9:16 PM, Ron Reiter wrote: > Hey. > > I've created a website for learning Python interactively online. Check it > out, and I would really appreciate it if you can also contribute tutorials. > > Thanks! > > -- > -- Ron > -- -- Ron ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] learnpython.org - Free Interactive Python Tutorial
Hey. I've created a website for learning Python interactively online. Check it out, and I would really appreciate it if you can also contribute tutorials. Thanks! -- -- Ron ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] New Issues with REGEX Greediness: (gpo)
psst, there is NO standardized reg-ex. you've been living in a perl bubble. undoubtedly other people will have better advice. "Life can only be understood backwards; But it must be lived forwards" --S.K. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] loop example from 'Learning to Program'
thanks Luke, you folks are awesome! Luggage? GPS? Comic books? Check out fitting gifts for grads at Yahoo! Search http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] loop example from 'Learning to Program'
ok, this code is written with vi: #/usr/bin/env python #foreach.py myList = [1,2,3,4] for index in range(len(myList)): myList[index] += 1 print myList ~ here's the result: ~$ ./foreach.py ./foreach.py: line 3: myList: command not found ./foreach.py: line 4: syntax error near unexpected token `(' ./foreach.py: line 4: `for index in range(len(myList)):' I think I liked the first result better! thanks again, ron Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center. http://autos.yahoo.com/green_center/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] loop example from 'Learning to Program'
So I'm starting to work my way through Alan's online book, reading, then typing in code and seeing it work. The following is a snippet of code in the Loops section. I'm getting an error message. Here's the code and error message: myList = [1,2,3,4] for index in range(len(myList)): myList[index] += 1 print myList File "", line 3 print myList ^ SyntaxError: invalid syntax can someone tell me what the syntax error is, and how to correct it? my thanks, ron Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase. http://farechase.yahoo.com/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] loop example from 'Learning to Program'
Here's the code and error message: Be a PS3 game guru. Get your game face on with the latest PS3 news and previews at Yahoo! Games. http://videogames.yahoo.com/platform?platform=120121 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How can I escape a pound symbol in my script?
in the US, # is a symbol for weight, not currency. How do you write out, with a quick symbol, "I'm going to buy 3# of potatoes? Of course now you're metric, but did you also use 'pounds' for weight before that? Ready for the edge of your seat? Check out tonight's top picks on Yahoo! TV. http://tv.yahoo.com/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 41, Issue 7
hi steve, I have summer class for next three monday and wednesday evenings. we'll catch up someday. sorry, ron Luggage? GPS? Comic books? Check out fitting gifts for grads at Yahoo! Search http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] urlretrieve
Is there a way to get the urlretrive module to grab multiple files similar to wget? Ron Nixon Expecting? Get great news right away with email Auto-Check. Try the Yahoo! Mail Beta. http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Update BLOB with odbc
It must be easier than I am making it. sql = "UPDATE sa2.outfalls SET photo_content = %s WHERE pppoint_id ='"+record[0].strip()+"';" newsql = sql%pstuff print newsql[:150] cursor.execute(newsql) __ the print newsql[:150] => "UPDATE sa2.outfalls SET photo_content = ÿØÿá*EExif . . . " and I get this error: TypeError: argument 1 must be string without null bytes, not str which sounds reasonable, but I don't know how to fix it. Is there some escape thing that I'm missing? Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] MySQLdb question.
That was it all right! Thanks, Kent! Ron___Ron Phillips wrote: > I am trying to write a script that adds data to a table using > MySQLdb.py. For some reason, "INSERT" seems to work temporarily. I > run a command to insert a row, and then do a select query, and it's > there. After the program shuts down, though, it's gone. No rows are > permanently created. SELECT works fine from MySQLdb, CREATE TABLE too, > but when I add data, it's only there while the script is executing, > then it's gone. Try calling conn.commit() before conn.close(). IIRC older versions of MySQL were set to auto-commit by default but newer versions require the explicit commit. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] MySQLdb question.
I am trying to write a script that adds data to a table using MySQLdb.py. For some reason, "INSERT" seems to work temporarily. I run a command to insert a row, and then do a select query, and it's there. After the program shuts down, though, it's gone. No rows are permanently created. SELECT works fine from MySQLdb, CREATE TABLE too, but when I add data, it's only there while the script is executing, then it's gone. I can add data from the MySQL Query Browser, and it's fine. I googled, but couldn't find anything. I'm running MySQL5, and the latest MySQLdb.py, too. Python 2.4. I am using animal.py from http://www.kitebird.com/articles/pydbapi.html, but it's been the same thing with other scripts. Is it a setting, or a thinko, or what? Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] making a python program part of xhtml
>>> Emily Fortuna < [EMAIL PROTECTED] > 6/8/2006 9:19 AM >>> Hola everyone, I'm working on creating a webpage in which a user can submit data into fields to be held in a database (there are other details, but this is the gist of the idea), and I need to use python. I am unfamiliar with manipulating data and web apps as a whole (and new to python), so I have been encountering much unfamiliar terrain. I _think_ I want to somehow embed the python into the page, but I'm really not sure how to do it. After googling I found some programs that generate xhtml from python, but I don't think that is what I want, or is it? Your help is appreciated! Emily You might look at http://karrigell.sourceforge.net/: karrigell lets you embed python in xhtml, xhtml in python, execute straight python scripts, or execute python from a karrigell application server. Even if you don't choose karrigell for some reason, at least the documentation can help you sort out the variations on the python/xhtml theme! Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] [Off topic] Is Zero Positive (was: Not Really Questions)
It seems that the confusion is exacerbated by the fact that we're using the theoretical number set to reference the common one. I suppose this is a carry-over from binary, since in binary if you don't have a zero, you also won't have a bunch of other numbers like 2, 4 and so forth. __ 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] Not Really Questions
I think we should say that the number set is zero through nine (not 1-10 as we were taught in school), making "zero" the first number in the set; thus the offset by one. Of course zero is not a number, but a placeholder for a number. Thankfully this concept was invented a few centuries ago in India and brought to the West by Arab scholars. Unfortunately I think it's still not widely understood. __ 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] a question about symbol
When I run this program using your code on Ubuntu Linux, I get: ~$ ./c2f.py 44 44\uF = 7\uC Please notice that the code you have posted has indentation block errors. __ 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] web intefaces?
I like Karrigell ...http://www.karrigell.com/ for being flexible, complete, lightweight, and easy to learn. I don't know how it scales, but that's not really a consideration for the applications you describe. Ron>>> "Chad Crabtree" <[EMAIL PROTECTED]> 5/8/2006 6:29 PM >>>While everything that Alan Guald said is true, there are a couple ofoptions for you. Provided you know HTML (you must), you couldgenerate html pragmatically but, knowledge of html is still mandatory.Your options are, basicallyhttp://www.cherrypy.org Which is an app server that should be fairly easy to package up with,say py2exe.Another option, with CGI (pretty easy) is found in the standard library.http://docs.python.org/lib/module-CGIHTTPServer.html If you do this as a personal app I would make sure to use an alternateport number like 11224, or something.HTHBest of Luck.On 5/6/06, Alfonso < [EMAIL PROTECTED] > wrote:> I would like to experiment with web interfaces and python. After some googling, I'm quite confused, does somebody know of a good link about this topic / what do you think that is the best software option to design web user intefaces with python? I mean web interfaces for common programms (so it's not important to me to have a very robust web server), the web server should run in the machine of the user of the programm.And it should be easy installed, as bundle, when I distribute the programm.>> Thank very much for your help.>>>> __> LLama Gratis a cualquier PC del Mundo.> Llamadas a fijos y móviles desde 1 céntimo por minuto.> http://es.voice.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] Brain In Vice: Why is this so fun to me?
Regex aside, just for a moment the subject line gets my vote for "Most Succinct Description of Programmer Mindset", if there's a competition on. Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Use iterator to refer to an object's attribute?
Alan Thanks for the thorough reply. > Hi Ron, I'm confused and may be missing something but it > sounds to me like a classic tree structure that you are trying > to build for each module. It seems like a tree to me. > I''m not sure why you put filling the database into a separate > function rather than as a method of the Database class, it > could then be called from the init method. This would give > it direct access to the Database attributes. This structure evolved. As I solved one problem, I ran into another, and eventually ended up with the current design. I know it's not ideal, but it's the result of my spotty knowledge of Python and what I was able to locate in the assorted documentation that I have skimmed through looking for things that looked relevant. > Also I don't understand why you need the componentlist > name. What is this used for? The name of the list is surely > an internal variable within the module of no relevance to > the outside world? I was hoping to eventually put all of the data in a separate Python module. That way if it ever changed, I could just edit that file. > I'm also not clear about the database structure. Is the one > represented here the final striucture - ie a set of Python lists. > Or will you eventually be loading the data from a config file > or a relational database at some point in the future? I'm not talking to a SQL database or anything like that. I just have this chunk of data. It will change occasionally, so I need a convenient place to edit the data > If it stays as it is then the whole design seems overly > complex since you could simply load the data as part of > the object construction/instantiation process, something like this: > > ModuleList = [ > Module( "Motherboard", > [Component("Camera", >[Command(p1,p2,p3), > Command(p4,p5)]), > ]), >Module("Controller", > [Component("Major Controller", >[Command(),]), > Component("Minor Controller", >[Command(),]),... > ]), >Module("End User", > [Component("xMotor", [Command(...),...]),... > ]) > ] That looks similar to something I did before and had to abandon. I suspect my earlier attempt was flawed in some way. The above might work. > I suspect the use of a dictionary might be beneficial too. Dictionaries are only pairs of data. I assume a list can be one of those elements, but I couldn't figure out how to make it work in the structure I presented. > However if the data varies at runtime and you have to read it > from an external source that approach won't work. It doesn't. > Why not a dictionary of modules keyed by module name? I wanted to make the methods flexible enough that I wouldn't have to edit every method if the module list ever changed. I guess I don't understand how a dictionary works in this situation. > Why not write constructors that take a list as a parameter. > The constructor can manage its own list and the higher > level constructor just passes in the appropriate list. That way > each class only needs to know about the data at the level > it is responsible for. So the Module class might look a bit like: > > class Module: >def __init__(self, name, componentlist): > self.components = {} > self.name = name > for component in componentlist: > self.components[component[0]] = Component(component) > > This implies that the component list is structured as a list of tuples. I originally had tuples, but you can't access individual elements. E.g., give me the second item in each tuple. I see you're using a dictionary in the above structure. Maybe that solves that issue. I'll have to give the above a try and see if it works. >> I have object "db.mb". I have iterator "shortmod" with a value of >> "mb". Why can't I call "db.shortmod"? > > You can use db.getattr(shortmod) That doesn't work. It tells me "Database instance has no attribute 'getattr'". > but I think its easier and clearer in this case to use: > > db.Modules[shortmod] If Modules is a class name, how am I able to call it like that? I plugged that into my program, and it said: "AttributeError: Database instance has no attribute 'Modules'" > I think you can make it a much closer equivalent than you > have at present, and I think that by breaking up the fill db > function and moving responsibility into the classes that it > will be much simplified. And use dictionaries rather than lists. > > HTH IDD (it definitely does!) I have to run off to work now. I'll try your suggestions when I get there. Thanks a whole lot!! Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Use iterator to refer to an object's attribute?
>> I wanted to make the methods flexible enough that I wouldn't have to >> edit every method if the module list ever changed. I guess I don't >> understand how a dictionary works in this situation. > > I don;t understand what you don;t understand here. Can you expand on > why you don't think a dictionary would work? This remark was based on one of my earlier designs. It didn't work there, so I abandoned dictionaries. The library reference says: "Only values containing lists, dictionaries or other mutable types (that are compared by value rather than by object identity) may not be used as keys." This added to the problem, at least in the design I attempted it in. >> I originally had tuples, but you can't access individual elements. > > What makes you think so? > >>>> t = (1,2,3) >>>> print t[0] > 1 I didn't work before when I used it as an index. Now it does. I must have done something different originally. But you are right. This works: >>> mylist = ['one', 'two', 'three'] >>> t = (0,1,2) >>> print mylist[t[0]] one >>>> I have object "db.mb". I have iterator "shortmod" with a value of >>>> "mb". Why can't I call "db.shortmod"? >>> >>> You can use db.getattr(shortmod) >> That doesn't work. It tells me "Database instance has no attribute >> 'getattr'". > > Its actually a special method so needs the underscores __getattr__ > and accessed via a function. I got my syntax muddled: > > getattr(db, shortmod) > > is how it should be written. That works! I knew there had to be a way! Thanks for the help! Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Use iterator to refer to an object's attribute?
Short version: How do I use an iterator to refer to an object's attribute? E.g., "z" is a list of attributes of "b": for x, y in z: for a in b.x.y Also, any suggestions for my overall structure below? -- Long version: I need to make a program to send commands to an instrument. I've been working on it for a while, and my employer is starting to get itchy. Here's a simplified description: • The instrument has three modules (motherboard, controller, and end user). • Each module has an arbitrary number of components (motherboard has internal camera; controller has major and minor controllers; and end user has x-, y-, and z-motors). • Each component has an arbitrary number of commands. • Each command has a fixed number of attributes. I will ultimately create a GUI with a 4-pane browser: • Pane 1 will display the modules. When the user clicks on a module, its components will appear in pane 2. • When the user clicks on a component, its commands will appear in pane 3. • When the user clicks on a command, its parameters will appear in pane 4. • The user will then click a Send button, which will send the command and its parameters to the instrument. I haven't coded the GUI yet, because I'm stuck on the underlying structure. Here's how I'm tackling it: • I have a bunch of lists that have everything defined in them (module_list; cpt_??_lists for components; and cmd_??_lists for commands). • I'm creating a database object, "db", which will hold everything. • I iterate across the module list. The idea here is to create within the database one module object for each real object in the instrument, in this case three. I should end up with: db.mb, db.ct, and db.eu. • There is a short name (for use by the program), a long name (which will be displayed to the user), and the name of that module's component list. • I also create an empty list object, which will ultimately be populated with the contents of that module's component list. • Then (theoretically) for each module, I iterate across that module's component list to create several component objects inside the module (I will then continue this process, creating command objects within the components.). -- My immediate problem is that Python doesn't let me use the iterator as the name of an object's attribute. E.g.: I have object "db.mb". I have iterator "shortmod" with a value of "mb". Why can't I call "db.shortmod"? Also, if you have any better ideas on how to put this thing together, I'm all ears. The reason for doing it this way is that I wanted my database to be the logical equivalent of the instrument. Here's the error message I get: -- Traceback (most recent call last): File "/Developer/Python/CZM Scripts/CmdList.py", line 111, in -toplevel- main() File "/Developer/Python/CZM Scripts/CmdList.py", line 108, in main fillout_DB(db) File "/Developer/Python/CZM Scripts/CmdList.py", line 62, in fillout_DB for shortcpt, longcpt, cmdlist in filldb.shortmod.cptlist: AttributeError: Database instance has no attribute 'shortmod' -- My code follows. If you jump down to the section marked "#---Logic---", you should be able to see the immediate culprit. I greatly appreciate any help that anybody on this list can provide! Thanks! Ron ** #--- Definitions--- # shortname, longname, component list name #---Modules module_list = [ ['mb', 'Motherboard', 'cpt_mb_list'], ['ct', 'Controller', 'cpt_ct_list'], ['eu', 'End User', 'cpt_eu_list']] #---Components # shortname, longname, command list name # Motherboard cpt_mb_list = [ ['icam', 'Internal Camera', 'cmd_icam_list']] # Controller cpt_ct_list = [ ['maj', 'Major Controller', 'cmd_maj_list'], ['min', 'Minor Controller', 'cmd_min_list']] # End User cpt_eu_list = [ ['xmtr', 'X Motor', 'cmd_xmtr_list'], ['ymtr', 'Y Motor', 'cmd_ymtr_list'], ['zmtr', 'Z Motor', 'cmd_zmtr_list']] #---Commands # Abbreviation, string, command, param1, param2 # Motherboard Commands cmd_icam_list = [ ['ss', 'Shutter Speed', 'shutSpeed', 0, 0], ['ap', 'Aperture', 'aperture', 0, 0], ['exp', 'Exposure', 'exposure', 0, 0]] # Controller Commands cmd_maj_list = [ ['on
Re: [Tutor] preliminary app design question
You might also consider JSON (http://www.json.org), which is generally lighter weight than XML, fairly human-readable, and useful in several languages (most, anymore) . Python, Javascript, and ECMAScript use it natively through Eval(), if you don't have security concerns; or through a wrapper if security is an issue. Python's pprint module will be a help if you go that route. I find it useful in development, so even if I am going to use some other storage, I'll leave any toJSON() and fromJSON() functions I write in place, anyway. Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] python mechanize examples
Anyone have or know where I can find working examples of python's mechanize modules. Try to reverse engineer a script to see how it works. Ron Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews, & more on new and used cars.___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python install on Linux
A simple way to migrate to Linux and get a recent version of Python by default would be to download a copy of Ubuntu Linux. You can burn it onto a CD, then pop it ino the cd drive and boot it on your Windows machine. It runs in a virtual machine, so you are assured that your Windows installation will never become corrupted by Linux. Or you can load it directly onto your hard drive in place of Windows. Python is loaded by default. Ubuntu is designed to ease your migration to Linux, You should be fairly comfortably up and running within two hours. I have it on my laptop, and it boots up in just over a minute. http://www.ubuntulinux.org/ __ 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] Complete programming newbie requires tutorial. (Chris Andrew)
Two things. First, I've been watching this list for several weeks now. I wanted to respond to Chris Andrew's question regarding Python tutorials (Complete programming newbie requires tutorial. (Message-ID: <[EMAIL PROTECTED]>Chris Andrew). Did I reply correctly? Second, I've found four Python tutorials helpful to new programmers. I list them in suggested order. BTW, I believe Danny's tutorial is where I heard about this list. 1) One Day of IDLE Toying, by Danny Yoo (http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/) 2) Python Org's IDLE Tutorial (http://www.python.org/idle/doc/idlemain.html) 3) A Byte of Python by Swaroop C H (http://www.ibiblio.org/g2swap/byteofpython/read/) 4) Mark Pilgrim's Python tutorial for experienced programmers (http://www.diveintopython.org/) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 23, Issue 7
Wouw, this is realy good!! Thanks for all, I can go on now with my DB. you were realy helpful, all. > > >>> import win32api > >>> CD_Info = win32api.GetVolumeInformation("D:/") > >>> serno = CD_Info[1] > >>> if serno < 0: >...serno_str = "%X" % (0x1+serno) >... else: >...serno_str = "%X" % serno >... > >>> serno_str >'8A73780D' > >>> > > Thanks Gr Ron Speerstra _ Een audiogesprek? Pak Messenger, niet de telefoon http://www1.imagine-msn.com/Messenger/Video.aspx ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] HD/DVD/CD
Hi, M-list, my name Ron Speerstra(the Netherlands) my question: howtoo read the HD/CD/DVD serial-numbers with Python. Volume-name, dir name, file name. no problem etc. Gr Ron$ _ Vind alles terug op je PC: MSN Search Toolbar http://toolbar.msn.nl/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Printing
>>> "John Corry" < [EMAIL PROTECTED] > 12/24/2005 12:28 PM >>>Hi + Season's Greetings!I have put together a program that queries and modifies a Gadfly database.I have captured my output. I now want to print it to paper.I have written the output to a text file. I have searched the tutor mailinglist and used the mailing list advice to get my data into nice lookingcolumns + tables.I am using Python 2.4, Glade 2, pygtk2.8.0 + wxWidgets2.6.1.I have downloaded win32, win32com, Preppy and PIL. I have had a go at usingthem but can't get them to work. At the moment I can't even print the textfile.Is there a good helpguide/FAQ page which deals with printing text files oris there simple code which prints a text file?Thanks,John.>>>>You might want to look at karrigell ( http://karrigell.sourceforge.net/ ) and consider making your output an html text file, styled with css, that you can view/print using the browser. I think karrigell is simple for desktop apps - - certainly simpler than wxWidgets, etc.TurboGears ( http://www.turbogears.org ) is more oriented toward a full website. Both frameworks are built on CherryPy, which is coming on strong as a full-featured, lightweight 'Pythonic" server.I like to use the browser for output because it does so much of the formatting for you and it's cross-platform, and I like using a framework because if you ever want to use your program over the web, you're nearly done. Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Favourite modules - Wiki Was Re: TurboGears - and some issues
>>> Ismael Garrido <[EMAIL PROTECTED]> 11/14/2005 11:55 PM >>> Kent Johnson wrote: >Maybe we should start a thread of favorite addons. For me, Jason Orendorff's path module is definitely #1 on the list, probably followed by Fredrik Lundh's ElementTree. > http://www.jorendorff.com/articles/python/path/ > http://effbot.org/zone/element-index.htm > > A wonderful idea! I have created a wiki page in Python.org with a list of such 'favourite' modules. Please take a look: http://wiki.python.org/moin/UsefulModules I put some of the modules I could remember being praised here. I hope I didn't miss any (well, save for web frameworks, I haven't been paying much attention) I hope I haven't made a mess, it was my first edit into python's wiki. I wasn't sure where to stick it, so I added it under DevelopmentTools. I hope the page helps somebody! (Today I'm "hopey" :) Bye, Ismael +++ That is a good idea, and a nice page. Another would be to implement some "social tagging" as on del.icio.us. It's kind of a popularity contest, but that's really what's wanted here, I think. OTOH, the wiki is probably the first place anyone would look, and I saw most of the modules I already use, and I learned about a couple that look very promising. One that I use a lot is Amara (http://uche.ogbuji.net/tech/4suite/amara/manual) for making xml more pythonic. Not to take anything away from ElementTree, it's a fine package; but I find Amara easier to use. Some others that seem 'missing': PIL and NumPy. I didn't try to put it on the wiki page because I wanted the tutors to have a chance to comment first. Anyway, thanks for the page. I have it bookmarked! Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tainted characters and CGI
--- Tim Johnson <[EMAIL PROTECTED]> wrote: > Hello: > I need to tighten my handling of CGI transmissions. > I particular, I need to develop a strategy of safely > dealing with "tainted" characters. Ahh... tainted characters. If by "tainted" you mean not UTF-8, there is a c tool called "iconv" that fixes "tainted" characters. I believe Python has a wrapper, but I didn't check before sending this e-mail. Good luck and please write back if you implement a working solution. -- Ronald Weidner http://www.techport80.com PHP Software developer for hire. __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Thanks, you prevented "Coder's Remorse"
Thanks to everyone who responded to my "Prevent Coder's Remorse" posting; the result of combining the ideas that you contributed is below. It's a little long, but I'm delighted with it so far, and maybe someone else can use it. It's nice for representing a sparse table, where all the records share columns, but a lot of the values in any given column are the same. Geographic points (my original question) are just a special case. One example is a table where the Null value isn't predefined but is represented by a 'magic value' that means null in that table. I realize now that I might have been better off just to use a database; they know all about nulls, tables. types, defaults, etc. Still, I learned a LOT. So, no remorse! Thanks again, Ron #magicvaluetable.py ### # -*- coding: utf-8 -*- #may use a guid to keep things straight import guid # Make it work with Python 2.3 try: set except NameError: from sets import Set as set class MVTRecord(dict): """A record belonging to a magic value table (MVTable). Requires a parent MVTable and an id assigned by it. Other attributes (column values) may be assigned. Attributes not specifically assigned at the record level are deferred to the parent MVTable's attDict.""" def __init__(self,mvtParent,id,**args): dict.__init__(self) self.mvtParent = mvtParent self.id = id for arg in args: self[arg]=args[arg] def __getitem__(self, key): if key in self.keys(): return dict.__getitem__(self, key) else: return self.mvtParent.attDict[key] raise KeyError,'Key "%s" was not found in MVTRecord or MVTable'%key def __setitem__(self, key, value): (nullValue,valueType)=self.__testType(value) if key not in self.mvtParent.attDict.keys(): self.mvtParent.addAttribute(key,nullValue) (whoCares,columnType)=self.__testType(self.mvtParent.attDict[key]) # make sure what's set is proper type or can degrade to proper type if valueType == columnType: dict.__setitem__(self, key, value) else: if columnType == 'float'and valueType=='int': dict.__setitem__(self, key, float(value)) elif columnType == 'string': dict.__setitem__(self, key, str(value)) else: msg = 'The %s attribute requires %s data'%(key, columnType) raise ValueError,msg def __delitem__(self, key): if key in self.keys(): dict.__delitem__(self, key) elif key in self.mvtParent.attDict.keys(): pass else: raise KeyError,'Key "%s" was not found in MVTRecord or MVTable'%key def __testType(self, value): try: if str(value)==str(int(value)): test = (self.mvtParent.nullInt,'int') else: test = (self.mvtParent.nullFloat,'float') except ValueError: test=(self.mvtParent.nullString,'string') return test class MVTable(object): """Defines a group of records (MVTRecord) with common columns. Attributes (record values in a given column) which are not specified at the record level are deferred to the MVTable attDict. Note: the nullInt, nullFloat, and nullString are designed to hold 'magic values' for use with data structures(CSV, DBF) having no defined 'null'.""" def __init__(self, nullInt=0, nullFloat=0.0, nullString='null'): self.nullInt=nullInt self.nullFloat = nullFloat self.nullString = nullString self.attDict = {} self.membersDict = {} def addMember(self,id=None,**args): if not id: id = guid.generate() self.membersDict[id]=MVTRecord(self,id=id,**args) return self.membersDict[id] def delMember(self,member): del self.membersDict[member.id] def addAttribute(self, name, nullValue=None): if nullValue == None:nullValue=self.nullString self.attDict[name]=nullValue def delAttribute(self, name): for member in self.membersDict: if member.has_key(name):del member[name] del self.attDict[name] def compactAttributesDictionary(self): """removes unreferenced attributes""" newkeys = set() for member in self.membersDict: for key in self.membersDict[member].keys(): newkeys.add(key) for key in self.attDict.keys(): if key not in newkeys: del self.attDict[key]
Re: [Tutor] Prevent "Coder's Remorse"?
Ok, I have three diverse answers from three of the tutors that I respect most. Kent Johnson's approach: subclass dict and overloads the __getitem__ , __setitem__, and __delitem__ methods. Alan G's idea: ". . . Get the init method to update a global (or class based) list of instances and write a del() method that removes itself. Then a class method can iterate that instance list doing whatever it needs to do..." And Danny Yoo's hierarchical structure: ". . . The idea here is that we impose some structure among the points. We can keep a central Point that has a set of child points within its satellite. ## >>> centralPoint = Point(40, -81, {}) >>> satellitePoint = Point(40, -81, {}, centralPoint) ## . . ." Very clever ideas, as far as I can tell. I need to play with all three of them so that I understand them thoroughly. I think that once I do, I'll be able to say I really understand OOP in Python! I believe that any one of these approaches will do what I need, though, so maybe it comes down to style. Maybe I should explain why I thought I wanted this object. I am trying to read, edit, and write shapefiles (actually, a shapefile is a collection of 3-6 files having the same filename, but different extensions. It's a legacy format that still gets a lot of use in geography.) One of the constituent files in a shapefile is a variant of Xbase, which knows nothing about NULL, so I have to provide some value in every column for every record when I write them. I thought that having a data structure that enforces a common set of "fields", the application would be more robust when it's being edited. (Prevent me from deleting an item for one record and not others, or adding a field to a record without adding at least some default value to all the others.) I just thought about it, but a CSV file has kind of the same problem. Thanks, everyone; this will be a real education, however I go! Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Prevent "Coder's Remorse"?
Kent Johnson wrote: I'm curious about why you want to do this, it is kind of a strange requirement. Yeah, that was bothering me, too. I was a little unsure if I'd even defined the problem properly; that's what I meant by: "Am I even asking the right questions?" I'll play around with the class a little and see if it helps me clarify to myself what I am trying to do. I was kind of on the right path, but I've never written much with __getitem__, __setitem__, etc. and it wasn't going at all like I had in mind. I've found that when I patch and patch and patch my code, it's usually because I am trying to do the wrong thing altogether. And I wasn't using Class attributes properly, either. Thanks so much! Sorry for the vague question, but I really think the class you made is close to what I needed. Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Prevent "Coder's Remorse"?
Maybe it's just me. I am always haunted by "coder's remorse" (the certainty that there's a more compact, beautiful, fun, maintainable way to code anything I finish.) At any rate, I am currently working on a script to model an ordered collection of geographic points, all of which must share the same collection of attributes. So, a little collection might be: pointList = [ {lat:40.123,lon:-81.456, 'attributes':{'msg':'example','beavers':34, 'distance':18.132} }, {lat:40.12345,lon:-81.45678, 'attributes':{'msg':'','beavers':0, 'distance':0.0} } ] If I add an attribute of 'newAtt':'newVal' to pointList[1]['attributes'], I want it to automatically add 'newAtt':'default' to all the other member's 'attributes' dictionary. If I delete an attribute, it should delete from all the member's dictionaries. The attributes are limited to string, integer, and float values. I can do this by brute force, but: Is there an elegant approach that occurs to anyone? Is there a data structure that forces all members to have the same keys? Is there an object structure that will let updates to one instance affect all instances? Am I even asking the right questions? I suspect there's an elegant solution, but it's beyond me right now. If not, fine; I'll happily go on with my ham-fisted approach. Regards, Ron Phillips Programmer/Analyst County of Summit Engineer 538 E. South St. Akron, OH 44311 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [tutor]web development
Well, I won't argue with anyone who chooses otherwise, but CherryPy http://www.cherrypy.org/ is easy to use, lightweight, quick, and pythonic. I write everything as plain old python, then webify it the very last thing. It's also the basis of a new, promising framework called TurboGears http://www.turbogears.org/, which Kevin Dangoor put together. He does a "Wiki in 20 minutes" tutorial that's pretty impressive. Ron PhillipsProgrammer/AnalystCounty of Summit Engineer538 E. South St.Akron, OH 44311 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Stuck: unicode in regular expressions
I am expecting users to cut-and-paste DMS data into an application like: +40 30 15 E40 15 34.56, -81 0 0, 81 57 34.27E, W 40° 13 27.343, 40° 13 27.343 S, 140° 13 27.343S, S40° 13 27.34454, 81:57:34.27E I've been able to write a regex that seems to work in redemo.py, but it doesn't do at all what I want when I try to code it using the re module. The problem seems to be the way I am using unicode specifically all those punctuation marks that might get pasted in. I anticipate the program getting its input from a browser; maybe that will narrow down the range somewhat. Anyway, given the string above, what regex will match the and characters, please? I have tried \x02BC and \x92 and \x2019 for the , but no result. I am sure it's simple; I am sure some other newbie has asked it, but I have Googled my brains out, and can't find it. Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Linux sound control
It's simple, without any bells and whistles. Move the slider up and down to change the volume on your Linux system. Written in Python and Tkinter, this little program should work with any window manager. http://www.techport80.com/soundctrl/sound_ctrl.tgz -- Ronald Weidner http://www.techport80.com PHP Software developer for hire. __ 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] Send attachment
--- Jorge Louis De Castro <[EMAIL PROTECTED]> wrote: > Hello, > > Any ideas how I can use Python and the Windows API > to open a PC's mail client and send an attachment? > The idea is saving some data onto a file and then > invoke the email client (OE or Outlook or whatever > is the default on the machine) with the recipient's > address filled in and the file ready to be sent as > an attachment. > Kinda like when we right-click on a file and select > the "send to mail recipient" behavior. > Been reading docs, trying out samples, and googling > this for a few days to no avail. > > Cheers I'm not sure how to do that but, if you learn how to use the smtp protocol, you won't need to use someones mail client. It's actually simple to use. Try looking at the problem from that angle and see if it gets you anywhere. Good luck -- Ronald Weidner http://www.techport80.com PHP Software developer for hire. __ 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] how to add python code to a webpage
Mustafa Abbasi asked: i want to create a simple page which has a formand takes in persons date of birth and give out exact age.how do i add python codeto an html page.i don't have any dreamweaver or frontpage.this is basically cuz some freinds advised me to create this isnce i am learning programming python..so please help I find CherryPy is easy and lightweight to get started. http://www.cherrypy.org Ron Header Description: Binary data ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tk -- which label clicked
--- geon <[EMAIL PROTECTED]> wrote: > Ron Weidner napsal(a): > > >This doesn't work. > >def icon_click(self, event=None): > > print event.widget.option_get("text", > event.widget) > > > > > > > maybe event.widget['text'] ? event.widget['text'] works. Thanks. Ronald Weidner http://www.techport80.com PHP Software developer for hire. __ 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] Tk -- which label clicked
This doesn't work. Not an error though. :) What I'm trying to do is get the text value of a label. def icon_click(self, event=None): print event.widget.option_get("text", event.widget) Or, more to the point... I need to dynamicaly create clickable labels, each using the same callback. When clicked, I need to know which one was clicked. I was hoping to use the "text" of the label as the argument to another function. Any ideas, suggestions, or recommeded URLs to study? Ronald Weidner http://www.techport80.com PHP Software developer for hire. Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tkinter query?
> > tk = Tk() > > tk.config(background='pink') > > tk.geometry('400x400') > > # 320 = width # 150 = height # # Left and down are relative to the screens uppeer left # # 200 = position left (x) # 200 = position down (y) tk.geometry( "320x150+200+200") hth Ronald Weidner http://www.techport80.com PHP Software developer for hire. Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] tk entry focus
I've struggled... Now I'm asking... What's wrong with this code? Or more to the point, how do you set the focus to an Entry widget? Traceback (most recent call last): File "./run_dialogue.py", line 33, in ? app = Run_dialogue( root ) File "./run_dialogue.py", line 23, in __init__ self.cmd.focus() AttributeError: 'NoneType' object has no attribute 'focus' class Run_dialogue: def __init__( self, master ): img_path = path.dirname(sys.argv[0]) img_path = path.abspath(img_path) #master.initial_focus.focus_set() master.geometry( "300x150+200+200") self.cmd_text = StringVar() self.frame = Frame( master ) self.icon = PhotoImage( file=img_path + "/target.gif" ) self.lbl_icon = Label( self.frame, image=self.icon ) self.lbl_icon.grid( row = 1, column = 0 ) self.label = Label( self.frame, text="Command: " ).grid( row = 1, column = 1 ) self.cmd = Entry( self.frame, textvariable=self.cmd_text ).grid( row = 1, column = 2 ) self.btn = Button( self.frame, text=" Run ", command=self.btn_run_click ) self.btn.grid( row = 2, column = 0, columnspan = 3, sticky = "e") self.btn.bind("", self.btn_run_click) self.frame.pack() self.cmd.focus() Ronald Weidner http://www.techport80.com PHP Software developer for hire. Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?
Yes, I believe you are right -- I posted a reply to the list indicating that I suspect IIS is at fault; not Python. Or perhaps I should say "my installation of IIS"; I have no confidence whatsoever in my abilities to administer IIS properly. Thanks for looking at the documentation -- I was stuck using 2.3 because of some other modules I needed, so I didn't look at the 2.4 docs. That would have made me less angry, but the script still wouldn't have run, because the problem (evidently) is in IIS, not my code. I was really hard up against it -- no response at all from IIS, just a lockup, and apparently when IIS locked up, it did so prior to writing to the error log. When I tried using the CGIHTTPServer, everything I did over the past 3 days worked without a hitch. What a relief!! Now I just need to work around IIS -- and we don't use it outside the firewall, anyway. I think I'll put Apache on my local machine and use that. Thanks, again Ron >>> Danny Yoo <[EMAIL PROTECTED]> 6/24/2005 2:44:44 PM >>> > The example code in the python online documentation calls a non-existant> "div" function, so it was obviously a typing exercise, not actual code> that anyone ever tested.Hi Ron,Ah, ok, I see. Check the bottom of: http://www.python.org/doc/lib/simple-xmlrpc-servers.htmlfor a working example of that div function in the MyFuncs class.I believe that the example you were looking at earlier, near the bottomof: http://www.python.org/doc/lib/node556.htmlhas is a documentation bug: the intent is clearly to compare and contrastSimpleXMLRPCServer and CGIXMLRPCRequestHandler, so the code should beusing the same example. The fact that it isn't is confusing, and shouldbe fixed. I'll send a bug report now. http://python.org/sf/1227181Try Kent's example again; XMLRPC stuff is itself not too bad. Your twoassumptions: 1. It's too easy to mention, and not worth talking about 2. It's too hard in practice, and not worth talking aboutare too black-and-white: XMLRPC itself is not bad at all, but CGI stuffcan be maddeningly difficult at first, because it involves not only Pythonbut also integration with an external web server.What I think you're running into is the CGI part, the part that doesn'tdebug as easily, just because error output doesn't automatically send tothe browser --- that would be a security risk! --- but instead is shuttledoff to your web server's error log file. So take a closer look at yourweb server's error logs; I wouldn't be surprised to see some Python errormessages there that should help to isolate the issue.Best of wishes to you!__This email has been scanned by the MessageLabs Email Security System.For more information please visit http://www.messagelabs.com/email __ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?
Kent wrote: CGI requires a running HTTP server in front of it. The server receives the HTTP request, sees that it is a CGI request, starts a new process with the environment set according to the CGI protocol, and runs the CGI handler. Do you understand this relationship? (I mean that kindly, your response makes me suspect there is a fair amount of black magic in this for you.) The snippet above just starts a simple CGI-capable HTTP server. It is useful for testing, not an essential part of the recipe. If you have other CGIs working you must have a working HTTP server already, such as Apache or IIS. In your initial post you said "I have run other CGI scripts in the same directory." Were those CGIs written in Python? How did you run them? Kent- Well, I understand the words, and I can see that the HTTP server (IIS, in this case) hands off CGI stuff to a CGI handler -- but I think that IS a fair amount of black magic! So no, I really can't claim any deep understanding of the process. What I ran before were simple little test scripts of the "HelloWorld.py" variety. I would put them in the cgi-bin directory and invoke them with the browser, or with the HTTPLib in the command line, and I would get something back. When I invoke any script in the cgi-bin that has CGIXMLRPCRequestHandler in it through localhost or localhost:80, the program freezes right up. Nothing returned, nothing in the IIS error log, no reply at all. However, the little test scripts that you and Joe provided run just fine as long as I don't use IIS as the server. Maybe I should have posted "IIS and CGIXMLRPCRequestHandler doesn't work at all!!" Seriously, it looks like my IIS installation is at fault -- probably some setting I need to change. I wonder if that's the reason for all those unanswered posts -- it's not a Python problem, per se? Odd, though, that IIS is perfectly happy to run a Python script unless it has CGIXMLRPCRequestHandler in it. Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?
##Run a simple CGI server by opening a command line to the parent dir of cgi-bin and runningpython -c "import CGIHTTPServer; CGIHTTPServer.test()" ## Oh, dear -- I responded before I read your post, Kent. It turns out it was option b), after all. But I had NO idea I would need to do anything like the little clip above. Anything else I run under CGI, I just send an HTTP request and it works. I read, and read, and read, but never read anything about starting a CGIHTTPServer -- I'll look it up right away, but I can't see how I missed that. Maybe by Googling "XMLRPC", which was what I really wanted to do. Anyway, thank you -- if I can find them again, I'll respond to all those other posts with a link to yours in the archives. Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?
Thanks for your response, Shuying Wang -- I was afraid no one even read the post. Now I see I wasn't clear. -- Shuying Wang: I'm not sure what you're trying to do. But I run cgi scripts and makexmlrpc requests with xmlrpclib with a connection withxmlrpclib.Server(server_uri), though I'm only doing this client side.I'm not running the server as cgi. ---I have a Python module that I am trying to expose via XMLRPC. I can get it running by assigning a port on the server using SimpleXMLRPCRequestHandler, but I would prefer to expose it through CGI if possible. This seems to be the stated purpose of the CGIXMLRPCRequestHandler, but I believe it is broken in some very serious way. The example code in the python online documentation calls a non-existant "div" function, so it was obviously a typing exercise, not actual code that anyone ever tested. In researching the module, I found several requests on various mailing lists for example code -- not a single one ever had a response. When I've seen this before, it has turned out that either: a) it is terribly difficult, or b)it is stupidly simple. Since this is a tutor list, and I have seen the members graciously answer some questions that seemed pretty simple, I thought I'd post it here. Since the only response (yours -- thanks again for responding!) was about xmlrpclib on the client side, not CGIXMLRPCRequestHandler on the server side, I can now conclude that it is terribly difficult, and slink off to publish using SOAP. Ron On 6/23/05, Ron Phillips <[EMAIL PROTECTED]> wrote:> > I believe I've tried every setting known to man, in every script in every> little scrap of documentation available. XMLRPC requests using> SimpleXMLRPCRequestHandler -- no problem. But try to run them as a CGI> script, and I get system lock ups and that's all. No error codes; no> response whatsoever. > > I am using Python 2.3, Windows XP. I have run other CGI scripts in the same> directory, so I know that works. > > Has anyone used this successfully? Can you share demo server and client> scripts -- just an echo function or something? > > Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?
I believe I've tried every setting known to man, in every script in every little scrap of documentation available. XMLRPC requests using SimpleXMLRPCRequestHandler -- no problem. But try to run them as a CGI script, and I get system lock ups and that's all. No error codes; no response whatsoever. I am using Python 2.3, Windows XP. I have run other CGI scripts in the same directory, so I know that works. Has anyone used this successfully? Can you share demo server and client scripts -- just an echo function or something? Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] CPAN for python
Is there a site like Perl's CPAN for Python? I've seen the stuff at ActiveState. Anything else? Ron Nixon __ Discover Yahoo! Have fun online with music videos, cool games, IM and more. Check it out! http://discover.yahoo.com/online.html ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Am I making this harder than it needs to be?
Ron Phillips wrote:>> short version: I need a way to get max and min E and N out of >> [(E0,N0),(E1,N1)...(En,Nn)] without reordering the list>>> Kent Johnson [EMAIL PROTECTED]> 5/25/2005 10:19 AM >>>For Python < 2.4 you need another set of [ ] e.g. min([e for e,n in coordList]) I knew I was working too hard!! That's exactly what I needed -- for some reason, ESRI (big name in geographic work) uses Python 2.2. Ron Phillips wrote: >> long version:>> >> I would like a list of geographic coordinates (Easting, Northing) to >> maintain a "bounding box" >> [(minEasting,minNorthing),(maxEasting,maxNorthing)] attribute.>>>>I did it like this:>>>>class geoCoordinateList(UserList):>>def __init__(self):>>UserList.__init__(self)>>self.boundingBox = geoBox(minEN=geoCoordinate(),>>maxEN=geoCoordinate())>>def append(self, geoCoord):>>self.extend([geoCoord])>>self.boundingBox.challenge(geoCoord)#bumps the max and min if >>necessary>>but I'd have to override almost all the UserList methods, unless there's >>a way to call boundingBox.challenge() on any change to the list.>If you don't need too much list functionality it might be easier to wrap a list and delegate the >things you need:>class geoCoordinateList(object):>def __init__(self):>self.list = list()>self.boundingBox = geoBox(minEN=geoCoordinate(),>maxEN=geoCoordinate())>def append(self, geoCoord):>self.list.append(geoCoord) # No need for extend() here...>self.boundingBox.challenge(geoCoord)#bumps the max and min if necessary>I think you will want at least __getitem__() and __len__() as well.>Kent Yep, that was my problem; I had "too much list functionality" to delegate -- your way is much better for the purpose. I can expose that class without promising all the functionality of a list. In most languages there are a half-dozen stupid, painful ways to do a job, and maybe one that's merely painful, but in Python there's a half-dozen "ok" ways to do a job, and at least one that's a real pleasure! Thanks for the answers! Ron Header Description: Binary data ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Am I making this harder than it needs to be?
Oh, thanks! That didn't exactly do the trick, because I had data like [(1, 22),(2,11)], but from your code I came up with: def getBB(self): Es=[] Ns=[] for i in range(len(self)): Es.append((self[i].E)) Ns.append((self[i].N)) self.boundingBox=geoBox((min(Es),min(Ns)),(max(Es),max(Ns))) return(self.boundingBox) which works fine, and I think will be pretty fast. Ron>>> Pujo Aji <[EMAIL PROTECTED]> 5/25/2005 9:47 AM >>> try this code: L = [(1,11),(2,22)] print max(L) print min(L)I don't know if that what you want.good luckpujoOn 5/25/05, Ron Phillips <[EMAIL PROTECTED]> wrote:> > short version: I need a way to get max and min E and N out of> [(E0,N0),(E1,N1)...(En,Nn)] without reordering the list > > long version: > > I would like a list of geographic coordinates (Easting, Northing) to> maintain a "bounding box"> [(minEasting,minNorthing),(maxEasting,maxNorthing)]> attribute. > > I did it like this: > > class geoCoordinateList(UserList):> def __init__(self):> UserList.__init__(self)> self.boundingBox = geoBox(minEN=geoCoordinate(),> maxEN=geoCoordinate())> > def append(self, geoCoord):> self.extend([geoCoord])> self.boundingBox.challenge(geoCoord)#bumps the max and min if> necessary> > but I'd have to override almost all the UserList methods, unless there's a> way to call boundingBox.challenge() on any change to the list. > > The other way I thought would be to make a getBB method, like: > > def getBB(self):> new=geoBox()> for gC in self:> new.challenge(gC)#bumps the corners if needed > self.boundingBox=new> return(new)> > but that seems like a lot of churning if nothing has changed. > > I suspect there's some slick, readable way to do this, and when I see it> I'll say "Doh!" > > > > ___> Tutor maillist - Tutor@python.org> http://mail.python.org/mailman/listinfo/tutor> > >__This email has been scanned by the MessageLabs Email Security System.For more information please visit http://www.messagelabs.com/email __ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Am I making this harder than it needs to be?
short version: I need a way to get max and min E and N out of [(E0,N0),(E1,N1)...(En,Nn)] without reordering the list long version: I would like a list of geographic coordinates (Easting, Northing) to maintain a "bounding box" [(minEasting,minNorthing),(maxEasting,maxNorthing)] attribute. I did it like this: class geoCoordinateList(UserList): def __init__(self): UserList.__init__(self) self.boundingBox = geoBox(minEN=geoCoordinate(), maxEN=geoCoordinate()) def append(self, geoCoord): self.extend([geoCoord]) self.boundingBox.challenge(geoCoord)#bumps the max and min if necessary but I'd have to override almost all the UserList methods, unless there's a way to call boundingBox.challenge() on any change to the list. The other way I thought would be to make a getBB method, like: def getBB(self): new=geoBox() for gC in self: new.challenge(gC)#bumps the corners if needed self.boundingBox=new return(new) but that seems like a lot of churning if nothing has changed. I suspect there's some slick, readable way to do this, and when I see it I'll say "Doh!" ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] buttons, scrollbar, tkinter
I was trying to put buttons in, but now I know why it wouldn't work. I'm going to take a look at PMW. Thanks. Ron A ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] buttons, scrollbar, tkinter
Is there any way to change this to put in a column of buttons and it will scroll like it does now. I've tried but when I put in the buttons the scrollbar just grows with all the buttons and won't do anything. from Tkinter import * root = Tk() scrollbar = Scrollbar(root) scrollbar.pack(side=RIGHT, fill=Y) listbox = Listbox(root, yscrollcommand=scrollbar.set) for i in range(55): listbox.insert(END, str(i)) listbox.pack(side=LEFT, fill=BOTH) scrollbar.config(command=listbox.yview) Ron A ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Opinions about this GIS script
Thank you, Andrei, that's just what I was hoping for -- I wondered about some of those issues, but was a little unsure how to approach a solution. Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Opinions about this GIS script
I made a script that opens GIS shapefiles and turns them into python objects. I posted it at http://www.geocities.com/tiltbike/GIS/py_shape_files.zip The only one that's mine, really, is the PyShape.py script; the others are there for support/testing. It's my first real effort at 'shareable' python. Everything else I've done so far is either a quick-and-dirty for my own use, or a simple illustration for instructional purposes. The script produces expected results, but if anyone is so inclined, I'd appreciate review/evaluation/critique of the 'pythonism' of the script. Ron Phillips ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] re.findall vs. re.search and re.match
Kent: The code is below. Here's the error message. Traceback (most recent call last): File "C:/Python24/reformat.py", line 5, in -toplevel- name = x.group(1) AttributeError: 'list' object has no attribute 'group' import re f = open('reformat.txt').read() pat = re.compile(r"([^\r\n]+)\n([^\r\n]*)\n([^\r\n]*) ([^\r\n]*) ([^\r\n]*)") x=re.findall(pat,f) name = x.group(1) address = x.group(2) citystate = x.group(3)+x.group(4) zipcd = x.group(5) o= open('reformat1.txt','w') o.write("%s,%s,%s,%s\n" % (name, address, citystate,zipcd)) o.close() print("%s,%s,%s,%s\n" % (name, address, citystate,zipcd)) --- Kent Johnson <[EMAIL PROTECTED]> wrote: > Ron Nixon wrote: > > Thanks to all who replied to my post earlier on > re's. > > I'm still preplexed by why re.search and re.match > > works in the code below, but not re.findall. > > re.findall is suppose to return all > non-voerlapping > > occurances of the pattern that matches in this > > example, but it returns errors. Looking through > the > > docs and from what I can see it should work. Can > > anyone provide advice. > > Please show the code that uses re.findall() and the > error you receive when you run it. > > Kent > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > __ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] re.findall vs. re.search and re.match
Thanks to all who replied to my post earlier on re's. I'm still preplexed by why re.search and re.match works in the code below, but not re.findall. re.findall is suppose to return all non-voerlapping occurances of the pattern that matches in this example, but it returns errors. Looking through the docs and from what I can see it should work. Can anyone provide advice. import re f = open('reformat.txt').read() pat = re.compile(r"([^\r\n]+)\n([^\r\n]*)\n([^\r\n]*) ([^\r\n]*) ([^\r\n]*)") x=re.search(pat,f) name = x.group(1) address = x.group(2) citystate = x.group(3)+x.group(4) zipcd = x.group(5) o= open('reformat1.txt','w') o.write("%s,%s,%s,%s\n" % (name, address, citystate,zipcd)) o.close() print("%s,%s,%s,%s\n" % (name, address, citystate,zipcd)) __ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] re help
The following program takes text data like this: Jimi Hendrix 2100 South Ave Seattle, WA 55408 and changes it to this Jimi Hendrix, 2100 South Ave,Seattle,WA,55488 and writes it to a file. The problem I'm running into is that it only writes this first address to a file and there are several others in the file. I believe it has something to do with using re.search instead of re.findall. But re.findall returns a error when I try using it. Suggestions? Thanks in advance. Here is the script: import re f = open('reformat.txt').read() pat = re.compile(r"([^\r\n]+)\n([^\r\n]*)\n([^\r\n]*) ([^\r\n]*) ([^\r\n]*)") x=re.search(pat,f) name = x.group(1) address = x.group(2) citystate = x.group(3)+x.group(4) zipcd = x.group(5) o= open('reformat1.txt','w') o.write("%s,%s,%s,%s\n" % (name, address, citystate,zipcd)) o.close() print("%s,%s,%s,%s\n" % (name, address, citystate,zipcd)) __ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Better Search and replace method
I'm trying to figure out a better solution to do multiple search and replaces in a text file without having to type: import re s = open('filename') re.sub('vaule1','value2',s) re.sub('vaule3','value4',s) etc I've tried putting all the vaules in a list and doing the replace, but came up short. Any suggestions? Thanks in advance Ron __ Celebrate Yahoo!'s 10th Birthday! Yahoo! Netrospective: 100 Moments of the Web http://birthday.yahoo.com/netrospective/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] RE help
Problem solved. Thanks --- Kent Johnson <[EMAIL PROTECTED]> wrote: > Try it with non-greedy matches. You are matching > everything from the first > in one match. Also I think you want to escape the . > before (you want just paragraphs that end > in a period?) > > pattern = re.compile(""" href="/(.*?)">(.*?)\.""", re.DOTALL) > > Kent > > Ron Nixon wrote: > > Trying to scrape a newspaper site for articles > using > > this code whic ws done with help from the list: > > > > import urllib, re > > pattern = re.compile(""" > href="/(.*)">(.*).""", re.DOTALL) > > page > > > =urllib.urlopen("http://www.startribune.com";).read() > > > > > for headline, body in pattern.findall(page): > > print body > > > > It should grab articles from this: > > > > Sid > Hartman: > > Franchise could be movedIf Reggie > Fowler > > and his business partners from New Jersey are > approved > > to buy the Vikings franchise from Red McCombs, it > is > > my opinion the franchise remains in danger of > > eventually being relocated. > > > > and give me this: Sid Hartman: Franchise could be > > movedIf Reggie Fowler and his business > > partners from New Jersey are approved to buy the > > Vikings franchise from Red McCombs, it is my > opinion > > the franchise remains in danger of eventually > being > > relocated. > > > > Instead it gives me this:Boxerjam. from > > this : > > > href="http://www.startribune.com/stories/1559/4773140.html";>Boxerjam. > > > > > > I know the re works in other programs I've tried. > Is > > there something different about re's in Python? > > > > > > > > > > > > __ > > Do you Yahoo!? > > Yahoo! Mail - Find what you need with new enhanced > search. > > http://info.mail.yahoo.com/mail_250 > > ___ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > __ Do you Yahoo!? The all-new My Yahoo! - What will yours do? http://my.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] RE help
Trying to scrape a newspaper site for articles using this code whic ws done with help from the list: import urllib, re pattern = re.compile("""(.*).""", re.DOTALL) page =urllib.urlopen("http://www.startribune.com";).read() for headline, body in pattern.findall(page): print body It should grab articles from this: Sid Hartman: Franchise could be movedIf Reggie Fowler and his business partners from New Jersey are approved to buy the Vikings franchise from Red McCombs, it is my opinion the franchise remains in danger of eventually being relocated. and give me this: Sid Hartman: Franchise could be movedIf Reggie Fowler and his business partners from New Jersey are approved to buy the Vikings franchise from Red McCombs, it is my opinion the franchise remains in danger of eventually being relocated. Instead it gives me this:Boxerjam. from this : href="http://www.startribune.com/stories/1559/4773140.html";>Boxerjam. I know the re works in other programs I've tried. Is there something different about re's in Python? __ Do you Yahoo!? Yahoo! Mail - Find what you need with new enhanced search. http://info.mail.yahoo.com/mail_250 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
RE: [Tutor] count words
Thanks to everyone who replied to my post. All of your suggestions seem to work. My thanks Ron --- Ryan Davis <[EMAIL PROTECTED]> wrote: > You could use split() to split the contents of the > file into a list of strings. > > ### > >>> x = 'asdf foo bar foo' > >>> x.split() > ['asdf', 'foo', 'bar', 'foo'] > ### > > Here's one way to iterate over that to get the > counts. I'm sure there are dozens. > ### > >>> x = 'asdf foo bar foo' > >>> counts = {} > >>> for word in x.split(): > ... counts[word] = x.count(word) > ... > >>> counts > {'foo': 2, 'bar': 1, 'asdf': 1} > ### > The dictionary takes care of duplicates. If you are > using a really big file, it might pay to eliminate > duplicates from the list > before running x.count(word) > > Thanks, > Ryan > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Ron > Nixon > Sent: Tuesday, February 15, 2005 11:22 AM > To: tutor@python.org > Subject: [Tutor] count words > > > I know that you can do this to get a count of home > many times a word appears in a file > > > f = open('text.txt').read() > print f.count('word') > > Other than using a several print statments to look > for > seperate words like this, is there a way to do it so > that I get a individual count of each word: > > word1 xxx > word2 xxx > words xxx > > etc. > > > > > > __ > Do you Yahoo!? > Yahoo! Mail - Find what you need with new enhanced > search. > http://info.mail.yahoo.com/mail_250 > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > __ Do you Yahoo!? The all-new My Yahoo! - Get yours free! http://my.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] count words
I know that you can do this to get a count of home many times a word appears in a file f = open('text.txt').read() print f.count('word') Other than using a several print statments to look for seperate words like this, is there a way to do it so that I get a individual count of each word: word1 xxx word2 xxx words xxx etc. __ Do you Yahoo!? Yahoo! Mail - Find what you need with new enhanced search. http://info.mail.yahoo.com/mail_250 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Negative IF conditions
And now for something only slightly different: education research shows that people process "positives" far more quickly and accurately than "negatives", so for readability I often code like: if os.path.exists('filename') #no-operation else #operation YMMV, of course. Ron At 08:52 AM 2/11/2005, Mark Brown wrote: Hi,I'm a newbie and was wondering which of these IF conditions is better structure:if not os.path.exists('filename'): if os.path.exists('filename') == False: ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Value Error solved. Another question
Ignore my first posting. Here's what I'm trying to do. I want to extract headlines from a newspaper's website using this code. It works, but I want to match the second group in (.*) and print that out. Sugguestions import urllib, re pattern = re.compile("""(.*)""", re.DOTALL) page = urllib.urlopen("http://www.startribune.com";).read() for headline in pattern.findall(page): print headline __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Value Error message
Trying to scrape some headlines off a newspaper with this code: import urllib, re pattern = re.compile("""(.*)""", re.DOTALL) page = urllib.urlopen("http://www.startribune.com";).read() for (headline, code, description) in pattern.findall(page): print (headline, code, description) I'm getting the error below and can't find anything in the documentation. Suggestions Traceback (most recent call last): File "C:/Python24/Stribwebscrape.py", line 13, in ? for (headline, code, description) in pattern.findall(page): ValueError: need more than 2 values to unpack __ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] writing list to new file
How would I save a list to a new file for example: If line.startswith('XXX'): save list to new file But I get errors saying only stings can be saved this way. __ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] error message
I'm dping something very simple in RE. Lets say I'm trying to match an American Phone number I write the code this way and try to match it: import re string = 'My phone is 410-995-1155' pattern = r'\d{3}-\d{3}-\d{4}' re.match(pattern,string).group() but I get this error message Traceback (most recent call last): File "C:/Python24/findphone", line 4, in -toplevel- re.match(pattern,string).group() AttributeError: 'NoneType' object has no attribute 'group' __ Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. http://mobile.yahoo.com/maildemo ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] print out lines that start with a word
Can anyone tell me what I've done wrong in this script. I'm trying to get only the lines that start with "This" for a text file. Here's what I wrote: >>> import re >>> f = open('c:/lines.txt').readlines() >>> for line in f: match = re.search('^This',f) if line == match: print match here's the error message I got: Traceback (most recent call last): File "", line 2, in -toplevel- match = re.search('^This',f) File "C:\Python24\lib\sre.py", line 134, in search return _compile(pattern, flags).search(string) TypeError: expected string or buffer Thanks in advance __ Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. http://promotions.yahoo.com/new_mail ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[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] Re:OT
54 years old -- father of 3, grandfather of 4 (and counting.) I started Pythoning because I work for a governmental agency that does Civil Engineering. To support mapping, I needed a wrapper for ESRI products (Python, AML, VBA), to support drafting, I needed a wrapper for AutoDesk products (Python, LISP, VBA), and to support IT, I needed languages for Linux servers (Python, C, etc.) and Windows servers and desktops (Python, VB, C#, etc.) and WindowsCE(Python, VBCE). What option did I really have, then? Besides, it's just so COOL. Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Re: [ANN] RUR: a Python Learning Environment (alpha)
Can't get it running -- it keeps saying: Traceback (most recent call last): File "C:/source/RUR/RURmain.py", line 28, in ? messenger.loadImages() # load them up here after initialising Handlers File "C:\source\RUR\messenger.py", line 27, in loadImages HIT_WALL_IMAGE = wxImage('ouch2.png').ConvertToBitmap() File "C:\Python23\Lib\site-packages\wx\_core.py", line 2282, in ConvertToBitmap return _core_.Image_ConvertToBitmap(*args, **kwargs)wx._core.PyNoAppError: The wx.App object must be created first! Ron ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor
[Tutor] Re: [ANN] RUR: a Python Learning Environment (alpha)
This looks like a very nice effort -- I am trying to get it running, since I am working with some other newbies to learn more Python. I wish there were a link from http://rur-ple.sourceforge.net/index.html to the download page! And I am not sure which of the downloaded files to run. I thought maybe WorldDisplay.py, or RURmain.py? Anyway, I really like the concept, and the screenshots look intriguing. You have a nice writing style in English, by the way -- I think kids will pick right up on the "fix the robot" metaphor. Which program do I start? Ron ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor
[Tutor] Graphics coordinates (bump?)
I sent the following yesterday, but since it was my first request to the list, I got an autoreply. It never showed up in my digest of the list, and I haven't seen a response. It's in the archives, but I am thinking that archiving/autoreply was all that happened (no actual posting.) Anyway, I am looking hard at PIL, and a little at PyGame. Still looking for suggestions, though. I work for a Civil Engineering organization. I need to give our users a means to generate geographic coordinates for our projects and structures. I plan to do this by making a viewer which will accept a graphic file (png or jpg) and two points (pixels) in that image for which geographic coordinates are given. Users can then click on the image where appropriate to generate a list of geographic points of interest for their work. The list will be saveable as an xml file or a shp file (a widely used geographic binary format.) In addition, other programs that I write will use the viewer as a dialog box: will call the viewer directly and get the points from it, just like a color picker dialog. What I am looking for: thoughts on which Python modules are most appropriate and generally applicable for this. PIL? Piddle? PyGIS? some of Hobu's modules? I believe I can write the glue-code, but I don't want to reinvent the wheel if there are existing modules that do almost (or even better, exactly) what I need. I work on WinXp, Linux, and WindowsCE. WindowsCE has a fairly plain-vanilla Python build, so it's better if I stick to the core modules as far as possible. Ron Phillips ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor
[Tutor] Re: PDF and Python
I just happened across an answer yesterday. PIL writes PDF s. http://www.pythonware.com/products/pil/ Ron ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor
[Tutor] Graphics coordinates
I work for a Civil Engineering organization. I need to give our users a means to generate geographic coordinates for our projects and structures. I plan to do this by making a viewer which will accept a graphic file and two points (pixels) in that image for which geographic coordinates are given. Users can then click on the image where appropriate to generate a list of geographic points of interest for their work. The list will be saveable as an xml file or a shp file (a widely used geographic binary format.) In addition, other programs that I write will use the viewer as a dialog box: will call the viewer directly and get the points from it, just like a color picker dialog. What I am looking for: thoughts on which Python modules are most appropriate and generally applicable for this. PIL? Piddle? PyGIS? some of Hobu's modules? I believe I can write the glue-code, but I don't want to reinvent the wheel if there are existing modules that do almost (or even better, exactly) what I need. I work on WinXp, Linux, and WindowsCE. WindowsCE has a fairly plain-vanilla Python build, so it's better if I stick to the core modules as far as possible. Ron Phillips ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor