[Tutor] class methods: using class vars as args?

2010-05-23 Thread Alex Hall
Hello all, I know Python reasonably well, but I still run into basic questions which those over on the other python list request I post here instead. I figure this would be one of them: Why would this not work: class c(object): def __init__(self, arg1, arg2): self.arg1=arg1 self.arg2=arg2 d

[Tutor] 2d list index inverting?

2010-05-25 Thread Alex Hall
Hello all, I have a 2d list being used for a battleship game. I have structured the program so that it uses a grid class, which implements this array along with a bunch of other methods and vars. For example, to get at the top left square, you would say: Grid.getSquareAt(0,0) and inside getSquareAt

Re: [Tutor] 2d list index inverting?

2010-05-25 Thread Alex Hall
On 5/25/10, Hugo Arts wrote: > On Wed, May 26, 2010 at 3:13 AM, Alex Hall wrote: >> Hello all, >> I have a 2d list being used for a battleship game. I have structured >> the program so that it uses a grid class, which implements this array >> along with a bunch of

Re: [Tutor] 2d list index inverting?

2010-05-25 Thread Alex Hall
On 5/25/10, Hugo Arts wrote: > On Wed, May 26, 2010 at 3:47 AM, Alex Hall wrote: >> >> I thought so, but I was hoping you would not say that as this means a >> logic bug deep in my code, and those are the hardest to track down... > > Unfortunately, yes. Bug hunting is

[Tutor] Battleship grid not working how I expect

2010-05-27 Thread Alex Hall
Hi all, I very much hoped not to have to do this, but I have been staring at my code for two days and I just cannot see what is going on. http://www.gateway2somewhere.com/bs.zip has my code in it. You need wxPython to run it. speech.py has some pywin stuff, but that is only to interface with screen

Re: [Tutor] class methods: using class vars as args?

2010-05-27 Thread Alex Hall
Thanks for all the explanations, everyone. This does make sense, and I am now using the if(arg==None): arg=self.arg idea. It only adds a couple lines, and is, if anything, more explicit than what I was doing before. On 5/27/10, Mark Lawrence wrote: > On 23/05/2010 20:40, Alex Hall wr

[Tutor] disregard Battleship post (for now)

2010-05-28 Thread Alex Hall
Hi all, A couple days ago I posted a request for help with a strange problem with my Battleship game. I finally double-checked the constructor for a wx.GridSizer and, to my surprise, found that I had reversed the column/row args in my call to said constructor. I will have to confirm with a sighted

Re: [Tutor] disregard Battleship post (for now)

2010-05-28 Thread Alex Hall
On 5/28/10, Hugo Arts wrote: > On Fri, May 28, 2010 at 11:06 PM, Alex Hall wrote: >> Hi all, >> A couple days ago I posted a request for help with a strange problem >> with my Battleship game. I finally double-checked the constructor for >> a wx.GridSizer and, to my

[Tutor] class methods as static methods?

2010-05-29 Thread Alex Hall
Hi all, In Battleship, I have a weapons.py file, currently with just one missile type (a Harpoon anti-ship missile). This Harpoon class defines a getImpactCoords method, which returns all coordinates on the map that it will hit. I would like to not instantiate a Harpoon object, just call the Harpoo

Re: [Tutor] class methods as static methods?

2010-05-29 Thread Alex Hall
On 5/29/10, Mark Lawrence wrote: > On 29/05/2010 20:49, Alex Hall wrote: >> Hi all, >> In Battleship, I have a weapons.py file, currently with just one >> missile type (a Harpoon anti-ship missile). This Harpoon class defines >> a getImpactCoords method, which returns

Re: [Tutor] class methods as static methods?

2010-05-30 Thread Alex Hall
On 5/30/10, Alan Gauld wrote: > "Alex Hall" wrote > >> that it will hit. I would like to not instantiate a Harpoon object, >> just call the Harpoon's getImpactCoords method and pass it the >> required arguments. Is this possible? > > Others have

[Tutor] playing game across internet: suggestions for design?

2010-05-30 Thread Alex Hall
Hi all, While Battleship is not quite where I want it in terms of weapons, and while I await a response on another list to improve that, I figured I would at least start inquiries on the internet front. My plan is to let myself and a friend play each other at the game over the internet. I realize t

Re: [Tutor] playing game across internet: suggestions for design?

2010-05-31 Thread Alex Hall
On 5/31/10, Alan Gauld wrote: > > "Alex Hall" wrote > >> I realize that one of us will have to play server and the other >> client, but the roles nake no difference. > > Actually since there are only two players in Battleships you > could dispense with a s

[Tutor] sockets, servers, clients, broadcasts...?

2010-06-03 Thread Alex Hall
Hi all, I am a CS major, so I have had the required networking class. I get the principles of networking, sockets, and packets, but I have never had to actually implement any such principles in any program. Now I have this Battleship game (not a school assignment, just a summer project) that I am t

Re: [Tutor] sockets, servers, clients, broadcasts...?

2010-06-04 Thread Alex Hall
to strange problems because of process scheduling and blocking (or not blocking)? On 6/4/10, spir wrote: > On Thu, 3 Jun 2010 18:03:34 -0400 > Alex Hall wrote: > >> Hi all, >> I am a CS major, so I have had the required networking class. I get >> the principles of network

Re: [Tutor] sockets, servers, clients, broadcasts...?

2010-06-04 Thread Alex Hall
On 6/4/10, Alan Gauld wrote: > > "Alex Hall" wrote > >> connect to you as a client. It appears, though, that I need a loop >> to >> have a server make any sense at all, to handle incoming data and >> connection requests. > > You need to liste

[Tutor] while loops causing python.exe to crash on windows

2010-06-06 Thread Alex Hall
-- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com; http://www.facebook.com/mehgcap ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] while loops causing python.exe to crash on windows

2010-06-06 Thread Alex Hall
On 6/6/10, bob gailer wrote: > On 6/6/2010 8:44 PM, Alex Hall wrote: >> -- >> Have a great day, >> Alex (msg sent from GMail website) >> mehg...@gmail.com;http://www.facebook.com/mehgcap >> >> > What is your question? > > > -- > Bob Gailer &

Re: [Tutor] while loops causing python.exe to crash on windows

2010-06-06 Thread Alex Hall
On 6/6/10, Lie Ryan wrote: > On 06/07/10 11:08, Alex Hall wrote: >> On 6/6/10, bob gailer wrote: >>> On 6/6/2010 8:44 PM, Alex Hall wrote: >>>> -- >>>> Have a great day, >>>> Alex (msg sent from GMail website) >>>> mehg...@gm

[Tutor] while loops / listeners

2010-06-06 Thread Alex Hall
Hi all, First off, I apologize to the list for my previous thread; somehow, despite my having written the post, it ended up blank () I have a main loop which will continue for as long as neither player1 nor player2 has won. Inside that loop I have a call to a function which should basically wa

Re: [Tutor] Looking for duplicates within a list

2010-06-11 Thread Alex Hall
On 6/11/10, Ken G. wrote: > I have been working on this problem for several days and I am not making > any progress. I have a group of 18 number, in ascending order, within a > list. They ranged from 1 to 39. Some numbers are duplicated as much as > three times or as few as none. FYI, Python's

Re: [Tutor] Python a substitute/alternative for PhP?

2010-06-11 Thread Alex Hall
Personally, I would learn Python. My college does not offer Python either, so I had to learn what I know on my own(of course, by that I mean constantly pestering this and other of the amazing Python email lists). PHP is fine in itself, but, after using it, Java, and intros to a few other languages,

Re: [Tutor] winsound.Beep(500,500) "Failed to beep"

2010-06-12 Thread Alex Hall
Not that it helps much, but using win7x64 and Python 2.6 it works as expected. Possibly your sound card? Update drivers? On 6/12/10, Richard D. Moores wrote: import winsound winsound.Beep(500,500) > Traceback (most recent call last): > File "", line 1, in > RuntimeError: Failed to be

Re: [Tutor] New to this

2010-06-20 Thread Alex Hall
On 6/20/10, Neil Thorman wrote: > I'm picking this up as a hobby really, not having done any programming since > Acorn I'm pretty much starting form scratch (and even back in the BASIC day > I never really got to grips with files). > This is from Alan Gauld's Learning to Program: Handling Files. >

Re: [Tutor] New to this

2010-06-20 Thread Alex Hall
On 6/20/10, Steven D'Aprano wrote: > On Mon, 21 Jun 2010 09:02:55 am Alex Hall wrote: >> On 6/20/10, Neil Thorman wrote: > [...] >> >>>>inp = file("menu.txt", "r") >> > >> > *What is inp? What does it now contain?* >>

[Tutor] upgrade from 2.6.2 to 2.6.5?

2010-06-22 Thread Alex Hall
Hi all, I am having problems with the Durus package, and I was told that changing Python versions might help. Most of the other dependencies of the project I have are 2.6 only, so I do not want to change versions from 2.6.x, but I would like to try upgrading to 2.6.5 to see if that fixes things. Wi

Re: [Tutor] upgrade from 2.6.2 to 2.6.5?

2010-06-22 Thread Alex Hall
Thanks, I'll go upgrade then, and hope this fixes things with this package! On 6/22/10, Tim Golden wrote: > On 22/06/2010 13:40, Alex Hall wrote: >> Hi all, >> I am having problems with the Durus package, and I was told that >> changing Python versions might help. Most

Re: [Tutor] GUI Creation Aide

2010-07-14 Thread Alex Hall
On 7/14/10, Corey Richardson wrote: > Hey tutors! I'm creating a GUI for a program. Really simple. I don't > mind coding it out, but I was looking into things like Glade and the > like. Do you recommend those over just coding it out by hand, or should > I try Glade (or similiar) out? Also, I don't

[Tutor] attachments?

2010-07-21 Thread Alex Hall
-- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com; http://www.facebook.com/mehgcap ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] "expected an indented block" (see attached)

2010-07-22 Thread Alex Hall
Hi all, Attached is a file. When I run the program it is part of, I get an error that says: line 62: IndentationError: expected an indented block. I can see nothing wrong with the indentation, though. This is part of my Battleship game, defining all the different ships and aircraft the user can ha

Re: [Tutor] "expected an indented block" (see attached)

2010-07-22 Thread Alex Hall
On 7/22/10, Evert Rol wrote: >> Attached is a file. When I run the program it is part of, I get an >> error that says: >> line 62: IndentationError: expected an indented block. > > This function: > > def fromString(self, str): > #creates a Craft object from the string > #end class Craft > > > I

Re: [Tutor] "expected an indented block" (see attached)

2010-07-22 Thread Alex Hall
On 7/22/10, Hugo Arts wrote: > On Thu, Jul 22, 2010 at 3:35 PM, Evert Rol wrote: >>> Attached is a file. When I run the program it is part of, I get an >>> error that says: >>> line 62: IndentationError: expected an indented block. >> >> This function: >> >> def fromString(self, str): >> #creat

[Tutor] sound libraries?

2010-07-22 Thread Alex Hall
Hi all, I am curious. If I wanted a library that would let me play sounds at specific positions in the stereo field, then update that position as the user "moved" so that it would seem to be a fixed reference point, what would I use? For example, say the left/right arrows move you left and right. I

Re: [Tutor] (no subject)

2010-07-22 Thread Alex Hall
This message was blank, I am not sure if that was the idea or not. On 7/22/10, ankur wrote: > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Have a gre

Re: [Tutor] how i can change two lists into one directory

2010-07-22 Thread Alex Hall
On 7/22/10, ANKUR AGGARWAL wrote: > hey i have just started making a app using python and just gt a problem.. > > i have two list > a=["x","z"] > b=[1,2] > > i want to make a directory like this It is called a dictionary, actually. > c={"x":1,"z":2} > > is it possible i mean i tried it using

Re: [Tutor] sound libraries?

2010-07-22 Thread Alex Hall
> Sent from my iPhone > > On Jul 22, 2010, at 6:49 PM, Alex Hall wrote: > >> Hi all, >> I am curious. If I wanted a library that would let me play sounds at >> specific positions in the stereo field, then update that position as >> the user "moved"

[Tutor] web-based python?

2010-08-01 Thread Alex Hall
Hi all, I have an IPowerWeb.com server, which claims to support Python. How would I use this? For example, to start, how would I print html code to the screen, or manage input from a form? Thanks. -- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com; http://www.facebook.com/m

Re: [Tutor] web-based python?

2010-08-01 Thread Alex Hall
On 8/1/10, Hugo Arts wrote: > On Sun, Aug 1, 2010 at 7:07 PM, Alex Hall wrote: >> Hi all, >> I have an IPowerWeb.com server, which claims to support Python. How >> would I use this? For example, to start, how would I print html code >> to the screen, or manag

Re: [Tutor] web-based python?

2010-08-01 Thread Alex Hall
On 8/1/10, bob gailer wrote: > On 8/1/2010 1:07 PM, Alex Hall wrote: >> Hi all, >> I have an IPowerWeb.com server, which claims to support Python. How >> would I use this? For example, to start, how would I print html code >> to the screen, or manage input fro

[Tutor] how to get str() to use my function?

2010-08-04 Thread Alex Hall
Hi all, I have a card class. A card object simply consists of a pair of numbers; 0,0 might be the ace of clubs, for example. I have a toString method in my card class. Is there a way to just say str(card) instead of card.toString()? Maybe some sort of basic, built-in function to override? TIA. Oh,

Re: [Tutor] how to get str() to use my function?

2010-08-04 Thread Alex Hall
self.card1)+','+str(self.card2)) > ... >>>> a = card(0,0) >>>> str(a) > '0,0' > > On Wed, Aug 4, 2010 at 10:37 AM, Alex Hall wrote: > >> Hi all, >> I have a card class. A card object simply consists of a pair of >> numbers;

Re: [Tutor] how to get str() to use my function?

2010-08-04 Thread Alex Hall
Thanks, and I also see what I did wrong with my __eq__ function. On 8/4/10, Huy Ton That wrote: > These are special method names. > > View section 3.4 and below here > > http://docs.python.org/reference/datamodel.html > > On Wed, Aug 4, 2010 at 11:37 AM, Alex Hall wrote: &

[Tutor] access class through indexing?

2010-08-04 Thread Alex Hall
Hi all, Further to my questions about overriding builtin methods earlier, how would I make a class able to be accessed and changed using index notation? For example, take the following: deck=CardPile(52) #creates a new deck of cards print(len(deck)) #prints 52, thanks to my __len__ function for c i

Re: [Tutor] access class through indexing?

2010-08-04 Thread Alex Hall
On 8/4/10, Jerry Hill wrote: > On Wed, Aug 4, 2010 at 4:17 PM, Alex Hall wrote: > >> Hi all, >> Further to my questions about overriding builtin methods earlier, how >> would I make a class able to be accessed and changed using index >> notation? For example, take t

Re: [Tutor] access class through indexing?

2010-08-04 Thread Alex Hall
On 8/4/10, Evert Rol wrote: Further to my questions about overriding builtin methods earlier, how would I make a class able to be accessed and changed using index notation? For example, take the following: deck=CardPile(52) #creates a new deck of cards print(len(deck)) #pr

Re: [Tutor] access class through indexing?

2010-08-04 Thread Alex Hall
On 8/4/10, Dave Angel wrote: > Alex Hall wrote: >> On 8/4/10, Evert Rol wrote: >> >>> >>> That depends how you create the Pile of 52 cards: list(52) also doesn't >>> generate 52 (random) items. >>> If you override __init__ to accept a

Re: [Tutor] flow problem with a exercise

2010-08-19 Thread Alex Hall
On 8/19/10, Roelof Wobben wrote: > > Hello, > > > > I have this exercise: > > > > Now write the function is_odd(n) that returns True when n is odd and False > otherwise. Include doctests for this function as you write it. > Finally, modify it so that it uses a call to is_even to determine if its >

Re: [Tutor] design of Point class

2010-08-20 Thread Alex Hall
On 8/20/10, Gregory, Matthew wrote: > Hi all, > > I often struggle with object design and inheritance. I'd like opinions on > how best to design a Point class to be used in multiple circumstances. > > I typically deal with geographic (either 2D or 3D) data, yet there are > occasions when I need n

Re: [Tutor] input problem

2010-08-22 Thread Alex Hall
On 8/22/10, Roelof Wobben wrote: > > Hello, > > > > I made this programm : > > > > def count_letters(n,a): > count = 0 > for char in n: > if char == a: > count += 1 > return count > > fruit="" > letter="" > fruit= input("Enter a sort of fruit: ") > teller = input("E

[Tutor] args to functions in a dictionary?

2010-08-25 Thread Alex Hall
Hi all, If I wanted to have a dictionary containing functions, could I pass args to those functions? For example: menu={ "option 1":f1, "option 2":f2 } How would I pass args to f1 or f2 in this case? TIA. -- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com; http://www.face

Re: [Tutor] args to functions in a dictionary?

2010-08-25 Thread Alex Hall
On 8/25/10, Wayne Werner wrote: > On Wed, Aug 25, 2010 at 4:58 PM, Alex Hall wrote: > >> Hi all, >> If I wanted to have a dictionary containing functions, could I pass >> args to those functions? For example: >> menu={ >> "option 1":f1, >>

Re: [Tutor] Trouble with exercise regarding classes

2010-08-25 Thread Alex Hall
On 8/25/10, Andrew Martin wrote: > All I want to do is add a line that displays that maximum height the > cannonball reaches. I created a variable zenith to store the highest y > value. I then wanted to compare the current y value of the cannonball to > zenith while the cannonballs y value is grea

Re: [Tutor] Giving a name to a function and calling it, rather than calling the function directly

2010-09-04 Thread Alex Hall
On 9/4/10, lists wrote: > Hi folks, > > I'm new to Python, I'm working my way through some intro books, and I > have a question that I wonder if someone could help me with please? > > This is my attempt at solving an exercise where the program is > supposed to flip a coin 100 times and then tell y

[Tutor] list dll functions?

2010-09-14 Thread Alex Hall
Hi all, Out of curiosity: I know I can call dll functions from python using the win32 lib, but is there any way to simply "examine" a loaded dll to see all of the functions and attributes it exposes for use? I would do no good with a hex editor since I have no idea what all the numbers mean, so I a

Re: [Tutor] list dll functions?

2010-09-14 Thread Alex Hall
On 9/14/10, R. Alan Monroe wrote: >> the win32 lib, but is there any way to simply "examine" a loaded dll >> to see all of the functions and attributes it exposes for use? I would > > http://www.dependencywalker.com/ A great program, thanks! Best of all, for me anyway, it works well (so far) with

Re: [Tutor] Why are arguments sometimes on the left side?

2010-09-20 Thread Alex Hall
On 9/20/10, Michael Scharf wrote: > Hi, > > > Why is it > > > >list0.extend(list1) > > > > and not > > >extend(list 0, list1) > > > > or > > >stri0 = stri0.strip() > > > and not > > >stri0 = strip(stri0) This is because you are calling methods on objects, in this case strings and

[Tutor] functions: use return or exceptions?

2010-09-23 Thread Alex Hall
Hi all, A general coding question: is it better to use return(False) (or 0, or -1, or whatever) or to raise whateverError("oops")? Are there cases for each? -- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com; http://www.facebook.com/mehgcap _

Re: [Tutor] functions: use return or exceptions?

2010-09-23 Thread Alex Hall
practice, depending on the implications, but > that's my general idea usually. > > - > Sent from a mobile device with a bad e-mail client. > - > > On Sep 23, 2010, at 2:47 PM, Wayne Werner wrote: > >> On Thu, Sep 23, 2010 at

[Tutor] dynamic arrays?

2010-09-27 Thread Alex Hall
Hi all, One thing I have never much liked about Python is its need for specifically sized arrays and lack of a dynamic, array-like data structure. For example, the following fails with a "list assignment index out of range" error: a=[] i=0 for l in open("file.txt", "r"): a[i]=l i+=1 Is there

Re: [Tutor] dynamic arrays?

2010-09-27 Thread Alex Hall
On 9/27/10, Brian Jones wrote: > On Mon, Sep 27, 2010 at 11:32 AM, Alex Hall wrote: > >> Hi all, >> One thing I have never much liked about Python is its need for >> specifically sized arrays and lack of a dynamic, array-like data >> structure. For example, th

Re: [Tutor] dynamic arrays?

2010-09-27 Thread Alex Hall
On 9/27/10, Brian Jones wrote: > On Mon, Sep 27, 2010 at 11:39 AM, Alex Hall wrote: > >> On 9/27/10, Brian Jones wrote: >> > On Mon, Sep 27, 2010 at 11:32 AM, Alex Hall wrote: >> > >> >> Hi all, >> >> One thing I have never much liked

[Tutor] filling 2d array with zeros

2010-09-27 Thread Alex Hall
Hi again everyone, I have a 2d array (I guess it is technically a list) which I want to fill with zeros. Later I will change some values, but any I do not change have to be zeros. I have two complex for loops, but I tried to scale things down to a couple list comprehensions and I broke things. What

Re: [Tutor] filling 2d array with zeros

2010-09-27 Thread Alex Hall
On 9/27/10, Steven D'Aprano wrote: > On Tue, 28 Sep 2010 03:54:55 am Alex Hall wrote: >> Hi again everyone, >> I have a 2d array (I guess it is technically a list) which I want to >> fill with zeros. Later I will change some values, but any I do not >> change have

Re: [Tutor] filling 2d array with zeros

2010-09-27 Thread Alex Hall
On 9/27/10, Sander Sweers wrote: > On 27 September 2010 23:15, Sander Sweers wrote: >>> objects: copying the memory location, not making a deep copy and >>> getting a duplicate object. >> >> It does not copy the object it makes multiple _references_ to the *same* >> object. > > Oops, You already

Re: [Tutor] filling 2d array with zeros

2010-09-27 Thread Alex Hall
On 9/27/10, Steven D'Aprano wrote: > On Tue, 28 Sep 2010 06:00:41 am Alex Hall wrote: >> > [ [0]*3 ]*4 behaves the same way. There's no problem in the inner >> > list, but the outer list doesn't make four copies of [0,0,0], it >> > has *one* list rep

Re: [Tutor] filling 2d array with zeros

2010-09-28 Thread Alex Hall
On 9/28/10, Steven D'Aprano wrote: > On Tue, 28 Sep 2010 11:56:33 am Alex Hall wrote: >> > (But don't forget that Python is not necessarily written in C. >> > There's Jython, written in Java, and CLPython written in Lisp, and >> > many others. How

Re: [Tutor] filling 2d array with zeros

2010-09-28 Thread Alex Hall
On 9/28/10, Dave Angel wrote: > > > On 2:59 PM, Alex Hall wrote: >> On 9/28/10, Steven D'Aprano wrote: >>> >>> >>> PyPy is a version of Python written in Python. It has an incredible >>> mission: to eventually produce versions of Python wh

[Tutor] using "in" with a dictionary

2010-09-28 Thread Alex Hall
Hi all, yet again: I have a dictionary that will look something like: d={ (1,2):"a", (3,4):"b" } How can I say: if (1,2) in d: print d[(1,2)] This is false, so I expect to have to use d.keys, but I am not quite sure how. I will be using this in a loop, and I have to know if there is a key in the

[Tutor] just what does read() return?

2010-09-30 Thread Alex Hall
Hi all, I have a parser class which is supposed to take a text file and parse it. I will then do more with the resulting data. The file is in a particular format, specified by my professor, though this is not homework (it will be used to do homework later). The file is in the format: l vx vy z vx v

Re: [Tutor] just what does read() return?

2010-09-30 Thread Alex Hall
On 9/30/10, Walter Prins wrote: > On 30 September 2010 23:32, Alex Hall wrote: > >> txt=str(self.original).split(r"\n+") #create an array where elements >> > > OK, consider this Python shell session: > >>>> s = "line1\nline2" >>

Re: [Tutor] just what does read() return?

2010-09-30 Thread Alex Hall
On 9/30/10, Steven D'Aprano wrote: > On Fri, 1 Oct 2010 08:32:40 am Alex Hall wrote: > >> I fully expected to see txt be an array of strings since I figured >> self.original would have been split on one or more new lines. It >> turns out, though, that I get this inst

[Tutor] regexp: a bit lost

2010-09-30 Thread Alex Hall
Hi, once again... I have a regexp that I am trying to use to make sure a line matches the format: [c*]n [c*]n n where c* is (optionally) 0 or more non-numeric characters and n is any numeric character. The spacing should not matter. These should pass: v1 v2 5 2 someword7 3 while these should not

Re: [Tutor] regexp: a bit lost

2010-10-01 Thread Alex Hall
On 10/1/10, Steven D'Aprano wrote: > On Fri, 1 Oct 2010 12:45:38 pm Alex Hall wrote: >> Hi, once again... >> I have a regexp that I am trying to use to make sure a line matches >> the format: [c*]n [c*]n n >> where c* is (optionally) 0 or more non-numeric ch

Re: [Tutor] regexp: a bit lost

2010-10-01 Thread Alex Hall
On 10/1/10, Steven D'Aprano wrote: > On Sat, 2 Oct 2010 01:14:27 am Alex Hall wrote: >> >> Here is my test: >> >> s=re.search(r"[\d+\s+\d+\s+\d]", l) >> > >> > Try this instead: >> > >> > re.search(r'\d+\s+\D*

[Tutor] trying it again: p2p for game

2010-10-14 Thread Alex Hall
Hi all, Alright: after a few months letting it rest, I am trying this Battleship thing again. I found a p2p library (attached) and have tried to implement it (p2p.py). However, I am always getting the same error: errno2: no connection could be made because the target machine actively refused it. I

Re: [Tutor] trying it again: p2p for game

2010-10-14 Thread Alex Hall
On 10/14/10, Steven D'Aprano wrote: > On Fri, 15 Oct 2010 01:30:56 pm Alex Hall wrote: >> Hi all, >> Alright: after a few months letting it rest, I am trying this >> Battleship thing again. I found a p2p library (attached) and have >> tried to implement it (p2p.p

[Tutor] pydoc?

2010-10-18 Thread Alex Hall
Hi all, Below is part of an email I got from someone in reply to a question about a program called brlapi. I am on Windows. Can someone explain what is going on here? > Hmm... I am relatively new to Python and have not found this pydoc. Well, I don't know how this is supposed to work on Windows.

[Tutor] 2.6 vs 2.7: package compatibility?

2010-10-24 Thread Alex Hall
Hi all, I want to run a certain program from source. One dependency, Durus, keeps giving me an error that no one can figure out. Someone said that it will work if I use 2.7 instead of 2.6, but a lot of packages I have installed work only on 2.6. I know I can install both, but here is the question:

Re: [Tutor] 2.6 vs 2.7: package compatibility?

2010-10-25 Thread Alex Hall
On 10/25/10, Tim Golden wrote: > On 25/10/2010 02:20, Alex Hall wrote: >> Hi all, >> I want to run a certain program from source. One dependency, Durus, >> keeps giving me an error that no one can figure out. Someone said that >> it will work if I use 2.7 instead of 2

Re: [Tutor] 2.6 vs 2.7: package compatibility?

2010-10-25 Thread Alex Hall
On 10/25/10, Tim Golden wrote: >> It tells me that persistent_dict does not exist, when it clearly does. >> Another user had the exact same problem when running the source on >> 2.6, but he had no problem when running 2.7. If you had an msi to >> install Durus for 2.6 specifically, it would be int

[Tutor] decorators (the "at" sign)?

2010-10-25 Thread Alex Hall
Hi all, Now that I am able to run the source code of an open source application I hope to one day help develop, I am trying to understand how it works. One thing I keep seeing is an at sign followed by a word, usually (maybe always) immediately preceeding a function definition. For example, and I k

Re: [Tutor] decorators (the "at" sign)?

2010-10-27 Thread Alex Hall
; need, and sets them back in their places (more or less). > > If you want the more complicated answer, I think I can take a reasonable > shot at showing how this works too and making an example.  But you may just > want a general description.  Also, I'm only about 4 months in

Re: [Tutor] if statement

2010-11-02 Thread Alex Hall
On 11/2/10, Glen Clark wrote: > File "/home/glen/workspace/test.py", line 19 > if confirmed == "y": >^ > SyntaxError: invalid syntax > > Why does this not work??? PyDev says "Expected:else" It may help to see the rest of the file, or at least more of the code surroundi

[Tutor] program hangs in while loop using wx.yield

2010-11-13 Thread Alex Hall
Hi all, I had this working back in the summer, but have since had to restructure some things in the code. Now, my program is hanging while it waits for the human player to take his/her turn, and I am not sure how to free it; as long as it hangs, the player cannot do anything, so it continues to han

Re: [Tutor] program hangs in while loop using wx.yield

2010-11-14 Thread Alex Hall
On 11/14/10, Alan Gauld wrote: > "Alex Hall" wrote > >> I had this working back in the summer, but have since had to >> restructure some things in the code. Now, my program is hanging >> while >> it waits for the human player to take his/her turn, and I

Re: [Tutor] program hangs in while loop using wx.yield

2010-11-14 Thread Alex Hall
On 11/14/10, Alan Gauld wrote: > "Alex Hall" wrote > >> The problem is that I want to go until there is a winner. You are >> right about just letting the mainloop of the gui handle input (I >> forgot the gui is already looping and waiting for input) but I wo

Re: [Tutor] age program

2010-11-29 Thread Alex Hall
On 11/29/10, Andre Jeyarajan wrote: > Write a short program that will perform the following:It will ask the user > for his age,it will then present the user with a menu, with 4 choices:Tell > the user whether his age is an even or an odd number > Tell the user his age squared > Tell the user how m

[Tutor] permutations?

2010-12-01 Thread Alex Hall
Hi all, I am wondering if there is a python package that will find permutations? For example, if I have (1, 2, 3), the possibilities I want are: 12 13 23 123 132 231 Order does not matter; 21 is the same as 12, but no numbers can repeat. If no package exists, does someone have a hint as to how to

Re: [Tutor] permutations?

2010-12-01 Thread Alex Hall
respond to this email to keep it in the same thread. Thanks again! Oh, to the person who asked, I have 2.6 and 2.7 installed, with the default being 2.6. On 12/1/10, bob gailer wrote: > On 12/1/2010 5:45 PM, Alex Hall wrote: >> Hi all, >> I am wondering if there is a python package

Re: [Tutor] permutations?

2010-12-01 Thread Alex Hall
it up again. Is there a better way of doing this that would avoid me having to write the function? On 12/1/10, Alex Hall wrote: > Thanks to everyone for the itertools hint; that sounds like it will work. > > Sorry I was not clearer: > 1. Order matters; I meant to say that direction do

Re: [Tutor] permutations?

2010-12-03 Thread Alex Hall
colon when used in lists. Thanks again to all! On 12/2/10, Steven D'Aprano wrote: > Alan Gauld wrote: >> >> "Alex Hall" wrote >> >>> Alright, I have it working. Now the problem is that it does not throw >>> out reversals. I tried to do this

Re: [Tutor] Newline

2010-12-03 Thread Alex Hall
On 12/3/10, Ashley Blackwell wrote: > Hello everybody, I'm new to the mailing list so I'm pretty sure I'll have > lots of questions:) That is what the list is for. :) > > It's a very basic question I have and everybody might look at this > question and say, "Wow, she reallly doesn't get it?" But o

Re: [Tutor] Newline

2010-12-04 Thread Alex Hall
On 12/4/10, Alan Gauld wrote: > > "Steven D'Aprano" wrote > >> >>> for i in (1, 2, 3): >> ... print(i, "spam", end="\n" if i==3 else "***") > > Ooooh! A new trick. > I hadn't thought of using the conditional expression there but it > makes a lot of sense. > Definitely more fun and flexible th

Re: [Tutor] Newline

2010-12-04 Thread Alex Hall
On 12/4/10, Steven D'Aprano wrote: > Alex Hall wrote: >> On 12/4/10, Alan Gauld wrote: >>> "Steven D'Aprano" wrote >>> >>>>>>> for i in (1, 2, 3): >>>> ... print(i, "spam", end="\n" if i==

[Tutor] 'or' in assignment (not if statement)?

2010-12-09 Thread Alex Hall
Hi all, I am reading the source of a project I hope to help with (http://www.qwitter-client.net). I sometimes see something like: val=val or 1 I am guessing that val is an int. If val==0, the 'or' kicks in and val=1, else the or is not needed and val=val. Am I close? Can other words or symbols be u

Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-09 Thread Alex Hall
Thanks to all for the quick responses. Python always surprises me with its shortcuts... On 12/9/10, Alan Gauld wrote: > > "Alex Hall" wrote > >> val=val or 1 > >> I am guessing that val is an int. If val==0, the 'or' kicks in and >> val=1,

[Tutor] the "**" operator?

2010-12-10 Thread Alex Hall
Hi all, I was googling a way to do something like mydict=mydict.extend(additionaldict) and someone on a forum recommends this: mydict=dict(mydict, **additionaldict) What is the ** doing here? I tried to look it up, but Google seems to ignore it since it is punctuation. The poster on the forum says

Re: [Tutor] the "**" operator?

2010-12-10 Thread Alex Hall
Thanks all! I thought update() would add an item even if it would be a duplicate, but apparently not. I also now better understand why I am always passing around *args and **kwargs when calling super(). Very interesting... On 12/10/10, Hugo Arts wrote: > On Fri, Dec 10, 2010 at 8:14 PM, A

Re: [Tutor] Problem with print

2010-12-19 Thread Alex Hall
Sorry to top-post (gMail mobile). This looks like you missed a quote, colon, or something on a line elsewhere in the file (likely above it). Find that and this should be fixed. On 12/19/10, jtl999 wrote: > File "GettingStarted.py", line 91 > print ("Lesson Two") > ^ > SyntaxError: in

[Tutor] subclass not inheriting attributes?

2011-01-03 Thread Alex Hall
Hi all, I have a solitaire game in which I use a "Pile" class. This class is meant to hold a bunch of cards, so I subclass it for the deck, the ace stacks, and the seven main stacks, defining rules and methods for each but also relying on the parent Pile class's methods and attributes. However, I k

  1   2   >