Re: [Tutor] Accessing callers context from callee method

2009-02-24 Thread wesley chun
> when i call a method foo from another method func. can i access func context > variables or locals() from foo > so > def func(): >   i=10 >   foo() > > in foo, can i access func's local variables A. python has statically-nested scoping, so you can do it as long as you: 1. define foo() as an in

Re: [Tutor] Changing the Attribute of a Variable

2009-02-17 Thread wesley chun
> # Date vars should be type datetime.time > config_value = str(stime) this is pretty much the offending code right here... in fact, the comment contradicts the assignment. it says that date vars should be of type datetime.time, yet it assigns a *string* to config_value

Re: [Tutor] Changing the Attribute of a Variable

2009-02-17 Thread wesley chun
>> Initally, a variable. self.stop_time is created as type datetime.time, >> with the default value 06:00:00, a time stamp, during entry into the >> mainloop. self.stop_time = datetime.time(10,10,10). The user reads his >> configuration file with the time stamp value of 08:00:00. self.time_stop >>

Re: [Tutor] Changing the Attribute of a Variable

2009-02-16 Thread wesley chun
On Mon, Feb 16, 2009 at 8:24 PM, Wayne Watson wrote: > I suspect I'm in need of setattr for this in a GUI program I'm modifying. > > Initally, a variable. self.stop_time is created as type datetime.time, with > the default value 06:00:00, a time stamp, during entry into the mainloop. > self.stop_t

Re: [Tutor] Variable to String?

2009-02-13 Thread wesley chun
On Fri, Feb 13, 2009 at 3:50 PM, Wayne Watson wrote: > That's pretty much the question in Subject. I've got a date time variable > with, for example, 15:00:00 in hh:mm:ss format, and I'd like to make it a > string. >>> import datetime >>> d = datetime.time(15,0) datetime.time(15, 0) >>> d dateti

Re: [Tutor] Extracting information from an EXCEL/Matlab file to use in Python

2009-02-11 Thread wesley chun
>>> I am trying to extract information from a spreadsheet to use it in Python. >> For reading .xls: http://pypi.python.org/pypi/xlrd/0.5.2 i forgot to mention that xlrd is on version 0.6.1 now: http://pypi.python.org/pypi/xlrd -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Re: [Tutor] Extracting information from an EXCEL/Matlab file to use in Python

2009-02-11 Thread wesley chun
On Wed, Feb 11, 2009 at 12:16 PM, "Shantanoo Mahajan (शंतनू महाजन)" wrote: > On 12-Feb-09, at 1:31 AM, Andres Sanchez wrote: > >> I am trying to extract information from a spreadsheet to use it in Python. > > For reading .xls: http://pypi.python.org/pypi/xlrd/0.5.2 > For writing .xls: http://sourc

Re: [Tutor] PyCon2009 Tutorial: An Introduction to Object-OrientedProgramming

2009-02-01 Thread wesley chun
> Such fun! I just wish I could afford the trip to the US! :-) PyCons are such a great way to (re)connect with the community and so many opportunities to learn from the masters (and mistresses) of Python. the conferences are so incredible that once you go, you have to go every year thereafter. as

Re: [Tutor] string fomatting

2009-01-31 Thread wesley chun
>> I want to search any characters in test after https://www.localhost.org/ >> and >> the search will end after it finds another / here's another solution that takes advantage of the 'maxsplit' parameter of the str.split() metho

Re: [Tutor] PyCon2009 Tutorial: An Introduction to Object-Oriented Programming

2009-01-31 Thread wesley chun
> David Letscher and I will be leading a tutorial at this year's > PyCon titled "An Introduction to Object-Oriented Programming." likewise, i'll be doing one on network programming, so if you ever wanted to know all about it, we take it from the lowest layer (socket level), up thru internet proto

Re: [Tutor] Want to write a Perl based IP to Domain Name converter.

2009-01-31 Thread wesley chun
>> >> The script in the following can do the batch conversion from domain >> >> name to IP: >> >> > This is a Python list, not Perl! >> >> OMG! It's my mistake, sorry for this. > > Lol..thats okay. Now that you are here and have seen what fun we have > writing Python code - why not join the party

Re: [Tutor] Convert String to Int

2009-01-19 Thread wesley chun
> if type(x) == int: # check its an integer i also understand that it's "isinstance(x, int)" should be used instead of the above or "if type(x) is int" but i'm running a blank as to why at this exact moment... perhaps it's an all-C function? however, all of these comparisons are only good if '

Re: [Tutor] "Pointer" to a function? Storing a function as an object property? Passing arguments by value/by reference?

2009-01-16 Thread wesley chun
> All Python values are references, so you are essentially storing a > pointer to the function object within the problem. Python assignment > does not copy. This is a fundamental concept of Python that often > confuses newbies, it is worth taking some time to understand it > correctly. My explanati

Re: [Tutor] eval and floating point

2009-01-15 Thread wesley chun
>>> eval("float(3/2)") >> >> That still does not work, because the 'float' comes after the >> division. 3/2 equals 1, so float(3/2) equals 1.0. To make it work, >> you'll have to put the float inside the division: >> eval("float(3)/2") correct. as long as one of the operands is a float, the divisi

Re: [Tutor] strings and int()

2009-01-14 Thread wesley chun
> If you have a string "6", and you do int("6"), you get the number 6. > But if you have a string "2*3" and you do int("2*3") you get a name error. the reason you get this error is because "2*3" is not a string representation of an integer whereas "6" is. in other words 2*3 is not a number. > Ho

Re: [Tutor] help with getting python to run from command prompt on Windows XP

2009-01-14 Thread wesley chun
On Wed, Jan 14, 2009 at 12:01 PM, Kent Johnson wrote: > On Wed, Jan 14, 2009 at 2:36 PM, Brian van den Broek > wrote: >> >> He's got python 2.6.1 installed as evidenced by the Startbar program >> icon for Idle launching as expected. When run from IDLE, `print >> sys.executable' yields `C:\\Python

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

2009-01-12 Thread wesley chun
> 1) itertools.dropwhile(cond, lst) will return a list with the desired element > first. i think in order to use this, the OP needs to invert his Boolean logic because it *drops* elements while the conditional is True. as soon as it hits False the 1st time, all remaining elements (including the o

Re: [Tutor] casting string to integer in a list of lists

2009-01-09 Thread wesley chun
>> A tuple of exceptions works, just like what we did above, and more, >> i.e., (IndexError, ValueError, TypeError, KeyError... >> > Thank you, thank you, thank you! I'm sure it's been staring me in the face, > but I never realized I could use a tuple of exception types - that's why I > said it wa

Re: [Tutor] casting string to integer in a list of lists

2009-01-08 Thread wesley chun
>> except: >>pass >> >> try not to code these 2 lines in anything that you do because it will >> come back to haunt you when something is not working right but you >> can't find any errors. that's because this code masks and throws away >> everything!! > > there are two potential error types: I

Re: [Tutor] casting string to integer in a list of lists

2009-01-08 Thread wesley chun
>> LoL = [['chrX', '160944034', '160944035', 'gnfX.145.788', '63.60'], >>: >> Now I want to cast the second and third "columns" from string to integer, >> like this >> >> LoL = [['chrX', 160944034, 160944035, 'gnfX.145.788', '63.60'], >>: >> Is there any elegant way to do this? I ca

Re: [Tutor] variable number of inputs

2009-01-07 Thread wesley chun
On Wed, Jan 7, 2009 at 7:01 PM, bob gailer wrote: > Mr Gerard Kelly wrote: >> >> How can you make a function accept a variable number of inputs without >> any particular limit? >>: >> But what if you want to be able to call the function and put in as many >> arguments as you want. > > def

Re: [Tutor] simple array access

2009-01-07 Thread wesley chun
> My attempt at array access (like this: array[1,2] ) does not work. What am > I overlooking? Thanks in advance! :) > : > pprint (grid.data[1,2]) is that really your name?!? you're famous! ;-) welcome to python! i'd try... pprint(grid.data[0][1]) ... as many languages start counting at 0

Re: [Tutor] Can subprocess run functions ?

2009-01-07 Thread wesley chun
> Anyhow, subprocess is working -- but I wonder if there is a way I can > send the entire *function* into its own subprocess ? this has been a highly-desired feature for quite awhile. starting in 2.6, you can use the new multiprocessing module (originally called pyprocessing): http://docs.python

Re: [Tutor] Very basic question about lists

2008-12-22 Thread wesley chun
> list1 = ['ar', 'fir', 'wo'] > list2 = ['ber', 'gar', 'gt'] > list3 = ['hu', 'mo', 'ko', 'tr'] > list4 = ['q', 'wer', 'duh'] > > whole = [list1, list2, list3, list4] > for item in whole: >if 'ar' or 'ko' in item: >print item > > So, the unexpected result was that I got all lists printe

Re: [Tutor] Very basic question about lists

2008-12-22 Thread wesley chun
>> if 'arr' or 'bell' in item: > > The interpreter sees this as > if ('arr') or ('bell' in item): > > 'arr' always evaluates to True so the condition is always true. The > correct way to express this condition is > if 'arr' in item or 'bell' in item: arrgh. yes, i saw this too but forgot to ment

Re: [Tutor] Very basic question about lists

2008-12-22 Thread wesley chun
eduardo, welcome to programming, and even better, welcome to Python! you've done your research and found a list of great people who can help you out. with regards to your question, my comment are below... > list1 = ['arr', 'bre', 'grau', 'lower', 'tudo'] > for item in list1: >if 'arr' in it

Re: [Tutor] How to exit program without sys.exit()

2008-12-17 Thread wesley chun
> I was practicing how to use a global counter and trying to understand > how functions can interact with each other. I can understand if I can > see the error's when I run the program. I know my terminology may be > hard to follow. Also I like your book :) you are well read since you already hav

Re: [Tutor] How to exit program without sys.exit()

2008-12-17 Thread wesley chun
> I make these silly programs to learn from examples I find on the list. I put > a couple together just to practice. I have heard it is not a good idea to > use sys.exit() but I can not figure out how to do it. Also any and all > comments are welcome. Thanks david, welcome to Python! it's defin

Re: [Tutor] Writing to a file problem....

2008-12-05 Thread wesley chun
marty, i applaud you in your efforts to port this script to the Win32 platform. the task is not as simple as one may expect, due to the differing file pathname nomenclatures that the different operating systems use. because of this, i have a couple of suggestions: 1. highly recommend converting

Re: [Tutor] what do you use @staticmethod for?

2008-11-19 Thread wesley chun
On 11/19/08, Alan Gauld <[EMAIL PROTECTED]> wrote: > "spir" <[EMAIL PROTECTED]> wrote > >> I have not yet found any use for this feature. > > Which makes it very different to an instance method. instance > methods act on instances. class methods act on the entire > class - ie they can affect all of

Re: [Tutor] fast list traversal

2008-10-30 Thread wesley chun
> They seem pretty similar. Here are two tests (code follows). Perhaps I > could have loaded them differently and it would have made more of a > difference. In this case I just made a list and populated the sets > from it. > > Results for 999 iterations: >Set: >Load: 1.2

Re: [Tutor] fast list traversal

2008-10-30 Thread wesley chun
based on the all the performance questions, i would say agree that dictionary access is faster than lists (hashes exist cuz they're fast) but they use up more memory, as shown in shawn's numbers. also, one of the reasons why slots was added to classes was because the attribute dictionary began to i

Re: [Tutor] String and integer

2008-10-20 Thread wesley chun
>> def nr(): >>nr1 = input('Enter value: ') >>print str(nr1).strip('nr0') >> >> The user input is always on the form "nr08756" and i'd like to take out >> the "nr0" and then print the result. >> I can see that there is a problem with a variable looking like "pn0123" >> because i get: NameEr

Re: [ANN] final 2008 Python courses, San Francisco

2008-10-15 Thread wesley chun
age -- From: wesley chun <[EMAIL PROTECTED]> Date: Fri, Sep 5, 2008 at 1:21 AM Subject: [ANN] final 2008 Python courses, San Francisco To: python-list@python.org, [EMAIL PROTECTED] Need to get up-to-speed with Python as quickly as possible? Come join me, Wesley Chun, author of Prentice-Hall

Re: [Tutor] using lists as values for key in dictionary?

2008-10-15 Thread wesley chun
>> >> so if you turn your list into a tuple (I can never remember, is that a >> >> cast or a coercion?) >> > >> >> lX = tuple(lX) >> > >> > To answer my own question: neither, but it's closer (in spirit) to a >> > cast. >> >> you're keeping everyone is suspense! :-) you are creating a brand new >>

Re: [Tutor] using lists as values for key in dictionary?

2008-10-15 Thread wesley chun
>> so if you turn your list into a tuple (I can never remember, is that a >> cast or a coercion?) > >> lX = tuple(lX) > > To answer my own question: neither, but it's closer (in spirit) to a cast. you're keeping everyone is suspense! :-) you are creating a brand new tuple by copying out the refer

Re: [Python-3000] Problem with grammar for 'except'?

2008-10-05 Thread wesley chun
On Thu, Sep 4, 2008 at 12:36 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On Wed, Sep 3, 2008 at 9:25 PM, Raymond Hettinger <[EMAIL PROTECTED]> wrote: >> [Brett] >>> I gave a talk last night at the Vancouver Python users group on >>> 2.6/3.0, and I tried the following code and it failed during

Re: [Tutor] Python class at Foothill College

2008-09-12 Thread wesley chun
On Fri, Sep 12, 2008 at 5:59 PM, Wayne Watson <[EMAIL PROTECTED]> wrote: > Interesting. I've been quite surprised that some community college in the > Bay Area hasn't offered Python recently. However, I'm long gone from there. > Sacramento, Davis, Rocklin, anyone? Haven't even seen any in UC extens

Re: [Python-3000] [Python-Dev] Not releasing rc1 tonight

2008-09-07 Thread wesley chun
>> Barry Warsaw wrote: >>> I'm not going to release rc1 tonight. >>> I'd like to try again on Friday and stick to rc2 on the 17th. > > There are 8 open release blockers, a few of which have patches that need > review. So I think we are still not ready to release rc1. But it worries > me because I

[ANN] final 2008 Python courses, San Francisco

2008-09-05 Thread wesley chun
Need to get up-to-speed with Python as quickly as possible? Come join me, Wesley Chun, author of Prentice-Hall's bestseller "Core Python Programming," for another comprehensive intro course plus a 1-day Internet programming course coming up in November in beautiful Northern Cal

[ANN] final 2008 Python courses, San Francisco

2008-09-05 Thread wesley chun
Need to get up-to-speed with Python as quickly as possible? Come join me, Wesley Chun, author of Prentice-Hall's bestseller "Core Python Programming," for another comprehensive intro course plus a 1-day Internet programming course coming up in November in beautiful Northern Cal

[Edu-sig] [ANN] final 2008 Python courses, San Francisco

2008-09-05 Thread wesley chun
*** will also X-post to CLP so apologies in advance for duplicates *** Need to get up-to-speed with Python as quickly as possible? Come join me, Wesley Chun, author of Prentice-Hall's bestseller "Core Python Programming," for another comprehensive intro course plus a 1-day Inter

[Tutor] [ANN] final 2008 Python courses, San Francisco

2008-09-05 Thread wesley chun
*** will also X-post to CLP so apologies in advance for duplicates *** Need to get up-to-speed with Python as quickly as possible? Come join me, Wesley Chun, author of Prentice-Hall's bestseller "Core Python Programming," for another comprehensive intro course plus a 1-day Inter

Re: [Python-3000] Several days later: no windows installers for b3

2008-08-24 Thread wesley chun
>> No b3 installers for windows at http://www.python.org/download/releases/3.0/ > We know. Martin, who usually does the Windows installer, is on vacation. once they're ready and the page updated, also change the 1st sentence under "Download" to reflect beta (and future release candidate) status as

Re: [Tutor] Problem with creating a class to access a 2d array

2008-08-23 Thread wesley chun
> I am currently trying to teach myself python. This isnt my first language, > as I used to be quite good at using java. you are in good shape... you will only need to "tweak" some of your notions with regards to Java for Python, and you will be in good shape. > I really like python, but the one

Re: [Tutor] Merging dictionaries

2008-08-06 Thread wesley chun
hmmm, somewhat off-topic, i was partially confused by the Subject line. i thought this post was about merging *dictionaries* and not merging the *contents of multiple dictionaries' values*. for those who are interested in the former, you use the update() method and here is an example: >>> d1 = d

Re: [Tutor] date formatter

2008-08-06 Thread wesley chun
>try: >month = int(month) >except ValueError: >for eachKey in month_dict.keys(): >if month.lower() in eachKey: >month = month_dict[eachKey] >

Re: [Tutor] Online class/education for Python?

2008-07-27 Thread wesley chun
> At $88 for 500 pages it had better be good or he will be stuxck > with academic-only sales! well, the other thing is that the 2nd review will really make ppl go back to the original title since it's $18 vs. $88 for the (apparently) same material, both academic and general sales. i can't imagine

Re: [Tutor] Online class/education for Python?

2008-07-26 Thread wesley chun
On Sat, Jul 26, 2008 at 7:11 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > At 01:43 AM 7/26/2008, wesley chun wrote: >> >> > I have the first edition of Python Programming for the Absolute >> > Beginner. >> > Will this work instead of the 2nd edition? >

Re: [Tutor] Online class/education for Python?

2008-07-26 Thread wesley chun
> I have the first edition of Python Programming for the Absolute Beginner. > Will this work instead of the 2nd edition? i just found out from bookpool today that the 2nd edition is now also out-of-print. does anyone know if a 3rd edition is being worked on? -- wesley - - - - - - - - - - - - - -

[TurboGears] Re: 500 Error when using Mako as a templating engine

2008-07-22 Thread wesley chun
just in case anyone has these problems switching from Kid to Mako and are searching the archives... 1. the Mako code is fixed now, so you can have just one single directory in the mako.directories list. for example, my app.cfg now has: : mako.directories=['templates'] : 2. another probl

Re: [Tutor] Guidance on jump-starting to learn Python

2008-07-20 Thread wesley chun
> Any recommended "homework" assignments? > > I have two books as well: > Core Python Programming from Wesley Chun , Second Edition. here are some exercises suggestions on "homework" based on the lab assignments i give in my courses based on that book. the le

[elixir] Re: ImportError: cannot import name EXT_PASS

2008-07-19 Thread Wesley Chun
fwiw, i get the same error, and i've "easy_install"ed both SQLalchemy and Elixir (on CentOS/RHEL5.1-2.6.18-53), and it does give me both E052 and SA05b2 which are incompatible with each other due to this failed import. reverting back to SA046 makes it work because that variable exists there. this

Re: [Tutor] character encoding

2008-07-08 Thread wesley chun
> > Hi, I'm puzzled by the character encodings which I get when I use Python > > with IDLE. The string '\xf6' represents a letter in the Swedish alphabet > > when coded with utf8. On our computer with MacOSX this gets coded as > > '\xc3\xb6' which is a string of length 2. I have configured IDLE

Re: [Tutor] random.choice()

2008-07-02 Thread wesley chun
> > It seems to me that Wes is saying only that all function objects are > > callable, not that all callable objects are functions. > > Wesley said that function objects have a "heaping distinction" of > being callable. Only he can say for sure what that means; I took it to > mean that being ca

Re: [Tutor] random.choice()

2008-07-02 Thread wesley chun
ok, someone has to be the bad guy and show an example of equivalent code that's more difficult to read: choice([use_for_float_demo, use_for_integer_demo])() seriously tho, the bottom line of what people have been telling you is that for the function (or method) foo(): def foo(): : there is

Re: [Tutor] String concatenation too slow

2008-06-30 Thread wesley chun
> I've been > using string concatenation to read through the string, and then create > the new one based on a dictionary lookup. However it becomes very slow > once the string gets very long (several thousand characters). [...] > I was wondering if there might be a > faster alternative to strin

Re: [Tutor] Is "var = None" in Python equivalent to "Set var = Nothing"in VB?

2008-06-30 Thread wesley chun
> Thanks for your reply (also thanks to others who replied). I was trying to > translate a VBA sample in this page http://tinyurl.com/3hvj3j to python. The > VBA > sample has a line "Set objDbx = Nothing". kelie, thanks for your reply... it helps clear things up -- i didn't think i was going to

Re: [Tutor] s[len(s):len(s)] = [x] ??

2008-06-29 Thread wesley chun
> > e.g. can you predict the result of the following operations without trying > > it? > > > > a = [1, 2, 3, 4] > > a[1:3] = [7, 8] > > print a > > [1, 7, 8, 4] Whew! > (I really wasn't positive that it shouldn't be [1, [7, 8], 4] !) good job dick! of course, you *know* i'm going to ask this.

Re: [Tutor] Is "var = None" in Python equivalent to "Set var

2008-06-29 Thread wesley chun
> As I understand it there are no cases where obj==None and obj is None > will give different results (which is not true for == vs is in > general), so is there any practical difference? Maybe you save a > handful of cycles? as far as i know, that's it. but if this comparison happens a *lot*

Re: [Tutor] Is "var = None" in Python equivalent to "Set var

2008-06-29 Thread wesley chun
> The original author asked about the similarity between VB setting an object > to Nothing, and Python vars being set to None > > Your answer implies that this is an outdate practice (or not preferred) in > Python nope, i just said it doesn't appear to be standard practice. i don't see it much i

Re: [Tutor] Is "var = None" in Python equivalent to "Set var

2008-06-29 Thread wesley chun
> >>the reason why i ask is because it's not standard practice i see > >>people doing this with Python, > > Why? i've been programming in Python continously/full-time for the past 11 yrs at 4+ companies, and i'll stand by my statement... i just don't see it in the code, nor do i do this myself. i

Re: [Tutor] Is "var = None" in Python equivalent to "Set var = Nothing"in VB?

2008-06-29 Thread wesley chun
> > Suppose var holds a reference to an objeect, my question is in the subject. > > Pretty much so, yes. > There may be very subtle differences due to how Python and VB > treat variables but the basic intent is the same one question i'd like to ask is, in what context is such a line part of yo

Re: [Tutor] Create file and input text

2008-06-28 Thread wesley chun
> The first line, the import of the 'os' module, is superfluous: it's > not being used. oops, good catch danny... i didn't even see that. > Python won't let you break any laws of gravity. But there are a lot > of good people here on Tutor who will be happy to be of assistance > when the pro

Re: [Tutor] Create file and input text

2008-06-28 Thread wesley chun
> Hi, I am very new to python and [...] came up with this; > #!/usr/bin/python > > import os > filename = raw_input('Enter the filename: ') > fobj = open(filename, 'w') > yourname = raw_input('What is your name: ') > fobj.write(yourname) > fobj.close() > > It seems to work Ok, I w

Re: [Tutor] Using Python in Windows

2008-06-28 Thread wesley chun
> Hmm. The instruction on adding something gasp the library seems to be > catered towards Linux. hmmm, you are correct, and apparently, this is a popular question to the maintainers (note these links are circular): https://answers.launchpad.net/gasp-code/+question/36144 https://answers.launchpad.

Re: [Tutor] Using Python in Windows

2008-06-28 Thread wesley chun
> IDLE 1.2.2 > >>> from gasp import * > > Traceback (most recent call last): > File "", line 1, in >from gasp import * > ImportError: No module named gasp as brian mentioned, gasp doesn't come with Python. in fact, this very thread came up just last month, and here was one of my repli

Re: [Tutor] "local variable 'l1' referenced before assignment"

2008-06-28 Thread wesley chun
> BTW I see that your book has what seems to be a thorough discussion of > namespaces and variable scopes in chapter 12. ah, that section (12.3) you're referring to is mostly about namespaces as it's in the Modules chapter. the real bit about variable scope that you're seeking is actually in the

Re: [Tutor] "local variable 'l1' referenced before assignment"

2008-06-28 Thread wesley chun
> Sorry to be dense, but how, in what way, is a1's l1 different from a2's > l1"? Both are [1,2,3]*100 . dick, alan and everyone else are correct, but let me just put it as simply as this: - in a1(), you're accessing l1 as a global variable - in a2(), you're making l1 a local variable but tryin

Re: [Tutor] Object attributes surviving deletion

2008-06-26 Thread wesley chun
> If I 'overwrite' a class variable > with an instance one (as I did originally), is the class variable > recoverable? Will objects created later have the class or the instance > variable? yes, but you need to access it with the class name: Grammars.database the other (uglier) alternative is to

Re: [Tutor] dollarize.py

2008-06-21 Thread wesley chun
> dollarize(1234567.8901) returns-> $1,234,567,89 >: > amount = raw_input("Enter an amount: ") > dollar_amount = dollarize(amount) > print dollar_amount the solution you're creating is *slightly* different than the original spec in the problem (Exercise 13-3). the argument to dollarize() is s

Re: [Tutor] Help! Character conversion from a rtf file.

2008-06-20 Thread wesley chun
> I'd like to learn the language by writing some simple programs rather than > keep reading books. My first program will convert certain uni-code characters > (let's say UTF-8) in an RTF file format based on a certain mapping > in another RTF file that is called a "RTF Control file". > : > The

FYA: visualizing repository commits

2008-06-16 Thread wesley chun
have you guys seen this on Slashdot yet? (i did a quick search in the archives and haven't seen any posts yet so hopefully this isn't a duplicate msg!) http://developers.slashdot.org/developers/08/06/16/1855209.shtml this video is a visualization of the commits to the source base (and made by who

Re: [Tutor] static methods and class methods

2008-06-12 Thread wesley chun
[static methods, class methods] > Both of these are rarely used; I don't think I have ever written a > class method in live code. I have used staticmethods as a convenient > way to put a function into a class namespace. this is someone out of the flow of the current thread now, but i forgot to me

Re: [Tutor] Uniform 'for' behavior for strings and files

2008-06-11 Thread wesley chun
> for item in block: > > where block is a file, then item becomes each line of the file in turn > But if block in a large string (let's say the actual text that was in > the file), item becomes each character at a time. Is there a way to > have a uniform iteration irrespective of whether block is a

Re: [Tutor] static methods and class methods

2008-06-11 Thread wesley chun
tcm.foo > > > > Did I do something wrong or is this an error on the book's part? > Intuitively, the answer I received makes more sense to me. I am still unsure > of the difference of static and class methods. Can someone enlighten me? hi there, thanks for picking up the book. there ar

Re: [Tutor] doc string format ?

2008-06-11 Thread wesley chun
> I am trying to improve my code quality and have started using doc > strings. What format do you guys use for your doc strings ? > I have 'made up' the following general format ... > > def gen_vhost(kmotion_dir): >""" >Generate the kmotion vhost file from vhost_template expanding %director

Re: [Tutor] doc string format ?

2008-06-11 Thread wesley chun
> I am trying to improve my code quality and have started using doc > strings. What format do you guys use for your doc strings ? > I have 'made up' the following general format ... > > def gen_vhost(kmotion_dir): >""" >Generate the kmotion vhost file from vhost_template expanding %director

Re: [Tutor] __del__ exception

2008-06-05 Thread wesley chun
> class Person: > population = 0 > > def __init__(self, name): > self.name = name > print '%s has been added' %self.name > Person.population += 1 > > def __del__(self): > print '%s is leaving' % self.name >

Re: [Python-3000] PEP 3101 str.format() equivalent of '%#o/x/X'?

2008-05-31 Thread wesley chun
>>> I'd be fine with adding '#' back to the formatting language for hex and oct. >> >> And bin, I assume? > > Of course. somewhat on-topic, can i hear from some of you as far as use-cases for oct() and hex() [plus bin()] in Python code? i find "%x" or "%o" (and its variants) sufficient in servin

Re: [Python-3000] PEP 3101 str.format() equivalent of '%#o/x/X'?

2008-05-29 Thread wesley chun
On 5/29/08, Eric Smith <[EMAIL PROTECTED]> wrote: > Marcin 'Qrczak' Kowalczyk wrote: > > Except that it works incorrectly for negative numbers. wow, that is a great point. i didn't think of this either. it makes it very inconvenient (see below) and makes it more difficult to say we've completed r

Re: [Python-3000] PEP 3101 str.format() equivalent of '%#o/x/X'?

2008-05-29 Thread wesley chun
> wesley chun wrote: >> >> i have to resort to the uglier: >> >>> 'dec: {0}/oct: 0o{0:o}/hex: 0X{0:X}'.format(i) >> 'dec: 45/oct: 0o55/hex: 0X2D' [Nick Coghlan <[EMAIL PROTECTED]>]: > Is being explicit about the displayed prefix

[Python-3000] PEP 3101 str.format() equivalent of '%#o/x/X'?

2008-05-29 Thread wesley chun
hi, i'm looking to duplicate this string format operator '#' functionality with the new format(). here it is using the old string format operator: >>> i = 45 >>> 'dec: %d/oct: %o/hex: %X' % (i, i, i) # no "#" means no leading "0" >>> or "0x/X" 'dec: 45/oct: 55/hex: 2D' >>> 'dec: %d/oct:

Re: [Tutor] I am a web designer wanting to learn Python

2008-05-29 Thread wesley chun
> Don't be so modest - your "Core Python Programming" (by Wesley Chun) is > also a great book for those looking to learn Python. malcolm, thanks for the kudos... really appreciate it. however, the reason why i didn't bring it up is because the target audience o

Re: [Tutor] I am a web designer wanting to learn Python

2008-05-28 Thread wesley chun
> I have been wanting to learn a language for the last 10 years, I am now > just getting around to it. I did some research on languages, because I > decided if I was going learn one, I wanted to learn something that I could > use for many different applications (web being one). Python seemed to of

Re: [Tutor] I am a web designer wanting to learn Python

2008-05-28 Thread wesley chun
> > Where should I begin/go to learn how to create web apps using Python? I > would like to create a dynamic "content managed" website and I have chosen > Python as my language of choice. Can anybody show me, a Mac user, where I, > a programming beginner, can find tutorials for using Python for

Re: [Tutor] String Replacement question

2008-05-22 Thread wesley chun
> > some = 'thing' > > print '%s %s %s %s' % (some,some,some,some) > > You can use named parameters, which moves the repetition to the format string: > > In [24]: print '%(some)s %(some)s %(some)s %(some)s' % (dict(some=some)) > thing thing thing thing > > With multiple values, a common trick

Re: [Tutor] New Style Classes, __getitem__ and iteration

2008-05-19 Thread wesley chun
> I think it is really magical that, when I define __getitem__ on classic > classes, the built-in iterator uses it. > > But, when I make the same class as a new style class, I lose this behavior. > > I didn't realize that something was lost in defining a new style class. > Maybe it's something

Re: [Tutor] datetime syntax error for May 8th and 9th 2008??

2008-05-16 Thread wesley chun
On Fri, May 16, 2008 at 9:29 PM, John Fouhy <[EMAIL PROTECTED]> wrote: > On 17/05/2008, Che M <[EMAIL PROTECTED]> wrote: >> >>> datetime.datetime(2008, 05, 08) >> SyntaxError: invalid token > > It's simpler than that... Try this: > x = 08 > File "", line 1 >x = 08 > ^ > SyntaxErro

Re: [Tutor] Python WSDL Generation Tools

2008-04-21 Thread wesley chun
> I am using SOAPpy for generating web services .I have also written a client > in python for accessing that web service ,and it works fine.Now when i try > to make a java client to access the web service created in python ,the java > client ask me for a wsdl file which is not present . > > So i wa

[Tutor] [ANN] May 2008 Python course

2008-04-01 Thread wesley chun
* apologies if you receive cross-posted duplicates * FINAL REMINDER Need to get up-to-speed with Python as quickly as possible? Come join me, Wesley Chun, author of Prentice-Hall's well-received "Core Python Programming," for another comprehensive intro course next month in bea

[Edu-sig] [ANN] May 2008 Python course

2008-04-01 Thread wesley chun
* apologies if you receive cross-posted duplicates * FINAL REMINDER Need to get up-to-speed with Python as quickly as possible? Come join me, Wesley Chun, author of Prentice-Hall's well-received "Core Python Programming," for another comprehensive intro course next month in bea

[ANN] Python course, May 2008

2008-04-01 Thread wesley chun
*** my apologies... this training course is next month, not this Fall! *** contact me privately off-list for further details. thanks! > FINAL ANNOUNCEMENT > > Need to get up-to-speed with Python as quickly as possible? Come join > me, Wesley Chun, author of Prentice-Hall's we

Re: [ANN] Python courses this Fall

2008-04-01 Thread wesley chun
FINAL ANNOUNCEMENT Need to get up-to-speed with Python as quickly as possible? Come join me, Wesley Chun, author of Prentice-Hall's well-received "Core Python Programming," for another comprehensive intro course next month in beautiful Northern California! I look forward

Re: [Tutor] Scripting Outlook

2008-03-27 Thread wesley chun
> > Can anyone direct me to some examples/documentation for using python to work > > with Outlook? > > and just for another example, here's some older code > which I post untested (altho' it certainly worked > once upon a time). If I get a chance I'll work it > into a how-do-i. i began to write a

What Programming Languages Should You Learn Next?

2008-03-18 Thread wesley chun
http://it.slashdot.org/it/08/03/18/1633229.shtml it was surprising and disappointing that Python was not mentioned *anywhere* in that article but when someone replied, it sparked a long thread of post-discussion. -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python P

Re: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/205183 idiom

2008-03-18 Thread wesley chun
> > You're mixing two completely different approaches of building a > > property. If that code is actually in the book like that, that's a typo > > that you should mention to the author. > > : > > The recipe you're referring to uses a magical function that returns a > > dictionary of getter f

Re: [Tutor] Processing unix style timestamp

2008-03-06 Thread wesley chun
> I looked at datetime, but it seems slightly complex to work with non GMT > timestamps. > > Any pointers? you may also want to take a look at dateutil http://labix.org/python-dateutil i think the online docs has a section devoted to just timestamp parsing. hope this helps! -- wesley - - - - - -

Re: Core Python Programming . . .

2008-01-22 Thread wesley chun
> > 6-11 Conversion. > >   (a) Create a program that will convert from an integer to an > > Internet Protocol (IP) address in the four-octet format of WWW.XXX.YYY.ZZZ > >   (b) Update your program to be able to do the vice verse of the above. > > I think it's is asking to convert a 32-bit int to th

Re: [Tutor] Python Versions

2007-12-12 Thread wesley chun
> Well I have 2.51 and have been encountering many errors > when I try to use some examples from the book "A byte of python". At first > I thought well a few minor things I will just move on and try the next. > Well some work and others dont, and mind you I am only trying to get the > basics down.A

<    1   2   3   4   5   6   >