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

2009-03-03 Thread Lie Ryan
Marc Tompkins wrote: > List comprehensions will make your head hurt the first few dozen times you encounter them. After that, they become easier to use than the longer for-loop structure they replace - as André pointed out, they read almost like English. I have to disagree, I immediately fell

Re: [Tutor] Convert XML codes to "normal" text?

2009-03-03 Thread Lie Ryan
Eric Dorsey wrote: _So here is my program, I'm pulling some information off of my Snipt feed .._ I know, for example, that the > code means >, but what I don't know is how to convert it in all my data to show properly? In all the feedparser examples it just smoothly has the output correct

Re: [Tutor] Code documentation

2009-03-04 Thread Lie Ryan
Alan Gauld wrote: In your experience which way is the best or what advantages/disadvantages do you see (experienced) with each approach that you are familiar. Fancy markup is a wasted luxury so far as I am concerned. Not to mention that using non-docstring documentation breaks help(), and us

Re: [Tutor] could someone explain why this happens to me.

2009-03-08 Thread Lie Ryan
Sander Sweers wrote: 2009/3/7 Alan Gauld : mycopy = original[:] Returns a slice of the original list. In this case it so happens the slice is the full list. mycopy = list(original) Use the list type constructor to make a list out of its argument. It just so happens the argument in this case

Re: [Tutor] while loop problem

2009-03-08 Thread Lie Ryan
mustafa akkoc wrote: hello i have syntax problem in this program After correcting the indentations, and putting a missing parentheses in line 24 (the last line), I don't see any Syntax Error. #!/usr/bin/python # Filename: while.py number = 23 running = True while running : guess= i

Re: [Tutor] Newby Linux Program review + help with regular expressions

2009-03-10 Thread Lie Ryan
David wrote: This program generates a report of a Linux System and some important ..conf files. The goal is for users to be able to post their information and compare with others, ask for help etc. Am I using the subrocess module too much because I am comfortable with the commands? Should I ju

Re: [Tutor] memory error files over 100MB

2009-03-10 Thread Lie Ryan
Sander Sweers wrote: 2009/3/10 Alan Gauld : newFile.write(zf.read(zfilename)) Remember you are reading the file into memory and then writing it out again in a single operation, that will use twice the space of the uncompressed files - plus some extra for overhead. Question, Do you m

Re: [Tutor] How can I extract a specific sublist from a nested list?

2009-03-11 Thread Lie Ryan
Emad Nawfal (عماد نوفل) wrote: Hi Tutors, How can I extract a specific sublist (??) from a nested list, for example, The same as the way you extract other objects from non-nested list if I want to extract the sublist ["ADJ", "good"], nested_list[1][2] or the bigger sublist ["NP",["DET"

Re: [Tutor] Replying to digest messages

2009-03-11 Thread Lie Ryan
Kent Johnson wrote: 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

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

2009-03-12 Thread Lie Ryan
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: ... 38277, 567 38277, 90023 38277, 6940 ... I've

Re: [Tutor] best gui for the job?

2009-03-13 Thread Lie Ryan
W W wrote: Hi, What is the best gui to implement a simple paint-esque program in? I already built a really simple one in Tkinter - but Tkinter lacks a save functionality. I considered using the PIL to draw in the background, but it didn't seem to have a good enough resolution. I thought about p

Re: [Tutor] TypeError: dict objects are unhashable

2009-03-15 Thread Lie Ryan
Emile van Sebille wrote: Mark Tolonen wrote: [dict(n) for n in set(tuple(n.items()) for n in l1)] Anyone know if the ordered items for two different dicts where dicta == dictb is guaranteed the same? I know the ordering is unspecified but you can depend on the sequence of keys matching data

Re: [Tutor] range() fractional increment

2009-03-30 Thread Lie Ryan
John Fouhy wrote: 2009/3/31 james carnell : for row in range(25,31,1): for col in range(10,12, 0.3): #<- Crash Bang doesn't work 0.3 = zero = infinite loop? [...] is there no way to do it with a range function (and have it still look like you're not on crack)? Well, you could do this: [

Re: [Tutor] output formatting

2009-04-27 Thread Lie Ryan
Matt Domeier wrote: Hi Wayne, Yes, that should work perfectly, but it is in writing files that I'm having the problem. I'm still very new to python, so I only know to use something like filename.write(str(listname)) to write my list to a file.. Is there a straightforward method of combining th

Re: [Tutor] finding mismatched or unpaired html tags

2009-04-28 Thread Lie Ryan
Dinesh B Vadhia wrote: A.T. / Marty I'd prefer that the html parser didn't replace the missing tags as I want to know where and what the problems are. Also, the source html documents were generated by another computer ie. they are not web page documents. If the source document was gener

Re: [Tutor] Can not run under python 2.6?

2009-04-29 Thread Lie Ryan
Jianchun Zhou wrote: Hi, there: I am new to python, and now I got a trouble: I have an application named canola, it is written under python 2.5, and can run normally under python 2.5 But when it comes under python 2.6, problem up, it says: Traceback (most recent call last): File "/usr/lib

Re: [Tutor] loops

2009-04-29 Thread Lie Ryan
Norman Khine wrote: hello, i have the following code: Uhh... 5 levels deep of nesting, and from the hint that you used self.blah earlier this is inside a class which adds a minimum of two extra levels, in total of 7 levels nesting... We're in deep trouble. is there a way to optimise the lo

Re: [Tutor] is it possible to traverse two lists simulatenously using python

2009-04-30 Thread Lie Ryan
Michiel Overtoom wrote: Kent Johnson wrote: Use zip() or itertools.izip(): And when the sequences are of unequal length: On python3.x, use itertools.zip_longest() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tut

Re: [Tutor] Why use decorators ?

2009-05-02 Thread Lie Ryan
sudhanshu gautam wrote: 1.import pyglet window=pyglet.window.Window() lable=pyglet.text.Lable('Hello, world', font_name='Times New Roman', font_size=36, x=window.width//2, y=window.height//2, anchor_x='center', anchor_y='center') *...@window.event * def on_draw(): window.clear() lab

Re: [Tutor] Code Dosent work.

2009-05-03 Thread Lie Ryan
David wrote: Jacob Mansfield wrote: hi everyone, I'm a bit new here but i was wondering if someone could check some of my code, it's not doing quite what it's meant to. thanks Why were you using pygame? The only line that uses pygame is pygame.time.delay(900). It is an overkill to import

Re: [Tutor] quick question to open(filename, 'r') vs. file(filename, 'r')

2009-05-04 Thread Lie Ryan
Alan Gauld wrote: > And file has been removed again in Python v3 In fact open is now an alias for io.open and no longer simply returns a file object - in fact the file type itself is gone too! A pity, there are cases where I found file() more intuitive than open and vice versa so liked havi

Re: [Tutor] Advanced String Search using operators AND, OR etc..

2009-05-05 Thread Lie Ryan
Alex Feddor wrote: Hi I am looking for method enables advanced text string search. Method string.find() or re module seems no supporting what I am looking for. The idea is as follows: Text ="FDA meeting was successful. New drug is approved for whole sale distribution!" I would like to sc

Re: [Tutor] Advanced String Search using operators AND, OR etc..

2009-05-05 Thread Lie Ryan
Kent Johnson wrote: On Tue, May 5, 2009 at 8:11 AM, Lie Ryan wrote: Bring on your hardest searches... Nice! The Suite class is only there to turn the NotFound sentinel from len(text) to -1 (used len(text) since it simplifies the code a lot...) How does this simplify the code? Why not

Re: [Tutor] Need help with registry access

2009-05-07 Thread Lie Ryan
spir wrote: Le Fri, 8 May 2009 01:20:32 +0100, "Alan Gauld" s'exprima ainsi: "Christopher Barkley" wrote My friend and I are techies, he's on my LAN. I want to disable his keyboard through the registry (or some other fun way) while he's in the middle of playing starcraft by running a scri

Re: [Tutor] How to set up an Array?

2009-05-11 Thread Lie Ryan
John Fouhy wrote: 2009/5/12 nickel flipper : sfr (key=PORTA addr=0xf80 size=1 access='rw rw rw u rw rw rw rw') reset (por='' mclr='') bit (names='RA7 RA6 RA5 - RA3 RA2 RA1 RA0' width='1 1 1 1 1 1 1 1') bit (tag=scl names='RA' width='8') bit (names='OSC1 OSC2 AN4 - AN3

Re: [Tutor] (a, b) = (l[0:2], l[2:])

2009-05-13 Thread Lie Ryan
Jabin Jezreel wrote: What is the idiomatic way to write the right side of (a, b) = (l[0:2], l[2:]) ? (not worried about the parens, just the splitting of the sequence) that way is fine. Although usually it don't use parens and 0 is omitted... a, b = l[:2], l[2:] In python, direct index a

Re: [Tutor] t = (1, *(2, 3))

2009-05-14 Thread Lie Ryan
Jabin Jezreel wrote: I am not allowed to do t = (1, *(2, 3)) But I am allowed to do def ts(*t): return t ts(1, *(2, 3)) (1, 2, 3) I realize I can do (1,) + (2,3) (1, 2, 3) What is the rationale behind not having t = (1, *(2, 3)) have the same semantics as the "ts" case abo

Re: [Tutor] Sorting a list

2009-05-14 Thread Lie Ryan
Timo wrote: Hello, I don't think this should be difficult, so maybe I look over it. But I can't seem to find the solution. I have a list with one word and a couple of numbers. Now I want the word to be kept in the first location and the numbers to be sorted. So this: [4, 6, 'word', 3, 9]

Re: [Tutor] t = (1, *(2, 3))

2009-05-14 Thread Lie Ryan
Steve Willoughby wrote: Lie Ryan wrote: Jabin Jezreel wrote: I am not allowed to do t = (1, *(2, 3)) But I am allowed to do def ts(*t): return t ts(1, *(2, 3)) (1, 2, 3) I realize I can do (1,) + (2,3) (1, 2, 3) What is the rationale behind not having t = (1, *(2, 3

Re: [Tutor] Python popen command using cat > textfile .... how to terminate

2009-05-15 Thread Lie Ryan
MK wrote: Ok. I explain it once more. Its not about reading the console output of the command. Its that i want to put a empty file in my subdirectories so that the name of the file is a message or url or something else. And if you want an empty file you can do that with "cat > IAmAnEmptyFileWith

Re: [Tutor] Python popen command using cat > textfile .... how toterminate

2009-05-18 Thread Lie Ryan
Alan Gauld wrote: "MK" wrote Seems that i did it the wrong way still from the beginning. I did it now with open and write an empty file. But anyway i would wish to know if it is possible to terminate a running cat. It depends on what you mean by a running cat. Of course it meant "a runn

Re: [Tutor] Find files without __doc__ strings

2009-05-18 Thread Lie Ryan
David wrote: spir wrote: Le Sat, 16 May 2009 21:46:02 -0400, David s'exprima ainsi: I am doing an exercise in Wesley Chun's book. Find files in the standard library modules that have doc strings. Then find the ones that don't, "the shame list". I came up with this to find the ones with;

Re: [Tutor] [Fwd: Re: Find files without __doc__ strings]

2009-05-18 Thread Lie Ryan
David wrote: Subject: Re: [Tutor] Find files without __doc__ strings From: David Date: Mon, 18 May 2009 14:02:38 -0400 CC: tutor@python.org Lie Ryan wrote: David wrote: spir wrote: Le Sat, 16 May 2009 21:46:02

Re: [Tutor] clean text

2009-05-19 Thread Lie Ryan
spir wrote: Hello, This is a follow the post on performance issues. Using a profiler, I realized that inside error message creation, most of the time was spent in a tool func used to clean up source text output. The issue is that when the source text holds control chars such as \n, then the er

Re: [Tutor] Iterating over list of functions

2009-05-20 Thread Lie Ryan
Robert Berman wrote: Hi, Given a list of options: option_1...option_n. For each option I have a corresponding function: func_1. func_n. I have all function names defined in a list similar to flist = [func_1, func_2,...func_n] which I know is a legitimate construct having found a simi

Re: [Tutor] Hi everyone

2009-05-20 Thread Lie Ryan
Doug Reid wrote: Now here is the code I'm having trouble following: while word: position = random.randrange(len(word)) jumble += word[position] word = word[:position] + word[(position + 1):] position = random.randrange(len(word)). This will create a starting point for the progra

[Tutor] missing first argument on subprocess.Popen w/ executable

2009-05-29 Thread Lie Ryan
I'm wondering whether I have misunderstood the documentation or this is a bug in either the documentation or the python: Python 2.5.4 (r254:67916, May 18 2009, 20:53:31) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import subprocess >>> subproces

Re: [Tutor] missing first argument on subprocess.Popen w/ executable

2009-05-29 Thread Lie Ryan
A.T.Hofkamp wrote: > Lie Ryan wrote: >> I'm wondering whether I have misunderstood the documentation or this is >> a bug in either the documentation or the python: >> >> Python 2.5.4 (r254:67916, May 18 2009, 20:53:31) >> [GCC 4.3.2] on linux2 >> Typ

Re: [Tutor] (no subject)

2009-05-29 Thread Lie Ryan
Gregory Morton wrote: > I'm having a problem understanding how this code works in lesson 4.4 on > the python tutorial. Can anyone explain it in easy-to-digest details? I > kind of know what most of the stuff means, but I can't comprehend how it > all works in unison. That, and I'm having a hard tim

Re: [Tutor] Text.index()

2009-06-02 Thread Lie Ryan
prasad rao wrote: > Hello > I created a gui app.I am finding it impossible to > use Text.insert().please some one give an example of using it. > In Tkinter.Text, insert's argument is a string of the form "line.collumn" instead of a number. >>> tb.insert("2.6", 'abc') you usually use %-format

Re: [Tutor] serious problem with graphics module

2009-06-02 Thread Lie Ryan
roberto wrote: > On Tue, May 26, 2009 at 12:45 AM, Gregor Lingl wrote: >> I know one situation in which can happen what you describe: >> >> If you use IDLE, issue the above commands and your Idle-shell-window >> covers the graphics window - then you have to move the shell window in order >> to see

Re: [Tutor] python workspace

2009-06-02 Thread Lie Ryan
roberto wrote: > hello, > i'd like to ask if there is anything in python which helps to see what > variables have been defined and their type and their dimension etc; > > if any of you has ever used Matlab, i mean something really similar to > its workspace, where all the user created variables ar

Re: [Tutor] my first gui

2009-06-03 Thread Lie Ryan
prasad rao wrote: > Hello. > I made my first mager gui program.I need your openions suggestions and > improvements. > > > #! usr\\bin\\env python Why is the shebang like that? > from Tkinter import * importing * is considered namespace pollution since you cannot control what name would be int

Re: [Tutor] array manipulations

2009-06-03 Thread Lie Ryan
NTB wrote: > Hello, > I'm an R user, who just started with numpy. I'm planning on setting up > a large nutrient database. Here's my question: > > I'm trying to reshape? or manipulate? the following array: > > array [['Food 1', 'Nutrient 1', 0.9], > ['Food 1', 'Nutrient 2', 0.2],

Re: [Tutor] stripping 0's from 01's - 09's

2009-06-04 Thread Lie Ryan
Norman Khine wrote: > Hello, > Simple, I guess, but I am trying to do a formated date function, which > I have working but for a small annoyance in that: > from datetime import date def format_date(day): > if day > 3 and day < 14: > return '%b %dth %Y' >

Re: [Tutor] Python 2.2... os.exec catch stdout

2009-06-04 Thread Lie Ryan
Chris Mueller wrote: > /Hello. > > I am relegated to running python 2.2; so I do not have access to subprocess. > > In my script; at one point, I need to run a program; interact with the > program; exit the program; and parse the output printed to stdout. > > This would be simple; if I did not

Re: [Tutor] Can't figure out why this is printing twice

2009-06-09 Thread Lie Ryan
The Green Tea Leaf wrote: > You don't happen to have a file called gzip.py in that catalog? > > On Tue, Jun 9, 2009 at 10:03, Mike Hoy wrote: >> >> On Tue, Jun 9, 2009 at 3:00 AM, Mike Hoy wrote: >>> Here's the screenshot: >>> >>> http://img40.imageshack.us/img40/7124/printtwice.png >>> >>> In ca

Re: [Tutor] Can't figure out why this is printing twice

2009-06-09 Thread Lie Ryan
Mike Hoy wrote: > On Tue, Jun 9, 2009 at 6:34 AM, The Green Tea Leaf > mailto:thegreenteal...@gmail.com>> wrote: > > I got an email from him that he had a gzip.pyc file in that folder. > Once he deleted that everything works OK. > > > Heh... I think I've made that mis

Re: [Tutor] glob.glob(pattern, dir) ?

2009-06-09 Thread Lie Ryan
spir wrote: > Hello, > > is there a way to make glob work in a specified dir? > (or is it necessary to use os.chdir first?) > > Thank you, > denis > -- > la vita e estrany > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/

Re: [Tutor] gui

2009-06-09 Thread Lie Ryan
Essah Mitges wrote: >1. > Traceback (most recent call last): >2. > File "C:\Users\John Doe\Desktop\D-Day\back.py", line 47, in >3. > main() >4. > File "C:\Users\John Doe\Desktop\D-Day\back.py", line 37, in main >5. > elif sbut.clicked(k

Re: [Tutor] question about class

2009-06-10 Thread Lie Ryan
Vincent Davis wrote: > Thanks again for the help, A little followup. > For my applicant class I have a few initial values that need to be set > but I what to choose the value (actually the calculation to set the > value) for each applicant (instance?) > Here is the start of my Applicant Class > >

Re: [Tutor] Syntax Error First Example

2009-06-10 Thread Lie Ryan
Randy Trahan wrote: > Hi, > Just opened the book Python Programming, Second Edition by Michael > Dawson and have my first question. Instead of the usual "Hello World" as > the first example he asked to type this: > > print "Game Over" > raw input("\n\nPress the enter key to exit.") > > First, I

Re: [Tutor] subprocess/files help

2009-06-10 Thread Lie Ryan
Essah Mitges wrote: > game runs fine out of the WODDS.py it when I start it from the menu lies the > problemup-1.png is the first pic file used in the program so I'm guessing > that all of the imported files from data have a problem if i took away up-1 > up-2 would start a problem then side-1 an

Re: [Tutor] How do I do this in python?

2009-06-11 Thread Lie Ryan
Robert Lummis wrote: > I want to write a function that I can use for debugging purposes that > prints the values of whatever list of object references it is given as > arguments, without knowing in advance how many object references it > will be called with or what they might be. For example, the c

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread Lie Ryan
eShopping wrote: > At 13:26 11/06/2009, you wrote: >> eShopping wrote: >>> import subprocess >>> x = subprocess.Popen(args="poly.exe",stdin=subprocess.PIPE) >>> for item in ["polyin.dat", "polyout.dat", "polyout.plt"]: >>> x.stdin.write('%s\n' % item) >>> but got the same error message >> >> Ab

Re: [Tutor] Help with file editing

2009-06-11 Thread Lie Ryan
tanner barnes wrote: > Ok, so i am creating a program for my school's football team and in one > part i need to store a list of variables (their name, height, weight, > and grade) in a txt file to bring up later. i know how to create and > read from files ( file = open("file_name", ''w/r/a") ). But

Re: [Tutor] use of __new__

2009-06-12 Thread Lie Ryan
spir wrote: > Hello, > > I have (again) some issue using __new__. > What I need is basically to catch an object creation and yield an object of > an alternate type, when a condition is met. > > Basically, the outline looks like: > > class Normal(object): > def __new__(cls, arg): > i

Re: [Tutor] use of __new__

2009-06-12 Thread Lie Ryan
spir wrote: > Le Fri, 12 Jun 2009 22:37:17 +1000, > Lie Ryan s'exprima ainsi: > > Right, thank you. I continued my trials and ended with seemingly working > code, close to yours. > > # case pattern is Klass: yield String instead >

Re: [Tutor] Best Python Editor

2009-06-14 Thread Lie Ryan
Michael Powe wrote: > It's good to see so much common sense prevailing on this topic. It's good that this newsgroup is not as prevalent to being flamed. In certain other newsgroup, even (an honest and naive) mentioning of preferred editor would turn the thread into World War E. > An > IDE such

Re: [Tutor] which is better solution of the question

2009-06-16 Thread Lie Ryan
Abhishek Tiwari wrote: > *Question :* > The first list contains some items, and the second list contains their > value (higher is better). > > items = [apple, car, town, phone] > values = [5, 2, 7, 1] > > Show how to sort the 'items' list based on the 'values' list so that you > end up with the

Re: [Tutor] Conversion question

2009-06-16 Thread Lie Ryan
xchime...@gmail.com wrote: > Thanks for the reply I would like to print the string in binary > Man=01001101011101101110 > What's M in binary? Nobody knows... What's M in encoded in 8-bit ASCII string: '0b1001101' Source: bin(ord('M')) ___ Tutor ma

Re: [Tutor] Conversion question

2009-06-16 Thread Lie Ryan
Tom Green wrote: > Correct 8-bit ASCII. Sorry about that. I am using Python 2.5.2, which > doesn't support bin. If I upgraded how would I go about converting the > entire string to 8-bit ASCII? > AFAIK, earlier versions of python does not have a function/module that converts a number to its bi

Re: [Tutor] Help needed

2009-06-16 Thread Lie Ryan
Raj Medhekar wrote: > So I figured out the solution to the missing letter and I will post my > code here. But I still need help figuring out the other stuff (please > see my original message included in this email)! Thanks for putting up > with me. Python is slowly but surely coming to me! I am psy

Re: [Tutor] Apparent incosistency with Python interperter in IDLE

2009-06-18 Thread Lie Ryan
Luke Paireepinart wrote: > So the problem is that the stdout of the "ls" command is appearing in > some location that you cannot see. > As for ways to remedy this - I don't know. The idea here, though, is > that even though the regular Python version has the side-effect that it > outputs it in the

Re: [Tutor] List Splicing

2009-06-18 Thread Lie Ryan
Luke Paireepinart wrote: > Robert Berman wrote: >> Emille, >> >> Thank you for the example of list splicing. Do you know if this is >> faster than a more conventional loop statement as in my code for >> primearray which is in my original post (reprinted here) > As has been mentioned, you will wan

Re: [Tutor] Tkinter idiosyncracies?

2009-06-19 Thread Lie Ryan
Wayne wrote: > I'd expect that upon clicking the button the text of the label would > change to 'Foo', then it would wait for 4 seconds, and then the text > would change to 'Bar'. It doesn't do this - instead, it waits for 4 > seconds, and then the text changes to foo, then bar, almost too fast to

Re: [Tutor] list of instance objects, access attribute

2009-06-19 Thread Lie Ryan
Alan Gauld wrote: > > "Vincent Davis" wrote > > class B(): > def __init__(self, b1, b2): > self.fooa = b1 > self.foob = b2 > > I assume thats what you really meant! > > Ok now I have several instances in a list > b1 = B(1, 2) > b2 = B(3, 4) > b3 = B(9, 10) > alist = [b1, b2, b3] > >>

Re: [Tutor] Writing a csv from a dictionary

2009-06-23 Thread Lie Ryan
Mark Tolonen wrote: > It's a good idea to cut-and-paste actual code and actual output. Your > above code doesn't work. I'd just like to clarify, in case someone misunderstood, it isn't a really good idea to simply cut-and-paste actual code and actual output for 2 reasons: 1) cut-and-paste means

Re: [Tutor] extracting lines in large file

2009-06-23 Thread Lie Ryan
Bryan Fodness wrote: > tried both again, they both return the same 9 lines, when i expect > 492. it dies on a blank line, but the if i_line takes care of the > previous ones. > Can you give a sample input that should, but not passed by the code? Unrelated Tips: You can rely on python's short-c

Re: [Tutor] string pickling and sqlite blob'ing

2009-06-24 Thread Lie Ryan
Richard Lovely wrote: > 2009/6/24 Dinesh B Vadhia : >> Hi Vince >> >> That's terrific! Once a string is compressed with gzip.zlib does it make a >> difference whether it is stored it in a TEXT or BLOB column? >> >> Dinesh >> >> >>From the MySQL language reference: > """A BLOB is a binary large obj

Re: [Tutor] Tkinter Button Issue

2009-06-28 Thread Lie Ryan
Adam Cunningham wrote: > Hi, I was hoping someone may be able to help me on an issue I'm having > with Tkinter buttons; or more specifically, the background and > foreground settings. > > I've created a program that is supposed to simulate an order system: the > first section (frame) is where the

Re: [Tutor] intefaces in python

2009-06-28 Thread Lie Ryan
Bob Rea wrote: > On Sun June 28 2009 1:48 pm, Alan Gauld wrote: >> advantages to them over defining, say, a mixin > > Noob, here, wanted to know what a mixin is > eh, just getting back into learning python > googled it, still not sure what it is, but > wikipedia says the name come from ice cream m

Re: [Tutor] When are strings interned?

2009-07-02 Thread Lie Ryan
Angus Rodgers wrote: > Hello, world! > > This is my first post to the Tutor list (although I've already > posted to comp.lang.python a couple of times). > > I'm currently reading Chapter 4 of Wesley Chun's book, "Core > Python Programming" (2nd ed.). > > I find this, in Python 2.5.4, on my Win9

Re: [Tutor] Need help with python game program

2009-07-02 Thread Lie Ryan
Luke Paireepinart wrote: > Please don't reply to messages like this. If you are starting a new > thread, send a new e-mail to tutor@python.org . > DO NOT start a thread by replying to another message. If you do, it > will bork on people's machines who use threaded e-mail

Re: [Tutor] printing tree structure

2009-07-03 Thread Lie Ryan
karma wrote: > Hi all , > > I have a nested list in the structure > [root,[leftSubtree],[RightSubtree]] that I want to print out. I was > thinking that a recursive solution would work here, but so far I can't > quite get it working. This is what I have so far: > > Can someone suggest whether this

Re: [Tutor] creating a dict-like class - asigning variables... this one may take some thought ; )

2009-07-03 Thread Lie Ryan
John [H2O] wrote: > > > spir wrote: >> >> What you're looking for is a dictionary... >> s = {"cheese":"Brie", "country":"France", ...} >> >> Or maybe a kind of object type that works ~ like a dict, but with object >> syntax (get rid of {} and "" for keys). Example: >> >> class Stuff(object): >>

Re: [Tutor] Floor and modulus for complex arguments

2009-07-03 Thread Lie Ryan
Angus Rodgers wrote: > I'm a little confused by: (i) the definition of the modulus and > floor division functions for complex arguments; (ii) the fact > that these functions for complex arguments are now "deprecated"; > and (iii) the fact that the math.floor() function is not defined > at all for

Re: [Tutor] When are strings interned?

2009-07-03 Thread Lie Ryan
Angus Rodgers wrote: > Presumably a different optimisation is going on here: > "green ideas" is "green ideas" > True You're correct, there is another layer of optimization, now related to constant string caching. The caching sometimes happens, sometimes not, depending on a very intricate imp

Re: [Tutor] window graphics

2009-07-03 Thread Lie Ryan
David H. Burns wrote: > Thanks, Alan, > > With the Python3.0, I have installed, he entry "from tkinter import *" > doesn't produce any error message, but "tk = TK()" results in > "NameError: 'TK' is not defined". Also for the word "canvas" Python is CaSe-SEnsITiVe. TK() is different from Tk() and

Re: [Tutor] Is my style OK in this elementary student exercise?

2009-07-04 Thread Lie Ryan
Angus Rodgers wrote: > > Any comments? (I don't expect the Spanish Inquisition!) > In addition to what others have mentioned: - use string formatting instead of concatenation as they're usually more readable (and faster too?): ans = raw_input(question + ' ' + true[0] + ' or ' + false[1] + '? ')

Re: [Tutor] Is my style OK in this elementary student exercise?

2009-07-04 Thread Lie Ryan
Angus Rodgers wrote: >> Date: Sat, 04 Jul 2009 13:26:12 +0100 >> From: Angus Rodgers >> Message-ID: >> >> (retention: 1 day) > > This is just a quick(ish!) response to the feedback so far. > > I realise, now, that I should have quoted what the exercise i

Re: [Tutor] Trickier exercise: convert string to complex number

2009-07-10 Thread Lie Ryan
Angus Rodgers wrote: > Wesley Chun, /Core Python Programming/, Ex. 6-13: > > "[...] An atoc() was never implemented in the string module, so > that is your task here. atoc() takes a single string as input, > a string representation of a complex number [...] and returns > the equivalent comple

Re: [Tutor] help

2009-07-16 Thread Lie Ryan
jonathan wallis wrote: > i have a duel loop that looks like thiswhile y > 0 and x > 0: > i cant figure out if there is a way to make so if one loop ends it says > something different than if the other loop ends. > while x > 0 or y > 0: ... if x > 0: print 'x is greater than 0'

Re: [Tutor] interactive naming of pointers

2009-07-16 Thread Lie Ryan
Wayne wrote: > On Thu, Jul 16, 2009 at 9:38 AM, chris Hynes > wrote: > > Yeah, I'm not sure if I'm explaining myself well or maybe I'm just > trying to make the code too interactive. > > in my code I would type something like: > > x=zeros((3,3)) >

Re: [Tutor] != -1: versus == 1

2009-07-17 Thread Lie Ryan
pedro wrote: > Hi I have been trying to understand a python script and I keep coming > across this kind of structure > that says "If it is not equal to negative one" > > > for line in theLines: >if line.find("Source Height") != -1: > #etc... > #

Re: [Tutor] Using insert method on a list matrix

2009-07-20 Thread Lie Ryan
Raj Medhekar wrote: > Thanks that works! But what if I wanted to modify 2 of the three lists > in 2 different positions? Could you please let me know how I would go > about doing that? M[0].insert(2, 'foo') M[2].insert(1, 'bar') ___ Tutor maillist - T

Re: [Tutor] Ptyhon GUI doubt

2009-08-25 Thread Lie Ryan
Reddy Etikela, Rajasekhar wrote: Hi Rich, I am using my organization machine. I am not aware of the firewall which we are using and don't have the access to it. You can just ignore the message if you cannot the administrator to adjust the firewall's setting. Just be aware that when IDLE is

Re: [Tutor] Declaration order of classes... why it is important?

2009-08-27 Thread Lie Ryan
Mac Ryan wrote: Second thing: the example that Dave gave me and that I left quoted above makes use of decorators, but this is something that I still do not understand. I believe I got a grasp of the concept of metaclasses, to which the concept of decorator seems to be related, but the official d

Re: [Tutor] Callbacks in Python

2009-08-27 Thread Lie Ryan
Jramak wrote: Hello I'm confused by callbacks. I would really appreciate any introduction or help in understanding the concept of callbacks. By example: def callback(nums): """ The callback function """ return sum(nums) * 2 def another_callback(nums): """ Yet another callback f

Re: [Tutor] Store Class in Tuple Before Defining it ...

2009-08-29 Thread Lie Ryan
Damon Timm wrote: Sorry for the double post! Went off by mistake before I was done ... Anyhow, I would like to have a tuple defined at the beginning of my code that includes classes *before* they are defined ... as such (this is on-the-fly-hack-code just for demonstrating my question): What

Re: [Tutor] Store Class in Tuple Before Defining it ...

2009-08-29 Thread Lie Ryan
Damon Timm wrote: Hi Everyone - thanks for your responses. Answered my direct questions: [1] can't be done at the top and actually you can, but it's opening a can of worms that I wouldn't dare to go near: VIDEO_RE = { re.compile(r'regex here'): 'Youtube', re.compile(r'regex there')

Re: [Tutor] How to iterate through unicode string.

2009-09-05 Thread Lie Ryan
Dirk Wangsadirdja wrote: Hi allen (and perhaps this goes also for others), just a suggestion, maybe when we post a problem, we should also mention the python version that we use. Every new subscribers to the tutor mailing list are sent an email that contains this: """ Finally, when you do

Re: [Tutor] working with multiple sets

2009-09-08 Thread Lie Ryan
Alan Gauld wrote: "kevin parks" wrote What would this look like if i want to use a straight up built-in dictionary type and not the collections.defaultdict. Not too different: Alternatively: import collections def foo(): lookup = collections.defaultdict(list) x = range(10) y = range(

Re: [Tutor] working with multiple sets

2009-09-09 Thread Lie Ryan
kevin parks wrote: This discussion is making my brain melt. It is also showing how clever Bob was to do it the way he did... I found a solution that i think works, and think has not yet been suggested. I quarantined Bob's code into a black box ... and then cast the output as a plain old fashi

Re: [Tutor] Vista UAC

2009-09-11 Thread Lie Ryan
g routine works (based on day-to-day observation, not some special research, I'd love to be proven wrong). You can also try using runas, though I never figured out how to make it work to obtain administrator privilege (sudo is much easier to work with): C:\Users\Lie Ryan>runas /user:&q

Re: [Tutor] Vista UAC

2009-09-11 Thread Lie Ryan
Jeff Johnson wrote: Dj Gilcrease wrote: I have a python app that requires elevated privileges on Vista when installed in "Program Files" since it has an auto updater. I was wondering if there was a way with a standard install of python 2.6 that I can check if I have the correct privileges and if

Re: [Tutor] Vista UAC

2009-09-11 Thread Lie Ryan
Jeff Johnson wrote: Lie Ryan wrote: Jeff Johnson wrote: I have an application that uses something that auto updates but it may not be the same process as yours. I have a "stub" executable that checks a network location for a different copy of the "real" executable. If o

Re: [Tutor] How to print the next line in python

2009-09-12 Thread Lie Ryan
ranjan das wrote: Hi, I am new to python and i wrote this piece of code which is ofcourse not serving my purpose: Aim of the code: To read a file and look for lines which contain the string 'CL'. When found, print the entry of the next line (positioned directly below the string 'CL') c

Re: [Tutor] Sorting 2-d data

2009-09-12 Thread Lie Ryan
Wayne wrote: Hi, I have a set of data that looks something like this: 3, 4, 3, 2, 1 2, 1, 1, 1, 1 4, 2, 2, 1, 2 1, 3, 1, 1, 1 I want to be able to sort it by the first column, keeping the rest of the values in the same position relative to the original: 1, 3, 1, 1, 1 2, 1, 1, 1, 1 3, 4, 3,

Re: [Tutor] Wordscramble.py

2009-09-16 Thread Lie Ryan
David wrote: kreglet wrote: This is my first Python project. I am doing this to help me learn the language. I was wondering if someone could give me some advice as I have a lot of questions. 1. I would like to have someone look over the code and tell me how to improve it. I am sure that a

<    1   2   3   4   >