Re: [Tutor] UTF-8 filenames encountered in os.walk

2007-07-04 Thread Terry Carroll
On Wed, 4 Jul 2007, William O'Higgins Witteman wrote: > >It is nonsense to talk about 'recasting' an ascii string as UTF-8; an > >ascii string is *already* UTF-8 because the representation of the > >characters is identical. OTOH it makes sense to talk about converting an > >ascii string to a un

Re: [Tutor] UTF-8 filenames encountered in os.walk

2007-07-04 Thread Terry Carroll
On Wed, 4 Jul 2007, Kent Johnson wrote: > Terry Carroll wrote: > > Now, superficially, s and e8 are equal, because for plain old ascii > > characters (which is all I've used in this example), UTF-8 is equivalent > > to ascii. And they compare the same: > > &

Re: [Tutor] back on bytes

2007-07-07 Thread Terry Carroll
On Fri, 6 Jul 2007, Jerry Hill wrote: > In your formula ( (176 & 127) * 256 + 192 ) you're only using 7 bits > of your high byte. Why are you masking off that last bit? I know in MP3 files, some of the ID3 lengths are coded this way, i.e. as a four-byte field, each byte of which has the high-o

Re: [Tutor] back on bytes

2007-07-10 Thread Terry Carroll
On Sat, 7 Jul 2007, Alan Gauld wrote: > I'm intrigued as to why people are using weird combinations > of math to manipulate bitstrings given that Python has a full > set of bitwise operators. Surely it is easier and more obvious > to simply shift the bits right or left using >> and << and use > bi

[Tutor] How do you install EGG files (was: storm anyone?

2007-07-11 Thread Terry Carroll
On Wed, 11 Jul 2007, shawn bright wrote: > Hey there all, > i got the news that storm was released as open source. Storm is a db orm for > python. > i have a downloaded package and i would like to play with it, but it does > not come with any install instructions. > i found the package here https:

Re: [Tutor] How do you install EGG files

2007-07-11 Thread Terry Carroll
On Wed, 11 Jul 2007, Eric Brunson wrote: > Add the full path of the egg to a .pth file in a directory in your > python path. Cool, thanks. To Shawn: So all I did was create a text file called "myeggs.pth" in my site-packages directory, with the following content: >cat c:\Python25\Lib\site-pa

Re: [Tutor] interpreter restarts

2007-07-13 Thread Terry Carroll
On Sat, 14 Jul 2007, elis aeris wrote: > why deos the interpreter restarts with this? > > f = open("data.ini","w") > > f.write("yeahppe") > > f.close() Not sure. It certainly doesn't, for me. >>> f = open("data.ini","w") >>> f.write("yeahppe") >>> f.close() >>> U:\>cat data.ini yeahppe _

Re: [Tutor] String or Re

2007-07-13 Thread Terry Carroll
On Fri, 13 Jul 2007, Que Prime wrote: > I'm working on the following code to read a log file and output lines > containing '10.52.10.10' but am unsure of whether to use a regular > expression or string to achive this. > for line in infile: > if line #contains '10.52.10.10': > outfile.

Re: [Tutor] String or Re

2007-07-13 Thread Terry Carroll
On Fri, 13 Jul 2007, Terry Carroll wrote: > Try this: > > for line in infile: >if line.find("10.52.10.11") != -1: > outfile.write(line) No, don't. Alan's solution is much nicer. ___ Tutor

Re: [Tutor] eyeD3 module installation on XP

2007-07-16 Thread Terry Carroll
On Fri, 13 Jul 2007, Richard Querin wrote: > Any pointers on how to go about installing this module? There's a file > called 'setup.py.in' as well. Not sure what that does.. Richard; I'm stumped. Can you try version 0.6.10? See why below. I'm using eyeD3-0.6.10, so I know it's possible to inst

Re: [Tutor] IDLE Usage - was Interpreter Restarts

2007-07-17 Thread Terry Carroll
Sara -- I'd also recommend that you find and install a Windows version of whatever editor (whether vi, vim or something else like emacs) you're going to be using on the Unix box. Play with it locally on your own machine for a while and get comfortable with it, and then start using the copy on the

Re: [Tutor] Style question with classes and modules

2007-07-19 Thread Terry Carroll
On Thu, 19 Jul 2007, Kent Johnson wrote: > Attribute lookup seems to have gotten better since Beazley wrote; here > is a test program that uses three ways to access math.sqrt - module > attribute, global name, local name. Note that in the third version, all > three names (sqrt, d, i) are local: .

Re: [Tutor] Style question with classes and modules

2007-07-19 Thread Terry Carroll
On Thu, 19 Jul 2007, Kent Johnson wrote: > This is such a common optimization that Raymond Hettinger (the king of > speed :-) wrote a decorator to do it automatically: Some day I'm going to have to figure out decorators. ___ Tutor maillist - Tutor@p

[Tutor] Decorators (was: Style question with classes and modules

2007-07-19 Thread Terry Carroll
On Thu, 19 Jul 2007, Kent Johnson wrote: > Here is my gentle introduction: > http://personalpages.tds.net/~kent37/kk/1.html Thanks. I see the concept, but I think the part that makes it so hard for me to really get is nicely summarized in your tutorial: Good beginner examples of real-wo

[Tutor] How to determine if every character in one string is in another string?

2007-07-20 Thread Terry Carroll
Is there a straightforward way to find out if all characters in one string are present in a second string? Basically, I have a string s, and I want to print it out only if every character in it is printable (because I accidentally brought my PC loudly to its knees printing a few thousand BEL char

Re: [Tutor] correlation matrix

2007-07-21 Thread Terry Carroll
On Sat, 21 Jul 2007, Beanan O Loughlin wrote: > I am new to python, and indeed to programming, but i have a question > regarding correlation matrices. Beanan, I never did get this kind of math, but have you looked at Numerical Python (NumPy), http://numpy.scipy.org/numpydoc/numpy.html ? Every

Re: [Tutor] Python program design

2007-07-21 Thread Terry Carroll
On Fri, 20 Jul 2007, Doug Glenn wrote: > I have a question on program design. The program will be a catalog of > portable media (DVD, CD, flash drive, floppy, etc). I am currently in the > preliminary stages of design and I currently would like to get input on what > the best method would be for

Re: [Tutor] How to determine if every character in one string is inanother string?

2007-07-23 Thread Terry Carroll
On Sun, 22 Jul 2007, Jerry Hill wrote: > On 7/21/07, Alan Gauld <[EMAIL PROTECTED]> wrote: > > > all(char in string.printable for char in testString) > > > > What is all? > > Is that a 2.5 thing (I'm still on 2.4 here) > > Yes, it's a 2.5 thing. That was my favorite, too. I didn't notice the ne

Re: [Tutor] Pass variable on command line

2007-07-26 Thread Terry Carroll
On Thu, 26 Jul 2007, jason wrote: > Hello, > > I have a situation where I have 2 lists > > List1 = ['blue', 'red', green'] > List2 = ['red', 'yellow', 'orange'] > > And I would like to pass the list name on the command line like so > > ./test.py List1 > > I know I can get the argument using s

Re: [Tutor] Sum of Scores

2007-07-26 Thread Terry Carroll
On Thu, 26 Jul 2007, Tiger12506 wrote: > > But you can call the random functions in your code as often as you want > > safely. > >> Perhaps this is a question for the 'language lawyers'? > >> > > Not sure what this means. > > I believe it means 'those who know the language inside and out' like a

Re: [Tutor] How to determine if every character in one string is inanother string?

2007-07-25 Thread Terry Carroll
On Tue, 24 Jul 2007, wesley chun wrote: > i don't have any time myself either (getting ready for OSCON talk), > but i'm not sure what terry's OP was about... looking for a > well-written piece of code, a faster-performing snippet, or both? i > think he was just unsatissfied with his 1st attempt.

Re: [Tutor] Code like a Pythonista

2007-07-27 Thread Terry Carroll
On Fri, 27 Jul 2007, Dick Moores wrote: > The handout is excellent! Thanks! > > But the slideshow at > , > isn't. You have to use the page-up and -down keys; or the spacebar (at least on Windows under Firefox). Took m

Re: [Tutor] Code like a Pythonista

2007-07-27 Thread Terry Carroll
On Fri, 27 Jul 2007, Kent Johnson wrote: > For navigation I use left and right arrows or mouse-over the > bottom-right of the screen to get a nav panel. But when I get to the > screen "Whitespace 1" there is nothing but white space under the title. Same here, but as I press the PgDn key (or th

Re: [Tutor] Which GUI?

2007-07-27 Thread Terry Carroll
On Fri, 27 Jul 2007, scott wrote: > now that I have a very basic understanding of Python I would like to > take a look at programming in a GUI. Which GUI is generally the easiest > to learn? As between Tkinter and wxPython, I started on Tkinter, but have been won over to wxPython, altho

Re: [Tutor] Which GUI?

2007-07-31 Thread Terry Carroll
On Wed, 1 Aug 2007, Ian Witham wrote: > I'm no expert (yet) but I have come across this fun online tool which helps > you choose a GUI toolkit for Python: > > Choose Your GUI Toolkit I think it's rigged. I answered it honestly, and it suggested wxPython,

Re: [Tutor] Which GUI?

2007-08-01 Thread Terry Carroll
On Wed, 1 Aug 2007, Kent Johnson wrote: > I think that is a good plan, Tkinter is pretty easy to learn but harder > to use to create polished, high-function interfaces. wxPython comes with > a lot more in the box. I've heard "Tkinter is easier to learn" before, and I think I would once have ag

[Tutor] sqlite: does "?" work in PRAGMA commands?

2007-08-01 Thread Terry Carroll
I'm using sqlite for the first time, so I'm not sure whether I'm trying to do something unsupported. or whether I'm trying to do something that's supported, but doing it wrong. I want to get information about a table in my database. The variable tablename holds the name of the table, and self.d

Re: [Tutor] sqlite: does "?" work in PRAGMA commands?

2007-08-02 Thread Terry Carroll
On Thu, 2 Aug 2007, John Fouhy wrote: > I'm not sure about PRAGMA, but you can do introspection in sqlite by > examining the table 'sqlite_master'. Thanks. That's how I get the table names, actually. But it doesn't give the column names. It does give the SQL used to create the table, so I c

Re: [Tutor] Which GUI?

2007-08-02 Thread Terry Carroll
On Thu, 2 Aug 2007, scott wrote: > I was thinking about finding a copy of that book, so maybe starting > WxPython would be easier then and not worry about Tkinter. Is "WxPython > in Action" a very good book? I can say that it's the best book on wxPython that I'm aware of. Of course, it's the

Re: [Tutor] Which GUI?

2007-08-02 Thread Terry Carroll
On Thu, 2 Aug 2007, Eric Brunson wrote: > Switching gears from linear to event driven programming is a pretty > significant paradigm shift. Will this book help him get his head around > that? Hard to say. It does have a chapter, Chapter 3, devoted to that. ___

[Tutor] [OT] Re: os.path.exists(path) returns false when the path actually exists!

2007-08-02 Thread Terry Carroll
On Thu, 2 Aug 2007, Tiger12506 wrote: > But they have provided Microsoft with much money because more useless > people can use computers. That's a little harsh, isn't it? A person using a computer is not useless by virtue of not wanting to program or understand technical details, but rather ju

Re: [Tutor] sqlite: does "?" work in PRAGMA commands?

2007-08-06 Thread Terry Carroll
On Wed, 1 Aug 2007, Terry Carroll wrote: > Does the "?" approach not work with PRAGMA commands or something; or am I > doing this wrong? Just a quick follow-up on this, in case anyone else cares. My conclusion is that it's not supported. Googling around I found this pysql

Re: [Tutor] superscript with easydialogs

2007-08-06 Thread Terry Carroll
On Mon, 6 Aug 2007, Alan Gauld wrote: > "Ben" <[EMAIL PROTECTED]> wrote > > > I have been working with easydialogs module lately > > especially the progress bar (for Windows). I would > > like to put superscript text like (TM) to (?) when > > calling the label function. > > The super-scripting i

Re: [Tutor] superscript with easydialogs

2007-08-06 Thread Terry Carroll
On Tue, 7 Aug 2007, Alan Gauld wrote: > The problem is I don't know whether Windows supports unicode(I suspect > it does nowadays) and if it does whether EasyDialogs supports changing > the system font. I think EasyDialogs is a Mac thing. ___ Tutor m

Re: [Tutor] superscript with easydialogs

2007-08-06 Thread Terry Carroll
On Mon, 6 Aug 2007, Luke Paireepinart wrote: > Ben mentioned Windows specifically in his original post. > I think that's why Alan was talking about it. Ah. I missed that, thanks. Well, in that case, since I use Windows, I can give it a shot instead of guessing. It turns out, no, Unicode won't

Re: [Tutor] Shelve problem

2007-08-08 Thread Terry Carroll
On Wed, 8 Aug 2007, TheSarge wrote: > I have five data files, that are used to build a database. > > 1.txt > 2.txt > 3.txt > 4.text > 5.txt > > I want to build a database using a persistent dictionary (shelve). > > The specifications are that the key for each dictionary keyword pair, is the > l

Re: [Tutor] Security [Was: Re: Decoding]

2007-08-13 Thread Terry Carroll
On Mon, 13 Aug 2007, Alan Gauld wrote: > eval() > exec() > execfile() > input() Two of my favorite things about Python 3000 will be having input() go away and fixing integer division. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mai

Re: [Tutor] Python Book Recommendations [Was:[Re: Security]]

2007-08-14 Thread Terry Carroll
On Mon, 13 Aug 2007, bhaaluu wrote: > Programming isn't for everyone! Until you find out whether or not > it's for you, don't spend hundreds and thousands of dollars on > computer programming books! =) Programming isn't unique in that respect. I tried to learn Chinese a few years back. I'm not

Re: [Tutor] Python Book Recommendations

2007-08-14 Thread Terry Carroll
On Tue, 14 Aug 2007, Brian Wisti wrote: > Check with your local library, too. Or even your not-so-local library. > The Seattle Public Library provides access to a limited selection of the > Safari books (stuff published in the last 2 years from a handful of > publishers). Maybe your region has

Re: [Tutor] Table Joins

2007-08-22 Thread Terry Carroll
On Wed, 22 Aug 2007, z machinez wrote: > Hi All: > > I have the following tables selected from a database: > > a1 > > a2 > > each table are of the same column length, same col names. How do I combine > or concatenate these tables ? So, I would like to have > > a3 = a1, a2 # combining all the

Re: [Tutor] Table Joins

2007-08-22 Thread Terry Carroll
On Wed, 22 Aug 2007, Terry Carroll wrote: > If you want to pull them out of the database as a single table > I was wondering that myself the other day. I was planning on looking > into whether you could just do a FULL OUTER JOIN (which is essentially a > union operation) on bot

Re: [Tutor] Table Joins

2007-08-22 Thread Terry Carroll
On Wed, 22 Aug 2007, Kent Johnson wrote: > Terry's ideas are good but it might be as simple as > a3 = a1 + a2 > if you don't need to worry about duplicates. Doh! I was thinking the no duplicates was part of it, but you're right; that's nowhere in the OP's question. _

Re: [Tutor] sorting lists in dictionary values

2007-08-26 Thread Terry Carroll
On Sun, 26 Aug 2007, Eric Abrahamsen wrote: > I wrote the stupid little script below for practice; it takes a text > file with a list of surnames, and returns a dictionary where the keys > are first letters of the names, and the values are lists of names > grouped under their appropriate fir

Re: [Tutor] validation

2007-08-27 Thread Terry Carroll
On Mon, 27 Aug 2007, Kent Johnson wrote: > For the built-in types, since Python 2.2 the familiar name (int, str, > float, list, dict, set) *is* the type and you can compare to that > directly, e.g.: > > In [13]: type(3)==int > Out[13]: True > In [14]: type([]) == list > Out[14]: True That is s

Re: [Tutor] validation

2007-08-27 Thread Terry Carroll
On Mon, 27 Aug 2007, Kent Johnson wrote: > isinstance can take a tuple of types as its second argument > > Note that >isinstance(thing, (list, tuple)) > > and >type(thing) in [list, tuple] > > are not equivalent. The first will be true for objects whose type is a > subclass of list

Re: [Tutor] validation

2007-08-28 Thread Terry Carroll
On Tue, 28 Aug 2007, Michael wrote: > I now have several methods in my arsenal and they all look quite simple, > now that I know. Just wondering, when would you use isInstance()? Well, as this thread has shown, I'm no expert, but let me take a stab on it. If nothing else, we'll all learn somet

Re: [Tutor] validation

2007-08-28 Thread Terry Carroll
On Tue, 28 Aug 2007, Kent Johnson wrote: > Terry Carroll wrote: > > > 1A) a variation of option 1 (which is why I said "depending on how you > > count" above): duck-typing with error recovery. > > > > def incr(n): > > "returns an increm

Re: [Tutor] A replacement for a "for" loop

2007-08-29 Thread Terry Carroll
On Wed, 29 Aug 2007, Scott Oertel wrote: > John Fouhy wrote: > > On 29/08/07, Trey Keown <[EMAIL PROTECTED]> wrote: > > > >> attrs={u'title': u'example window title', u'name': u'SELF', u'icon': > >> u'e.ico'} > >> keys = ['name','title','icon'] > >> for (tag, val) in attrs.iteritems(): > >>

[Tutor] Python 3000 has just become less mythical

2007-08-31 Thread Terry Carroll
The first Alpha release of Python 3000 was released today: http://python.org/download/releases/3.0/ Guido's post: http://www.artima.com/weblogs/viewpost.jsp?thread=213583 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/l

Re: [Tutor] evaluating AND

2007-09-13 Thread Terry Carroll
On Thu, 13 Sep 2007, Orest Kozyar wrote: > Given a variable x that can either be None or a tuple of two floats [i.e. > (0.32, 4.2)], which syntax is considered most appropriate under Python > coding standards? > > if x and x[0] > 0: > pass > > =OR= > > if x: > if x[0] > 0: >

Re: [Tutor] evaluating AND

2007-09-13 Thread Terry Carroll
On Thu, 13 Sep 2007, Adam Bark wrote: > The problem is what if it's an empty list or tuple? It would pass but have > not value > whereas if x would work fine. Exactly. The poster stated that x is supposed to be either None or a tuple of two floats. Just to put a bit of meat on the example, let

Re: [Tutor] evaluating AND

2007-09-14 Thread Terry Carroll
On Fri, 14 Sep 2007, Rikard Bosnjakovic wrote: > For me, "if x" would be enough. If you think it's a bad thing when x > is of the wrong data, then you really should check that it contains > *correct* data as well. That's an okay approach, but, but it's also non-Pythoninc; more of the look-before

Re: [Tutor] Just bought Python in a Nutshell

2007-09-14 Thread Terry Carroll
On Thu, 13 Sep 2007, Lamonte Harris wrote: > http://www.powells.com/biblio/63-9780596001889-7 Used, has anyone read this > book. Any additional information that you like,dislike about this book? I love it, and use it more than any other Python book. Much as I hate to be the bearer of bad news

Re: [Tutor] remove blank list items

2007-09-14 Thread Terry Carroll
On Fri, 14 Sep 2007, Michael Langford wrote: > What you want is a set, not a list. Lucky for you, a python dict uses a > set for its keys, so cheat and use that. Is that true? >>> d={1:"a", 2:"b"} >>> k=d.keys() >>> type(k) ___ Tutor maillist -

Re: [Tutor] referencing vars()

2007-09-16 Thread Terry Carroll
On Sat, 15 Sep 2007, John wrote: > I'm trying to do the above, but of course get an error because vardict is > only referencing vars(), thus changes size... also, I tried > vardict=[vars()], but this fails as well?? How about import copy vardict=copy.copy(vars()) That way, you've made a copy

Re: [Tutor] Finding even and odd numbers

2007-09-19 Thread Terry Carroll
On Wed, 19 Sep 2007, Boykie Mackay wrote: > if not n&1: > return false > > The above should return false for all even numbers,numbers being > represented by n.I have tried to wrap my head around the 'not n&1' but > I'm failing to understand what's going on.Could someone please explain > the s

Re: [Tutor] quick question

2007-09-24 Thread Terry Carroll
On Mon, 24 Sep 2007, max baseman wrote: > for example how hard would it be to write a program that take's a > input of a in out table and finds the rule > > ex: > > in out > 10 23 > 5 13 > 1 5 > 0 3 > > the rule is in*2+3 This is call

Re: [Tutor] largest and smallest numbers

2007-09-24 Thread Terry Carroll
On Mon, 24 Sep 2007, Christopher Spears wrote: > How can I find the largest float and complex numbers? That's an interesting question.. I just tried this: x = 2.0 while True: x = x*2 print x if repr(x) == "1.#INF": break to just keep doubling X until Python began representing it as

Re: [Tutor] Need help speeding up algorithm.

2007-09-24 Thread Terry Carroll
On Tue, 25 Sep 2007, Ian Witham wrote: > I am attempting to do this project for > the Sphere Online Judge. (Summary of the problem: for a given integer N, determine the number of trailing zeroes in N! For example, for N=10, N! = 3628800, so the number of t

Re: [Tutor] largest and smallest numbers

2007-09-25 Thread Terry Carroll
On Tue, 25 Sep 2007, John Fouhy wrote: > You've got upper and lower bounds - maybe you could do a binary search > to find the max exactly? It should only take the same number of steps > again... I thought of that; and then I thought I'd rather go home and have dinner. ___

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Terry Carroll
On Tue, 25 Sep 2007, Ian Witham wrote: > As I was using a list comprehension I wasn't sure how to make the > calculations stop when the result of integer division == 0. I don't see how to do that, either. Someone on this list (sorry, I forget who) once suggested that the list comprehension shou

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Terry Carroll
On Wed, 26 Sep 2007, Ian Witham wrote: > My solution still took over 5 seconds on the Sphere Judge machine. How much data are they throwing at you? For the sample data they provide on the website, your first "slow" solution finished on my machine almost instantaneously. _

Re: [Tutor] detecing palindromic strings

2007-09-28 Thread Terry Carroll
On Fri, 28 Sep 2007, Christopher Spears wrote: > I'm trying to write a script that detects if a string > is palindromic (same backward as it is forward). This > is what I have so far: > my_str = raw_input("Enter a string: ") > string_list = [] Here you are creating a list and assiging the name

Re: [Tutor] Need help speeding up algorithm.

2007-10-02 Thread Terry Carroll
Ian, thanks for cleaning this up and submitting it. I was curious what its performance would be. On Wed, 26 Sep 2007, Ian Witham wrote: > while count > 0: > fivecount += count > count /= 5 This is a great improvement, and I'm embarrased that I didn't think of it myself!

Re: [Tutor] random number generator

2007-10-04 Thread Terry Carroll
On Thu, 4 Oct 2007, Jim Hutchinson wrote: > Any idea what I'm doing wrong? > while (guess != number): This is your problem. Like all^h^h^h most numbers in computing, floating point numbers are stored in binary. They only approximate the decimal values they print out as. Two numbers can prin

Re: [Tutor] random number generator

2007-10-04 Thread Terry Carroll
On Thu, 4 Oct 2007, Jerry VanBrimmer wrote: > I'm no Python wizard, I'm still learning myself. But I think you need > another "if" statement to check if "guess" is equal to "number". > > if guess == number: > print "Congratulations!" No, he's got the equivalent function in his while statemen

Re: [Tutor] os.rename anomaly in Python 2.3 on Windows XP

2007-10-10 Thread Terry Carroll
On Tue, 9 Oct 2007, Tony Cappellini wrote: > Unfortunately,os.listdir() returns the same string as glob.glob, for > the problem file I mentioned. Tony -- Try specifying the argument to os.listdir as a unicode string. I've found that cures many ailments like this. e.g., instead of something lik

Re: [Tutor] 2 problems in a small script

2007-10-12 Thread Terry Carroll
On Fri, 12 Oct 2007, Kent Johnson wrote: > Dick Moores wrote: > > > I'm just not comfortable with list comprehensions yet, > > Hmm, too bad. I use list comps and generator expressions constantly. It took me a while to get list comprehensions. It's one of those things that suddenly snaps into p

Re: [Tutor] data structure question

2008-01-18 Thread Terry Carroll
On Fri, 18 Jan 2008, Alexander wrote: > I'm trying to write a small todo list/task manager... Hi, Alexander. Not to derail your actual question, but have you looked at Task Coach? It's a small todo list/task manager, written in Python using wxPython. It does much, perhaps all, of what you're

Re: [Tutor] Projects

2008-01-23 Thread Terry Carroll
On Wed, 23 Jan 2008, Jason Massey wrote: > An example routine to translate a number into [its] english equivalent > was given (again, this is Java): > static String convertDigitToEnglish(int d) { > switch ( d ) > { > > case 1: return "one"; > case 2: return "two"

[Tutor] What web framework?

2008-01-28 Thread Terry Carroll
I'm writing a pretty small database program. It tracks CDROMs with archives of, say, MP3 files; although I'm writing it with an eye to to generalize to, for example, support a collection of image files, or actual audio CDs, as well; or just about any types of files that might lend themselves to

Re: [Tutor] Change dictionary value depending on a conditional statement.

2008-02-13 Thread Terry Carroll
I don't think I saw anyone point this out yet, but, using "list" as a variable name is a bad idea, because it hides the list method. >>> x = list("abcdefg") >>> x ['a', 'b', 'c', 'd', 'e', 'f', 'g'] This works. You now have a variable named "x" that is a list. >>> list = list("hijklmnop") >>> l

Re: [Tutor] library to create venn diagrams?

2008-02-25 Thread Terry Carroll
On Tue, 26 Feb 2008, John Fouhy wrote: > On 25/02/2008, Danny Navarro <[EMAIL PROTECTED]> wrote: > > Hi all, > > > > Does anyone know a Python library to generate Venn diagrams with more > > than 3 datasets? The area of the datasets and the intersections should > > be proportional to the quanti

Re: [Tutor] Python oddity

2008-02-27 Thread Terry Carroll
On Wed, 27 Feb 2008, Keith Suda-Cederquist wrote: > Hi, > > I'm using iPython and I've run into an occasional problem that I don't > understand. Here is what I'm seeing: > > >>aa=range(0,10) > >>bb=aa > >>print aa > [0,1,2,3,4,5,6,7,8,9] > >>print bb > [0,1,2,3,4,5,6,7,8,9] > >> # okay, everyth

Re: [Tutor] Video file metadata? (MP4/WMV)

2008-03-05 Thread Terry Carroll
On Tue, 4 Mar 2008, Allen Fowler wrote: > I can't seem to find a simple description of the MP4 sepc... it might be > because there is not one. :) Does this help? http://www.digitalpreservation.gov/formats/fdd/fdd000155.shtml I think, though, that using Python to drive an already-written utility

Re: [Tutor] raw string - solution to open_new() problem

2005-08-08 Thread Terry Carroll
On Mon, 8 Aug 2005, Tom Cloyd wrote: > So, thie > > webbrowser.open_new("file://C:\__Library\folders\02394 Yale Style > Manual\02394 Yale_Style_Manual.htm") > > does not work, but this > > webbrowser.open_new(r"file://C:\__Library\folders\02394 Yale Style > Manual\02394 Yale_Style_Manual.ht

Re: [Tutor] reading excel and access files

2005-08-22 Thread Terry Carroll
On Mon, 22 Aug 2005, ZIYAD A. M. AL-BATLY wrote: > Someone posted this link on this list a while ago (sorry, I can't > remember who). I found it very useful under Win32: > > http://www.microsoft.com/technet/scriptcenter/scripts/python/pyindex.mspx What a great resource. Thanks for posting the U

Re: [Tutor] Sort a Set

2005-08-23 Thread Terry Carroll
On Tue, 23 Aug 2005, Terry Carroll wrote to Jonas: > I don't know if you're in a position to rely on the sortedness of the > input data, but even if not, this works: > > >>> l=[24, 24, 15, 16, 16, 15, 24] > >>> l=sorted(list(set(l)), reverse=True)

Re: [Tutor] Sort a Set

2005-08-23 Thread Terry Carroll
On Tue, 23 Aug 2005, Jonas Melian wrote: > I get a list of repeated numbers [24, 24, 24, 16, 16, 15, 15 ] > Is possible get it without repeated numbers, without using set()? > > If I use set, then the list is unsorted and i cann't sorting it. Converting it to a set will eliminate dupes, and con

Re: [Tutor] Sort a Set

2005-08-23 Thread Terry Carroll
On Tue, 23 Aug 2005, Kent Johnson wrote: > Actually the reverse parameter is new in 2.4 too, you have to do that in > a separate step also: Doh! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Splitting a unicode string into characters (was "(No Subject)")

2005-08-25 Thread Terry Carroll
Jorge, please include a subject line. On Thu, 25 Aug 2005, Jorge Louis de Castro wrote: > What is the best way to split a unicode string in its characters? > Specifically, having this unicode chinese string > > u'\u8C01\u4ECA\u5929\u7A7F\u4EC0\u4E48 I'm assuming you've actually got the close-q

Re: [Tutor] Generate 8 digit random number

2005-08-26 Thread Terry Carroll
On Fri, 26 Aug 2005, Alberto Troiano wrote: > I need to generate a password..It has to be an 8 digit number and it has > to be random > > import random > random.randrange(,) > > The code works but sometimes it picks a number with 7 digits. Is there any > way that I can tell him

Re: [Tutor] New Tutorial topic

2005-08-29 Thread Terry Carroll
On Sun, 28 Aug 2005, Alan G wrote: > I've just uploaded two new files to my tutorial the second is the > first of these and introduces databases, SQL and using the Python DBI > interface. Alan, thanks for this. I was just casting around for a tutorial on SQLite, and its use in Python. I've

[Tutor] re.findall(), but with overlaps?

2005-09-02 Thread Terry Carroll
A friend of mine got bitten by an expectations bug. he was using re.findall to look for all occurances of strings matching a pattern, and a substring he *knew* was in there did not pop out. the bug was that it overlapped another matching substring, and findall only returns non-overlapping str

Re: [Tutor] re.findall(), but with overlaps?

2005-09-03 Thread Terry Carroll
On Sat, 3 Sep 2005, Kent Johnson wrote: > AFAIK that is the way to do it. I may put in an enhancement request to change the name of re.findall to re.findsome. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] re.findall(), but with overlaps?

2005-09-03 Thread Terry Carroll
On Sat, 3 Sep 2005, Kent Johnson wrote: > But I would say your chances of getting the name changed are slim to > none, the Python developers are extremely reluctant to make changes that > break existing code. Yeah, I know. I was mostly joking. Mostly. __

Re: [Tutor] MySQLdb error - PLEASE SAVE ME!

2005-09-17 Thread Terry Carroll
On Sat, 17 Sep 2005, Ed Hotchkiss wrote: > I think that I am having some kind of error with my csv going into the > fields and being broken apart correctly. Ed, I'd suggest using the CSV module to parse out CSV files, rather than splitting it yourself. __

Re: [Tutor] Maths: getting degrees from radians (or am I wrong?)

2005-09-20 Thread Terry Carroll
On Tue, 20 Sep 2005, R. Alan Monroe wrote: > > >>> math.degrees(_) <--- in all my time on tutor > I have never noticed > this underscore trick > before That *is* cool. I've usually done something like: >>

Re: [Tutor] Can anyone teach me...?

2005-10-12 Thread Terry Carroll
On Wed, 12 Oct 2005, Alan Gauld wrote: > However I have to be honest and say that building GUIs in VB ... is a > lot easier than in Python IMHO. I have to say, I agree with that. I just started using VB a month ago (for a course I'm taking, all projects need to be in VB), and it's really a ple

Re: [Tutor] index and find

2005-10-22 Thread Terry Carroll
On Sat, 22 Oct 2005, Shi Mu wrote: > what is the difference between index and find in the module of string? > for both "find" and "index", I got the position of the letter. index raises a ValueError if the string isn't found: >>> s = "spam" >>> s.find('m') 3 >>> s.index('m') 3 >>> s.find('z') -1

Re: [Tutor] Boolean math question

2005-10-22 Thread Terry Carroll
On Sat, 22 Oct 2005, Joe Bennett wrote: > Anyone know of a good explanation of either how to perform boolean math > in Python? What I am trying to do is AND two numbers together: > > e = 51 AND 15 > > 00110011 > > > 0011 Use '&' rather than "AND": >>> e = 51 & 15 >>

Re: [Tutor] Can anyone help me?

2005-10-28 Thread Terry Carroll
On Fri, 28 Oct 2005, bob wrote: > At 09:42 PM 10/27/2005, Nathan Pinno wrote: > > >If I create a program that randomly draws 6 numbers, its like the lottery. > >According to an article I read in Reader's Digest, if you get a Quick Pick > >- which is six numbers at random - you increase your odd

[Tutor] Using debuglevel with urllib2?

2005-11-08 Thread Terry Carroll
With urllib, you can set httplib.HTTPConnection.debuglevel to see the HTTP conversation. But it doesn't work with urllib2. Can someone explain how to use it in conjunction with urllib2? Longer story: debuuglevel is a nice debug tool that lets you see the client-server HTTP conversation: >>

Re: [Tutor] Using debuglevel with urllib2?

2005-11-08 Thread Terry Carroll
On Tue, 8 Nov 2005, Kent Johnson wrote: > You have to create your own HTTPHandler, set it to debug and install it > in urllib2. Like this: Thanks, Kent! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] List-question

2005-12-19 Thread Terry Carroll
On Mon, 19 Dec 2005, Ed Singleton wrote: > On 19/12/05, Ed Singleton <[EMAIL PROTECTED]> wrote: > > > > list2 = list.copy() > > > > Slices create a copy, so a shortcut is: > > > > list2 = list[:] > > Sorry, you need to: > > from copy import copy > > before you can use copy. It should also be,

Re: [Tutor] Print random letters

2005-12-21 Thread Terry Carroll
On Wed, 21 Dec 2005, Johan Geldenhuys wrote: > I want to print out random letters from A - Z. I know how to do this > with numbers, but don't know with letters. >>> import string >>> import random >>> string.uppercase[random.randint(0,len(string.uppercase)-1)] 'K' >>> >>> string.uppercase[random

Re: [Tutor] Print random letters

2005-12-21 Thread Terry Carroll
On Wed, 21 Dec 2005, Kent Johnson wrote: > Take a look at random.choice() or possibly random.shuffle() or > random.sample(). And remember that a string is a kind of sequence. Good call; I should have read all the replies first. >>> random.choice(string.uppercase) is much clearer than my suggest

Re: [Tutor] Printing

2005-12-27 Thread Terry Carroll
On Mon, 26 Dec 2005, John Corry wrote: > Thanks for the prompt reply. This is exactly what I am looking for. > However, I have tried the code on the page and I can't get it to work. ... > Traceback (most recent call last): > File "c:\python24\jhc.py", line12, in ? > 0 > pywintypes.error:

Re: [Tutor] Printing

2005-12-27 Thread Terry Carroll
On Tue, 27 Dec 2005, John Corry wrote: > I am saving the code to c:\python24\jhc2.py > The code creates the file c:\python24\testprint.txt John, I would *very* strongly advise not to store your code in c:\python24 or any subdirectory in it. That is where Python itself lives, and it's very possib

Re: [Tutor] HD/DVD/CD

2006-01-03 Thread Terry Carroll
On Tue, 3 Jan 2006, Ron Speerstra wrote: > my question: howtoo read the HD/CD/DVD serial-numbers with Python. I can take you part-way there, at least under Windows. Hopefully someone can finish the job. I'm assuming you want the same serial # that shows up when you do a DIR on the CD, e.g.:

<    1   2   3   4   5   >