Re: [Tutor] bruteforce match word in text file

2009-01-21 Thread bob gailer
Also take a look at the syntax of the for statement and notice it has an else clause. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Volunteer opportunities

2009-01-21 Thread bob gailer
://en.wikipedia.org/wiki/Python_Pipelines for a brief description. Let me know if you want to know more. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] dict() versus {}

2009-01-21 Thread bob gailer
ot evaluate thing? How can it take it as a literal string without quotes? I suggest you look dict up in the Python documentation. There it shows the result you got as an example. When in doubt read the manual. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] dict() versus {}

2009-01-21 Thread bob gailer
al to {"one": 2, "two": 3}: ... dict( two=3) From: bob gailer To: wormwood_3 Cc: Python Tutorlist Sent: Wednesday, January 21, 2009 11:02:35 PM Subject: Re: [Tutor] dict() versus {} wormwood_3 wrote: When creating a list of dictionaries thr

Re: [Tutor] Volunteer opportunities

2009-01-21 Thread bob gailer
jadrifter wrote: On Wed, 2009-01-21 at 22:53 -0500, bob gailer wrote: Eric Dorsey wrote: Does anyone know of any good volunteer opportunities for projects that learning Python coders can work on? Or possibly nonprofits or the like that need smaller-type

Re: [Tutor] Possible to search text file for multiple string values at once?

2009-01-23 Thread bob gailer
with python? Yes - and also possible with almost all other programming languages. Here is one of several ways to do it in Python: for first_name in ('Bob', 'John', 'Joe', 'Jim', 'Fred'): if first_name in text: print first_name, 'found' -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Defining "bit" type

2009-01-24 Thread bob gailer
+ to act as or     self._value |= other   def __mul__(self, other): # causes * to act as and     self._value &= other b = Bit(1) b.value # returns 1 b.value = 0 b.value # returns 0 b.value + 1 # sets value to 1 b.value * 0 # sets value to 0 -- Bob Gailer Chapel Hill NC 919-636-4239 __

Re: [Tutor] Defining "bit" type

2009-01-24 Thread bob gailer
Vicent wrote: On Sat, Jan 24, 2009 at 19:48, bob gailer <bgai...@gmail.com> wrote:   The problem is: there is no way that I know of to add fundamental types to Python. Also realize that variables are dynamically typed - so any assignment can create a variable of a ne

Re: [Tutor] Python Program: Newton's Method

2009-01-26 Thread bob gailer
results. If the program raises an exception, post the entire traceback. If something else, explain that. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python Program: Newton's Method

2009-01-27 Thread bob gailer
t "The guess is", loops, "which is", loops - math.sqrt(x),"away from", math.sqrt(x) main() ^Do you have any suggestions as to what I should do? -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@pytho

Re: [Tutor] Find a Word in *.py (Win XP)

2009-01-29 Thread bob gailer
works with 2003 Server. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Defining "bit" type -- why not '!' ?

2009-01-30 Thread bob gailer
Lie Ryan wrote: [snip] AFAIK no CPU implements hardware logical operation). I disagree. But perhaps logical operation means different things to you. Please expand. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor

Re: [Tutor] jumping from function to function

2009-01-30 Thread bob gailer
s that of main(), but the call to f() is nested in main(); it does not "jump out". Also: does Python go back to the function call main()'s position after step 3)? Yes. when f() is called the position in main() is placed on a "stack". When f() returns, the position of

Re: [Tutor] string fomatting

2009-01-31 Thread bob gailer
1, https://www.localhost.org/ 2. testmodule 3. /dev/trunk/admin/sql/mytest.sql Thanks, Jay ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] string fomatting

2009-01-31 Thread bob gailer
ing" applies to this question. The obvious answer is: print("1, https://www.localhost.org/""; print() print("2. testmodule") print() print("3. /dev/trunk/admin/sql/mytest.sql") If that is not what you are looking fo

Re: [Tutor] string fomatting

2009-01-31 Thread bob gailer
. Much clearer. header = "https://www.localhost.org/"; test = "https://www.localhost.org/foo/bar"; # we desire to extract 'foo' start = len(header) end = test[start:].find('/') + start result = test[start: end] print res

Re: [Tutor] Determining periodicity of rand.randint()

2009-01-31 Thread bob gailer
a repeatable set of numbers at some point? I'm trying to understand the periodicity (or lack of) of the numbers generated by rand.randint() random uses AFAIK the Mersenne Twister algorithm. See http://en.wikipedia.org/wiki/Mersenne_twister -- Bob Gailer Chapel Hill NC 919-636

[Tutor] struct question

2009-02-03 Thread bob gailer
>>> struct.calcsize('s') 1 >>> struct.calcsize('d') 8 >>> struct.calcsize('sd') 16 Why? Should not that be 9? -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] reading binary files

2009-02-03 Thread bob gailer
s and report back your results. And also the FORTRAN variable types if you have access to them. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] reading binary files

2009-02-03 Thread bob gailer
("2s8s2si2s1s") items = struct.unpack("2s8s2si2s1s",data[start:stop]) print items print data[:40] I'm pretty sure that when I tried this at the other PC there were a bunch of \x00\x00 characters in the file but they don't appear in NotePad ... any

Re: [Tutor] struct question

2009-02-03 Thread bob gailer
W W wrote: On Tue, Feb 3, 2009 at 6:25 PM, bob gailer <mailto:bgai...@gmail.com>> wrote: >>> struct.calcsize('s') 1 >>> struct.calcsize('d') 8 >>> struct.calcsize('sd') 16 Why? Should not that be

Re: [Tutor] reading binary files

2009-02-04 Thread bob gailer
. At 21:41 03/02/2009, bob gailer wrote: First question: are you trying to work with the file written UNFORMATTED? If so read on. Well, did you read on? What reactions do you have? eShopping wrote: Data format: TIME 1 F 0.0 DISTANCE 10 F 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 F=

Re: [Tutor] reading binary files

2009-02-04 Thread bob gailer
>>> x=open('x','w') # write "normal" allowing \n to be translated to the OS line end. >>> x.write("Hello\n") >>> x=open('x','rb') # read binary, avoiding translation. >>> x.read() 'Hello\r\n' where \r = \x0d -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] (no subject)

2009-02-06 Thread bob gailer
Okeke emmanuel wrote: ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor At least the subject is accurate! -- Bob Gailer Chapel Hill NC

Re: [Tutor] any best practice on how to glue tiny tools together

2009-02-06 Thread bob gailer
://en.wikipedia.org/wiki/Python_Pipelines Thank you for the plug! The code is currently in flux so not available. I hope to have an alpha version out soon. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http

Re: [Tutor] any best practice on how to glue tiny tools together

2009-02-06 Thread bob gailer
quot;finalizing". Assistants are always welcome. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] improving the speed of prime number code

2009-02-06 Thread bob gailer
- there is no need to multiply remprod by the remainders as you don't use that result later. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Is this correct?

2009-02-08 Thread bob gailer
correct? -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Is this correct?

2009-02-08 Thread bob gailer
n the principal. " balance = principal + interest print balance, "is the new principal. " count = count + 1 if tuition > principal: print principal + interest, "was available for the last student." if count > 10: print count, "Students used this grant." -

Re: [Tutor] Is this correct?

2009-02-08 Thread bob gailer
Thanks again, Pat On Feb 8, 2009, at 3:11 PM, bob gailer wrote: principal = balance = 50 # Starting fund amount. interestRate = .05 # Interest rate added to the principal annually. tuition = 34986 # Starting tuition fee tuitionInc = 1.041 # The annual increase applied to the tuition.

Re: [Tutor] Reading binary files #2

2009-02-09 Thread bob gailer
etrade.griffi...@dsl.pipex.com wrote: Hi following last week's discussion with Bob Gailer about reading unformatted FORTRAN files, I have attached an example of the file in ASCII format and the equivalent unformatted version. Thank you. It is good to have real data to work with. Bel

Re: [Tutor] permutations?

2010-12-01 Thread bob gailer
Above you show some "combinations" and a subset of the permutations. What rules did you apply to come up with your result? -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscr

Re: [Tutor] a print puzzle

2010-12-02 Thread bob gailer
n I find: "All non-keyword arguments are converted to strings like str() does" Under str() I find: "returns its nicely printable representation." OK but still kinda vague. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tut

Re: [Tutor] updating databases with null values

2010-12-09 Thread bob gailer
s? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tut

Re: [Tutor] Can't even get hello to work???!!

2010-12-16 Thread bob gailer
I agree. What do we do to fix the "problem"? -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] vim as a python editor; FOLLOW-UP QUESTION

2010-12-16 Thread bob gailer
whether it makes sense (or is even possible) to use vim in Windows (I use Windows XP-SP3). FWIW I started 10 years ago using Python For Windows as my development environment. I have never regretted that choice. -- Bob Gailer 919-636-4239 Chapel Hill NC ___

Re: [Tutor] Dictionary Question

2010-12-22 Thread bob gailer
On 12/22/2010 7:31 AM, Steven D'Aprano wrote: Also note: len(dict.keys()) == len(dict.values()) == len(dict) -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] Python 2.7.1 interpreter complains about NameError: global name 'levenshtein_automata' is not defined

2010-12-27 Thread bob gailer
', 1, m))) line 174 ## I cannot understand why the Python 2.7.1 interpreter complains about NameError: global name 'levenshtein_automata' is not defined. On line 125 , I try to define levenshtein_automata(self,term,k) as a method of the class DFA. I am n

Re: [Tutor] blank space after a number

2010-12-28 Thread bob gailer
1 while b < 10: print a, b, a, b = a, b + 1 ... do you think is there any reasonable way to transform the '0' number into string and then back to numeral - after the printing action? Use formatting: print '%i%i' % (a,b) -- Bob Gailer 919-636-4239 Chapel Hill NC

Re: [Tutor] blank space after a number

2010-12-28 Thread bob gailer
: print "%02d" % b Personally I'd go for string formatting because of its much more powerful and flexible options. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] blank space after a number

2010-12-28 Thread bob gailer
Now that I understand what you want - for b in range(120): print '%0*i' % (max(2,int(math.log10(b))), b) -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription opt

Re: [Tutor] blank space after a number

2010-12-28 Thread bob gailer
On 12/28/2010 8:09 PM, bob gailer wrote: Now that I understand what you want - for b in range(120): print '%0*i' % (max(2,int(math.log10(b))), b) Sorry forgot to add import math -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tuto

Re: [Tutor] Python 2.7.1 interpreter passing function pointer as function argument and Shedskin 0.7

2010-12-28 Thread bob gailer
** testdfa = DFA(1) length = len(list(testdfa.find_all_matches('food', 1, m))) line 174 *** ___________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Bob

Re: [Tutor] syntax error that i cant spot!

2011-01-01 Thread bob gailer
#x27; >>> c = a + b >>> print c ab Now you can recall seeing it. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] syntax error that i cant spot!

2011-01-01 Thread bob gailer
t the concatenation of s and t a = 'a' b = 'b' c = a + b print c ab Now you can recall seeing it. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription option

Re: [Tutor] __init__() - is it required?

2011-01-09 Thread bob gailer
IN this case it is a waste of time. It could even do harm in cases where you ingherit from a superclass that does have an init() since the pass will mean it never gets called! Whereas if you omit the init() the suiperclass init(if it exists) will get called. HTH,

Re: [Tutor] about import statement

2011-01-10 Thread bob gailer
to be used by more than one main program. HTH. Please return with more questions. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Equality of numbers and Strings

2011-01-10 Thread bob gailer
00): s = eval("'" + 'wrtnjasdflkasjj'*n + "'") t = eval("'" + 'wrtnjasdflkasjj'*n + "'") if id(s) != id(t): print n; break whereas if I insert a ";" in the literal the program prints 1!

Re: [Tutor] Equality of numbers and Strings

2011-01-10 Thread bob gailer
hy in the program I posted I used the equivalent of eval("'" + letters*n + "'") which gives different results than eval("letters*n")! [snip] -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Missing Data in Txt Files

2011-01-10 Thread bob gailer
, and also give us enough additional details so we fully understand what you want. Sample input - sample output would help a lot. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription

Re: [Tutor] color of "print" function

2011-01-14 Thread bob gailer
mped. Could it be the glasses you are wearing. Or could you tell us just a bit more about your situation - such as WHERE does this happen? An editor, IDLE, what? -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To uns

Re: [Tutor] how to print random number multiply

2011-01-14 Thread bob gailer
e code you wrote, so we have some idea of what you mean by "bind" and "call". I could guess but you should learn to provide sufficient information so we don't have to. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tut

Re: [Tutor] When I print random.random

2011-01-14 Thread bob gailer
[0.0, 1.0). The Python tool for converting float to integer is the int function. However int(random.random() ) will always return 0. In what range do you want the integers to fall? -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist

Re: [Tutor] When I print random.random

2011-01-14 Thread bob gailer
lt;= b. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to plot graph?

2011-01-18 Thread bob gailer
Thank you for seeking help. Next time please start a new thread rather than "hijacking" an existing one. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription opt

Re: [Tutor] Convert an IP address from binary to decimal

2011-01-18 Thread bob gailer
sum = sum + 2**i i = i - 1 dec_list.append(str(sum)) dec_ip = '.'.join(dec_list) print dec_ip if __name__ == '__main__': bin_ip = sys.argv[1:] convert(bin_ip) If I knew the input to be perfect it would be a simple matter '.'.join((str(int(input_ip[x:x+8],

Re: [Tutor] What is __weakref__ ?

2011-01-18 Thread bob gailer
t the literal integer number to its associated string representation.""" return self.enums[literal] Note this does not handle invalid literal. If you are happy with range 14) you could alternatively use a list: enums = ['transistor, 'mos', ...] -- Bob Ga

Re: [Tutor] What is __weakref__ ?

2011-01-18 Thread bob gailer
is does not handle the upper/lower case issue. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] (no subject)

2011-01-19 Thread bob gailer
e a single non-tuple object. [4] Otherwise, /values/ must be a tuple with exactly the number of items specified by the format string, or a single mapping object (for example, a dictionary)." An easier way to create the list: self.board = [" "]*64 -- Bob Gail

Re: [Tutor] Telephone app

2011-01-23 Thread bob gailer
mentioned earlier - TAPI is your friend. And should I be thinking of it any differently than a USB port which has 4 pins two data(+-), and two dc current(+-)? As I warned above, YES. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist

Re: [Tutor] The trap of the year

2011-01-25 Thread bob gailer
is generally not what was intended. A way around this is to use None as the default, and explicitly test for it in the body of the function, e.g.: -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or cha

Re: [Tutor] Is it possible to make a circle of 1 hour

2011-01-28 Thread bob gailer
In future please start a new thread instead of hijacking an existing one. We track things by thread, and I almost missed your question! -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change

Re: [Tutor] Wrapping my head around global variables!!

2011-01-28 Thread bob gailer
or maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python and Tuples

2011-01-30 Thread bob gailer
e one-line version: print [x*y for x,y in t] or even better, in Python 3.x [print(x*y) for x,y in t] -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.pytho

Re: [Tutor] making object iterable

2011-02-05 Thread bob gailer
ould solve many problems. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] JES Jython

2011-02-07 Thread bob gailer
On 2/7/2011 2:45 PM, Eun Koo wrote: Hi I have a problem in JES getting a solution to a function. Is there a way you guys can help? Maybe. You might say more about the problem. What is JES and how does it relate to Python? -- Bob Gailer 919-636-4239 Chapel Hill NC

Re: [Tutor] Tutor Digest, Vol 84, Issue 56

2011-02-14 Thread bob gailer
On 2/14/2011 4:59 PM, Daniel Otero wrote: Did you want something? If so state clearly and delete all non-relevant messages. Did you notice: When replying, please edit your Subject line so it is more specific than "Re: Contents of Tutor digest..." -- Bob Gailer 919-636-4239 Chap

Re: [Tutor] Tic-Tac-Toe

2011-02-19 Thread bob gailer
ToO(c1) board.print1() print("Game Over") if __name__ == "__main__": main() ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Tic-Tac-Toe

2011-02-19 Thread bob gailer
1] != " ": print "Cell is occupied." else: board[int(cell)-1] = player if any(1 for a,b,c in ((0,3,1), (3,6,1), (6,9,1), (0,7,3), (1,8,3), (2,9,3), (0,9,4), (2,7,2)) if board[a:b:c] == [player]*3): print player, "wins" break player

Re: [Tutor] how to connect to Django's irc

2011-02-20 Thread bob gailer
.org <mailto:Tutor@python.org> To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailma

Re: [Tutor] tic tac toe

2011-02-20 Thread bob gailer
On 2/20/2011 9:49 AM, Ben Ganzfried wrote: Thanks, Bob. I'd love some specific feedback. Exactly what did I offer that you found useful? Also please always reply-all so a copy goes to the list. -- Bob Gailer 919-636-4239 Chapel Hill NC ___

Re: [Tutor] Concatenating string

2011-02-22 Thread bob gailer
How do you determine the type of an object? 1 - Use the type() function. 2 - notice '' around a and not around d 3 - Read the documentation: bin(/x/) Convert an integer number to a binary string. The documentation is weak here, but at least it tells you that the result is a string.

Re: [Tutor] help

2011-02-24 Thread bob gailer
Request: When posting a question use a meaningful subject line, as some of us track email by subject. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http

Re: [Tutor] Dictionnaries in object

2011-02-24 Thread bob gailer
ke 20 powers, it will be long no ? is there any solution shorter (and better ?) 1 - define a Power class and create instances class Power: def __init__(self, name, desc): self.name = name self.desc = desc powerAll = [ Power('Flammes infernales' , 'Embrase lenemi et le

Re: [Tutor] Dictionnaries in object

2011-02-24 Thread bob gailer
ot; target.health -=self.strenght // care about it is - = print (self.name <http://self.name>, "hit",target.name <http://target.name>, "for", self.strenght, "damage") Sorry, object is very new for me... 2011/2/24 bob gailer mailto:bgai...

Re: [Tutor] Display all field of a listuples

2011-02-24 Thread bob gailer
ot;does not work" always show us what results you got as well as what you wanted. Also get in the habit of using Capitalized names for classes and unCapitalized names for variables and functions. powerAll is a list of class instaces. You must (in some way) identify the attributes of those

Re: [Tutor] comparing strings

2011-02-25 Thread bob gailer
character representation. This is not always ASCII. On IBM Mainframes it is EBCDIC. The ord values are different, and the order is different. See http://www.dynamoo.com/technical/ascii-ebcdic.htm -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist

Re: [Tutor] PyQuery

2011-03-09 Thread bob gailer
to tell how PyQuery relates to that table. What have you tried? What results did you get? Why PyQuery as opposed to another html tool such as Beautiful Soup? The more you can tell us the easier it is for us to help. -- Bob Gailer 919-636-4239 Chapel Hill NC _

Re: [Tutor] multiple if and or statement

2011-03-14 Thread bob gailer
a. if (i == 'test1') or (i=='test2'): is one way to do what you want. Another is if i in ('test1', 'test2'): Instead of a tuple of values you could also provide a list, a set or a dictionary. -- Bob Gailer 919-636-4239 Chapel Hill NC _

Re: [Tutor] How to use a str object, to find the class in exact name?

2011-03-14 Thread bob gailer
h_command() File "./main.py", line 44, in dispatch_command method = self.GetMethod(args[0],args[1]) File "./main.py", line 25, in GetMethod a=cls() AttributeError: dispatcher instance has no __call__ method The erro

Re: [Tutor] Boolean question

2011-03-16 Thread bob gailer
Thanks for your response and for the rules, but for some reason I'm not understanding. In the above quote, what is meant by "thing"? Thing in this context means 'anything". could be a string, number, list, any Python object. True and 1 = 1 True and 'a'= &

Re: [Tutor] Print/Loop Question

2011-03-17 Thread bob gailer
between 1 - 100: ")) *if* guess > number : *print* ("Too high") *elif* guess < number : *print* ("Too low") *else*: *print* ("Just right" ) That program is not the one you ran! Something is missing! Please also inform us: Python Version Operating Syste

Re: [Tutor] lambda

2011-03-19 Thread bob gailer
t items) which should return a negative, zero or positive number depending on whether the first argument is considered smaller than, equal to, or larger than the second argument: cmp=lambda x,y: cmp(x.lower(), y.lower())." -- Bob Gailer 919-636

Re: [Tutor] lambda

2011-03-19 Thread bob gailer
indirection in code reading). def char(rec, tot): return tot + len(rec) etc -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Saving information for my program

2011-03-21 Thread bob gailer
ves under a key akin to a dictionary. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Error in programming

2011-03-24 Thread bob gailer
do this by adding the brackets around text output in line 26. This seemed to allow me to type main against margin rather than it wanting to indent but didn't fix the problem. Your suggestions would be appreciated.* ** *Thank* *Lea* _

[Tutor] Tutoring

2011-03-25 Thread bob gailer
I have recently become a tutor to several Python students. I enjoy tutoring and they benefit from it. I work with some students using remote access, so we can be geographically far apart. Who do you know who might benefit from receiving one-on-one tutoring? -- Bob Gailer 919-636-4239

Re: [Tutor] String formatting question.

2011-03-31 Thread bob gailer
IMHO % formatting is the easiest to use and understand. I am sorry that it has been slated for removal. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http

Re: [Tutor] Importing sub modules

2011-03-31 Thread bob gailer
der or destroy the material! "STRICTLY PROHIBITED" oh I am so scared! So there! -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Passing a Variable

2011-04-03 Thread bob gailer
eturn #If it gets this far, it's because the timer already ran, the player is 'safe', and another check is being performed self.auto_check() Also note if self.auto_check_timer == False: can be simplified to if

Re: [Tutor] Calling another script

2011-04-03 Thread bob gailer
bscription options: http://mail.python.org/mailman/listinfo/tutor -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Evaluating program running time?

2011-04-08 Thread bob gailer
c approaches to this? I found the "timeit" module, but that doesn't seem to be quite what I'm looking for. I like to use the time module import time start = time.time() rest of program print time.time() - start I believe that gives best precisioni on *nix On Windows use time.c

Re: [Tutor] Python on TV

2011-04-11 Thread bob gailer
video ... cannot be viewed from your currrent country ..." Sigh. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Import multiple lines of text into a variable

2011-04-11 Thread bob gailer
o me, as long as the file fits available memory. There will be 2 copies of the file after the split. Another way: textFile = open('myfile','r') for line in textFile: if line.startswith('notes'): notes = textFile.read() -- Bob Gailer 919-636-4239 Chapel Hill NC ___

Re: [Tutor] Python on TV

2011-04-15 Thread bob gailer
On 4/15/2011 3:35 PM, Alan Gauld wrote: "bob gailer" wrote The show should be here - Pause at 1 minute 20 for the Python screnshot: http://fwd.channel5.com/gadget-show/videos/challenge/surprise-special-part-4 I am told "the video ... cannot be viewed from your currrent co

Re: [Tutor] voluntary work :p:

2011-04-25 Thread bob gailer
What magic? Did you see an image of a monitor with 2 to the 38 on it? Did you see "Hint: try to change the URL address."? Did you try that? -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubs

Re: [Tutor] triple-nested for loop not working

2011-05-04 Thread bob gailer
the 3 files finalmotifs = motif_file.readlines() for line in seqalign: for item in finalmotifs: if item in line: align_file.write('~' * len(line) + '\n') # close the 3 files -- Bob Gailer 919-636-4239 Chapel Hill NC

Re: [Tutor] Reading elements in a file

2011-05-05 Thread bob gailer
available as string methods. string.capwords(s[, sep]) string.maketrans(from, to) -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo

Re: [Tutor] How to extract a value from a matrix.

2011-05-07 Thread bob gailer
does "list that has been opened from a text file" mean? Is the source of the list important (e.g. does it matter whether it comes from a file)? Please provide an example. What does the list look like? How do you determine which element you want? Bob Gailer 919-636-4239 Chap

Re: [Tutor] Python Hard_way 40

2011-05-11 Thread bob gailer
d_city" function. This stores a reference to the function. The following line is the call to the function. city_found = cities['_find'](cities,state) [snip] -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@pytho

<    5   6   7   8   9   10   11   12   13   14   >