Re: [Tutor] how to join two text files ?

2011-03-29 Thread Peter Otten
Mateusz K wrote: > I have many text files, where data is delimited by space. > Each file contain three colums: coordinate x, coordinate y and value for > this location. > > I would like to join this data to get one big file which will > contain columns: > coordinate x, coordinate y, value1,v

Re: [Tutor] Grouping based on attributes of elements in a List

2011-03-30 Thread Peter Otten
ranjan das wrote: > I have the following list > > List=[( 'G1', 'CFS', 'FCL', 'R1' ),('G3', 'LOOSEFREIGHT', 'MIXEDLCL', > 'R9'), > ('G4', 'CFS', 'FCL', 'R10' ), ('G2', 'LOOSEFREIGHT', 'LCL', 'R4' ), > ('G1', > 'CFS', 'FCL', 'R2' ), ('G2', 'LOOSEFREIGHT', 'LCL', 'R5') ] > > > now I want to gro

Re: [Tutor] Converting a numpy matrix to a numpy array

2011-03-31 Thread Peter Otten
David Crisp wrote: > Hello, > > I have a very simple question / problem I need answered. The problem > is imnot entirely sure of the correct terminology and langauge to use > to describe it. (One of the reasons im using this miling list) > > I have a 2d matrix representing the X the Y and the

Re: [Tutor] Removing values from a dictionary if they are present in a list

2011-04-01 Thread Peter Otten
ranjan das wrote: > I have the following information > > A={'g2': [4,5,3], 'g1': [1, 3]} > > B=[2,3,5] > > Now I want to remeove the elements in B if they are present (as values) in > dictionary A. > > My expected solution is > > A= {'g2': [4], 'g1': [1] } > > I wrote the following piece of

Re: [Tutor] Removing values from a dictionary if they are present in a list

2011-04-01 Thread Peter Otten
Steven D'Aprano wrote: > b = set(B) > for key, values in A.items(): > A[key] = list( set(values).difference(b) ) > > > For Python 3, you will need to change the call A.items() to > list(A.items()), but otherwise they should be the same. The documentation doesn't say so explicitly, see http

Re: [Tutor] Finding prime numbers script runs much faster when run via bash shell than idle

2011-04-02 Thread Peter Otten
Jaime Gago wrote: > I wrote a simple piece of code as an exercise to an online -free- class > that finds prime numbers. When I run it via IDLE it's taking way more time > than if I run it via a (bash) shell (on Os X 10.6) while doing $>python -d > mypp.py > > I'm really curious from a performance

Re: [Tutor] Regex question

2011-04-03 Thread Peter Otten
Hugo Arts wrote: > 2011/4/3 "Andrés Chandía" : >> >> >> I continue working with RegExp, but I have reached a point for wich I >> can't find documentation, maybe there is no possible way to do it, any >> way I throw the question: >> >> This is my code: >> >> contents = re.sub(r'Á', >> "A", contents

Re: [Tutor] Converting a numpy matrix to a numpy array

2011-04-04 Thread Peter Otten
David Crisp wrote: > np.array([np.arange(9)//3, np.arange(9)%3, a.flatten()], >> dtype=object).transpose() >> array([[0, 0, x], >> [0, 1, o], >> [0, 2, o], >> [1, 0, o], >> [1, 1, x], >> [1, 2, x], >> [2, 0, o], >> [2, 1, x], >> [2, 2, o]], dtype=object) >> >> If that's not good enough you may

Re: [Tutor] Showing/hiding widgets in Tkinter

2011-04-06 Thread Peter Otten
The Green Tea Leaf wrote: > Hi all, > > I'm trying to learn a bit about how to show/hide objects using the > available layout managers and have no problems using Pack or Grid but > when I try to use Place then I'm missing something > > My test code looks like this > > from Tkinter import * > >

Re: [Tutor] Showing/hiding widgets in Tkinter

2011-04-06 Thread Peter Otten
The Green Tea Leaf wrote: > > which implies that tk does not store the placement information > > automatically. Assuming that Python's Tkinter behaves the same way you can > > write > > > > def toggle(): > >if mylabel.visible: > >mylabel.pi = mylabel.place_info() > >mylabel.pl

Re: [Tutor] Generating XML using Python

2011-04-11 Thread Peter Otten
tee chwee liong wrote: > i'm using python to generate xml with elementtree api. and i'm getting > error when opening the output xml. it doesnt give error when running. i > also tried to use python to output to a text file and it works without any > error. Pls advise me how i can rectify the error

Re: [Tutor] Generating XML using Python

2011-04-11 Thread Peter Otten
tee chwee liong wrote: > thanks for your reply. seems that xml doesnt accept a space in between. > anyway, the output generated is: > > - > > > - > > > 2 > > 3 > > > > it overwrites every time the port number is incremented and only capture > the last iteration number. how can

Re: [Tutor] Generating XML using Python

2011-04-11 Thread Peter Otten
tee chwee liong wrote: > > sorry for lack of details. yes i would like to output in 1 xml file. > i would like to generate port 1 and its details (link, speed etc) then > move to second port, port 2 and generate its details (link, speed etc) tq As I said, instead of creating a new root on every

Re: [Tutor] Fwd: Python skipping if statement (Really simple code)

2011-04-15 Thread Peter Otten
Casey Key wrote: > -- Forwarded message -- > From: Casey Key > Date: Thu, Apr 14, 2011 at 4:02 PM > Subject: Python skipping if statement (Really simple code) > To: tu...@python.com > > > Hey im a newbie to python, but i made this test code. and it is just > skipping over the if

Re: [Tutor] Trouble executing an if statement with a string from aninput

2011-04-18 Thread Peter Otten
Alan Gauld wrote: > > "Sylvia DeAguiar" wrote > >> The code runs fine on python shell (from run module) but >> when I try to execute the program from its file, it always >> prints out c, regardless > >> x = input("a, b, or c:") >> ... >> else: >> print ('c') > > It looks like IDLE is runn

Re: [Tutor] Metaclass confusion...

2011-04-19 Thread Peter Otten
Modulok wrote: > List, > > I've been messing with metaclasses. I thought I understood them until I > ran into this. (See code below.) I was expecting the generated class, > 'Foo' to have an 'x' class-level attribute, as forced upon it by the > metaclass 'DracoMeta' at creation. Unfortunately, it

Re: [Tutor] Type error: must be string or read-only character buffer, not seq

2011-04-19 Thread Peter Otten
Kann Vearasilp wrote: > I tried concatenating string variables with multiple strings and have the > file handle write the statement into a file. I don't know why I always get > the type error: must be string or read-only character buffer, not seq > error. I tried casting the whole new concatenated

Re: [Tutor] Jokes on Python Language

2011-04-21 Thread Peter Otten
Ratna Banjara wrote: > Does anybody knows jokes related to Python Language? > If the answer is yes, please do share it... import antigravity http://entrian.com/goto/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options

Re: [Tutor] Unbound Method Error

2011-04-26 Thread Peter Otten
Greg Nielsen wrote: > if crash: > for BlueCarSprite in crash: > redracersprites26.BlueCarSprite.collide(crash, playerCar) > for GreenCarSprite in crash: > redracersprites26.GreenCarSprite.collide(crash, playerCar) > for Tr

Re: [Tutor] Equivalent of Set in PtO

2011-04-26 Thread Peter Otten
Becky Mcquilling wrote: > I have a code snippet that I have used to count the duplicates in a list > as such: > > from sets import Set > > def countDups(duplicateList): > uniqueSet = Set(item for item in duplicateList) > return[(item, duplicateList.count(item)) for item in uniqueSet] > > >

Re: [Tutor] Deleting strings from a line

2011-04-26 Thread Peter Otten
Spyros Charonis wrote: > Hello, > > I've written a script that scans a biological database and extracts some > information. A sample of output from my script is as follows: > > LYLGILLSHAN AA3R_SHEEP26331 > > LYMGILLSHAN AA3R_HUMAN26431

Re: [Tutor] confusions about re module

2011-05-01 Thread Peter Otten
naheed arafat wrote: > someone please tell me why i'm getting this output? > specially the 'e3%' ! ! ! import re re.findall('([\w]+.)','abdd.e3\45 dret.8dj st.jk') > ['abdd.', 'e3%', 'dret.', '8dj ', 'st.', 'jk'] > > I am getting the same output for the following too.. re.findall(r

Re: [Tutor] Ipython console

2011-05-02 Thread Peter Otten
Mateusz Koryciński wrote: > Hi, > > I am using ipython console on one of servers and it's great. Because of > that I've tried to install it on my laptop, but unfortunately I am getting > this error: > > Traceback (most recent call last): >> File "/usr/bin/ipython", line 26, in >> import I

Re: [Tutor] ValueError

2011-05-03 Thread Peter Otten
Johnson Tran wrote: > Thanks for the replies..so I added the "try" block but it still does not > seem to be outputting my default error message: > > def Conversion(): > try: > > print "This program converts the first value from inches to > centimeters and second value

Re: [Tutor] ValueError

2011-05-04 Thread Peter Otten
Kushal Kumaran wrote: > On Tue, May 3, 2011 at 5:31 PM, Peter Otten <__pete...@web.de> wrote: >> >> >> Also you should make the try...except as narrow as possible >> >> try: >> centimeters = float(centimeters) >> except ValueError as e: >&

Re: [Tutor] create an xls file using data from a txt file

2011-05-12 Thread Peter Otten
Steve Willoughby wrote: > On 11-May-11 15:54, Prasad, Ramit wrote: >>> Core windows commands don't generally accept it, including native >>> Windows applications (although sometimes they're lenient in what they >>> accept). It'll work for command-line Python script usage because it's >>> *python*

Re: [Tutor] Overriding a method in a class

2011-05-13 Thread Peter Otten
Terry Carroll wrote: > I have a pretty basic point of confusion that I'm hoping I can have > explained to me. I have a class in which I want to override a method, and > have my method defined externally to the class definition invoked instead. > But when I do so, my external method is invoked wit

Re: [Tutor] searching data from a list read from a file

2011-05-15 Thread Peter Otten
Lea Parker wrote: [Lea, please reduce the number of empty lines in your posted source code.] > When you have time I would like some advice on where to go. I have created > a program that reads charge account numbers from a file. The user is to > enter a charge account number from the list present

Re: [Tutor] can I walk or glob a website?

2011-05-18 Thread Peter Otten
Albert-Jan Roskam wrote: > How can I walk (as in os.walk) or glob a website? I want to download all > the pdfs from a website (using urllib.urlretrieve), extract certain > figures (using pypdf- is this flexible enough?) and make some > statistics/graphs from those figures (using rpy and R). I forg

Re: [Tutor] Data conversion

2011-05-18 Thread Peter Otten
Joe Aquilina wrote: > I am new to this list and very much a beginner to Python. Please excuse > me if this is a silly question, but in all my searches this morning I > have not been able to find an answer. > > I have a (single table) database file (SQLite3). It has one table, call > it literature

Re: [Tutor] python scripting using "./"

2011-05-24 Thread Peter Otten
Hank Wilkinson wrote: > I am trying to do script in python using "./" > Here is a session showing "bad interpreter: No such file or directory" > Is this a python question/problem? It's a bash problem. The shell cannot cope with Windows line endings: ^M in the error message stands for chr(13) or

Re: [Tutor] Creating a dictionary

2011-05-27 Thread Peter Otten
Válas Péter wrote: > I think I am new to here, as far as I remember. :-) > > http://docs.python.org/dev/library/stdtypes.html#dict says: > we can create a dictionary with > >- dict({'one': 1, 'two': 2}) > > What is the adventage of this form to simply writing d = {'one': 1, 'two': > 2}? Is

Re: [Tutor] Importing classes when needed

2011-05-30 Thread Peter Otten
Timo wrote: > Hello all, > > I have a question about how this is done the best way. > > In my project I have a folder with multiple file parsers, like this: > - src > -- main.py > -- parsers >--- __init__.py >--- parser1.py >--- parser2.py > > The parsers just contain a class wh

Re: [Tutor] regex woes in finding an ip and GET string

2011-06-20 Thread Peter Otten
Gerhardus Geldenhuis wrote: > I am trying to write a small program that will scan my access.conf file > and update iptables to block anyone looking for stuff that they are not > supposed to. > > The code: > #!/usr/bin/python > import sys > import re > > def extractoffendingip(filename): > f =

Re: [Tutor] set the BETWEEN range in the SQL query using the python datetime function

2011-06-24 Thread Peter Otten
Norman Khine wrote: > hello, i have this code http://pastie.org/2112997 > > but i am not sure how to make the date range so that i get a list > based on the daily totals not the results i am now getting: > > (2L, Decimal('173.958344'), Decimal('159.966349')) 2011-06-23 00:00:00 > 2011-06-23 23:5

Re: [Tutor] set the BETWEEN range in the SQL query using the python datetime function

2011-06-24 Thread Peter Otten
Norman Khine wrote: > thank you, it was simpler than what i was trying to do, here is the > revised version: > > http://pastie.org/2115586 > > one thing i am getting an error is on like 103, in that if, i change > (http://pastie.org/2115615): > > -plt.legend(('Income - GBP', 'Discounts', 'Googl

Re: [Tutor] BadPickleGet error

2011-06-25 Thread Peter Otten
Rick Pasotto wrote: > Traceback (most recent call last): > File "/usr/share/rss2email/rss2email.py", line 748, in > else: run() > File "/usr/share/rss2email/rss2email.py", line 488, in run > feeds, feedfileObject = load() > File "/usr/share/rss2email/rss2email.py", line 439, in load

Re: [Tutor] Efficiency

2011-06-25 Thread Peter Otten
naheed arafat wrote: > Is there any way easier to do the following? > input: > 'How are you' > 'I am fine' > output: > 'you I are am How fine' > > solution: ' '.join(reduce(lambda x,y:x+y, zip('How are you'.split(' ')[::-1], > 'I am fine'.split(' ' reversed(items) instead of items[::-1]

Re: [Tutor] Algorithm for sequence matching

2011-07-02 Thread Peter Otten
ANKUR AGGARWAL wrote: > Hey > I am looking for an algo for the largest sequence search in the two list. > > Example : list a accepts some say 'm' numbers. list b accept says 'n' > numbers. I want to look for the largest same sequence between the two list > and then display it. I tried out but fai

Re: [Tutor] Help with making emacs work with python syntax checking?

2011-07-04 Thread Peter Otten
Tidal Espeon wrote: > I need help with installing this setup on my emacs: > http://hide1713.wordpress.com/2009/01/30/setup-perfect-python-environment- in-emacs/ > The problem is that I have no clue how to access any .emacs file or > .emacs.d folder. I'm running linux, and they are apparently invis

Re: [Tutor] Using a dict value in the same dict

2011-07-05 Thread Peter Otten
Válas Péter wrote: > I have a dictionary with the keys 'a' and 'b'. It is not in a class. (I > know that everything is in a class, but not explicitly.) > May I use the value of 'a' when defining the value of 'b'? If so, what is > the syntax? >>> d = {} >>> d["a"] = 1 >>> d["b"] = d["a"] + 1 >>> d

Re: [Tutor] Hello World in Python without space

2011-07-10 Thread Peter Otten
Robert H wrote: > I have Python 3.2 installed on Windows 7. I am a complete beginner playing > around with the basic functions. My problem is the following script: > > > name="world" > print("Hello", name,"!") > > > The result is: > Hello world ! > > > However, I don't want the space before

Re: [Tutor] compare and arrange file

2011-07-12 Thread Peter Otten
Edgar Almonte wrote: > thanks emile i understand exactly what you explain me but i was unable > to accomplish it ( too noob in python ) but i solved the problem with > this code > http://pastebin.com/4A6Jz4wZ > > i will try do what you suggest me anyway but that will tomorrow , > tonight i done a

Re: [Tutor] compare and arrange file

2011-07-13 Thread Peter Otten
Edgar Almonte wrote: > fist time i saw the statement "with" , is part of the module csv ? , > that make a loop through the file ? is not the sortkey function > waiting for a paramenter ( the row ) ? i don't see how is get pass , > the "key" is a parameter of sorted function ? , reader is a functio

Re: [Tutor] how to add directory to python search list

2011-07-17 Thread Peter Otten
Surya P.K. Kasturi wrote: > OS : Ubuntu Linux > Python Version : 2.6.4 > > I have some third party modules to be installed in my computer. > So, I want to add the module directory to python search list. The way I find most convenient is to create a text file with the .pth suffix in a directory t

Re: [Tutor] error in using TurtleWorld modules, ThinkPython.org Book

2011-07-17 Thread Peter Otten
Surya P.K. Kasturi wrote: > I am using Think Python book, to learn python. > There is a module TurtleWorld that they described to draw lines < > http://www.greenteapress.com/thinkpython/swampy/install.html> > > Though I could run the below code in the python shell, I couldn't do it > through a s

Re: [Tutor] Question related to Tkinker

2011-07-24 Thread Peter Otten
Emeka wrote: > for i,cha in enumerate(wordi): > > label = Label(root, image=photoimage, text = cha) > label.grid(row=1, column=i, columnspan=1, rowspan=1,sticky=W+E+N+S, > padx=0, pady=1) > label1 = Label(root, image=IMAGE) > > I used grid ... Though I used labels, I was dealing on

Re: [Tutor] List problem

2011-07-25 Thread Peter Otten
David Merrick wrote: > def append(self,item): > '''Adds an item to the end of the List''' > > current = self.head > previous = None > while current.getNext() != None: > previous = current > current = current.getNext() > if

Re: [Tutor] Logger object not passed between modules

2011-07-26 Thread Peter Otten
Luke Thomas Mergner wrote: > I am very new to Python and programming, basically just a curious > hobbyist. I am building a learning app that hopefully will include a > wxPython GUI. Right now I am trying to understand my code better by > including print statements. Now I know that I could just

Re: [Tutor] output sequentially

2011-07-26 Thread Peter Otten
lina wrote: > I have below file, > > I wish the output following: > > The first field 169 -170 sequential, and then the filed 2 from 1-29, > ignore the rest 4 fields, > > 169CHOL O28 1612 6.966 6.060 6.429 Read the lines from the file, sort them with a proper key function, write

Re: [Tutor] Python Tkinter event activated with time

2011-07-27 Thread Peter Otten
Emeka wrote: > I am putting together a small game, and I would want to enable my callback > function using time passed. > > How to do something like this with Tkinter event. > > from time import time > > ftime = time() >if ftime - time() > 2000: > dosomething You can schedule a fu

Re: [Tutor] how to temporarily disable a function

2011-07-28 Thread Peter Otten
Pete O'Connell wrote: > Hi I was wondering if there is a way to disable a function. > Hi have a GUI grid snapping function that I use in a program called Nuke > (the film compositing software) > > Here is the function (which loads when Nuke loads): > ### > def theAutoplaceSnap

Re: [Tutor] Mainloop conflict

2011-07-29 Thread Peter Otten
Stefan Behnel wrote: > Christopher King, 29.07.2011 17:08: >> On Thursday, July 28, 2011, Dave Angel wrote: >>> On 07/28/2011 08:32 PM, Christopher King wrote: Dear Tutor Dudes, I have a socket Gui program. The only problem is that socket.recv >> waits for a response, whic

Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Peter Otten
Sandip Bhattacharya wrote: > On Sat, Jul 30, 2011 at 10:28:11PM -0700, Richard D. Moores wrote: >> File "c:\P32Working\untitled-5.py", line 2 >>return path.replace('\', '/') >>^ >> SyntaxError: EOL while scanning string literal >> Process terminated with an exit

Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Peter Otten
Richard D. Moores wrote: >> What happens if the path looks like >> >> r"C:relative\path\to\my\file.txt" >> >> or >> >> r"C:/mixed\slashes.txt"? > > Not quite sure what the intent of your question is, but all the paths > I want to modify are full, with only back slashes. If you invoke your fwd2bk

Re: [Tutor] Question about sorting a list within a dictionary within a list

2011-08-01 Thread Peter Otten
ian douglas wrote: > I'm using the Bono library for talking to EC2, and I'm getting a list of > EC2 instances back in a list called "reservations". Each element in the > list is a dictionary of information. One of those dictionary elements is > a list called 'instances', and I only ever care about

Re: [Tutor] Question about sorting a list within a dictionary within a list

2011-08-01 Thread Peter Otten
ian douglas wrote: > On 08/01/2011 01:03 PM, Peter Otten wrote: >> ian douglas wrote: >> >>> I'm using the Bono library for talking to EC2, and I'm getting a list of >>> >>> I cannot help you with the django or boto part. > > Well, I su

Re: [Tutor] Question about sorting a list within a dictionary within a list

2011-08-01 Thread Peter Otten
Peter Otten wrote: > Untested: > > from operator import attrgetter, itemgetter > from itertools import imap > > firsts = imap(itemgetter(0), conn.get_all_instances()) > reservations = sorted(firsts, key=attrgetter("launch_time")) > > This gives you objec

Re: [Tutor] Indexing a list with nested tuples

2011-08-03 Thread Peter Otten
Alexander Quest wrote: > Hi guys- I'm having a problem with a list that has nested tuples: > > attributes = [("strength", 0), ("health ", 0), ("wisdom ", 0), > ("dexterity", 0)] > > I've defined the list above with 4 items, each starting with a value of 0. > The player > enters how many points

Re: [Tutor] Puzzled again

2011-08-03 Thread Peter Otten
Richard D. Moores wrote: > I wrote before that I had pasted the function (convertPath()) from my > initial post into mycalc.py because I had accidentally deleted it from > mycalc.py. And that there was no problem importing it from mycalc. > Well, I was mistaken (for a reason too tedious to go into

Re: [Tutor] Puzzled again

2011-08-03 Thread Peter Otten
Richard D. Moores wrote: > On Wed, Aug 3, 2011 at 10:11, Peter Otten <__pete...@web.de> wrote: >> Richard D. Moores wrote: >> >>> I wrote before that I had pasted the function (convertPath()) from my >>> initial post into mycalc.py because I had accident

Re: [Tutor] adding dictionary value at position [-1]

2011-08-06 Thread Peter Otten
Alan Gauld wrote: > On 06/08/11 12:32, Norman Khine wrote: >> hello, >> i know that there are no indexes/positions in a python dictionary, >> what will be the most appropriate way to do this: >> >> addresses = {} >> for result in results.get_documents(): >>

Re: [Tutor] tkinter issue in python 3

2011-08-07 Thread Peter Otten
Khalid Al-Ghamdi wrote: > I'm studying this > tutorialabout > tkinter, but it that it's code in a 2.X. > > I'm using the following code in python 3, but when i hit quite in the > resulting widget it hangs. I've tried modifyi

Re: [Tutor] commandline unable to read numbers?

2011-08-07 Thread Peter Otten
Robert Sjoblom wrote: > I have a quite odd problem, and I've come across it before but > probably ignored it at the time because I had other concerns. I've > tried googling for the answer but haven't really come closer to > solving it. > This is what happens: > C:\[path]\nester>C:\Python32\python.

Re: [Tutor] How to use __iter__

2011-08-08 Thread Peter Otten
Jia-Yu Aw wrote: > How to use __iter__ > Von: > Jia-Yu Aw > Antwortadresse: > Jia-Yu Aw > Datum: > Dienstag, 9. August 2011 03:48:20 > An: > tutor@python.org > Gruppen: > gmane.comp.python.tutor > Hi all > > I've been learning Classes and have read the documentation on __iter__ but st

Re: [Tutor] How to get the keys of a dict inside a dict. ValueError: too many values to unpack

2011-08-09 Thread Peter Otten
Kayode Odeyemi wrote: > Thanks so much. This is exactly what I'm looking for. In addition, since > fields is obviously a dict, I won't want to have to display it's keys > repeatedly. Is there a way to get the keys once, have it displayed and > used as columns, then it's values are displayed beneat

Re: [Tutor] function remember calls?

2011-08-09 Thread Peter Otten
Robert Johansson wrote: > This is my attempt to generate all pairs of relatively prime pairs of > nonnegative integers (n, m) such that n + m <= N, using the Stern-Brocot > tree. > > def rp_bounded_sum(n, i = 0, p = (0, 1), q = (1, 1), S = set([(0, 1), (1, > 1)])): > # Returns a set S with al

Re: [Tutor] precision?

2011-08-10 Thread Peter Otten
Steven D'Aprano wrote: > Shwinn Ricci wrote: >> When comparing a given value with a database of values, but allowing for >> freedom due to variation at say, the thousandth digit, how does one >> generalize the precision to this degree? I don't want to truncate, so is >> there a round() function th

Re: [Tutor] Tkinter: no module named messagebox

2011-08-13 Thread Peter Otten
brandon w wrote: > I have tried to follow the tutorial I found here: > > Python 2.7 Tutorial > http://www.youtube.com/watch?v=uh6AdDX7K7U > > This is what I have done so far: > > #!/usr/bin/python > > from Tkinter import * > import Tkinter.MessageBox > > myapp = Tk() > myapp.title("This is th

Re: [Tutor] Tkinter: no module named messagebox

2011-08-13 Thread Peter Otten
brandon w wrote: > On 08/13/2011 04:49 PM, Peter Otten wrote: >>> How do I find the modules in Tkinter? >>> >> The simplest approach is probably to explore your file system: >> >> Step 1: where's Tkinter? >> >> $ python -c &#x

Re: [Tutor] tkinter.TclError

2011-08-13 Thread Peter Otten
brandon w wrote: > radio1 = Radiobutton(master=myapp, text="had breakfast", value="had > breakfast", variable=relStatus, commmand=iClicked).pack() > *Traceback (most recent call last): >File "tkwindow.py", line 54, in > radio1 = Radiobutton(master=myapp, text="had breakfast", value="had

Re: [Tutor] Moveable and Animated Sprites

2011-08-15 Thread Peter Otten
Jordan wrote: > Is there a more Pythonic way to create the class > "MoveableAnimatedSheetSprite" I am using multiple inheritance but I see > that I am really loading the image twice when I call __init__ for > "AnimatedSheetSprite" and "MoveableSprite". Should I just make a > moveable class and hav

Re: [Tutor] print to file probelm

2011-08-15 Thread Peter Otten
John Collins wrote: > Hi, > I'm a baffled beginner. The script below is one of a suite of scripts > written by Simon Tatham a decade ago; > http://www.chiark.greenend.org.uk/~sgtatham/polyhedra/ > http://www.chiark.greenend.org.uk/~sgtatham/polyhedra/polyhedra.tar.gz > > OS: WinXP > Py Ver: 2

Re: [Tutor] directory within directory

2011-08-16 Thread Peter Otten
questions anon wrote: > I would like to open up a bunch of files within a folder within a folder > and then process them and output them in another location but with the > same folder structure. I seem to having trouble with the folder within > folder section. > I have a separate folder for each y

Re: [Tutor] Passing functions(with parameters) as paramiters to (looping)functions.

2011-08-16 Thread Peter Otten
Jeff Peters wrote: > Hi; > > I am trying to run a function inside a continuing loop, but do not seem > to be able to pass any parameters (arguments ) when I do so. > I have placed working and non-working code , with output below. > > ## This works: > > def loop(fn ): > for i in range(5): >

Re: [Tutor] directory within directory

2011-08-17 Thread Peter Otten
questions anon wrote: > Thank you, that does create the directories in the new place but when I > process the data it does not put the outputs in the correct directory they > all end up in the last directory created. > Below is the code of what I am trying to do. > Any feedback will be greatly app

Re: [Tutor] Printing in the same place

2011-08-17 Thread Peter Otten
brandon w wrote: > I am trying to print in the same place to make a clock in a tkinter > window. I will loop the following code to update the time. > > This seems to work but it is not printing in the same place: > > #!/usr/bin/python > #Python 2.6.6 > > import time > > for t in range(5): >

Re: [Tutor] Where is sys.py?

2011-08-21 Thread Peter Otten
Lisi wrote: > If sys.py is a file, it must be somewhere; but I can't find it. Where is > it? I would like to look at it. You are out of luck, there is no sys.py. The sys module is so tightly integrated that Python cannot run without it; it has to be part of the interpreter and is written in C.

Re: [Tutor] Please help understanding unittest fixtures

2011-08-22 Thread Peter Otten
Steven D'Aprano wrote: > D. Guandalino wrote: >> In this case is there a >> way to force just one setUp() call? > > > I don't know if this is the best way, but the first way that comes to > mind is this: > > > class C(TestCase): > initialised = False > def setUp(self): > if

Re: [Tutor] eval func with floating...

2011-08-23 Thread Peter Otten
simulacrx wrote: > check=(1,2,3,4,5,6,7,8,9,"/","*","-","+","(",")","[","]") You have to quote the digits: 1 is an integer while "1" is a string of length one: >>> "1" == 1 False Also, you forgot the "0". Note that there's no need to use a tuple as set() will happily accept a string: check

Re: [Tutor] eval func with floating...

2011-08-23 Thread Peter Otten
Chanakya Mitra wrote: [simulacrx] > c=set(a).intersection(set(check)) [Chanakya Mitra] > shouldn’t this be: > c=set(a).issubset(set(check)) > ? > set(a).intersection(set(check)) will be true as long as only one element > appears in both. ie. 15/a8 kill the process and spit out an error instead >

Re: [Tutor] Help with if-elif-else structure

2011-08-26 Thread Peter Otten
Robert Sjoblom wrote: > #assuming target number 15 > roll = (result, initial_mins, initial_max) > if roll[0] > 15: > if roll[1] >= 2: > print("Success") > elif roll[2] >= 2: > print("Critical failure!") > else: > print("Failure.") > elif roll[0] <= 15: > if

Re: [Tutor] largest palindrome number

2011-08-27 Thread Peter Otten
surya k wrote: > If you take a close look at my code. > > for i in range (1,100) : > for j in range (i,100) : >Temp = palindrome(i*j) > > here, as the loop goes on, i*j can never become smaller in any case. > which is why I think it, as long as "PNum" gets a new number, its > bigger

Re: [Tutor] Can't find error :-(

2011-08-28 Thread Peter Otten
Lisi wrote: > Here is the error message: > /usr/local/bin/AddressBook: line 6: syntax error near unexpected token `(' > /usr/local/bin/AddressBook: line 6: `name = raw_input("Type the Name - > leave blank to finish")' > > (sorry KMail wrapped it.) > > Here is what I typed: > name = raw_input("Ty

Re: [Tutor] Loops and matrices'

2011-08-29 Thread Peter Otten
Reed DA (Danny) at Aera wrote: > I have a matrix which contains temperatures. The columns are time, spaced > 33 seconds apart, and the rows are depth intervals. What I'm trying to do > is create another matrix that contains the rate of change of temperature > for each depth. The array is called LS

Re: [Tutor] select particular directories and files

2011-08-29 Thread Peter Otten
questions anon wrote: > I am trying to select particular files within a particular subdirectory, I > have been able to do both but not together! > When I try to select my files within the dir loop nothing comes up, but > when I leave the files outside the dir loops it selects all the files > not j

Re: [Tutor] xml parsing without a root element

2011-08-30 Thread Peter Otten
rail shafigulin wrote: > hello everyone. > > i need to parse a an xml-like file. the problem that i'm facing is that > this file doesn't have the root element but in all other terms it is the > same as xml, i.e > > > > > > > > > > does anybody know if there is a module in python that all

Re: [Tutor] reclassify values in an array

2011-09-01 Thread Peter Otten
questions anon wrote: > I have been going round in circles trying to solve something that sounds > simple. I have a huge array and I would like to reclassify the values. > Firstly just make them zeros and ones, for example if the values in the > array are less than 100 make them 0 and if greater t

Re: [Tutor] use of logging module is shared by all?

2011-09-01 Thread Peter Otten
James Hartley wrote: > I'm just needing to verify some behavior. > > Functionality within the logging module is exercised by calling functions > defined within the module itself. I am using SQLAlchemy for database > access, but it can be configured to dump out intermediate access > information >

Re: [Tutor] 'function' object has no attribute 'writer'

2011-09-05 Thread Peter Otten
Susana Iraiis Delgado Rodriguez wrote: Susana, please use 4-space indents for your code samples. I've said it before, but I think it's worthwhile repeating because it makes it much easier to grasp the structure of a script at first sight. > But now I get a differente error, this script is going

Re: [Tutor] how to sort the file out

2011-09-07 Thread Peter Otten
lina wrote: > HI, I have two files, one is reference file, another is waiting for adjust > one, > > File 1: > > 1 C1 > 2 O1 [...] > 33 C19 > 34 O5 > 35 C21 > > File 2: > 3 H16 > 4 H5 [...] > 39 H62 > 40 O2 > 41 H22 > > I wish the field 2 from file 2 arranged the same sequence as the field > 2

Re: [Tutor] how obsolete is 2.2, and a pickle question

2011-09-08 Thread Peter Otten
c smith wrote: > oh, and a question on 'pickle': > can pickle deserialize things that were not serialized by python? > can it convert data into a python data type regardless of it was > originally a 'c array' or something else that python doesn't support? As long as the file written by C is a val

Re: [Tutor] understanding **kwargs syntax

2011-09-08 Thread Peter Otten
John wrote: > Following up on this... > > Why does pylint seem to think it is a bad idea? > > Description ResourcePathLocationType > ID:W0142 plot_ts_array_split_x: Used * or ** > magic tsplot.py /research.plot line 299PyLint Problem I would guess it's a rea

Re: [Tutor] need advice about a dictionary ({})

2011-09-08 Thread Peter Otten
Richard D. Moores wrote: > I've succeeded in writing a dictionary ({}) that I can use as a small > personal phone book. The dictionary (very shortened and simplified) > looks like this in the script; > > p = {} > > p['bp1'] = 'xxx' > p['bp2'] = 'ooo' > p['ch'] = 'zzz' > p['me'] = 'aaa' > p['mg']

Re: [Tutor] a quick Q: what does the "collapse" mean?

2011-09-08 Thread Peter Otten
Steven D'Aprano wrote: > lina wrote: > >> one example: >> >> def info(object, spacing=10, collapse=1): >> """Print methods and docs strings. >> >> Take modules, class, list, dictionary, or strong.""" >> methodList = [e for e in dir(object) if callable(getattr(object, e))] >> pro

Re: [Tutor] Get a single random sample

2011-09-09 Thread Peter Otten
kitty wrote: > Hi, > > I'm new to python and I have read through the tutorial on: > http://docs.python.org/tutorial/index.html > which was really good, but I have been an R user for 7 years and and am > finding it difficult to do even basic things in python, for example I want > to import my data

Re: [Tutor] Get a single random sample

2011-09-09 Thread Peter Otten
Steven D'Aprano wrote: > # Get ten random samples, sampling with replacement. > samples = [random.choice(subset) for i in range(10)] That may include subset items more than once. Use the aptly named random.sample(subset, 10) to avoid that. ___ Tu

Re: [Tutor] Get a single random sample

2011-09-09 Thread Peter Otten
Peter Otten wrote: > Steven D'Aprano wrote: > >> # Get ten random samples, sampling with replacement. I can quote. But not read ;( >> samples = [random.choice(subset) for i in range(10)] Sorry for the noise. ___ Tutor mailli

Re: [Tutor] taking input for a list in a list

2011-09-26 Thread Peter Otten
surya k wrote: > Actually my programming language is C.. learning python. > > I'm trying to write sudoku program for which I need to take input. > This is what I did merely > > *list = [] > for i in range (0,4) : > for j in range (0,4) : >list[i][j].append (" int (raw_input("En

Re: [Tutor] last part of my programme

2011-09-29 Thread Peter Otten
ADRIAN KELLY wrote: > can anyone tell me why the last part of my programme wont work. i want > the user to have to press enter to exit but it doesn't happen through the > python interface. > > the programme works fine otherwise but just shuts down when finished (I'm assuming you are on Windows

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