Re: [Tutor] Website monitoring program.

2005-11-21 Thread Ben Vinger
Below is a program I found at http://starship.python.net/crew/neale/ (though it does not seem to be there anymore.) It uses a seperate file for the URLs --- Adisegna <[EMAIL PROTECTED]> wrote: > My question is how to use a loop to go through a > tuple of URLs. Please feel > free to suggest an ea

[Tutor] Lists with just an item

2005-11-21 Thread Negroup -
Hi all. In my application I have chosen as data structure a list of dictionaries. Each dictionary has just one key and the corresponding value. structure = [{'field1': lenght1}, {'field2': lenght2}, ] Initially, to obtain the key and the value I used this code, for structure in record_st

Re: [Tutor] reduce with comprehension

2005-11-21 Thread Brian van den Broek
János Juhász said unto the world upon 2005-11-21 01:20: > Hi, > > I can't imagine how this could be made with list comprehension. > > import operator a = (([1],[2],[3,31,32],[4]), ([5],[6],[7, 71, 72]), ([8],[9])) reduce(operator.add, a) # it makes a long list now > > ([1], [2], [3,

Re: [Tutor] Lists with just an item

2005-11-21 Thread Brian van den Broek
Negroup - said unto the world upon 2005-11-21 03:26: > Hi all. > In my application I have chosen as data structure a list of > dictionaries. Each dictionary has just one key and the corresponding > value. > > structure = [{'field1': lenght1}, {'field2': lenght2}, ] > > Initially, to obtai

Re: [Tutor] Lists with just an item

2005-11-21 Thread Pujo Aji
Hi,       mydic = {'one': 1, 'two': 2}        # to access key:    for x in mydic.keys():    print x        # to access value --> use key    print mydic['one']   Cheers, pujo On 11/21/05, Negroup - <[EMAIL PROTECTED]> wrote: Hi all.In my application I have chosen as data structure a list ofd

Re: [Tutor] reduce with comprehension

2005-11-21 Thread Alan Gauld
>>> a = (([1],[2],[3,31,32],[4]), ([5],[6],[7, 71, 72]), ([8],[9])) >>> reduce(operator.add, a) # it makes a long list now ([1], [2], [3, 31, 32], [4], [5], [6], [7, 71, 72], [8], [9]) When I make list comprehension, the list hierarchy is allways the same or >>> [item for item in a] # the deepnes

Re: [Tutor] Lists with just an item

2005-11-21 Thread Alan Gauld
> Each dictionary has just one key and the corresponding > value. > > structure = [{'field1': lenght1}, {'field2': lenght2}, ] I'd use a tuple rather than a dictionary here: structure = [('field1', lenght1), ('field2', lenght2), ] > but after some thoughts I arrived to: > field_n

Re: [Tutor] Lists with just an item

2005-11-21 Thread Negroup -
2005/11/21, Brian van den Broek <[EMAIL PROTECTED]>: > Hi Negroup, > > why not just make structure a dict: > > structure = {'field1': lenght1, 'field2': lenght2} > > What does having a list of dicts all with a single key add but a layer > of referencing when you want to access? > > If you are tryi

Re: [Tutor] Lists with just an item

2005-11-21 Thread Negroup -
2005/11/21, Alan Gauld <[EMAIL PROTECTED]>: > > Each dictionary has just one key and the corresponding > > value. > > > > structure = [{'field1': lenght1}, {'field2': lenght2}, ] > > I'd use a tuple rather than a dictionary here: Of course, this makes a lot of sense. [cut] > you can now

Re: [Tutor] reduce with comprehension

2005-11-21 Thread Kent Johnson
János Juhász wrote: > Hi, > > I can't imagine how this could be made with list comprehension. > import operator a = (([1],[2],[3,31,32],[4]), ([5],[6],[7, 71, 72]), ([8],[9])) reduce(operator.add, a) # it makes a long list now > > Is it possible to substitute reduce with comprehensio

[Tutor] Numeric array incosistence in unittest

2005-11-21 Thread Pujo Aji
hello, I found that if I use Numeric.array into unittest it is not consistance, Is that normal ?   import unittestimport Numeric class myTest(unittest.TestCase):    def runTest(self):    var1 = Numeric.array([1,22])    var2 = Numeric.array([1,33])    self.assertEqual(var1,var2) if __

[Tutor] Tkinter modal dialogs

2005-11-21 Thread K . Weinert
Hello tutors! My file search dialog is working now! I attach a copy of the module. It would be nice, if someone could look over it and make suggestions to improve it. There are at least two points I find not very elegant in the program: 1. The dialog is ended by raising a SystemExit exception. (I

[Tutor] again... regular expression

2005-11-21 Thread lmac
Hallo. I want to parse a website for links of this type: http://www.example.com/good.php?test=anything&egal=total&nochmal=nummer&so=site&seite=22";> - re_site = re.compile(r'http://\w+.\w+.\w+./good.php?.+";>') for a in file:

Re: [Tutor] again... regular expression

2005-11-21 Thread Kent Johnson
lmac wrote: > Hallo. > I want to parse a website for links of this type: > > http://www.example.com/good.php?test=anything&egal=total&nochmal=nummer&so=site&seite=22";> > > - > re_site = re.compile(r'http://\w+.\w+.\w+./good.php?

[Tutor] again... regular expression

2005-11-21 Thread lmac
Ok. There is an error i made. The links in the HTML-Site are starting with good.php so there was no way ever to find an link. re_site = re.compile(r"good\.php.+'") for a in file: z = re_site.search(a) if z != None: print z.group(0) This will give me every line sta

Re: [Tutor] again... regular expression

2005-11-21 Thread Kent Johnson
lmac wrote: > Ok. There is an error i made. The links in the HTML-Site are starting > with good.php so there was no way ever to find an link. > > re_site = re.compile(r"good\.php.+'") > for a in file: > z = re_site.search(a) > if z != None: > print z.group(0) > > > This

Re: [Tutor] Trouble with classes - Pypeg again

2005-11-21 Thread bob
At 08:52 PM 11/20/2005, ->Terry<- wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ok, I've got my peg game roughed out and I'm having problems. The error is: Traceback (most recent call last):    File "pypeg.py", line 113, in ? main()    File "pypeg.py", line 107, in main x.draw_b

Re: [Tutor] Lists with just an item

2005-11-21 Thread Hugo González Monteverde
> Probably due to the lacking of experience, but each time I code a > datastructure I am never satisfied, and I have the feeling that I'm > not on the right way.. The same thing happens to me. I actually have a very similar problem to yours now, and I'm rather considering a list of two-element t

[Tutor] smtplib problems ?

2005-11-21 Thread dave
Hi all, I am not sure if this is a Python problem not not but here goes I wrote the following small script to email by boss 'email_addr' a rather important reminder and also send a copy to myself 'email_addr2' several times a day. #!/usr/bin/env python # -*- coding: iso8859_1 -*- fr

Re: [Tutor] smtplib problems ?

2005-11-21 Thread Python
On Mon, 2005-11-21 at 19:59 +, dave wrote: > Traceback (most recent call last): > File "/home/dave/my files/andrew_torture/email_remind.py", line 49, in ? > email_remind() > File "/home/dave/my files/andrew_torture/email_remind.py", line 43, in > email_remind > raise 'Mail Failure

Re: [Tutor] Tkinter modal dialogs

2005-11-21 Thread John Fouhy
Hi Karsten, You might want to look at Python MegaWidgets: http://pmw.sourceforge.net/ PMW is an alternative to Tix, built using only python and basic Tkinter. It has a scrolled listbox widget and a way of easily creating modal dialogs. -- John. ___ Tu

Re: [Tutor] reduce with comprehension

2005-11-21 Thread John Fouhy
On 21/11/05, János Juhász <[EMAIL PROTECTED]> wrote: > I can't imagine how this could be made with list comprehension. > > >>> import operator > >>> a = (([1],[2],[3,31,32],[4]), ([5],[6],[7, 71, 72]), ([8],[9])) > >>> reduce(operator.add, a) # it makes a long list now > ([1], [2], [3, 31, 32], [4]

[Tutor] O/T:META: Crossposting

2005-11-21 Thread Danny Yoo
On Mon, 21 Nov 2005, enas khalil wrote: > i want to confirm with you that the right addresses to send to are : > python-list@python.org > tutor@python.org > arent they ? [Keeping Tutor in CC; if I'm out of line, I want to make sure someone calls me on it and keeps me grounded.] Hi Ena

Re: [Tutor] O/T:META: Crossposting

2005-11-21 Thread Danny Yoo
On Mon, 21 Nov 2005, enas khalil wrote: > thanks again ,sir > i finally understand what you mean > sorry for annoying you several times ,promise not to do this again > > execuse me can i ask you aquestion about how can i use codecs in read > and tag an arabic text file > thanks again

[Tutor] Ellipsis syntax

2005-11-21 Thread Hugo González Monteverde
Hi all, I have looked for any references of ellipsis '...' syntax for Python slices, but I keep finding the same BNF grammar in the LanguageRreference. Is there any page with examples on how to do this, or is this just very obscure? I remember reading something about this syntax somewhere, lon

Re: [Tutor] Ellipsis syntax

2005-11-21 Thread John Fouhy
On 22/11/05, Hugo González Monteverde <[EMAIL PROTECTED]> wrote: > I have looked for any references of ellipsis '...' syntax for Python > slices, but I keep finding the same BNF grammar in the > LanguageRreference. Is there any page with examples on how to do this, > or is this just very obscure?

Re: [Tutor] Ellipsis syntax

2005-11-21 Thread Kent Johnson
Hugo González Monteverde wrote: > Hi all, > > I have looked for any references of ellipsis '...' syntax for Python > slices, but I keep finding the same BNF grammar in the > LanguageRreference. Is there any page with examples on how to do this, > or is this just very obscure? ellipsis is used

Re: [Tutor] Ellipsis syntax

2005-11-21 Thread Hugo González Monteverde
Ok, now I know I don't need them just now *grin* Next time I will remember to search the newsgroup Now I think it was the perlish skeletons in my closet coming back to me. Thanks a lot for that, Hugo ___ Tutor maillist - Tutor@python.org http:/

[Tutor] Website monitoring program.

2005-11-21 Thread Adisegna
I need to add the count statement to give urllib access the tuple of urls. urllib needs to be given a different value each time in order to check all the urls. This is the only way I could get the value (web) in urllib to change each time. I tried indenting the count statement and it runs without e

[Tutor] Fwd: Website monitoring program.

2005-11-21 Thread Adisegna
This worked for me. Thanks! -- for web in urls:          for site in urllib.urlopen(web): --- You have to indent the statement 'count += 1' so it is part of the loop. But you misunderstand the for loop

[Tutor] Help with objects

2005-11-21 Thread Vincent Wan
I'm trying to write a tree data structure as part of my first object oriented program I have an error "can't assign to function call" caused by this line: Tree.nodeList(self.name) = self however, nodeList is a dictionary I'm trying to index. Beyond the error I'm still not sure I understand how t

Re: [Tutor] Help with objects

2005-11-21 Thread bob
At 08:38 PM 11/21/2005, Vincent Wan wrote: >I'm trying to write a tree data structure as part of my first >object oriented program > >I have an error "can't assign to function call" caused by this line: >Tree.nodeList(self.name) = self Tree.nodeList[self.name] = self >however, nodeList is a dicti

Re: [Tutor] Help with objects

2005-11-21 Thread Vincent Wan
Thank you bob. I fixed the errors where I tried to index a dictionary with name() so so that they say name[] >> Beyond the error I'm still not sure I understand how to make and >> use a tree data structure using objects. There is a new error as well Traceback (most recent call last): File "

[Tutor] about global definition

2005-11-21 Thread Shi Mu
I have a code here. I understand i can not draw lines without the global definition of lastX and lastY. But still confused by its use. when should we use global definition? from Tkinter import * root = Tk() c = Canvas(root, bg='#0e2e0e', height=500, width=1000) frame = c lastX="" lastY="" def cl

Re: [Tutor] reduce with comprehension

2005-11-21 Thread János Juhász
Hi John, thanks it. It is great. I looked for it, but I couldn't made it. I have tried it with wrong order: # I have tried it so [x for x in y for y in a] [[8], [8], [8], [9], [9], [9]] # that is wrong, # Instead of that you wrote [x for y in a for x in y] [[1], [2], [3, 31, 32], [4], [5], [6],