Re: [Tutor] RE Silliness

2009-01-05 Thread bob gailer
Omer wrote: Bob, I tried your way. >>> import re >>> urlMask = r"http://[\w\Q./\?=\R]+()?" >>> text=u"Not working examplehttp://this.is.a/url?header=nullAnd another linehttp://and.another.url"; >>> re.findall(urlMask,text) [u'&

Re: [Tutor] Convert values in a list back and forth from ints and time

2009-01-05 Thread bob gailer
. FWIW you could dispense with reverse in convertValue by testing the type of value for int or str. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Convert values in a list back and forth from ints and time

2009-01-06 Thread bob gailer
Sander Sweers wrote: On Tue, Jan 6, 2009 at 04:38, bob gailer wrote: I also suggest splitting convertValue into two functions, one that takes strings and one that takes numbers. A lot easier to read and maintain. FWIW you could dispense with reverse in convertValue by testing

Re: [Tutor] Getting multi-line input from user

2009-01-06 Thread bob gailer
r_input.append(entry) entry = raw_input("") user_input = ' '.join(user_input) print user_input 2) How can I combine and print the output so that paragraphs and the like are preserved? I don't understand. Please give an example. -- Bob Gailer Chapel Hill NC 919-636-

Re: [Tutor] variable number of inputs

2009-01-07 Thread bob gailer
to call the function and put in as many arguments as you want. Say it's a really simple function just adding them all together or something (I know sum does that, but I'm just thinking of a simple example). def func(*a) # a will be a tuple of whatever arguments are passed in the call

Re: [Tutor] Selecting first matching element from a list

2009-01-12 Thread bob gailer
2: desired = lst2[0] else: deal with element not found. OR for x in lst: if cond(x): break else: deal with element not found. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] HOW DO I PYTHONIZE A BASICALLY BASIC PROGRAM?

2009-01-12 Thread bob gailer
e scripts. That's really unfortunate. Would you for your learning take one of them, tell us what if any parts of it you understand and let us nudge you toward more understanding. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor m

Re: [Tutor] Selecting first matching element from a list

2009-01-14 Thread bob gailer
Noufal Ibrahim wrote: bob gailer wrote: 2) "looks bad" and "is ugly" are emotional responses. What are you feeling and wanting when you say those things? It's hard for me to qualify really but my general idea of list comprehensions is that they transform and fi

Re: [Tutor] single key ordered sequence

2009-01-15 Thread bob gailer
dictionary is, for practical purposes, unpredictable. BTW [item for item in mydict.iteritems()] can be written as just mydict.items(). Kent I realise that what you have said is true, however can you show me a case where > items = dict(items).items() will not preserve order?

Re: [Tutor] Translating FORTRAN (77?) to Python?

2009-01-17 Thread bob gailer
Wayne Watson wrote: I may have a need down the line to convert a large number of lines of FORTRAN code to Python. Is there a good translator available to do this? I guess from the responses and Google Search that no such translator exists. It is possible but not trivial to write one. I probabl

Re: [Tutor] Convert String to Int

2009-01-18 Thread bob gailer
ut as a string, check and see if it's convertible to an integer, convert it if it is and ask them to try again if it's not? a = raw_input("Enter an integer:") if a.isdigit(): # process input else: # complain -- Bob Gailer Chapel Hill NC 919-636-4239 _

Re: [Tutor] Concerning Programming Exercise #6 of Chapter 2 of Python Programming John Zelle Textbook

2009-01-20 Thread bob gailer
: 10 The value in 1 years is 105.0 The value in 2 years is 215.25 The value in 3 years is 331.0125 The value in 4 years is 452.563125 And so on.. ^Please help me!!! ___ Tutor maillist - Tutor@python.org http://mail.py

Re: [Tutor] bruteforce match word in text file

2009-01-21 Thread bob gailer
d = 'loser' wordlist = '/home/david/Challenge-You/wordlist.txt' try: words = open(wordlist, 'r').readlines() except IOError, e: print "Sorry no words" for word in words: word = word.replace("\n","") if password in word:

Re: [Tutor] bruteforce match word in text file

2009-01-21 Thread bob gailer
David wrote: bob gailer wrote: David wrote: I have to ask for a pointer, not sure what I am doing wrong. The first thing you are doing "wrong" is failing to tell us what is in the wordlist file and what results you get when you run the program. Please re-post with that i

Re: [Tutor] bruteforce match word in text file

2009-01-21 Thread bob gailer
David wrote: Thanks Bob, I changed the wordlist.txt to next block is meat and the program; #!/usr/bin/python password = 'loser' wordlist = '/home/david/Challenge-You/wordlist.txt' try: words = open(wordlist, 'r').readlines() except IOError, e: print &quo

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
) will certainly have a "find", "replace", or even "find in files" (to search multiple files for a value) function, but this is searching for one string at a time. I would like to search a text file for a list of strings, like a sql query. For instance: To search a

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
Jay Jesus Amorin wrote: Thanks bob. I want to search any characters in test after https://www.localhost.org/ <https://www.localhost.org/testmodule/dev/trunk/admin/sql/mytest.sql> and the search will end after it finds another / and when i print it will display *testmodule*. Ah

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
eShopping wrote: Bob I am trying to read UNFORMATTED files. The files also occur as formatted files and the format string I provided is the string used to write the formatted version. I can read the formatted version OK. I (naively) assumed that the same format string was used for both

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
Please always reply-all so a copy goes to the list. We all participate and learn. Would you also respond to my requests for clarified algorithm? cclpia...@comcast.net wrote: Hi Bob, Thanks for your input! I ran the program in IDLE and it worked just fine. Apparently my calculations were

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
On 1/18/2011 9:34 AM, Karim wrote: Hello Bob, Thanks for this better and simple approach! To be perfect I would like to be able to do. >>> type = CategoryType() >>> type.TRANSISTOR Add to the class: def __getattr__(self, name): return self.enums[name] Note th

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* _

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