Re: [Tutor] Dave Angel

2015-08-18 Thread wesley chun
left a message of condolence on behalf of the tutor list. > > > > Alan G. > > List moderator. > -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "A computer never does what you want... only what you tell it." +wesley chun <http://google.com/+WesleyChun> : wescpy at gmail : @

Re: [Tutor] syntax error with raw input

2014-11-12 Thread wesley chun
> > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.flickr.com/photos/alangauldphotos > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.pytho

Re: [Tutor] “has a value of True” versus “evaluates true” (was: don't understand iteration)

2014-11-10 Thread wesley chun
> >Tutor maillist - Tutor@python.org > >To unsubscribe or change subscription options: > >https://mail.python.org/mailman/listinfo/tutor > > > ___ > Tutor maillist - Tutor@python.org > To unsub

Re: [Tutor] Python open source for beginners

2014-07-16 Thread wesley chun
hat you want... only what you tell it." +wesley chun <http://google.com/+WesleyChun> : wescpy at gmail : @wescpy <http://twitter.com/wescpy> Python training & consulting : http://CyberwebConsulting.com "Core Python" books : http:

Re: [Tutor] Python 2 Vs python 3

2014-07-15 Thread wesley chun
see what has been said in the past. I also answered this question on Quora <http://www.quora.com/Python-programming-language-1/As-someone-interested-in-learning-Python-should-I-start-with-2-x-or-go-straight-to-3-x/answer/Wesley-Chun>and provided several references as well as a few talks I&

Re: [Tutor] how do I set variables in Python 3.4

2014-07-14 Thread wesley chun
goal if possible. It will help us understand what programming >> model you've got in your head. For example, can you explain what the >> first three lines of your program are intended to do? >> > > > > -- > Thank you, > Danielle Salaz > Signature Fin

Re: [Tutor] I am having difficulty grasping 'generators'

2014-05-28 Thread wesley chun
- - - - - - - - - - - - - - - - - "A computer never does what you want... only what you tell it." +wesley chun <http://google.com/+WesleyChun> : wescpy at gmail : @wescpy<http://twitter.com/wescpy> Python training & consulting :

[Tutor] OT: supporting Python & the PSF with a half/quarter-page ad?

2014-02-26 Thread wesley chun
- - - - - "A computer never does what you want... only what you tell it." +wesley chun <http://google.com/+WesleyChun> : wescpy at gmail : @wescpy<http://twitter.com/wescpy> Python training & consulting : http://CyberwebConsulting.com "Core Python"

Re: [Tutor] Regarding Exceptions

2014-02-21 Thread wesley chun
>>> __builtins__.Exception you can also find out what all the other built-ins are using dir(): >>> dir(__builtins__) ['ArithmeticError', 'AssertionError', 'AttributeError',...] hope this helps! --wesley - - - - - - - - - - - - - - - - - - - - - - -

Re: [Tutor] How to correct decimal addition.

2014-01-24 Thread wesley chun
one for someone. > > -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "A computer never does what you want... only what you tell it." +wesley chun <http://google.com/+WesleyChun> : wescpy at gmail : @wescpy<http://twitter.com/wescpy> Pyth

Re: [Tutor] List Python Question..Please help

2013-09-27 Thread wesley chun
line resources and having a hard time coming up >>> with >>> >> anything. >>> >> Please help! >>> >> >>> >> composers = ['Antheil', 'Saint-Saens', 'Beethoven', 'Easdale', >>> 'Nielsen']

Re: [Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread wesley chun
As I > said before these results will not be consistent from one computer to > another. > > > Oscar > _______ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/

Re: [Tutor] if/else option for making a choice

2013-02-18 Thread wesley chun
milar purposes however, it's easy to move back-n-forth between either via dict(), dict.items(), iter/zip(), etc. cheers, -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "A computer never does what you want... only what you tell it." +wesley chun : wescpy at gmai

Re: [Tutor] if/else option for making a choice

2013-02-18 Thread wesley chun
and add either the cost or zero, respectively. that will help keep your code less complex as well. you would just be maintaining a running total until the user is done with all their selections. good luck! -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "A computer never doe

Re: [Tutor] If a method has no return type?

2013-02-06 Thread wesley chun
27;t think of any others... can you? best regards, -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "A computer never does what you want... only what you tell it." +wesley chun : wescpy at gmail : @wescpy Python training & consulting : http://Cyberweb

Re: [Tutor] Python books

2012-11-09 Thread wesley chun
_ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor> > -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "A computer never does what you want... only what you tell

Re: [Tutor] combining c and python

2012-09-18 Thread wesley chun
another option that no one has mentioned yet is the use of 'ctypes' with existing C libraries: http://docs.python.org/library/ctypes cheers, -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "A computer never does what you want... only what you tell it.&qu

Re: [Tutor] python installation problem

2012-05-03 Thread wesley chun
fresh install, document the procedure, and make a blogpost out of it! :-) cheers, --wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "A computer never does what you want... only what you tell it."     wesley chun : wescpy at gmail : @wescpy/+wescpy     Python training &

Re: [Tutor] Emailing code

2012-04-06 Thread wesley chun
-- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "A computer never does what you want... only what you tell it."     wesley chun : wescpy at gmail : @wescpy/+wescpy     Python training & consulting : http://CyberwebConsulting.com     "Core Python" books : http://CorePython.com     Python

Re: [Tutor] generators

2012-04-03 Thread wesley chun
my Python courses that a student recorded. if interested in viewing it, you can find it half-way down http://cyberwebconsulting.com hope this helps! -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "A computer never does what you want... only what you tell it."     wesley chun

Re: [Tutor] Question about login=''.join(choice(lc) for j in range(llen))

2012-04-03 Thread wesley chun
still there even after the loop has ended. it's as if you did the following: >>> i = 0 >>> print i 0 >>> i = 1 : >>> i = 4 >>> print i # 1st time, part of the "loop" 4 >>> print i # 2nd time, "outside&quo

Re: [Tutor] New to Python programing

2012-04-03 Thread wesley chun
://cyberwebconsulting.com cheers, -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "A computer never does what you want... only what you tell it."     wesley chun : wescpy at gmail : @wescpy/+wescpy     Python training & consulting : CyberwebConsulting.co

Re: [Tutor] New to Python programing

2012-04-02 Thread wesley chun
ners with no programing > experience. Can you please suggest me a good one to use. Thank you. > > Walter -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "A computer never does what you want... only what you tell it."     wesley chun : wescpy at gmail : @wescpy/+we

Re: [Tutor] 答复: Any book to study Python

2012-03-28 Thread wesley chun
- - - - - - - - - - - - - - - - - - "A computer never does what you want... only what you tell it."     wesley chun : wescpy at gmail : @wescpy/+wescpy     Python training & consulting : CyberwebConsulting.com     "Core Python" books : CorePython.com     Python-flavored blog:

Re: [Tutor] 答复: Any book to study Python

2012-03-19 Thread wesley chun
estions, please cut-n-paste your code here along with the output, and everyone can help you more effectively. 谢谢! -- wesley - 陈仲才 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "A computer never does what you want... only what you tell it." wesley chun : wescpy at gma

Re: [Tutor] Any book to study Python

2012-03-19 Thread wesley chun
你好 Xianming, I have a book -- *Python 核 心 编 程 (第二版)* -- that is for people who already program but want to learn Python. It is available in China from at least 3 online stores: http://www.china-pub.com/39969 http://www.amazon.cn/dp/bkbk835890 http://mall.sina.com.cn/product_1749023.htm In the A

Re: [Tutor] question on self

2012-03-13 Thread wesley chun
i want to expand specifically on steve's response and note the big distinction that needs to be made for everyone is that this is primary the difference between calling a *function* and calling a *method* (which is a function that belongs to/defined for a class). with that instance (self), that me

Re: [Tutor] specific recommendation for a Python book, to move from baby-level to intermediate-level

2012-02-15 Thread wesley chun
tooting my own horn, http://corepython.com gets good reviews too. however, it does target existing programmers who want to learn Python as quickly and as comprehensively as possible. it's not a good book if you're a beginner to programming or are looking for a pure reference like PER or Nutshell.

Re: [Tutor] best book for OOP

2011-12-11 Thread wesley chun
what do you think you are missing? is there something in the book that you don't/can't understand? those of us on the list may be able to help you out... sometimes humans are better at explaining things than just books. :-) best regards, --wesley On Sun, Dec 11, 2011 at 6:49 AM, surya k wrote:

Re: [Tutor] Python Saved the Day

2011-12-04 Thread wesley chun
Congrats! I love hearing stuff like this... keep them coming! I'm curious as to how Python was able to help you get your job done this time (without going into anything confidential naturally). What was it about the language? Or was it specific Python modules/packages you used for the analysis? Do

Re: [Tutor] What's the difference between %s and %r?

2011-07-23 Thread wesley chun
27;foo') Traceback (most recent call last): File "", line 1, in File "", line 1, in NameError: name 'foo' is not defined >>> eval("'foo'") 'foo' -wesley On Sat, Jul 23, 2011 at 12:06 PM, wesley chun wrote: > %s

Re: [Tutor] What's the difference between %s and %r?

2011-07-23 Thread wesley chun
%s = send object to str() first then drop it into the string %r = send object to repr() first then drop it into the string pretty straightforward: >>> x = 'foo' >>> str(x) 'foo' >>> repr(x) "'foo'" why do people do %r at all? to get the quotes for free: :-) >>> x = 'Python' >>> print "What is t

Re: [Tutor] BF Program hangs

2011-06-18 Thread wesley chun
On Sat, Jun 18, 2011 at 10:02 PM, Kaustubh Pratap chand wrote: > Hello i made this program which interprets brainf*** > > But i don't understand why it doesn't endsand also it doesn't print > anything can you tell us more about the code other than "it doesn't end" and "it doesn't print anythi

Re: [Tutor] python2 vs python3 urllib

2011-04-23 Thread wesley chun
i strongly recommend you consider using the 2to3 tool if porting apps from 2.x to 3.x... it will show you much more than you may think. here's the output from the 2.7 version of 2to3: $ 2to3 test.py RefactoringTool: Skipping implicit fixer: buffer RefactoringTool: Skipping implicit fixer: idioms R

Re: [Tutor] help with re module and parsing data

2011-03-07 Thread wesley chun
>> import re >> file = open('file.txt','r') >> file2 = open('newfile.txt','w') >> >> LineFile = ' ' >> >> for line in file: >>    LineFile += line >> >> StripRcvdCnt = re.compile('(P\w+\S\Content|Re\w+\S\Content)') >> >> FindRcvdCnt = re.findall(StripRcvdCnt, LineFile) >> >> for SrcStr in FindRcvdC

Re: [Tutor] Exercise suggestions

2011-01-22 Thread wesley chun
> [...] I'm finding that I > understand concepts, but have no real way to implement them. > > So now my problem emerges... can anyone give me suggestions of exercises I > should do to help improve  my knowledge of what I can "actually" do with the > concepts I have. michael, first of all, welcom

Re: [Tutor] errors in "Python Programming for the Absolute Beginner"??

2011-01-13 Thread wesley chun
input() must be avoided at all costs in Python 2.x. if you find any Python (2.x) book which employs that, consider the author uninformed. it is a huge security risk and the main reason why in Python 3 raw_input() is renamed to and replaces input(). cheers, -- wesley - - - - - - - - - - - - - - - -

Re: [Tutor] Beginning Python and other resources (was Re: SlicingTuples)

2011-01-13 Thread wesley chun
>> Object Oriented Programming" by Dusty Phillips - and found it on Amazon for >> $43 new on up and $70 for used but maybe that was hardback?  Do you happen >> to know of some other way to obtain it for less than $45? the retail price of the book is $49.99, and Packt books are usually POD (print o

Re: [Tutor] Equality of numbers and Strings

2011-01-10 Thread wesley chun
On Mon, Jan 10, 2011 at 8:54 AM, bob gailer wrote: > On 1/10/2011 11:07 AM, Karim wrote: > >> >> s ='xyz' >> >>> t = str('xyz') >> >> >>> id(s) == id(t) >> True >> >> Thus if I create 2 different instances of string if the string is >> identical (numerically). >> > > Python "interns" certain lite

Re: [Tutor] Python using version 3.1

2010-12-18 Thread wesley chun
On Sat, Dec 18, 2010 at 8:13 PM, Hugo Arts wrote: > On Sun, Dec 19, 2010 at 4:42 AM, Lea Parker wrote: >> I am having problems working out what I have done incorrectly. The game over >> block writing should stay on the same line but the bottom half of the word >> over comes up next to the top hal

Re: [Tutor] os.system

2010-12-17 Thread wesley chun
On Fri, Dec 17, 2010 at 4:17 PM, Emile van Sebille wrote: > On 12/17/2010 4:07 PM jtl999 said... >> >> I want to pass a variable to os.system which is dir > dir=raw_input ("Dir Please ") > os.system ("ls"  + dir) >> sh: ls/: No such file or directory > > this has concatenated "ls" and dir

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

2010-12-16 Thread wesley chun
On Thu, Dec 16, 2010 at 10:13 AM, bob gailer wrote: > I agree. What do we do to fix the "problem"? something like "quit" (or friends) might be nice, as they are already special cases in the interpreter: $ python Python 2.5.1 (r251:54863, Feb 9 2009, 18:49:36) [GCC 4.0.1 (Apple Inc. build 5465)]

Re: [Tutor] PHP

2010-12-04 Thread wesley chun
On Sat, Dec 4, 2010 at 12:44 PM, Brett Ritter wrote: > On Sat, Dec 4, 2010 at 2:27 PM, Kirk Bailey wrote: >> and continue in html. What a BLOODY shame we can't do that in python, >> which is otherwise awesome and superior in every way i can thus far >> evaluate. > > As someone mentioned, you CAN

Re: [Tutor] PHP

2010-12-04 Thread wesley chun
> Straightaway, i was impressed by one powerful property; the ability to > imbed php into a html webpage, and switch into and out of php as needed, > and let normal ssi and html and css work the rest of the time, outside > of php. all I have to do is start the php block with > write code; > ?> # e

Re: [Tutor] Python and Tkinter Programming by Grayson--New Version?

2010-11-28 Thread wesley chun
On Sun, Nov 28, 2010 at 7:18 PM, Terry Carroll wrote: > On Thu, 25 Nov 2010, Alan Gauld wrote: >> "Yves Dextraze" wrote >>> Sent from my iPod >> >> There is no mention on Amazon of any new editions and they usually >> announce several months in advance... >> >> A pity a new Tkinter book using Tix

Re: [Tutor] PYTHON 3.1

2010-05-27 Thread wesley chun
greetings and welcome (back) to Python! i have a few comments for you: 1. The syntax for Python 3.x has changed from 2.x, so please be aware of the differences as you are learning. Most books and code out there is still 2.x. 3.x is being adopted but because of the differences, it is slower than mo

Re: [Tutor] Python 2.5.4 - error in rounding

2010-05-21 Thread wesley chun
correct, it is a floating point issue regardless of language.. it's not just Python. you cannot accurately represent repeating fractions with binary digits (bits). more info specific to Python here: http://docs.python.org/tutorial/floatingpoint.html also, keep in mind that '%f' is not a rounding o

Re: [Tutor] Programming microsoft excel

2010-05-06 Thread wesley chun
> guys can i use python's win32com module to do the same tasks that i do with > visual basic for applications (vba). I mean automating tasks for excel e.t.c > and accessing Access databases. If win32com doesnt which module can i use? that's definitely the right one, and yes, you can use VB/VBA

Re: [Tutor] set and sets.Set

2010-04-21 Thread wesley chun
> When sets were introduced to Python in version 2.3. they came as a separate > "sets" module. > > In version 2.6 built-in set/frozenset types replaced this module. 2.4 > So either way is OK for now, but the sets module might go away in a newer > version. agreed cheers, -- wesley - - - - - -

Re: [Tutor] Django Book Recommendation

2010-04-07 Thread wesley chun
t a copy of Python Web Development with Django > last month, and I can't recommend it enough. > > On Wed, Apr 7, 2010 at 8:46 PM, wesley chun wrote: >> >> i worked on another well-received Django book with a pair of great >> co-authors called "Pytho

Re: [Tutor] Django Book Recommendation

2010-04-07 Thread wesley chun
i worked on another well-received Django book with a pair of great co-authors called "Python Web Development with Django", Addison Wesley (2009). rather than taking the existing Django docs, which are great BTW, and expanding on them, we wanted to have a more comprehensive look at Django developme

Re: [Tutor] Help with simple text book example that doesn't work!!!

2010-04-04 Thread wesley chun
similarly, you get an error if: "print int(reply) ** 2 print 'Bye'" ... is all a single line and/or if you mixed spaces and TABs. -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall, (c)2007,2001 "Python Fundamentals", Prentice Hall,

Re: [Tutor] What Editori?

2010-02-23 Thread wesley chun
> what text-editor do you use for python? as an FYI Guido himself uses both emacs and vi/m... he mentioned this during his PyCon 2010 keynote last week, to which someone tweeted: http://twitter.com/bradallen137/status/9337630806 i primarily use vi/m and emacs as necessary, -- wesley - - - - - -

Re: [Tutor] NameError: global name 'celsius' is not defined (actually, solved)

2010-02-09 Thread wesley chun
> I just wrote this message, but after restarting ipython all worked fine. > How is it to be explained that I first had a namespace error which, after a > restart (and not merely a new "run Sande_celsius-main.py"), went away? I > mean, surely the namespace should not be impacted by ipython at all!?

Re: [Tutor] [OT] Python Study Group

2010-01-29 Thread wesley chun
as well? > > On Fri, Jan 29, 2010 at 3:15 PM, David Abbott wrote: >> >> A group of beginners and intermediate Pythonerrs and getting together to >> study the book Core Python Programming by Wesley Chun. We are starting >> on chapter one on Feb first. We are hoping to

Re: [Tutor] Python and Ajax classes at Foothill College

2010-01-29 Thread wesley chun
for future reference, you can go sign up for the courses at http://foothill.edu ... i'll be delivering the intermediate Python course next year FWIW. cheers, -wesley On Fri, Jan 29, 2010 at 10:45 AM, Scott Pritchard wrote: > Oh, sorry about that. > > Rich Lovely wrote: >> >> I think you've got

Re: [Tutor] adding more text to a file

2010-01-18 Thread wesley chun
On Sun, Jan 17, 2010 at 5:19 PM, Alan Gauld wrote: > > "Magnus Kriel" wrote > >> It might be that when you create a file for the first time with 'a', that >> it >> will through an exception. So you will have to try with 'w', and if there >> is >> an exception, you know the file does not exist and

Re: [Tutor] adding more text to a file

2010-01-17 Thread wesley chun
> while True: >    name = raw_input("what is the name ") >    age = raw_input("what is the age ") > >    out_file = open("persons.txt", "w") >    out_file.write("name: ") >    out_file.write(name) >    out_file.write("\n") >    out_file.write("age: ") >    out_file.w

Re: [Tutor] what is dynamic about "dynamic name resolution" ?

2010-01-17 Thread wesley chun
On Sun, Jan 17, 2010 at 12:10 PM, Robert wrote: > In the Python tutorial (highlighted here http://awurl.com/N1XvzIo2Q) > > What exactly is "dynamic name resolution" ? specifically what is > "dynamic" about it ? what this means is that as your code is executing and the interpreter encounters an i

Re: [Tutor] Searching in a file

2010-01-13 Thread wesley chun
> I have a file generated from a webpage. > I want to search that file for a specific keyword, in my case 'NEW'. > Once I have found that keyword I want to retrieve information below it, e.g. > web link, size of file etc. > When I have this information I move off until I find another 'NEW' and the

Re: [Tutor] how to sort a tab delim file

2010-01-13 Thread wesley chun
> I have a tab-delim file: > > col1 col2 col3 > andrew    1987   1990 > jake 1974   1980 > jim   1964   1970 > lance    1984   1992 > > how can I sort column 2 and get : > jim   1964   1970 > jake 1974   1980 > lance    1984   1992 > andrew    198

Re: [Tutor] What books do you recommend?

2009-12-09 Thread wesley chun
> - learning to program by gauld http://www.freenetpages.co.uk/hp/alan.gauld/ update: alan's latest tutorial lives here: http://www.alan-g.me.uk/tutor/ -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Python Web Development with Django", Addison Wesley, (c) 2009 http://w

Re: [Tutor] What books do you recommend?

2009-12-09 Thread wesley chun
> I wan't to buy some books about python 3. Do you have any recommendations? > I started with no previous programming experience, and I've finished a few > tutorials  and I guess I can be considered a beginner. greetings khalid, and welcome to Python! based on your background, i would like you s

Re: [Tutor] Moving from Python 2 to Python 3

2009-12-02 Thread wesley chun
>> I have the first edition of your book. What is the difference between >> two editions? i believe the 1st ed is 3.0 and the 2nd ed is 3.1 but haven't confirmed with him yet. -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall, (c)2007,2

Re: [Tutor] Nested loop of I/O tasks

2009-11-24 Thread wesley chun
On Tue, Nov 24, 2009 at 2:42 PM, Bo Li wrote: > > I am new to Python and having questions about its usage. Currently I have to > read two .csv files INCT and INMRI which are similar to this: > [...] > I was a MATLAB user and am really confused by what happens with me. I wish > someone could help

Re: [Tutor] Faster list searching?

2009-11-18 Thread wesley chun
On Wed, Nov 18, 2009 at 1:51 PM, GoodPotatoes wrote: > I'm dealing with bigger lists than I have been, and noticed this is getting > really slow. Is there a faster way to do this? > > for x in list1: > if x not in list2: > list3.append(x) > > My search is taking up to 5 minutes to com

Re: [Tutor] Should a beginner learn Python 3.x

2009-11-15 Thread wesley chun
>> Should I advise him to >> stick with 2.6 for a bit, since most of the material out  there will >> be for 2.x?  Or since he's learning from scratch, should he jump >> straight to 3.x  In which case what can you recommend for him to work >> through - I must stress he has absolutely no clue at all

Re: [Tutor] Should a beginner learn Python 3.x

2009-11-15 Thread wesley chun
>> i get asked this question a lot, esp. when it pertains to my book, >> "Core Python Programming." which should i learn? is your book >> obsolete? etc. i basically tell them that even though they are >> backwards-incompatible, it's not like Python 2 and 3 are so >> different that you wouldn't

Re: [Tutor] Should a beginner learn Python 3.x

2009-11-14 Thread wesley chun
>> My brother in law is learning python. He's downloaded 3.1 for >> Windows, and is having a play. It's already confused him that print >> "hello world" gives a syntax error >> >> He's an absolute beginner with no programming experience at all. I >> think he might be following 'Python Progra

[Tutor] ANN: Python course, San Francisco, Nov 9-11

2009-10-27 Thread wesley chun
hey gang, not sure i made the original announcement on this list a few months ago, but if you're on this list because you need to learn Python as quickly and as in-depth as possible for an immediate need, i have few more openings in my upcoming course in San Francisco, and below is the reminder i'v

Re: [Tutor] list comprehensions

2009-10-08 Thread wesley chun
> I've been studying python now for a few weeks and I've recently come > into list comprehensions. [...] > Those make sense to me. The way I understand them is: > do something to x for each x in list, with an optional qualifier. that's pretty much correct. > On the other hand I've seen a few exa

Re: [Tutor] if n == 0 vs if not n

2009-10-08 Thread wesley chun
> Thanks all for the informative discussion. To re-confirm it was mostly > for boolean checks like "if b == True". wow, as the OP, you must have been surprised to see how far we have taken your (seemingly) simple question. we went from boolean checks to interning! commenting on my previous reply,

Re: [Tutor] Which version to start with?

2009-10-05 Thread wesley chun
On Mon, Oct 5, 2009 at 2:24 PM, Nick Hird wrote: > What is the best version of python to start out with? I see some > discussions on the net about not going to 3.1 but staying with the 2.x > releases. But then i see that 3.1 is better if your just starting. greetings nick! ironically, i just ga

Re: [Tutor] if n == 0 vs if not n

2009-10-05 Thread wesley chun
> I am going through someone's python script and I am seeing a lot of the > following boolean checks. > > if not s == "" > if not n == 0 > if b == True > if not b == True > etc.. > > All of these can be written without the == notation like "if n", "if s" > etc.Now in this case where it is only used

Re: [Tutor] Poorly understood error involving class inheritance

2009-10-05 Thread wesley chun
>    def __init__(self, time, mods=[], dur=None, format='%1.2f'): >        : > The mods that were added to the first instance of oneStim also appear in the > second, newly created instance! > > It appears that what is happening here is that the __init__() method is > being parsed by the interpreter

Re: [Tutor] small program

2009-10-03 Thread wesley chun
> I would like to create a program which > should repeat a simply string several times with list number before. > Like "1. Wanna more. 2. Wanna more. ..." > Suppose to a loop here repeating, say x times. Should it look like that: > > y="Wanna more. " > x=1 > x=x+d: > d=<100 > print d+y > > How to c

Re: [Tutor] How to perform variable assignment and

2009-10-02 Thread wesley chun
On Fri, Oct 2, 2009 at 11:14 PM, Oxymoron wrote: > Hello, > > On Sat, Oct 3, 2009 at 3:56 PM, Didar Hossain > wrote: >> >> homedir = os.environ.get('HOME') >> >> if homedir: >>    print "My home directory is %s" % homedir >> >> >> I do this in Perl - >> >> my $home; >> >> if ($home = $ENV{'HOME'}

Re: [Tutor] Help!

2009-09-29 Thread wesley chun
> I need help writting a program. > 1) Random string generation > 2) no repeating letters > Can anyone help me,please? I am so confused. The only problem is I have to > use the code that is written there but add on to it. > > import random > > alphabet = "abcdefghijklmnopqrstuvwxyz" > myNewString =

Re: [Tutor] python win32 drive mapping help

2009-09-25 Thread wesley chun
>> I tried this: >> win32net.NetUseDel(None, 1,{'local':'k:'}) >> >>  but I got this error: >> Traceback (most recent call last): >>  File "test.py", line 33, in >>    win32net.NetUseDel(None, 1,{'local':'k:'}) >> TypeError: an integer is required > > You have the wrong sequence for NetUseDel().  

Re: [Tutor] NameError

2009-09-21 Thread wesley chun
On Mon, Sep 21, 2009 at 2:06 PM, Wayne wrote: > On Mon, Sep 21, 2009 at 4:00 PM, kreglet wrote: >> >> I keep getting the following error and don't uderstand why: >> >> Traceback (most recent call last): >>  File "/home/kreglet/bin/test.py", line 15, in btnStatclick >>    btnStat.set_label("Presse

Re: [Tutor] eazy python question involving functions and parameters

2009-09-21 Thread wesley chun
>> an expression is something ... that evaluates to *some* Python object >>: >> in contrast, a statement is something that has no intrinsic value > >               Umm.you just completely confused me. What does it do? ok, now *i*'m the one confused... what does *what* do? both expression

Re: [Tutor] eazy python question involving functions and parameters

2009-09-21 Thread wesley chun
>> Just think: 4 players left means that this is the semi final. > > What a brilliant answer! It tells him how to do it if he just stops and > thinks but gives nothing away. I love it. :-) i agree with alan on this. in fact, i can just picture the brackets in my head already. :-) another thing f

Re: [Tutor] Still Trying to Understand GAE

2009-09-13 Thread wesley chun
hi Giorgio, welcome to Python (whether directly or from GAE!) :-) my comments below. > with import i can import modules or single functions. And this is ok. not quite true. regardless of whether you use import or from-import, you're *always* importing (and loading) modules or packages in their

Re: [Tutor] Automating creation of presentation slides?

2009-08-12 Thread wesley chun
On Wed, Aug 12, 2009 at 1:07 PM, David Kim wrote: > Unfortunately I live on the East Coast, otherwise I'd definitely attend! I > am attracted to the declarative nature of reStructuredText, but I also > recognize that A LOT of people use Powerpoint and are comfortable with it. > Going with something

Re: [Tutor] Automating creation of presentation slides?

2009-08-12 Thread wesley chun
> I'm wondering what people consider the most efficient and brain-damage free > way to automate the creation of presentation slides with Python. Scripting > Powerpoint via COM? this is how i'm doing it. i'm working on a Python script that takes plain text with minimal markup that then uses COM t

Re: [Tutor] Currency conversion module in python

2009-07-30 Thread wesley chun
On Thu, Jul 30, 2009 at 11:18 AM, Che M wrote: > Did you actually look at what happens when you click that > link?  (i.e. where you are brought to?). > > Because upon viewing this I achieved enlightenment!  :D lucky you... i achieved recursion. :-) ___

Re: [Tutor] how to join two different files

2009-07-30 Thread wesley chun
>> Maybe you could break that up a bit? This is the tutor list, not a >> one-liner competition! > > rather than one-liners, we can try to create the most "Pythonic" solution. > below's my entry. :-) > > myMac$ cat parafiles.py > #!/usr/bin/env python > > from itertools import izip > from os.path i

Re: [Tutor] implementing set operations [was Re: (no subject)]

2009-07-29 Thread wesley chun
> - you probably don't want to call set1.remove(). lists are immutable, > and you would've change the contents of set1. sorry, make that "mutable." sets, dicts, and lists are standard Python types that are mutable. -wesley ___ Tutor maillist - Tutor@p

[Tutor] implementing set operations [was Re: (no subject)]

2009-07-29 Thread wesley chun
> could this be done in a more elegant fashion? in addition to alan's obvious solution, if you wanted to roll your own, you have a good start. my comments below. > def Unite(set1, set2):          # evaluate 2 lists, join both into 1 new list >        newList = [] >        for item in set1: >    

Re: [Tutor] Issues with regex escaping on \{

2009-07-29 Thread wesley chun
in addition to the good advice from vince (watch out for greediness regardless of what you're looking for) and bill (use raw strings... regexes are one of their primary use cases!), another thing that may help with the greediness issue are the character sets you're using inside to match with. for

Re: [Tutor] Reading Data From File

2009-07-24 Thread wesley chun
On Fri, Jul 24, 2009 at 11:40 PM, Chris Castillo wrote: > Okay I really need help with the program I am writing. I've can't seem to > figure out what I need to do and have tried several different methods. hi chris, and welcome to Python! the tutors here are very helpful to those who are new to pr

Re: [Tutor] Syntax Problem

2009-07-24 Thread wesley chun
On Fri, Jul 24, 2009 at 2:34 PM, Jesse Harris wrote: > for d in Decks.all(): #loop thru all available decks >   self.response.out.write(''+d.name) >       self.response.out.write(''+d.description) > self.response.out.write('') > self.response.out.write('') > > : invalid syntax (main.py,

Re: [Tutor] how to join two different files

2009-07-18 Thread wesley chun
on a related note, there is a module called fileinput that doesn't do what you (the OP) need for this particular problem, but it is one to keep in mind for the future as there may be a situation for which it is the right tool. it doesn't get a lot of buzz but can come in handy -- for me, it was in

Re: [Tutor] how to join two different files

2009-07-18 Thread wesley chun
>> Thankyou sir it is working.but one more thing i want to ask that if my >> file will have entries like:--- >> >> fileA and fileB >> 12         10 >> 13         12 >> 14 >> 15 >> >> means if their no. of entries will not match then how to combine them(both >> input files have more than one col

Re: [Tutor] how to join two different files

2009-07-17 Thread wesley chun
> Maybe you could break that up a bit? This is the tutor list, not a > one-liner competition! rather than one-liners, we can try to create the most "Pythonic" solution. below's my entry. :-) cheers, -wesley myMac$ cat parafiles.py #!/usr/bin/env python from itertools import izip from os.path im

Re: [Tutor] decorators, __call__ (able) objects

2009-07-15 Thread wesley chun
>>> > Can some one give, or point to some good examples of how @decorators >>> > work, and __call__ (able) objects? > > simple example of calling a class > > class myKlass(object): > > def __call__(self, *args, **kws): > print "i was called" > > >>> test = myKlass() > >>> test() > i wa

Re: [Tutor] just one question

2009-07-15 Thread wesley chun
On Wed, Jul 15, 2009 at 8:29 AM, Rich Lovely wrote: > 2009/7/15 vince spicer : >>: >> import re >>: >>     values = re.split("\s+", line) # split values on spaces EX: ['47', '8', > > That isn't what they're after at all. > Something more like > : >        n, pos, ala, at, sy

Re: [Tutor] While and for loops

2009-07-14 Thread wesley chun
> I'm not sure if this is good practice, but I could assign a variable within > the while loop, that is assigned something that will then break the outer > loop. > > while True: >    breakout = True >     >    for i in items: >        if i > 10: >            breakout = False >        else: >    

Re: [Tutor] While and for loops

2009-07-14 Thread wesley chun
> So how would you break out from this situation? as i mentioned in my other msg, you need another break statement that is *not* in another loop. in your case, not in the for-loop. you need a break statement somewhere within your while block (again, that's not in any other loop). IOW, it should be

Re: [Tutor] assigning list to keys

2009-07-14 Thread wesley chun
> The other day I needed to pack a dictionary, the value of each key was a > list. In the code I was packing the list and the dictionary at the same time. > First I tried something like this: > > list = [] > dict = {} > x = 1 > > dict['int'] = list.append(x) > > The result was {'int': None}. Why

  1   2   3   4   >