Re: [Tutor] Which version to start with?

2009-10-05 Thread wesley chun
On Mon, Oct 5, 2009 at 2:24 PM, Nick Hird nrh...@gmail.com 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!

Re: [Tutor] How to perform variable assignment and

2009-10-03 Thread wesley chun
On Fri, Oct 2, 2009 at 11:14 PM, Oxymoron moron@gmail.com wrote: Hello, On Sat, Oct 3, 2009 at 3:56 PM, Didar Hossain didar.hoss...@gmail.com wrote: homedir = os.environ.get('HOME') if homedir:    print My home directory is %s % homedir I do this in Perl - my $home; if ($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 create a program

Re: [Tutor] Help!

2009-09-30 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 = for

Re: Python book

2009-09-30 Thread wesley chun
On Sep 30, 4:58 am, lallous lall...@lgwm.org wrote: Can anyone suggest a good book Python book for advancing from beginner level? (I started with Learning Python 3rd ed) From: James Matthews nyt...ail.com Date: Wed Sep 30 18:47:58 CEST 2009 I like core python programming and dive into

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 module    win32net.NetUseDel(None, 1,{'local':'k:'}) TypeError: an integer is required You have the wrong sequence for NetUseDel().  Try:

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 from

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 expressions and

Re: [Tutor] NameError

2009-09-21 Thread wesley chun
On Mon, Sep 21, 2009 at 2:06 PM, Wayne sri...@gmail.com wrote: On Mon, Sep 21, 2009 at 4:00 PM, kreglet kreg...@gmail.com 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    

[ANN] Intro+Intermediate Python course, San Francisco, Nov 2009

2009-09-15 Thread wesley chun
-on labs will help hammer the concepts home. Come join me, Wesley Chun, author of Prentice-Hall's bestseller Core Python Programming, for a comprehensive course coming up this Fall in beautiful Northern California to get up-to-speed with Python as quickly and as in-depth as possible! WHERE: near

[ANN] Intro+Intermediate Python course, San Francisco, Nov 2009

2009-09-14 Thread wesley chun
-on labs will help hammer the concepts home. Come join me, Wesley Chun, author of Prentice-Hall's bestseller Core Python Programming, for a comprehensive course coming up this Fall in beautiful Northern California to get up-to-speed with Python as quickly and as in-depth as possible! WHERE: near

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

[Edu-sig] Significant drop in CS interest in high schools

2009-08-27 Thread wesley chun
AP CS Courses (and Students) on the Decline, CSTA Survey Finds This spring, the 2009 CSTA National Secondary Computer Science Survey collected responses from some 1,100 high school Computer Science teachers. The results: only 65 percent reported that their schools offer introductory or pre-AP

Re: [Tutor] Automating creation of presentation slides?

2009-08-12 Thread wesley chun
On Wed, Aug 12, 2009 at 1:07 PM, David Kimdavidki...@gmail.com 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.

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 import exists

Re: [Tutor] Currency conversion module in python

2009-07-30 Thread wesley chun
On Thu, Jul 30, 2009 at 11:18 AM, Che Mpine...@hotmail.com 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] 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] Reading Data From File

2009-07-25 Thread wesley chun
On Fri, Jul 24, 2009 at 11:40 PM, Chris Castilloctc...@gmail.com 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

Re: [Tutor] Syntax Problem

2009-07-24 Thread wesley chun
On Fri, Jul 24, 2009 at 2:34 PM, Jesse Harrismrjes...@yahoo.com wrote: for d in Decks.all(): #loop thru all available decks   self.response.out.write('OPTION'+d.name)       self.response.out.write('OPTION'+d.description) self.response.out.write('/SELECT/div')

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 column). this is up to

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

Re: [Tutor] just one question

2009-07-15 Thread wesley chun
On Wed, Jul 15, 2009 at 8:29 AM, Rich Lovelyroadier...@googlemail.com wrote: 2009/7/15 vince spicer vinces1...@gmail.com: : 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

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 was called close. the

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

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    do something    for i in items:        if i 10:            breakout = False        else:      

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: tough-to-explain Python

2009-07-10 Thread Wesley Chun
On Jul 7, 1:04 pm, kj no.em...@please.post wrote: I'm having a hard time coming up with a reasonable way to explain certain things to programming novices. : How do I explain to rank beginners (no programming experience at all) why x and y remain unchanged above, but not z? : What do

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

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

2009-07-09 Thread wesley chun
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 put it online. thx for the pointer

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 Galvancynicalairr...@gmail.com 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

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. what do

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 it came

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 Python manages its memory. with regards to

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 there

Re: [Tutor] Print on 3.1 for Mac?

2009-06-29 Thread wesley chun
On Mon, Jun 29, 2009 at 3:59 AM, Christian Wittscwi...@compuscan.co.za 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

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 the same

Re: [Tutor] filling in web forms

2009-06-21 Thread wesley chun
On Sat, Jun 20, 2009 at 10:25 PM, Pete Frosliefros...@gmail.com 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

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... that is,

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: changeflexion() takes

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 insight as to

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 tyethec...@hotmail.com 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:

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

Re: [ANN] Introduction to Python course, San Francisco, Jun 2009

2009-05-15 Thread wesley chun
! cheers, -wesley On Thu, Apr 9, 2009 at 6:04 PM, wesley chun wes...@gmail.com wrote: 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 a comprehensive intro course coming up this June

Re: [ANN] Introduction to Python course, San Francisco, Jun 2009

2009-05-14 Thread wesley chun
! cheers, -wesley On Thu, Apr 9, 2009 at 3:45 PM, wesley chun wes...@gmail.com wrote: 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 a comprehensive intro course coming up this June

[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

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 of an entire

[Edu-sig] [ANN] upcoming Python education events (Apr-Jul)

2009-04-16 Thread wesley chun
i'm doing 3 Python knowledge/education events within the next few months. 1. APRIL: O'Reilly/Safari Books Online What is Python? webcast (FREE to all) http://www.safaribooksonline.com/events/WhatIsPython.html 2. JUNE: Comprehensive Introduction to Python (3-day training course in San Francisco

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 accomplished

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:   ThisKlass

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 popular book

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', 'filepath0',

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         

[ANN] Introduction to Python course, San Francisco, Jun 2009

2009-04-10 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 a comprehensive intro course coming up this June in beautiful Northern California! Please pass on this note to whomever you think may

[ANN] Introduction to Python course, San Francisco, Jun 2009

2009-04-09 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 a comprehensive intro course coming up this June in beautiful Northern California! Please pass on this note to whomever you think may

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 conversion

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 simple.

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+:

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 pypro...@gmail.com 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

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):

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 jessica06c...@yahoo.com 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

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 shown?

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 IDJoseph/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 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 then you

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 inner

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 inner

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 becomes

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-16 Thread wesley chun
On Mon, Feb 16, 2009 at 8:24 PM, Wayne Watson sierra_mtnv...@sbcglobal.net 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

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 (शंतनू महाजन) shanta...@gmail.com 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:

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] 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] 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? Don't be shy to

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

Re: [Tutor] string fomatting

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

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 'x'

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 explanation

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 division will be (or

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 ken...@tds.net wrote: On Wed, Jan 14, 2009 at 2:36 PM, Brian van den Broek br...@cc.umanitoba.ca 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

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. How do you take

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

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 was a pain

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 can't assume that

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: IndexError and

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):

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] variable number of inputs

2009-01-07 Thread wesley chun
On Wed, Jan 7, 2009 at 7:01 PM, bob gailer bgai...@gmail.com 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.

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

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 mention it

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 printed, when I

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

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 have

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 the

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

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.24

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: NameError: global name

<    1   2   3   4   5   6   >