Re: [Tutor] Passing perimeters in dictionary values?

2009-02-24 Thread Kent Johnson
On Tue, Feb 24, 2009 at 2:03 PM, nathan virgil wrote: > I'm experimenting with OOP using the Critter Caretaker script from Python > Programming for the Absolute Beginner as my basis. I've noticed that a > dictionary/function combo is a great way to handle menus, and so I've > adapted the menu to r

Re: [Tutor] Passing perimeters in dictionary values?

2009-02-24 Thread Kent Johnson
On Tue, Feb 24, 2009 at 2:35 PM, spir wrote: > Le Tue, 24 Feb 2009 14:03:09 -0500, > nathan virgil s'exprima ainsi: >> so that I can call methods from a dictionary, instead of having an >> excruciatingly long if structure. Unfortunately, the problem I'm running >> into with this is that I can't

Re: [Tutor] Passing perimeters in dictionary values?

2009-02-24 Thread Kent Johnson
On Tue, Feb 24, 2009 at 5:13 PM, nathan virgil wrote: > I'm not familiar with lambdas yet, and I don't think this book will > introduce me to them; they aren't listed in the index, anyway. Here are two brief introductions: http://docs.python.org/tutorial/controlflow.html#lambda-forms http://www.i

Re: [Tutor] re Formating

2009-02-25 Thread Kent Johnson
On Wed, Feb 25, 2009 at 7:46 AM, prasad rao wrote: > hi licenseRe = re.compile(r'\(([A-Z]+)\)\s*(No.\d+)?') for license in licenses: >       m = licenseRe.search(license) >       print m.group(1, 3) > > Traceback (most recent call last): >   File "", line 3, in >     print m.group(1, 3)

Re: [Tutor] overwriting input file

2009-02-25 Thread Kent Johnson
On Wed, Feb 25, 2009 at 8:26 AM, Noufal Ibrahim wrote: > Bala subramanian wrote: >> >> Hello all, >> >> query 1) How should i overwrite the input file >> I want to open 5 files one by one, do some operation on the lines and >> write the modified lines on the same file (overwritting). Can some plea

Re: [Tutor] Standardizing on Unicode and utf8

2009-02-25 Thread Kent Johnson
On Wed, Feb 25, 2009 at 12:46 PM, Thorsten Kampe wrote: > * spir (Fri, 20 Feb 2009 13:02:59 +0100) >> > Use the header: # -*- coding: utf8 -*- >> >> You don't even need fancy decoration: >> >> # coding: utf-8 >> >> is enough. > > Sure? Never heard of that. Interesting... >From PEP 263 (http://ww

Re: [Tutor] overwriting input file

2009-02-25 Thread Kent Johnson
On Wed, Feb 25, 2009 at 1:53 PM, Alan Gauld wrote: > > "Bala subramanian" wrote > >> query 1) How should i overwrite the input file >> I want to open 5 files one by one, do some operation on the lines and >> write >> the modified lines on the same file (overwritting). Can some please tell >> me >

Re: [Tutor] format a file

2009-02-26 Thread Kent Johnson
On Thu, Feb 26, 2009 at 4:09 AM, prasad rao wrote: > hello > I find it difficult to use horizontal scroll bar to read text documents. > So I want to split lines in the text file in to two lines. > > def  myforrmat(source,desty): > so=open(source) > de=open(desty,'w') > for line in

Re: [Tutor] Linear Algebra weirdness

2009-02-26 Thread Kent Johnson
On Thu, Feb 26, 2009 at 12:32 AM, Mr Gerard Kelly wrote: > I am getting some very strange behaviour from the Linear Algebra module. > > Look at this code: > > from LinearAlgebra import * > > a=5 > print a > > And look at the output that I get when I run it: > > 50.0 > 0.0 > 0.25 > 0.0 > 0.5 > 0.0

Re: [Tutor] Convert a string of numbers to a list

2009-02-26 Thread Kent Johnson
On Thu, Feb 26, 2009 at 2:00 AM, wrote: > Hi, > > I am trying to convert an output from subprocess.Popen() from a byte string > to a list of numbers.  This is what Popen returns: > > print SAL.stdout.readlines() > > ['[335, 180, 201, 241, 199]\r\n'] For one line: In [11]: s = '[335, 180, 201, 24

Re: [Tutor] learning new features of python

2009-02-26 Thread Kent Johnson
On Thu, Feb 26, 2009 at 6:28 AM, Bala subramanian wrote: > Dear Friends, > > Is there any website/tutorial that explains new features that are constantly > getting embedded in python. Every new release comes with a "What's New in Python xx" document. This is often the best, and sometimes the only

Re: [Tutor] re.format a file

2009-02-26 Thread Kent Johnson
On Thu, Feb 26, 2009 at 8:43 AM, prasad rao wrote: > hello > Thank you Lie and Kent. > I forgot  about newline character and the fact that string can be sliced. > Thanks for your timely help > BTW I have gone through  the Python library reference and find no examples > in fileinput module. > z=fil

Re: [Tutor] learning new features of python

2009-02-26 Thread Kent Johnson
On Thu, Feb 26, 2009 at 10:35 AM, Alan Gauld wrote: > > "Bala subramanian" wrote >> Similaraly in Alan Guald Learn to program link, he has given information >> on >> opening a file with file() and open() functions. > > And in V3 they took that back out again :-( ?? open() is in V3. file() is no

Re: [Tutor] Extract strings from a text file

2009-02-27 Thread Kent Johnson
On Fri, Feb 27, 2009 at 2:22 AM, spir wrote: > Anyway for a startup exploration you can use regular expressions (regex) to > extract individual data item. For instance: > > from re import compile as Pattern > pattern = Pattern(r""".*(.+)<.+>.*""") > line = "text text text Joseph" > print pattern.

Re: [Tutor] re Format a file

2009-02-27 Thread Kent Johnson
On Fri, Feb 27, 2009 at 5:09 AM, prasad rao wrote: > Hello > Finally I  managed to writ a function to format a file. > Thank to everybody for their tips. > > def mmm(a): > import os,textwrap > so=open(a) > d=os.path.dirname(a)+os.sep+'temp.txt' > de=open(d,'w') > import te

Re: [Tutor] Converting "HH:MM:SS" to datetime

2009-03-01 Thread Kent Johnson
On Sun, Mar 1, 2009 at 3:51 PM, Wayne Watson wrote: >     x = str(self.start_time) >     set_loc_dict["start_time"] = > datetime.datetime.strptime(x,"%H:%M:%S") > > It seems like there should be a simpler way to wrestle this to datetime. You say self.start_time is a str, so there is no ne

Re: [Tutor] Add elements to list and display it [Very newbie question]

2009-03-02 Thread Kent Johnson
On Mon, Mar 2, 2009 at 5:36 PM, Network Administrator wrote: > I appreciate your explanation about the reserved word "list" as well as the > code you gently wrote to me. Now, I want to show everybody what I did: > > #!/usr/bin/env python > # > # This function fills any given li

Re: [Tutor] Shelve: remove dictionary from list

2009-03-03 Thread Kent Johnson
On Tue, Mar 3, 2009 at 12:18 PM, Timo wrote: > Hello all, I'm using the Shelve module to store dictionaries in a list as a > value of a key. > > So: > > key = [{'keyA' : 1, 'keyB' : 2}, {'key1' : 1, 'key2' : 2}] > > The problem is I can't remove a dictionary from the list. > > > import shelve > >

Re: [Tutor] What is this [] construction?

2009-03-04 Thread Kent Johnson
On Wed, Mar 4, 2009 at 2:56 AM, Alan Gauld wrote: > In Python v3 list comprehensions and generator expressions have been > "merged" in that putting a GE inside [] has the same effect as a LC. In > practice this makes little or no difference to the programmer its just how > Python handles it behin

Re: [Tutor] Code documentation

2009-03-04 Thread Kent Johnson
On Wed, Mar 4, 2009 at 3:06 AM, Alan Gauld wrote: > > "Carlos Daniel Ruvalcaba Valenzuela" wrote > >> which approach should I take on documentation (API docs) for a python >> library I have been working on, there is currently code docstrings, > > docstrings are the minimum since they show up on h

Re: [Tutor] wxPython vs PyQt

2009-03-04 Thread Kent Johnson
On Wed, Mar 4, 2009 at 9:06 AM, Neven Goršić wrote: > Hi! > > I am about to begin to learn GUI programming with Python. What are pros and > cons for PyQT and wxPython? > > I read that PyQT has PyQT Designer which makes GUI programming easier. Is it > owned and supported by Nokia? > What about wxPy

Re: [Tutor] Configuration File, Tkinter, IntVars--Manufacturing Variables

2009-03-04 Thread Kent Johnson
On Tue, Mar 3, 2009 at 2:54 PM, Wayne Watson wrote: > I see my post of yesterday, "Maintaining the Same Variable Type--Tkinter", > went over like a lead balloon. :-) > (Note though the Myth Busters TV series successfully built and flew a lead > balloon.) > > Let's see if I can really simplify what

Re: [Tutor] Configuration File, Tkinter, IntVars--Manufacturing Variables

2009-03-05 Thread Kent Johnson
On Thu, Mar 5, 2009 at 11:36 AM, Wayne Watson wrote: > It looks like your sample code code has the right idea, but the hang up with > the original code is getting entered values back to the main program and > available globally through it. The trick in your code, I think, is to get > the data bac

Re: [Tutor] array and ndarray

2009-03-06 Thread Kent Johnson
On Thu, Mar 5, 2009 at 8:38 PM, Mr Gerard Kelly wrote: > I am trying to convert something using the old Numeric module to the numpy > module. > > This is the code so far:: > > from __future__ import division > > import pygame, time, random, pygame.sndarray > sample_rate = 44100 > > from numpy imp

Re: [Tutor] Misunderstanding the Entry Widget

2009-03-06 Thread Kent Johnson
On Thu, Mar 5, 2009 at 10:52 PM, Wayne Watson wrote: > Apparently Entry does not have a callback. It seems as though it should. If > one enters data into it and presses Return, then it would be good to know > what the data is, so it can be used elsewhere. However, that's not the way > it works. On

Re: [Tutor] Misunderstanding the Entry Widget

2009-03-06 Thread Kent Johnson
On Fri, Mar 6, 2009 at 7:15 AM, Wayne Watson wrote: > Control variables. What is the difference between IntVar,  BooleanVar, > StringVar,  and DoubleVar? The difference is the type of value returned by get(). > For example, in the program below, it looks like > I get the same result usint IntVa

Re: [Tutor] using re groups

2009-03-06 Thread Kent Johnson
On Fri, Mar 6, 2009 at 7:56 AM, ski wrote: > Hello, > I have this: > import re s = "Association of British Travel Agents (ABTA) No. 56542\nAir Travel Organisation Licence (ATOL)\nAppointed Agents of IATA (IATA)\nIncentive Travel & Meet. Association (ITMA)" licenses = re.sp

Re: [Tutor] does id function return location of reference or the referenced object?

2009-03-06 Thread Kent Johnson
On Fri, Mar 6, 2009 at 11:08 AM, Serdar Tumgoren wrote: > Hi all, > > I've managed to think myself in circles and was hoping someone could help > clarify the nature of the "id" function and references in general. > > I initially got confused while dealing with file objects, so I'll stick with > th

Re: [Tutor] does id function return location of reference or the referenced object?

2009-03-06 Thread Kent Johnson
On Fri, Mar 6, 2009 at 12:09 PM, Serdar Tumgoren wrote: > So can I ask what happens internally in python when you create open a file > object in a loop without assigning that file object to a variable? > > E.g.: > > for line in open(file.py): >    print line > > In the above, is pythonimplicitly c

Re: [Tutor] Misunderstanding the Entry Widget

2009-03-06 Thread Kent Johnson
On Fri, Mar 6, 2009 at 11:26 AM, Wayne Watson wrote: > I've just got to stop using one letter for variables, especially ones that > sound alike! :-) > > Other than v tracking every value change made, did I gain anything by using > it? It seems to me that control variables are of marginal use. I mi

Re: [Tutor] image processing

2009-03-06 Thread Kent Johnson
On Fri, Mar 6, 2009 at 7:05 PM, Harris, Sarah L wrote: > Could someone please let me know where I can find 'lots' of examples of > image processing using python? Particularly MODIS and ASTER examples. > Any feedback will be greatly appreciated. There is one complete example here: http://pyevolve.

Re: [Tutor] glob in order of the file numbers

2009-03-06 Thread Kent Johnson
On Fri, Mar 6, 2009 at 9:52 PM, Emad Nawfal (عماد نوفل) wrote: > Hi Tutors, > suppose I have four files in the current directory: 1.temp, 2.temp, 3.temp, > and 4.temp. I want to use glob, or anything else, to print the contents of > the files in their respective orders, where the content of 1.temp

Re: [Tutor] print problem python

2009-03-07 Thread Kent Johnson
On Sat, Mar 7, 2009 at 7:51 AM, W W wrote: > On Sat, Mar 7, 2009 at 3:11 AM, Alan Gauld wrote: >> Python 3 has a lot of >> changes and most of the beginners material hasn't caught >> up yet. It will be easier to get answers to your questions if >> you stick with v2.6 and then when comfortable wit

Re: [Tutor] Long list error

2009-03-08 Thread Kent Johnson
On Sun, Mar 8, 2009 at 8:27 PM, William Stephens wrote: > Hello, > > I was working on a sieve of eratosthenes and ran into an error I don't > understand. > size = 10 000 000 000 l = [0,1]*(size/2) > Traceback (most recent call last): >  File "", line 1, in > OverflowError: cannot fit 'l

Re: [Tutor] creating new dictionary based on membership testing

2009-03-09 Thread Kent Johnson
On Mon, Mar 9, 2009 at 10:28 AM, ski wrote: > hello, > > i have this list which contains a number of dictionaries. > d1 = [{'is_selected': False, 'id': 'AAC', 'title': 'Association of Airline Cons.'}, {'is_selected': False, 'id': 'AALA', 'title': 'Adv. Activity Licence. Auth.'}, {'is

Re: [Tutor] HELP ON A ANAGRAM PYTHON PROGRAM

2009-03-09 Thread Kent Johnson
On Mon, Mar 9, 2009 at 1:38 PM, jessica cruz wrote: > I don't know how to figure out the error since the only message that I get > is that "there's an error: invalid syntax" Please copy & paste the whole error message including the traceback so we know where the error is. Kent _

Re: [Tutor] comparing lists of dictionaries

2009-03-09 Thread Kent Johnson
On Mon, Mar 9, 2009 at 4:20 PM, ski wrote: > what am i missing here, i would like to get a list of the diff between list1 > and list2 What do you mean by diff in this case? Items in one list and not in the other? Items that are in both lists but with different elements? What elements do you wan

Re: [Tutor] comparing lists of dictionaries

2009-03-09 Thread Kent Johnson
On Mon, Mar 9, 2009 at 5:56 PM, ski wrote: > i was looking to list all the items in list1 that are not in list2 based on > the key['id] and key['affiliation'] respectively. OK. Generally, when you want to test for membership, a set or dict is a good choice. In this case, I would first make a set

[Tutor] Replying to digest messages

2009-03-11 Thread Kent Johnson
When replying to digest messages, please - change the subject to the subject of the message you are replying to - trim the message body to contain only the (portion of the) message you are replying to Thanks, Kent ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Sorting large numbers of co-ordinate pairs

2009-03-12 Thread Kent Johnson
On Thu, Mar 12, 2009 at 9:43 AM, Dinesh B Vadhia wrote: > Have a large number (> 1bn) of integer co-ordinates (i, j).  The i are > ordered and the j unordered. > > I want to create (j, i) with j ordered and i unordered ie. > > from: > > ... > 6940, 22886 > 6940, 38277 > 6940, 43788 > ... > > to: >

Re: [Tutor] loop performance in global namespace (python-2.6.1)

2009-03-12 Thread Kent Johnson
On Thu, Mar 12, 2009 at 8:13 AM, Poor Yorick wrote: > In the following snippet, the loop in the global namespace takes twice as > long > as the loop in the function namespace.  Why? Because local name lookup is faster than global name lookup. Local variables are stored in an array in the stack fr

Re: [Tutor] loop performance in global namespace (python-2.6.1)

2009-03-12 Thread Kent Johnson
On Thu, Mar 12, 2009 at 11:41 AM, spir wrote: > Le Thu, 12 Mar 2009 11:13:33 -0400, > Kent Johnson s'exprima ainsi: > >> Because local name lookup is faster than global name lookup. Local >> variables are stored in an array in the stack frame and accessed by >> i

Re: [Tutor] reading lists from a text file

2009-03-12 Thread Kent Johnson
2009/3/12 Emad Nawfal (عماد نوفل) : > Hi Tutors, > I've never had a situation in which this was useful for me, but I'm just > curious. > If there is a text file that has a list or number of lists in it, is there > is a way to read the lists in the file as lists, and not as a string. Sample > file a

Re: [Tutor] Having an Issue

2009-03-13 Thread Kent Johnson
On Fri, Mar 13, 2009 at 8:43 PM, Jared White wrote: > I dunno how this works but hopefully someone can help me > > I am trying to build a program in Python but for someone i can not get what > i am trying to build WORK > > by email you guys is there a way i can get some help some pointer on the >

Re: [Tutor] Simple User Entry Verification

2009-03-15 Thread Kent Johnson
On Sat, Mar 14, 2009 at 5:52 PM, R. Alan Monroe wrote: > >> while type(start)!=float: > > Did you try quotes around the word "float"? That won't help, type(start) is a type object, not a string. It's also possible that Ian is entering an integer, he didn't show the input value: In [1]: print typ

Re: [Tutor] How to only give the user so much time to enter response?

2009-03-15 Thread Kent Johnson
On Sun, Mar 15, 2009 at 4:22 AM, james carnell wrote: > Trying to use Timer in console based game that gives the user so much time > to act. If they do not act then it just passes the turn back to the program > to do the next thing. I have Python 2.5 and Windows XP. > so... this kind is where I a

Re: [Tutor] TypeError: list objects are unhashable

2009-03-15 Thread Kent Johnson
On Sun, Mar 15, 2009 at 8:27 AM, qsqgeekyog...@tiscali.co.uk wrote: l1 = [{'url': 'ws.geonames.org', 'type': 'findNearby', > 'parameters': [50.101, 10.02]}, {'url': 'ws.geonames.org', > 'type': 'findNearby', 'parameters': [50.101, 10.02]}, > {'url': 'ws.geonames.org',

Re: [Tutor] wxPython vs PyQt

2009-03-16 Thread Kent Johnson
2009/3/16 Elena of Valhalla : > 2009/3/16 Neven Goršić : >> I just would like to correct my incomplete PyQT pricing list from >> above and mislead none. >> >> If you intent to write commercial programs you have to pay: >> >> 400 EURO   for PyQT     AND    3000 EURO  for QT !!! > > actually, QT is m

Re: [Tutor] memory error files over 100MB

2009-03-16 Thread Kent Johnson
On Mon, Mar 16, 2009 at 12:30 PM, A.T.Hofkamp wrote: > I don't know what code is executed in an assignment exactly, but > **possibly**, first the 'read()' is executed (thus loading a very big string > into memory), before assigning the value to the variable (which releases the > previous value of

Re: [Tutor] help with ftplib and file modification date

2009-03-16 Thread Kent Johnson
On Mon, Mar 16, 2009 at 6:27 PM, Rene Bourgoin wrote: > i'm doing a simple upload to an FTP server using the ftplib module and > wanted to know how i can preserve the file modification date all the way > through the process. I lose the file mod date because i read the original > file then ftp writ

Re: [Tutor] list.replace -- string.swap

2009-03-17 Thread Kent Johnson
On Tue, Mar 17, 2009 at 7:01 AM, spir wrote: > Is there a list.replace builtin I cannot find? Or a workaround? Just assign directly to list elements. To replace s1 with s2 in l: for i, x in enumerate(l): if x == s1: l[i] = s2 > Also: How would perform string.swap(s1, s2) in the following

Re: [Tutor] (no subject)

2009-03-17 Thread Kent Johnson
On Tue, Mar 17, 2009 at 6:56 AM, Jared White wrote: > Would anyone know how to Write an application that displays the following > patterns separately, one below the other. Yes. How about if you try? Presumably this is homework. What have you learned that might be helpful here? Kent _

Re: [Tutor] combining Python 2.x and Python 3

2009-03-17 Thread Kent Johnson
On Tue, Mar 17, 2009 at 7:33 AM, Andre Engels wrote: > I have an open source project I have done some work on, which is > programmed in Python 2.3-2.6. I would like to change it so that it can > be run under both Python 3 and Python 2.x. Two questions for that: > * is there a place where I can fin

Re: [Tutor] memory error files over 100MB

2009-03-17 Thread Kent Johnson
On Tue, Mar 17, 2009 at 6:34 AM, A.T.Hofkamp wrote: >> http://personalpages.tds.net/~kent37/kk/00012.html > > Nice web-page! Thanks! > You can do the above statements also iteratively of course > > for i in ... >  s = read() >  # write s > > but since the loop does nothing with either s or read

Re: [Tutor] (no subject)

2009-03-17 Thread Kent Johnson
On Tue, Mar 17, 2009 at 9:03 AM, wrote: > Honestly I'm doing tutorials, I'm not in school.  I am trying to learn it for > my own sake. > > I got the *'s to come up but they are not forming the way I would like it to. >  So that why I was asking for help. OK, then show us the code you have and

Re: [Tutor] combining Python 2.x and Python 3

2009-03-17 Thread Kent Johnson
On Tue, Mar 17, 2009 at 8:59 AM, Kent Johnson wrote: > There are quite a few porting anecdotes in blogs, etc. Some googling > should turn them up. Google "python 3 porting" for lots of resources. Kent ___ Tutor maillist - Tutor

Re: [Tutor] (no subject)

2009-03-17 Thread Kent Johnson
On Tue, Mar 17, 2009 at 3:16 PM, Jared White wrote: > howmany = int(raw_input('How many lines ')) > rhowmany = howmany > strout = '*' > while howmany > 0: >     print strout >     strout += '*' >     howmany -= 1 Another hint: learn how to use the range() function and for loops: In [1]: for i i

Re: [Tutor] combining Python 2.x and Python 3

2009-03-17 Thread Kent Johnson
On Tue, Mar 17, 2009 at 3:54 PM, wesley chun wrote: >> I would like to change it so that it can be run under both Python 3 and >> Python 2.x. > > everyone who has responded so far are telling about converting your > piece of code from Python 2 to Python 3, for example, using the "2to3" > tool tha

Re: [Tutor] combining Python 2.x and Python 3

2009-03-18 Thread Kent Johnson
On Wed, Mar 18, 2009 at 1:50 AM, wesley chun wrote: > wow, great links Kent. i didn't think that people would be as bold as > to do this, but i guess it was inevitable. > it may be worthwhile to collate all of > this info into a "2to3 FAQ" at some point. http://wiki.python.org/moin/PortingPythonT

Re: [Tutor] Iterating over letters or arbitrary symbols like they were numbers...

2009-03-18 Thread Kent Johnson
On Wed, Mar 18, 2009 at 5:26 PM, Alexander Daychilde (Gmail) wrote: > exp_list = [] > > exp_range = exp.split(":") > > min_padding = len(exp_range[0]) > > for i in range(int(exp_range[0]),(int(exp_range[1])+1)): > >    exp_list.append('%0*d' % (min_padding, i)) This could be a little cleaner usi

Re: [Tutor] adding dictionary values

2009-03-20 Thread Kent Johnson
2009/3/20 greg whittier : > This looks like it will work, but you can accomplish this more compactly by > just looping over the items in both dictionaries and making use of the > default argument of the dictionaries get method. > > newDict = {} > for k, v in dict1.items() + dict2.items(): >     ne

Re: [Tutor] adding dictionary values

2009-03-20 Thread Kent Johnson
2009/3/20 Emad Nawfal (عماد نوفل) : > if I want to do this with more than two dictionaries, the obvious solution > for me is to use something like the reduce functions with a list of > dictionary names like: > dictList = [dict1, dict2, dict3] > newDict = reduce(addDicts, dictList) > > Is this a sa

Re: [Tutor] Executing a C Program from RH Linux ... (Cygwin)

2009-03-20 Thread Kent Johnson
On Fri, Mar 20, 2009 at 1:49 PM, Wayne Watson wrote: > First questions about Cygwin is I see a 1.7 Beta download version for it, > and references to 1.5 downloads. Where's 1.6? Is it past Beta? > > Wayne Watson wrote: > > That's a lot of text to respond to, but let me see if I can broadly do it. >

Re: [Tutor] Inspiration/examples

2009-03-22 Thread Kent Johnson
On Sun, Mar 22, 2009 at 6:02 PM, Mathias Andersson wrote: > Hi all! > > Im currently trying to learn how to use python. But my only problem seems to > be at what to make? So anyone have a nifty list or some ideas on things to > program, school tasks or algorithms to try and implement. Beginner- to

Re: [Tutor] no output

2009-03-23 Thread Kent Johnson
On Mon, Mar 23, 2009 at 1:08 AM, John Jenkinson wrote: > My Code: > > # Game Over - Version 2.0 > # Demonstrates the use of quotes in strings > > print "Program 'Game Over' 2.0" > > print \ > """ >  -  --- ---  ---    - > /  ___|    /   |   /   |/   |  |  ___| > | |

Re: [Tutor] swapping lines between files

2009-03-23 Thread Kent Johnson
On Mon, Mar 23, 2009 at 12:39 PM, Bala subramanian wrote: > Dear Friends, > > Thanks for your replies for my previous mail. > > I have two files as follows. > > file 1 file2 > 200   1 3.55 > 210   2 4.55 > 242   3 1.22 > 248   4  

Re: [Tutor] Difference between SimpleCookie and SmartCookie

2009-03-24 Thread Kent Johnson
On Tue, Mar 24, 2009 at 10:33 AM, Kumar wrote: > I just came to know about this classes SimpleCookie and SmartCookie. > I could get that usage. But I didn't get the difference between these > classes? > Can anybody please tell me what is the difference between this classes? SmartCookie allows coo

Re: [Tutor] Python Logo

2009-03-24 Thread Kent Johnson
On Tue, Mar 24, 2009 at 4:45 PM, Tim Johnson wrote: > Hi Folks: > My company is setting up a new website, like to have a python logo > on it. Can anyone recommed a logo that would be legal for us to > use? http://www.python.org/community/logos/ Kent __

[Tutor] Fwd: swapping lines between files

2009-03-24 Thread Kent Johnson
Forwarding to the list -- Forwarded message -- From: Bala subramanian Date: Tue, Mar 24, 2009 at 11:23 AM Subject: Re: [Tutor] swapping lines between files To: Kent Johnson Hai Kent, Thank you. I tried the same zip with a list and a file, instead of just two files. It works

Re: [Tutor] Python Logo

2009-03-25 Thread Kent Johnson
On Tue, Mar 24, 2009 at 6:26 PM, wrote: > http://img99.imageshack.us/img99/5422/webpy.png That is the logo for web.py (a Python web framework), not for the Python language itself. http://luke.jottit.com/webpy_logo Kent ___ Tutor maillist - Tutor@pyt

Re: [Tutor] Difference between SimpleCookie and SmartCookie

2009-03-25 Thread Kent Johnson
On Wed, Mar 25, 2009 at 12:35 AM, Kumar wrote: > Thanks a lot for the reply Kent . > Could you please tell me If I will try to move from SmartCookie to > SimpleCokkie in out application, what precautions should I take care? Make sure that all the values in the Morsels are strings. Kent _

Re: [Tutor] Using C in python

2009-03-25 Thread Kent Johnson
On Wed, Mar 25, 2009 at 5:13 PM, amit sethi wrote: > what are the ways in which i can use C in python programs . I know there is > SWIG bindings are there any other . Also Could anyone explain how Swig > bindings work? There are quite a few options: SIP, SWIG and ctypes (in the std lib) build wr

Re: [Tutor] printing files

2009-03-26 Thread Kent Johnson
On Thu, Mar 26, 2009 at 2:58 PM, ALAN GAULD wrote: > Use '\n'.join(handle[1:]) > It will create a string from your list with newline as separator. The lines from readlines() include the newlines already. > When i use the following > > print>>out, handle[1:] > > In the out file, it saves the line

Re: [Tutor] plotting with python

2009-03-27 Thread Kent Johnson
On Fri, Mar 27, 2009 at 7:46 AM, Bala subramanian wrote: > Friends, > I am not sure if this forum is appropriate to ask question about a > particular package. After getting suggestions from some of you for python > based plotting, I have just started with matplotlib. I am bit confused with > the r

Re: [Tutor] ImportError: No module named conf

2009-03-29 Thread Kent Johnson
On Sun, Mar 29, 2009 at 3:11 PM, andré palma wrote: > Hey, i was trying to install python d2xx files but i got an error saying: What is d2xx? Be more specific about what you are trying to install. Kent ___ Tutor maillist - Tutor@python.org http://m

Re: [Tutor] how are unicode chars represented?

2009-03-30 Thread Kent Johnson
On Mon, Mar 30, 2009 at 3:36 AM, spir wrote: > Everything is in the title ;-) > (Is it kind of integers representing the code point?) Unicode is represented as 16-bit integers. I'm not sure, but I don't think Python has support for surrogate pairs, i.e. characters outside the BMP. Kent _

Re: [Tutor] __callattr__ ?

2009-03-30 Thread Kent Johnson
On Mon, Mar 30, 2009 at 5:51 AM, spir wrote: > Hello, > > Is there something like a __callattr__ magic method that would catch either > unknown (like __getattr__) or all (like __getattribute__) method calls? > If not, how would you do that? Also if not, do you know why we have > __getattr__, __s

Re: [Tutor] how are unicode chars represented?

2009-03-31 Thread Kent Johnson
On Tue, Mar 31, 2009 at 1:52 AM, Mark Tolonen wrote: > Unicode is simply code points.  How the code points are represented > internally is another matter.  The below code is from a 16-bit Unicode build > of Python but should look exactly the same on a 32-bit Unicode build; > however, the internal

Re: [Tutor] My Program stopped working, can anyone help

2009-04-01 Thread Kent Johnson
On Wed, Apr 1, 2009 at 6:06 AM, Jared White wrote: > I am trying to produce A Caesar cipher is a simple substitution cipher , > that would code For example, if the key value is 2, the word “Sourpuss” > would be encoded as “Uqwtrwuu > > Here is my code: ( but i keep getting a ERROR) It works for me

Re: [Tutor] How to make the difference between binary and text files ?

2009-04-04 Thread Kent Johnson
On Sat, Apr 4, 2009 at 7:07 AM, Dominique wrote: > Hello, > > I am developing a very small multi-platform app to search for a specific word > or > expression in files located in a drive or directory. > So I need to open files to search for the word. > > I read that opening a binary file as a text

Re: [Tutor] renumbering a sequence

2009-04-04 Thread Kent Johnson
On Sat, Apr 4, 2009 at 3:37 PM, Christopher Spears wrote: > > I want to write a script that takes a list of images and renumbers them with > a user supplied number.  Here is a solution I came up while noodling around > in the interpreter: > alist = ["frame.0001.tif","frame.0002.tif","frame.

Re: [Tutor] Formatting zip module arguments correctly

2009-04-05 Thread Kent Johnson
On Sun, Apr 5, 2009 at 4:54 PM, Benjamin Serrato wrote: > Please tell me why this code fails. I am new and I don't understand why my > formatting of my zip arguments is incorrect. Since I am unsure how to > communicate best so I will show the code, the error message, and what I > believe is happen

Re: [Tutor] Checking for string in a list strangeness

2009-04-06 Thread Kent Johnson
On Mon, Apr 6, 2009 at 3:30 AM, AdamC wrote: > I'm writing a small cgi application for children to use and I want to > check that the name they enter isn't a swear word. > #for i in swearlist:       # shows swear list OK > #    print i; Perhaps the words in swearlist include some whitespace? Tr

Re: [Tutor] Checking for string in a list strangeness

2009-04-06 Thread Kent Johnson
On Mon, Apr 6, 2009 at 8:26 AM, AdamC wrote: > 2009/4/6 Kent Johnson : >> On Mon, Apr 6, 2009 at 3:30 AM, AdamC wrote: >>> I'm writing a small cgi application for children to use and I want to >>> check that the name they enter isn't a swear word. >> &

Re: [Tutor] unicode to plain text conversion

2009-04-06 Thread Kent Johnson
On Mon, Apr 6, 2009 at 6:48 PM, Pirritano, Matthew wrote: > Hello python people, > > I am a total newbie. I have a very large file > 4GB that I need to > convert from Unicode to plain text. I used to just use dos when the file > was < 4GB but it no longer seems to work. Can anyone point me to some

Re: [Tutor] unicode to plain text conversion

2009-04-07 Thread Kent Johnson
On Tue, Apr 7, 2009 at 10:44 AM, Pirritano, Matthew wrote: > How can I find out the type of coding that was used to create this file? > Is there a way to do this other than just asking the person who created > it? That is possible, but I was just curious. If you can look at the data as hex value

Re: [Tutor] why is unicode converted file double spaced?

2009-04-07 Thread Kent Johnson
On Tue, Apr 7, 2009 at 12:52 PM, Pirritano, Matthew wrote: > So Kent's syntax worked to convert my Unicode file to plain text. But > now my data is double space. How can I fix this.  Here is the code I'm > using. > > import codecs > > inp = codecs.open('g:\\data\\amm\\text files\\test20090320.txt'

Re: [Tutor] why is unicode converted file double spaced?

2009-04-07 Thread Kent Johnson
On Tue, Apr 7, 2009 at 1:11 PM, Marc Tompkins wrote: > Anyway, try this - > >> import codecs >> >> inp = codecs.open('g:\\data\\amm\\text files\\test20090320.txt', 'r', >> 'utf-16') >> outp = open('g:\\data\\amm\\text files\\new_text_file.txt', 'w') >> >> for outLine in inp: >>     outp.write(outL

Re: [Tutor] why is unicode converted file double spaced?

2009-04-07 Thread Kent Johnson
On Tue, Apr 7, 2009 at 2:59 PM, Pirritano, Matthew wrote: > Traceback (most recent call last): > >   File "C:\Projects\unicode_convert.py", line 8, in > >     outp.write(outLine.strip()+'\n') > > UnicodeEncodeError: 'ascii' codec can't encode characters in position > 640-641: ordinal not in rang

Re: [Tutor] Python Logging Module

2009-04-07 Thread Kent Johnson
On Tue, Apr 7, 2009 at 6:34 PM, wrote: > Hello everyone... > > My intention is to create a generic logging function I can use across > scripts. I have a few things I would like this function to be able to > accomplish: > > 1. log info and above to console > 2. log debug and above to file > 3. for

Re: [Tutor] Python Lists--A Suggestion

2009-04-07 Thread Kent Johnson
On Tue, Apr 7, 2009 at 9:13 PM, Wayne Watson wrote: > Perhaps the Pyton organization could produce their mail lists, if they have > any control over them. Maybe that's the source of the inconsistency? That > is, some are not sponsored by them. I don't really know what you mean by "produce" their

Re: [Tutor] why is unicode converted file double spaced?

2009-04-08 Thread Kent Johnson
On Wed, Apr 8, 2009 at 3:55 AM, spir wrote: > Le Tue, 7 Apr 2009 17:54:42 -0400, > Kent Johnson s'exprima ainsi: > >> >     outp.write(outLine.strip()+'\n') > >> UnicodeEncodeError: 'ascii' codec can't encode characters in position

Re: [Tutor] Regex for a variable within a string

2009-04-08 Thread Kent Johnson
On Wed, Apr 8, 2009 at 6:28 AM, David Cash wrote: > Hi, I'm new to python and have decided to develop a web crawler / file > downloader as my first application. I am at the stage where the script > requests a page and parses the page for URLs, then prints them out. However, > I'd like to change my

Re: [Tutor] problem in replacing regex

2009-04-08 Thread Kent Johnson
> Kumar s'exprima ainsi: > >> Hi Danis, >> >> Just to be more specific that I can add [^/] in my expression which will >> successfully work for url (i.e. http://sdfs/123-34) but it will also work >> for non url (i.e. /123-34 ) so u am just trying it to make it specific for >> url only >> I have al

Re: [Tutor] Creating an uncompile module?

2009-04-08 Thread Kent Johnson
On Wed, Apr 8, 2009 at 1:23 PM, Muneeb Akhter wrote: > I am registered on your list serv. so I geuss I could get some help on a > personal project that will read bytecode for python 2.6 and spit out the > original code or atleast the steps. Does something like this already exist > (must be somethi

Re: [Tutor] Python Lists--A Suggestion

2009-04-08 Thread Kent Johnson
On Tue, Apr 7, 2009 at 11:55 PM, Wayne Watson wrote: > My suggestion is aimed at those who want to use graphic > material to support their questions or problems. Make a postable web site > called something like www.python-tutor-pix-post.net, where one could easily > put something there for 30 days

Re: [Tutor] Python Lists--A Suggestion

2009-04-08 Thread Kent Johnson
On Wed, Apr 8, 2009 at 4:27 PM, Wayne Watson wrote: > Sounds fine to me. Is that actually a real link though? If so, who posts > there. If not, I'd suggest, www.pytutor-sendspace.com. Yes it is real, try it! It's open to the public so anyone can post. Kent > Kent Johnson wro

Re: [Tutor] Consolidate reused code blocks

2009-04-08 Thread Kent Johnson
On Wed, Apr 8, 2009 at 8:38 PM, David wrote: > Hi Everyone, > > I have a simple todo list program with functions to add, delete, edit and > print out a list of todo's. I need to understand how to remove the same > blocks of code I use in each function. Should I create a class for the same > block

Re: [Tutor] BeautifulSoup confusion

2009-04-09 Thread Kent Johnson
On Thu, Apr 9, 2009 at 7:27 PM, Steve Lyskawa wrote: > I'm having a > problem with Beautiful Soup.  I can get it to scrape off all the href links > on a web page but I am having problems selecting specific URI's from the > output supplied by Beautiful Soup. > What exactly is it returning to me and

Re: [Tutor] How to write server which listens to specific port

2009-04-10 Thread Kent Johnson
On Fri, Apr 10, 2009 at 4:59 AM, ShivKumar Anand wrote: > I have to implement HL7 in my existing application. > so, I have to send/receive messages which are in a text file (not > implementing v3.0, in which the messages are in xml format) Googling "python hl7" finds a couple of hints for the se

<    1   2   3   4   5   6   7   8   9   10   >