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] 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] 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] 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] 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] 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] [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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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-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] 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] Extract strings from a text file

2009-02-27 Thread wesley chun
> There is a text file that looks like this: > > text text text Joseph > text text text text text text text text text text text > text text text text text text text text text text text > text text text text text text text text text text text > text text text text text text text text text text text

Re: [Tutor] Class definition...

2009-02-27 Thread wesley chun
>> I am looking for a good tutorial to walk through that really explains class >> definition. > > I assume from that you have been through the basic tutors like mine? >: > OK, I explain self in my OOP tutor topic ( a sub heading under > "Using Classes"), but again if thats not sufficient th

Re: [Tutor] What does the L at the end of a number means?

2009-02-28 Thread wesley chun
> I have started learning phyton today! > I was playing around with some large numbers (fibonacci series) > and noticed that in some large calculations results have an "L" at the end > of a number. > Does this L stands for Large? Is there any way to disable this feature, so > that all numbers are s

Re: [Tutor] HELP ON A ANAGRAM PYTHON PROGRAM

2009-03-09 Thread wesley chun
On Mon, Mar 9, 2009 at 10:38 AM, jessica cruz wrote: > I made this program but it says that there is an error and I have a hard > time trying to solve the problem with program. >        : > I don't know how to figure out the error since the only message that I get > is that "there's an error: inva

Re: [Tutor] combining Python 2.x and Python 3

2009-03-17 Thread wesley chun
> I would like to change it so that it can be run under both Python 3 and > Python 2.x. everyone who has responded so far are telling about converting your piece of code from Python 2 to Python 3, for example, using the "2to3" tool that comes with Python 2.6+: http://docs.python.org/library/2to3.

Re: [Tutor] sets module equivalent with Python 2.6

2009-03-17 Thread wesley chun
On Tue, Mar 17, 2009 at 2:34 PM, PyProg PyProg wrote: > > I want to use an equivalent of sets module with Python 2.6 ... but > sets module is deprecated on 2.6 version. it is deprecated only because sets have been rolled into Python proper starting in 2.4. replace sets.Set() with set(), and there

Re: [Tutor] combining Python 2.x and Python 3

2009-03-17 Thread wesley chun
> I think the intent of 2to3 is that you maintain the > Python 2.6 version and automatically create the Python 3 version from > it. So there is only one source file. At least one person found this > practical, for a large codebase (well, he says it "mostly works"): > http://wiki.python.org/moin/Por

Re: [Tutor] HI, #Include like in python

2009-03-19 Thread wesley chun
>    import listen > > You can use the __import__ function if you want, but generally you > want the import statement as above.  The equivalent to 'import listen' > is: > >    listen = __import__('listen') > > See the tutorial here: http://docs.python.org/tutorial/modules.html you also have to ma

Re: [Tutor] unicode to plain text conversion

2009-04-06 Thread wesley chun
> I am a total newbie. I have a very large file > 4GB that I need to > convert from Unicode to plain text. I used to just use dos when the file > was < 4GB but it no longer seems to work. Can anyone point me to some > python code that might perform this function? can you elaborate on your convers

Re: [Tutor] unicode to plain text conversion

2009-04-06 Thread wesley chun
> Previously I was able to convert just by using: > Type Unicode_filename.txt > new_text_file.txt > That's it. wow, if that's all you had to do, i'm not sure it's worthwhile to learning a new programming language just to process it with an application when your original solution was so dead simpl

Re: [Tutor] OOPS Problem

2009-04-13 Thread wesley chun
hi, and welcome to Python! my comments below... > I made a class with the name student that prints simply name of the student > as well as his roll_no also, pasting code here . sounds pretty straightforward > class student: >     def __init__(self,name,roll_no): >         self.name=name >    

Re: [Tutor] python books

2009-04-14 Thread wesley chun
>> I am new in python , so need a good books , previously read python Bible and >> swaroop but not satisfied . >> >> >> so tell me good books in pdf format those contents good problems also if you like a conversational style and know at least one programming language, i've written a pretty popul

Re: [Tutor] sorting file paths made up of of strings and numbers

2009-04-14 Thread wesley chun
> How can I sort the following list in a way that takes care of the right > order of numbers? The sorted function compares strings here as far as I can > see, but I want to have filepath2 follow filepath1. Your help is > appreciated. myList > ['filepath54', 'filepath25', 'filepath49', 'filepat

Re: [Tutor] Here's something to talk about

2009-04-15 Thread wesley chun
> 1. Python is not Java although i agree with all 4 points that paul makes, this 1st one stands out the most. when i saw the code the first time, the immediate thought that came to my mind was, "This looks like Java code written with Python syntax." i thing the same functionality can be accomplish

Re: [Tutor] Here's something to talk about

2009-04-15 Thread wesley chun
>> i think it's a common style guideline in multiple >> languages i'm familiar with (other than Python) to Capitalize class >> names but keep variables, functions, and methods all lowered. > > In most cases I know, class names are capitalized, while func and method > names are camel-cased: >   Thi

[Tutor] beginners resources list, Python education events

2009-04-16 Thread wesley chun
hey all, i'm trying to collate a complete newbie-to-programming list of resources and was wondering if you could help me fill in the holes... thx in advance! BOOKS Python Programming for the Absolute Beginner (Dawson, 2005) Python For Dummies (Maruch, Maruch, 2006) Python Programming: An Introduc

Re: [Tutor] importance of Docstring

2009-04-16 Thread wesley chun
def f(x): > > '''f(x) -> x+5''' > return x+5 > help(f) > > Help on function f in module __main__: > > f(x) >   f(x) -> x+5 another thing that has not been mentioned is that if you put docstrings everywhere, you can use tools like Epydoc, doxygen, or sphinx to generate full documentation

Re: [Tutor] quick question to open(filename, 'r') vs. file(filename, 'r')

2009-05-05 Thread wesley chun
> It seems that open(filename, 'r') and file(filename, 'r') are > used interchangeably, and I wonder what this is all about. as alan and others have pointed out, file() was added in 2.2. this was part of the unification of types and classes. every object now has a factory function, i.e., list() c

Re: [Tutor] Replacement for __del__

2009-05-18 Thread wesley chun
> I've been told numerous times that using __del__ is not the way to handle > clean-up because it is finicky. matthew, welcome to Python and this Tutor mailing list! and yes, i'll echo everyone else in saqying that using __del__ should be avoided. the most critical issues regarding this is becau

Re: [Tutor] Displaying range in 3.0.1

2009-05-28 Thread wesley chun
On Thu, May 28, 2009 at 10:22 AM, Gregory Morton wrote: > I've been reading this Python 3.0.1 > tutorial(http://docs.python.org/3.0/tutorial/controlflow.html), and now I'm > stuck at the second example in 4.3. This is what the example says the output > should look like: > > range(5, 10) >5 t

Re: [Tutor] unicode, utf-8 problem again

2009-06-04 Thread wesley chun
>>  But, I still get this error: >>  Traceback (most recent call last): >> ... >> UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in >> position 76: ordinal not in range(128) >>  What am I missing? > > Take a read through http://evanjones.ca/python-utf8.html which will give you >

Re: [Tutor] Need better understanding of **kwargs

2009-06-06 Thread wesley chun
>> Hello, I thought I understood **kwargs until I stumbled with this >> function: >> >> def changeflexion(myword, mytag, **dicty): >>: >> >> but when I import the module and call: >> a = conjugate.changeflexion('estaban', 'VLFin', conjugate.mydict) >> I get this error: >> TypeError: changef

Re: [Tutor] Simple factorial program

2009-06-11 Thread wesley chun
hi eddie, a few more nits to tweak... > factorialNum = 1L change to "1" instead of "1L" -- "L" numbers are going away and will be permanently not available starting in 3.0. > print "Factorial finder" > number = int(input("Please enter a non-negative integer: ")) change "input" to "raw_input".

Re: [Tutor] 3.0 on Mac

2009-06-11 Thread wesley chun
> A 'python3' command is not recognized. I'd like to > know what I need to change to access V3.0.1 from a Terminal window. try python3.0 if that doesn't work, then you may have to add the directory where it's installed to your PATH. hope this helps, and welcome to Python! -- wesley - - - - - - -

Re: [Tutor] filling in web forms

2009-06-20 Thread wesley chun
On Sat, Jun 20, 2009 at 10:25 PM, Pete Froslie wrote: > Thank you so much.. I will start looking into twill and I just finished > installing Mechanize. those are very well-known individual tools that will meet your needs. for larger web testing frameworks, you may also consider Windmill and Selen

Re: [Tutor] does python have something like "#include" in C?

2009-06-29 Thread wesley chun
> However, it seems that I can't put the function definition in a file > and import it because I can't find a way to refer to an object in the > main program file from within a module file. I understand that it's a > good thing to contol which namespaces are referenced by which code but > isn't the

Re: [Tutor] "Print" on 3.1 for Mac?

2009-06-29 Thread wesley chun
On Mon, Jun 29, 2009 at 3:59 AM, Christian Witts wrote: > l...@ithstech.com wrote: >> >> Have I installed something incorrectly in Python 3.1 for Mac if I get a >> syntax error on >> >> print "hello world" >> >> My Python 2.3.5 executes this just fine.  What have I missed? > > Please take a read th

Re: [Tutor] does python have something like "#include" in C?

2009-06-29 Thread wesley chun
>> from showmodule import show >> >> then everything else will work. > > I don't think so. The exec in show() must be run in the namespace in > which the symbols being displayed are defined. yep, you're right. i didn't see the exec. it will only work if the called function somehow had access to t

Re: [Tutor] When are strings interned?

2009-07-01 Thread wesley chun
n = "colourless" o = "colourless" n == o > True n is o > True p = "green ideas" q = "green ideas" p == q > True p is q > False > > Why the difference? angus, welcome to Python! you're definitely doing your homework when it comes to trying to understand how

Re: [Tutor] mac os x executable

2009-07-07 Thread wesley chun
>> >I'm having trouble finding good tutorials on creating standalone >> > executable >> >files for mac os x.. I've been looking at 'py2app', [...] pete, welcome to Python! in order for all to answer your question more appropriately, you'll have to describe the problem in slightly more detail.

Re: [Tutor] mac os x executable

2009-07-07 Thread wesley chun
>>> After all with Python 2.3 pre installed on MacOS X >> Is Python 2.3 really the most recent version of Python distributed with >> new Macs? > I think *new* Macs come with 2.5. My 2-year-old MacBook Pro has 2.3. i got a new MBP from work about half a year ago with leopard 10.5.6 installed, and

Re: [Tutor] Python Tutorials: How to create useful programs after learning the syntax?

2009-07-08 Thread wesley chun
On Sun, Jul 5, 2009 at 11:48 PM, Luis Galvan wrote: > Hello all, this is my first time using a mailing list, so I'm not sure if > I'm doing this right!  Anyway, I have a wee bit of a problem.  I've recently > completed watching a Youtube video series on Python 2.6 by thenewboston > which helped me

Re: [Tutor] Python Tutorials: How to create useful programs after learning the syntax?

2009-07-09 Thread wesley chun
Robert, Emile, Malcolm, wow, you guys are making me blush while hijacking this thread! people are gonna start thinking i paid you off somehow LOL! :-) seriously, thanks for the kudos. since i'm a technical instructor, i wrote it not only from the software engineer's perspective, but also a teache

Re: [Tutor] Python Tutorials: How to create useful programs after learning the syntax?

2009-07-09 Thread wesley chun
Safari Books (you may have to signup for a free > account to see the video). > > What is Python by CPP (Core Python Programming) by author Wesley Chun > http://www.safaribooksonline.com/Corporate/DownloadAndResources/webcasts.php ah, i wasn't aware that they finished editing it and pu

Re: [Tutor] Python Tutorials: How to create useful programs after learning the syntax?

2009-07-11 Thread wesley chun
luis, thanks for the kind words... i am glad that i am able to help you with developing your Python programming skills. you are indeed "taking it to the next level" by adding more to the problem without me asking you to. i think that's great! i am a software engineer by profession, which doesn't

Re: [Tutor] While and for loops

2009-07-14 Thread wesley chun
> Can you run for loops in while loops and if yes, why did my if condition not > break the loop? > > I read that loops sort of have an order of precedence, does that have > anything to do with this problem? todd, welcome to Python! you're right in that your questions are related to each other

Re: [Tutor] While and for loops

2009-07-14 Thread wesley chun
>> So how would you break out from this situation? > > finished = False > while not finished: >     >     for i in items: >         if i > 10: >             finished = True  # Do not do the next while-iteration >             break            # and break out of the for loop >         else: >      

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

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] 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] 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] 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] 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] 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-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] 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] 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] 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

[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] 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

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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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-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] 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

[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] 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

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-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] 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] 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] 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] 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] 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] Inherit from int?

2007-05-13 Thread wesley chun
> I'm stumped. This silly bit of code doesn't work. I expect the > output to be 8, not 18. What am I missing? > > class Under10(int): > def __init__(self, number): > number %= 10 > int.__init__(self, number) marilyn, i agree with most of the earlier replies... you need to u

  1   2   3   4   >