Re: [Tutor] while loops / listeners

2010-06-07 Thread Francesco Loffredo
Hi all, I think that simply erasing those "continue" statements will let Python respond again. Those statements are both useless and damaging, because the following "time.sleep(.1)" statements will NEVER be executed. And this, in turn, is IMHO the reason why Python stops responding: it lacks t

[Tutor] Tkinter mainloop()

2010-07-06 Thread Francesco Loffredo
Hello all, this is the first time I ask for advice but I've been lurking for some month and i'm sure I'll find more than I need. I'm learning Python and Tkinter, and I chose an old board game as a practice field. I used a Canvas and many Polygons, one for each hexagonal space of the board, and I

Re: [Tutor] Tkinter mainloop()

2010-07-06 Thread Francesco Loffredo
RTFM I happened to find the answer just a couple of hours after having sent this message. How could I miss the update method of the Canvas? Now my game works as expected, maybe I'll post it when it's complete. Thanks to all! Francesco Il 05/07/2010 21.00, Francesco Loffredo

Re: [Tutor] Tkinter mainloop()

2010-07-06 Thread Francesco Loffredo
Il 06/07/2010 17.32, Alan Gauld wrote: "Francesco Loffredo" wrote How can I ask a Canvas to redraw itself at my command? And if i can't, when should I call the auto move? You can ask the canvas to repaint itself by calling update_idle_tasks() method. Thank you, Alan. As man

Re: [Tutor] Tkinter mainloop()

2010-07-08 Thread Francesco Loffredo
Il 07/07/2010 9.11, Alan Gauld wrote: "Francesco Loffredo" wrote ... What's the difference between the two methods? Its a little bit subtle but I believbe update() updates all widgets whereas update_idle_tasks will only update those widgets that have changed since the la

Re: [Tutor] exercise problem

2010-08-27 Thread Francesco Loffredo
On 27/08/2010 12.23, Roelof Wobben wrote: From: rwob...@hotmail.com To: alan.ga...@btinternet.com Subject: RE: [Tutor] exercise problem Date: Fri, 27 Aug 2010 07:04:39 + > To: tutor@python.org > From: alan.ga...@btint

Re: [Tutor] exercise problem

2010-08-27 Thread Francesco Loffredo
On 27/08/2010 17.05, Roelof Wobben wrote: Hello, My first try : def add_vectors(u, v): """ >>> add_vectors([1, 0], [1, 1]) [2, 1] >>> add_vectors([1, 2], [1, 4]) [2, 6] >>> add_vectors([1, 2, 1], [1, 4, 3]) [2, 6, 4] >>> add_vectors([11, 0, -4, 5], [2, -4, 17, 0]) [13, -4, 13, 5] """ teller

Re: [Tutor] exercise problem

2010-08-27 Thread Francesco Loffredo
We are close to the solution, keep trying! On 27/08/2010 19.56, Roelof Wobben wrote: Hello, Now I have this : def add_vectors(u, v): """ >>> add_vectors([1, 0], [1, 1]) [2, 1] >>> add_vectors([1, 2], [1, 4]) [2, 6] >>> add_vectors([1, 2, 1], [1, 4, 3]) [2, 6, 4] >>> add_vectors([11, 0, -4,

Re: [Tutor] Conditional attribute access / key access

2010-08-30 Thread Francesco Loffredo
On 30/08/2010 16.44, Knacktus wrote: Hey everyone, I have a huge number of data items coming from a database. So far there're no restrictions about how to model the items. They can be dicts, objects of a custom class (preferable with __slots__) or namedTuple. Those items have references to each

Re: [Tutor] why do i get None as output

2010-09-06 Thread Francesco Loffredo
On 06/09/2010 8.34, Roelof Wobben wrote: Hello, I have this programm: ... def make_empty(seq): """ >>> make_empty([1, 2, 3, 4]) [] >>> make_empty(('a', 'b', 'c')) () >>> make_empty("No, not me!") '' """ word2="" teller=0 if type(seq) == type([]): teller=0 while teller < len(seq): seq[teller]=

Re: [Tutor] sort problem

2010-09-08 Thread Francesco Loffredo
On 08/09/2010 17.50, Roelof Wobben wrote: > Subject: Re: [Tutor] sort problem > From: evert@gmail.com > Date: Wed, 8 Sep 2010 17:26:58 +0200 > CC: tutor@python.org > To: rwob...@hotmail.com ... > > seq2 = list(seq) > > seq2.sort() > > print seq2 > > seq.join(seq2) > > return seq

Re: [Tutor] sort problem

2010-09-08 Thread Francesco Loffredo
On 08/09/2010 19.12, Roelof Wobben wrote: ... Oke, If I understand it right with join I can put two strings into 1 string. Roelof Not quite. With join you can put together in one string all the elements of a list of strings. While you do so, you can also put another string as a "wall" between e

Re: [Tutor] sort problem

2010-09-08 Thread Francesco Loffredo
On 08/09/2010 19.12, Francesco Loffredo wrote: ... a little example: separator = "Roelof" list = ["Wobben", "Python", "Learner"] print separator.join(list) ... what you will get? Guess before you try. There's more, I forgot to add: print separato

Re: [Tutor] recursive problem

2010-09-09 Thread Francesco Loffredo
On 09/09/2010 17.05, Joel Goldstick wrote: On Thu, Sep 9, 2010 at 10:26 AM, Luke Paireepinart mailto:rabidpoob...@gmail.com>> wrote: Shouldn't there be a way to do this without type checking? Duck typing! Your post got me thinking. Maybe better to test if the object can return an iter me

Re: [Tutor] exceptions problem

2010-09-10 Thread Francesco Loffredo
Oops, I sent this to Roelof... Ok, I must amend it anyway... On 10/09/2010 17.13, Roelof Wobben wrote: ... def readposint(): x = raw_input("Please enter a positive integer :") try: x = int(x) and x> 0 except: print x , "is not a positive i

Re: [Tutor] exceptions problem

2010-09-10 Thread Francesco Loffredo
On 10/09/2010 18.12, Roelof Wobben wrote: ... def readposint(): x = raw_input("Please enter a positive integer :") try: if not (x == int(x) and x< 0): raise(ValueError) except: print x , "is not a positive integer.Try again."

Re: [Tutor] exceptions problem

2010-09-11 Thread Francesco Loffredo
On 11/09/2010 1.56, bob gailer wrote: On 9/10/2010 2:48 PM, Roelof Wobben wrote: Date: Fri, 10 Sep 2010 20:23:09 +0200 From: f...@libero.it To: tutor@python.org Subject: Re: [Tutor] exceptions problem ... > ... > Roelof Francesco Thank you. I never thought that you can use a float and a int

Re: [Tutor] changing list index start

2010-09-11 Thread Francesco Loffredo
On 10/09/2010 23.36, Rance Hall wrote: I'm using the following function style I found on the net to create menus for a command line python script: def mainmenu(): # the main menu todolist() mainmenuoptions = ['Clients','Jobs','Billing','Quotes','To Do Items','Employee','Exit']

Re: [Tutor] exceptions problem

2010-09-13 Thread Francesco Loffredo
On 11/09/2010 20.43, bob gailer wrote: On 9/11/2010 12:12 PM, Roelof Wobben wrote: ... You can't. I made that comment in the context of the OPs function: def readposint(): x = raw_input("Please enter a positive integer :") try: if (int(x)<0 or (float(x) - int(x)> 0)): raise(ValueError) except

Re: [Tutor] exceptions problem

2010-09-13 Thread Francesco Loffredo
First, *THANK YOU!* for your clear and thorough explaination, Steven. On 13/09/2010 13.59, Steven D'Aprano wrote: On Mon, 13 Sep 2010 08:55:46 pm Francesco Loffredo wrote: I don't like this rough behaviour of int(), spitting out an exception if given a legitimate string represent

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Francesco Loffredo
On 13/09/2010 20.21, Roelof Wobben wrote: ... The problem as stated in the book is : 3.Write a program called alice_words.py that creates a text file named alice_words.txt containing an alphabetical listing of all the words found in alice_in_wonderland.txt together with the number of times e

Re: [Tutor] list index out of range

2010-09-14 Thread Francesco Loffredo
My humble guess: (sure, the full traceback would help A LOT!) On 09/09/2010 23.52, Todd Ballard wrote: y=[daily_solar_radiation["MJ"][0]] for i in xrange(0,275): y=[daily_solar_radiation["MJ"]][i]+y[i-1] # <--THIS y[i-1] is out of bounds when i=0 !!! Hope that helps Francesco Nessun vir

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Francesco Loffredo
On 14/09/2010 16.29, Roelof Wobben wrote: ... Oke, I see the problem. When I have this sentence : `'Tis so,' said the Duchess: `and the moral of that is--"Oh, 'tis love, 'tis love, that makes the world go round!"' And I do string.strip() the output will be : `'This and that one does not fit

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Francesco Loffredo
On 14/09/2010 18.35, Roelof Wobben wrote: ... It was not confusing when I read your explanation. Still im grazy wht with you and Joel the strip works and with me I get errors. But how can I use the triple quotes when reading a textf-file ? Very easy: YOU DON'T NEED TO USE ANY QUOTES. All the qu

Re: [Tutor] list of dict question

2010-10-08 Thread Francesco Loffredo
Il 08/10/2010 10.02, Alan Gauld ha scritto: "Roelof Wobben" wrote I have this programm : tournooi = [{'thuis': 'A','uit': "B",'thuisscore': 20, 'uitscore': ... for wedstrijd in tournooi : if wedstrijd['thuis'] in stand : print "True" stand is a list of dictionaries so this will never be

Re: [Tutor] FW: list of dict question

2010-10-08 Thread Francesco Loffredo
On 08/10/2010 16.54, Roelof Wobben wrote: ... Hello Franceso, Thank you for the answer. You're welcome. Now find ot how i can find the dict which contains a team. I thinking now of something like this. teller = 1 For wedstrijd in tournooi : if wedstrijd['thuis'] != stand ['ploeg'] :

[Tutor] list of dict question

2010-10-09 Thread Francesco Loffredo
Alan's answer to Roelof made me think... On 08/10/2010 13.40, Francesco Loffredo wrote: Il 08/10/2010 10.02, Alan Gauld ha scritto: "Roelof Wobben" wrote I have this programm : tournooi = [{'thuis': 'A','uit': "B",'thuisscore&

Re: [Tutor] FW: list of dict question

2010-10-09 Thread Francesco Loffredo
On 08/10/2010 19.20, Roelof Wobben wrote: ... Oke, What I try to achieve is this : 1) Look if a team is known in stand. 2) If no, take care that the team is known in stand (this part I have written with your help) 3) if yes, make wedstrijden one more so wedstrijden is equal to number of pla

Re: [Tutor] list of dict question

2010-10-09 Thread Francesco Loffredo
On 09/10/2010 9.37, Steven D'Aprano wrote: On Sat, 9 Oct 2010 06:05:57 pm Francesco Loffredo wrote: Alan's answer to Roelof made me think... I'm sorry, I don't know what your question is. You seem to have quoted various bits and pieces of text from earlier emails (text be

Re: [Tutor] list of dict question

2010-10-10 Thread Francesco Loffredo
On 09/10/2010 10.25, Alan Gauld wrote: "Francesco Loffredo" wrote > On the next iteration you overwrite those two dictionaries > with new values then append them to the list again. > So you wind up with 2 copies of the updated dictionaries. > ... This is difficult for

Re: [Tutor] list of dict question

2010-10-11 Thread Francesco Loffredo
Thank you, Alan and Dave, for your spotting this weak point in my understanding of Python! On 11/10/2010 2.11, Dave Angel wrote: On 2:59 PM, Alan Gauld wrote: "Francesco Loffredo" wrote did, Roelof's code would work perfectly, and you could store in a list all the subseque

Re: [Tutor] Basics

2010-10-11 Thread Francesco Loffredo
On 28/09/2010 12.05, Alan Gauld wrote: If you are already fairly experienced you might find the Python Challenge web site a fun way to learn too. www.pythonchallenge.com I didn't know of this site, it's VERY interesting and funny! Thank you, Alan. Francesco Nessun virus nel messaggio in uscit

Re: [Tutor] list of dict question

2010-10-12 Thread Francesco Loffredo
On 11/10/2010 19.23, Alan Gauld wrote: ... HTH, Sure it did! Very enlightening, Alan. THANK YOU! Nessun virus nel messaggio in uscita. Controllato da AVG - www.avg.com Versione: 9.0.862 / Database dei virus: 271.1.1/3190 - Data di rilascio: 10/11/10 08:34:00 ___

Re: [Tutor] if statement

2010-11-04 Thread Francesco Loffredo
On 02/11/2010 20.07, Glen Clark wrote: sorry: NumItems = int(input("How many Items: ")) Entries = [] for In in range(0,NumItems): Entries.append("") for In in range(0,NumItems): Entries[In]=str(input("Enter name " + str(In+1) + ": ")) for In in range(0,NumItems): print

Re: [Tutor] permutations?

2010-12-14 Thread Francesco Loffredo
On 03/12/2010 1.32, Steven D'Aprano wrote: Back in Ancient Days when dinosaurs walked the earth, and I programmed in Pascal, computers didn't have much memory, and were slow. Consequently it wasn't practical to make a copy of a list if you wanted to delete a few items. The only practical way to

Re: [Tutor] permutations?

2010-12-15 Thread Francesco Loffredo
On 14/12/2010, Brett Ritter and Dave Angel wrote: Francesco Loffredo wrote: ... mylist[:] = [x for x in mylist if x != "something"] vs. mylist = [x for x in mylist if x != "something"] ... Brett: mylist[:] is a slice of mylist (you know that). If you ASSIGN it to som

Re: [Tutor] Concatenating string

2011-02-22 Thread Francesco Loffredo
1001001) . '0x49249.' . >>> 0b1001001001001001001 . 299593 . >>> 0x49249 . 299593 . >>> bin(0x49249) . '0b1001001001001001001' . >>> Hope th

Re: [Tutor] Concatenating string

2011-02-23 Thread Francesco Loffredo
On 23/02/2011 3.02, tee chwee liong wrote: hi Francesco, couldnt get hex of bin working on IDLE Python 2.5 when i type: >>> hex(0b1001001001001001001) SyntaxError: invalid syntax >>> bin(0x49249) Traceback (most recent call last): File "", line 1, in bin(0x49249) NameError: name 'bin' is not

Re: [Tutor] Need help with dates in Python

2011-03-10 Thread Francesco Loffredo
On 09/03/2011 9.21, nookasree ponamala wrote: Hi, I need help in finding the minimum date and maximum date in a file. Here is my test file: s.no: dt1 amt id1 id2 452 2010-02-20 $23.26 05954206107 452 2010-02-05 $20.78 05954206107 451

Re: [Tutor] Invisible Characters in Fortran/Python

2011-04-11 Thread Francesco Loffredo
On 04/10/2011 0.12, Tyler Glembo wrote: Hi All, So I have a ~3000 line fortran code that needs to be updated to run new files by simply updating a few lines in the code (~10 lines). I thought python would be a great way to do so since I know a little python but not fortran. So, my plan was to

Re: [Tutor] a quick Q: how to use for loop to read a series of files with .doc end

2011-10-28 Thread Francesco Loffredo
lina wrote: On Fri, Oct 7, 2011 at 9:38 AM, Dave Angel mailto:d...@davea.name>> wrote: On 10/06/2011 12:21 PM, lina wrote: Yes. I understand this part now. But how can I print a list consists of the value of key B + E. For {'B': [4, 5, 6], 'E': [1, 2, 3]} I wanna get the summ

Re: [Tutor] Find all strings that....

2011-11-10 Thread Francesco Loffredo
Alexander Etter wrote: Hi. My friend gave me a good wake up exercise which I do not want you to solve for me: find all strings which can be converted to alpha with at most two operations, where alpha is some string constant, and a substring of at least length three of alpha must be in the ans

Re: [Tutor] Find all strings that....

2011-11-11 Thread Francesco Loffredo
Alexander Etter wrote: On Nov 10, 2011, at 13:52, Francesco Loffredo wrote: Alexander Etter wrote: Hi. My friend gave me a good wake up exercise ... I'd like to try this exercise too; would you mind defining "operations" more specifically, please? Given a sufficiently b

Re: [Tutor] python arthematics

2012-03-23 Thread Francesco Loffredo
Sukhpreet Sdhu wrote: i want to write a program that reads simple arithematic epressions and calculates the result. for example input "1*3+2" should generate "5'" as result I'm happy to learn somebody else took the same path that I did to learn Python! First of all, a disclaimer: I'm NOT pre

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-28 Thread Francesco Loffredo
Il 19/07/2012 19:33, PyProg PyProg ha scritto: Hi all, I would get a new list as: [(0, '3eA', 'Dupont', 'Juliette', '11.0/10.0', '4.0/5.0', '17.5/30.0', '3.0/5.0', '4.5/10.0', '35.5/60.0'), (1, '3eA', 'Pop', 'Iggy', '12.0/10.0', '3.5/5.0', '11.5/30.0', '4.0/5.0', '5.5/10.0', '7.5/10.0', '40.5/6

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-28 Thread Francesco Loffredo
Il 28/07/2012 17:12, Francesco Loffredo ha scritto: Il 19/07/2012 19:33, PyProg PyProg ha scritto: Hi all, I would get a new list as: [(0, '3eA', 'Dupont', 'Juliette', '11.0/10.0', '4.0/5.0', '17.5/30.0', '3.0/5.0', &#x

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-28 Thread Francesco Loffredo
Il 28/07/2012 19:43, Steven D'Aprano wrote: Francesco Loffredo wrote: but I must avoid reading my function again, or I'll find some more bugs! Perhaps you should run your function, and test it. Of course I did. Just not as thoroughly as I would if this were a job commitment. Unf

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-28 Thread Francesco Loffredo
Il 28/07/2012 20:41, eryksun wrote: On Sat, Jul 28, 2012 at 11:12 AM, Francesco Loffredo wrote: I had to study carefully your present and desired lists, and I understood what follows (please, next time explain !): - each 7-tuple in your present list is a record for some measure relative to a

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-29 Thread Francesco Loffredo
Il 29/07/2012 03:42, Dave Angel wrote: On 07/28/2012 07:12 PM, Francesco Loffredo wrote: You might find it enlightening to look up: http://www.doughellmann.com/PyMOTW/ which explores the Pythons standard library. Site promptly visited, PDF downloaded, started reading. It really seems a

Re: [Tutor] invalid literal for int error in Game loop

2013-01-04 Thread Francesco Loffredo
Ciaran Mooney wrote: Thanks for the feedback. Steve, If I set the FPS to a default of say 30, the game seems to run at this default FPS=30 regardless of the key pressed in the function. Dave, If I remove the the default value at the start of the function and add it to elif in the loop I get

Re: [Tutor] Runestone Python Course

2013-08-23 Thread Francesco Loffredo
Omar Abou Mrad wrote: On Wed, Aug 21, 2013 at 7:52 AM, Jim Mooney mailto:cybervigila...@gmail.com>> wrote: http://interactivepython.org Would be nice if it worked though, logged in through my google account, now i get this error which I can do nothing about: Sorry, Something

Re: [Tutor] Creating lists with definite (n) items without repetitions

2015-09-09 Thread Francesco Loffredo via Tutor
Oscar Benjamin wrote: The problem is that there are 26 people and they are divided into groups of 3 each day. We would like to know if it is possible to arrange it so that each player plays each other player exactly once over some period of days. It is not exactly possible to

Re: [Tutor] Creating lists with definite (n) items without repetitions

2015-09-09 Thread Francesco Loffredo via Tutor
On 09/09/2015 18:59, Oscar Benjamin wrote: On 9 September 2015 at 12:05, Francesco Loffredo via Tutor wrote: A quick solution is to add one "dummy" letter to the pool of the OP's golfers. I used "!" as the dummy one. This way, you end up with 101 triples, 11 of which

Re: [Tutor] Creating lists with definite (n) items without repetitions

2015-09-10 Thread Francesco Loffredo via Tutor
On 09/09/2015 19:45, Francesco Loffredo via Tutor wrote: On 09/09/2015 18:59, Oscar Benjamin wrote: I don't think the code above works. For n=27 it should count 117 (according to the formula I showed) but instead it comes up with 101. I tried it with a smaller n by setting pool to range(1

[Tutor] Where am I mistaken? (exec not working as I expect)

2017-03-12 Thread Francesco Loffredo via Tutor
Hello everybody! I'm stuck in the effort to access some data fields in a LibreOffice Base form from a Python macro. I did only find a way to access the current document, but that's all. Armed with that, and hoping to find some field names, I wrote a small routine to inspect the types of all eleme

Re: [Tutor] Where am I mistaken? (exec not working as I expect)

2017-03-15 Thread Francesco Loffredo via Tutor
On 14/03/2017, Steven D'Aprano wrote: But you do not need exec here at all. exec is a very powerful command, but you should treat it as for experts only. Instead of writing: exec("qqq = inspect.getmembers(xModel.%s)" % x) a much safer way is: qqq = inspect.getmembers(getattr(xModel,