Re: [Tutor] Olle-Olla

2006-04-18 Thread János Juhász
Dear All, Thanks your answers about why I can't redifne the print. I just wanted to play with Python dynamic possibilities. I wanted to replace function in a loaded module instead of create an inherited class and using that. It was easier to try it with print. Alan Gauld wrote: > Guido's call.

Re: [Tutor] unit testing raw_input()

2006-04-18 Thread Alan Gauld
> Suppose I had a function like the following: # def y_n(prompt="Answer yes or no"): while True: answer = raw_input(prompt) if answer in ['y', 'Y', 'yes']: print "You said yes!" break elif answer in ['n', 'N', 'no']: print

Re: [Tutor] encode

2006-04-18 Thread Danny Yoo
On Wed, 19 Apr 2006, kakada wrote: > I wonder if we can check the encoding of text in one text file. user is > free to encode the file whether Latin1, utf-8, ANSI... In the general case, this is difficult, and "solving" it might be worse than not. See: http://www.joelonsoftware.com/art

Re: [Tutor] encode

2006-04-18 Thread Python
On Wed, 2006-04-19 at 10:10 +0700, kakada wrote: > Hi again folks, > > I wonder if we can check the encoding of text in one text file. > user is free to encode the file whether Latin1, utf-8, ANSI... > Any ideas? def decode_file(filepath): '''Order of codecs is important. ASCII is most r

Re: [Tutor] Python programmer needs to learn Java

2006-04-18 Thread Justin Ezequiel
> If you already know a language "Just Java" (now titled "Just Java 2") by > Peter van der Linden is very good. Thanks Terry. Will surely check this out. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] encode

2006-04-18 Thread kakada
Hi again folks, I wonder if we can check the encoding of text in one text file. user is free to encode the file whether Latin1, utf-8, ANSI... Any ideas? Thx da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python programmer needs to learn Java

2006-04-18 Thread Justin Ezequiel
> The only online resources I recommend for Java are: > 1) Bruce Eckel's Thinking in Java and > 2) The official Sun tutorial > > The only book I've found that I like is: > O'Reilly Learning Java > > The Java in a Nutshell is a useful reference too. > Thanks Alan. Will check these out ASAP. ___

Re: [Tutor] unit testing raw_input()

2006-04-18 Thread Danny Yoo
On Tue, 18 Apr 2006, Andre Roberge wrote: > Suppose I had a function like the following: > > def y_n(prompt="Answer yes or no"): >while True: >answer = raw_input(prompt) >if answer in ['y', 'Y', 'yes']: >print "You said yes!" >break >elif answe

Re: [Tutor] unit testing raw_input()

2006-04-18 Thread Michael
On Tuesday 18 April 2006 23:34, Andre Roberge wrote: > Hi all- > > Suppose I had a function like the following: > > [ function that interacts with the outside world ] ... > How could I go about to write an automated test for it? You create a mock for raw_input, put the above code inside a module a

Re: [Tutor] Version of a .pyc file

2006-04-18 Thread Terry Carroll
On Tue, 18 Apr 2006, Don Taylor wrote: > How can I tell if a .pyc file was built with 2.3 or 2.4? There's a "Magic Number" in the first 2 or 4 bytes, (depending on whether you consider the \r\n part of the MN). >>> f = open("pycfile.pyc", "rb") >>> magictable = {'\x3b\xf2\r\n': "2.3", '\x6d\xf2

[Tutor] unit testing raw_input()

2006-04-18 Thread Andre Roberge
Hi all- Suppose I had a function like the following: def y_n(prompt="Answer yes or no"): while True: answer = raw_input(prompt) if answer in ['y', 'Y', 'yes']: print "You said yes!" break elif answer in ['n', 'N', 'no']: print "You s

[Tutor] Version of a .pyc file

2006-04-18 Thread Don Taylor
I want like to write a script to scan all of the .pyc on my pythonpath to find out if they were built with Python 2.3 or 2.4. How can I tell if a .pyc file was built with 2.3 or 2.4? Thanks, Don. ___ Tutor maillist - Tutor@python.org http://mail.py

Re: [Tutor] creating a tab delim file

2006-04-18 Thread Karl Pfl?sterer
On 18 Apr 2006, [EMAIL PROTECTED] wrote: > The problem: > > I have 50 tab delim files. Each file has 500 rows and > 50 columns. > > I have to read the first column of each file. Repeat > the same for 50 files and write a tab delim text file > containing 500 rows and 50 columns. > > code that wo

Re: [Tutor] Tutorial on bitwise Python?

2006-04-18 Thread Alan Gauld
> Can anyone point me to a tutorial on bit manipulations (testing and > setting) in Python? Look at the sidebar in my OS topic. It covers using bitmasks to test the bits set by the file stat functions. HTH, Alan G Author of the learn to program web tutor http://www.freenetpages.co.uk/hp/alan.g

Re: [Tutor] Olle-Olla

2006-04-18 Thread Kent Johnson
Andre Engels wrote: > 2006/4/18, Kent Johnson <[EMAIL PROTECTED]>: >> János Juhász wrote: >>> Hi All, >>> >>> Is it possible to replace the print statement with one of mine function ? >>> >>> In reality, I would like to replace the print in my PyCrust app with the >>> log.write() function. >> Best:

[Tutor] creating a tab delim file

2006-04-18 Thread Srinivas Iyyer
Hi group, I asked similar questions in the past. I am unable to get to the crux of this problem so that I can solve on my own. apologies for my ignorance. The problem: I have 50 tab delim files. Each file has 500 rows and 50 columns. I have to read the first column of each file. Repeat the s

[Tutor] Help Entry !!!

2006-04-18 Thread Cesar Garcia
Hi !!! Friends, i nedd process Data Entry in python Example   Entry = 20 Result = 20*10   This Result in Windows (Tkinter) How do you do Think !!!   Regards Cesar Exmaple from Tkinter import * class MyDialog:     def __init__(self, parent):    top = self.top = Toplevel(parent

Re: [Tutor] GUI

2006-04-18 Thread Eric Walker
Alan Gauld wrote: >> I want to create a GUI, and I downloaded the pyQT stuff. > > > Any reason why you must use PyQt? > > Not that it's a bad toolkit but there is less expertise in using it so > unless you already use it from another language - like C++ - its going > to be a lot harder to learn

Re: [Tutor] Olle-Olla

2006-04-18 Thread Alan Gauld
> Is it possible to replace the print statement with one of mine function ? No precisely because the print statement is a statement (or more accurately a command) not a function. But of course you can create your own print *function*, just call it a slightly different name - printit(), or display

Re: [Tutor] wanted exercises in python

2006-04-18 Thread Alan Gauld
> As I mentioned I have been reading Python a lot in last 2 months but > lack of examples and coding is not getting me anywhere. Can someone give > me some exercises or I can try them myself There are a few suggestions in the last topic of my tutor - Refernces etc... But the best place to find s

Re: [Tutor] GUI

2006-04-18 Thread Alan Gauld
> I want to create a GUI, and I downloaded the pyQT stuff. Any reason why you must use PyQt? Not that it's a bad toolkit but there is less expertise in using it so unless you already use it from another language - like C++ - its going to be a lot harder to learn than Tkinter or wxPython which

Re: [Tutor] Olle-Olla

2006-04-18 Thread Kent Johnson
János Juhász wrote: > Hi All, > > Is it possible to replace the print statement with one of mine function ? > > In reality, I would like to replace the print in my PyCrust app with the > log.write() function. Best: Use a good editor to change your print statements to log.write() Not so good: R

Re: [Tutor] Python programmer needs to learn Java

2006-04-18 Thread Terry Carroll
On Tue, 18 Apr 2006, Justin Ezequiel wrote: > I am seeking book recommendations or preferrably online tutorials > to help me learn Java. If you already know a language "Just Java" (now titled "Just Java 2") by Peter van der Linden is very good. It's intended for people who are moving from C to J

Re: [Tutor] functions in Python

2006-04-18 Thread Terry Carroll
On Tue, 18 Apr 2006, Danny Yoo wrote: > Just as a side note: no semicolons needed. *wink* Yesterday, I tested something with a two-line perl program. I could not for the life of me see why I was getting a syntax error. It was only after 15 minutes of looking up red herrings that it finally d

Re: [Tutor] Alan Gauld Tutorial - OOP

2006-04-18 Thread R. Alan Monroe
> Thanks for the prompt response. My real problem is that there is no > place inside a tutorial where all the terms like object, data, method, > operation, attributes are explained on a single page *with* one small > example of each. I am *really* confused when they occur now. I found The _He

[Tutor] Tutorial on bitwise Python?

2006-04-18 Thread Terry Carroll
Can anyone point me to a tutorial on bit manipulations (testing and setting) in Python? I'm very clear on the concepts (in a previous lifetime, I used to do systems programming in IBM System/3x0 assembler), but weak on how some things would be approached in Python, and need an orientation. ___

Re: [Tutor] Quick networking question

2006-04-18 Thread Danny Yoo
On Tue, 18 Apr 2006, Tino Dai wrote: > I am writing a script to do some simple networking. When I do a > close on the socket and exit the program, I getting a time wait on the > port, and the port can''t be utilized again until the time wait > disappears. How do I get port to shut down a

Re: [Tutor] wanted exercises in python

2006-04-18 Thread Andy
Well, these are from a Ruby group but I don't see any reason why you couldn't do them in Python. http://www.rubyquiz.com Look through their quiz's, might find something fun to try. -Andy "Be who you are and be that well." - Saint Francis de Sales On 4/18/06, Payal Rathod <[EMAIL PROTECTED]> w

Re: [Tutor] Olle-Olla

2006-04-18 Thread Danny Yoo
> Is it possible to replace the print statement with one of mine function ? Hi Janos, Yes; there are a set of reserved "keywords" that Python does not allow to be rebound as something else. It's a particular consequence of the way Python's language grammar is parsed. You'll want to watch ou

Re: [Tutor] pyexpat

2006-04-18 Thread Danny Yoo
On Tue, 18 Apr 2006, Andre Engels wrote: > 2006/4/18, Kent Johnson <[EMAIL PROTECTED]>: >> Andre Engels wrote: >>> I am working for the Python Wikipediabot Framework >>> (http://www.sourceforge.net/pywikipedia). A user noted me to an >>> apparent deadlock in the XML parsing. I tried to get to th

Re: [Tutor] wanted exercises in python

2006-04-18 Thread Paul D. Eden
If you have some programming experience already in another language you may want to try the examples in http://www.diveintopython.org/toc/index.html Paul Payal Rathod wrote: > Hi, > As I mentioned I have been reading Python a lot in last 2 months but > lack of examples and coding is not gettin

[Tutor] wanted exercises in python

2006-04-18 Thread Payal Rathod
Hi, As I mentioned I have been reading Python a lot in last 2 months but lack of examples and coding is not getting me anywhere. Can someone give me some exercises or I can try them myself (pythonchallenge.com please excuse). I am reading Alan's tut now and covered Basis set and regex from adv

Re: [Tutor] functions in Python

2006-04-18 Thread Danny Yoo
> New at this but the f(x) with the return statement passes the value back > to be used in something. The one with the print statement just prints > it. Correct me if I am wrong experts > def f(x): > x = x + 1; > return x > > def g(x): > x=x + 1; > print x; Hi Eric, Yes, you've got it

Re: [Tutor] Alan Gauld Tutorial - OOP

2006-04-18 Thread Alan Gauld
> No, I read the tutorial from start. I am not understanding how data, > objects, attributes etc. are related to each other. That is back in the Raw Materials section. And objects are then expanded in the OOP topic. > I am really curious, why didn't you make the whole tutorial Python only. Bec

Re: [Tutor] Alan Gauld Tutorial - OOP

2006-04-18 Thread Payal Rathod
On Tue, Apr 18, 2006 at 03:29:28PM +0100, Alan Gauld wrote: > Have you read through the basics section of the tutor or are you > simply picking topics of intrest? You can do that with the advanced No, I read the tutorial from start. I am not understanding how data, objects, attributes etc. are

[Tutor] Quick networking question

2006-04-18 Thread Tino Dai
Hi Everybody,  I am writing a script to do some simple networking. When I do a close on the socket and exit the program, I getting a time wait on the port, and the port can''t be utilized again until the time wait disappears. How do I get port to shut down and be able to reuse that port? Thanks

Re: [Tutor] My Name is John and I copy and paste

2006-04-18 Thread Bob Gailer
John CORRY wrote: > > Hi, > > > > Thanks for all the help so far on my database questions. I have now > developed a program that reads in info from a csv file and updates > already existing records in my database. I have enclosed the code > below. The good news is that it is working. Howev

[Tutor] GUI

2006-04-18 Thread Eric Walker
All, I want to create a GUI, and I downloaded the pyQT stuff. Ok, now that I am reading my but off trying to figure out how to use this thing and learn python at the same time, I read some stuff about having to purchase licenses. For commercial development, who do I need to contact for licensing

Re: [Tutor] Alan Gauld Tutorial - OOP

2006-04-18 Thread Alan Gauld
> I want something like this. e.g. Alan when I read your tut for OOP, I > don't get what you mean by data, variable, and object and difference > between them. Those terms were all explained back in the Raw Materials section since they are fundamental building blocks of programming. Have you

[Tutor] Olle-Olla

2006-04-18 Thread János Juhász
Hi All, Is it possible to replace the print statement with one of mine function ? Is it any extra reason why print isn't similar to the functions I can make with def ? >>> def olle(dummy): print 'olle:', dummy ... >>> def olla(dummy): print 'olla:', dummy ... >>> olle('Hopp') olle: Hopp >>> ol

Re: [Tutor] pyexpat

2006-04-18 Thread Andre Engels
2006/4/18, Kent Johnson <[EMAIL PROTECTED]>: > Andre Engels wrote: > > I am working for the Python Wikipediabot Framework > > (http://www.sourceforge.net/pywikipedia). A user noted me to an > > apparent deadlock in the XML parsing. I tried to get to the actual > > That's pretty surprising, I wouldn

Re: [Tutor] functions in Python

2006-04-18 Thread Eric Walker
Payal Rathod wrote: On Mon, Apr 17, 2006 at 05:42:05PM +0100, Steve Nelson wrote: When you define a function, you are writing a block of code which you can ask to perform a task. The task may be simple, and not require any additional information, or it may be more complex and need informati

Re: [Tutor] Alan Gauld Tutorial - OOP

2006-04-18 Thread Payal Rathod
On Tue, Apr 18, 2006 at 11:19:32AM +0100, Alan Gauld wrote: > I mean the data and the functions that are used to create an object. > As the definition above states, objects are collections of data and > the functions that operate on the data. Another name for a function > inside an object is "oper

Re: [Tutor] pyexpat

2006-04-18 Thread Kent Johnson
Andre Engels wrote: > I am working for the Python Wikipediabot Framework > (http://www.sourceforge.net/pywikipedia). A user noted me to an > apparent deadlock in the XML parsing. I tried to get to the actual That's pretty surprising, I wouldn't expect the parser to use any locks. Can you say more

[Tutor] pyexpat

2006-04-18 Thread Andre Engels
I am working for the Python Wikipediabot Framework (http://www.sourceforge.net/pywikipedia). A user noted me to an apparent deadlock in the XML parsing. I tried to get to the actual parsing code to see what went wrong. The furthest I get, however, is in the feed() method of the class ExpatParser in

[Tutor] Tutor projects

2006-04-18 Thread Tino Dai
Hi there, This list is great! I really like the aspect of mentor-mentee relationship. Ok, I have been programming in various languages for many many years, and here is my dilemna. I jump into a huge project such as Zope or Mambo (php side) and spend a couple of weeks on it, get frustrated, and

Re: [Tutor] My Name is John and I copy and paste

2006-04-18 Thread Kent Johnson
John CORRY wrote: > Thanks for all the help so far on my database questions. I have now > developed a program that reads in info from a csv file and updates > already existing records in my database. I have enclosed the code > below. The good news is that it is working. However, I used copy

Re: [Tutor] Tutor Digest, Vol 26, Issue 56

2006-04-18 Thread Alan Gauld
- Original Message - From: <[EMAIL PROTECTED]> Subject: Re: [Tutor] Tutor Digest, Vol 26, Issue 56 Please don't reply to the digest message, we get all of the digest plus your question tagged on at the end! >> >> End of Tutor Digest, Vol 26, Issue 56 >> *

Re: [Tutor] Python programmer needs to learn Java

2006-04-18 Thread R. Alan Monroe
> Greetings. > I am seeking book recommendations or preferrably online tutorials > to help me learn Java. _Head First Java_ Alan ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Alan Gauld Tutorial - OOP

2006-04-18 Thread Alan Gauld
> I am reading Alan's tut and have stuck on the OOP chapter. > What does he mean by, > > | Objects are collections of data and functions that operate on that > |data. These are bound together so that you can pass an object from one > |part of your program and they automatically get access to n

Re: [Tutor] Python programmer needs to learn Java

2006-04-18 Thread Alan Gauld
> I am seeking book recommendations or preferrably online tutorials > to help me learn Java. The only online resources I recommend for Java are: 1) Bruce Eckel's Thinking in Java and 2) The official Sun tutorial The only book I've found that I like is: O'Reilly Learning Java The Java in a Nutshe

Re: [Tutor] Tutor Digest, Vol 26, Issue 56

2006-04-18 Thread nywbon001
Quoting [EMAIL PROTECTED]: > Send Tutor mailing list submissions to > tutor@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/tutor > or, via email, send a message with subject or body 'help' to > [EMAIL PROTECTED]

[Tutor] My Name is John and I copy and paste

2006-04-18 Thread John CORRY
Hi,   Thanks for all the help so far on my database questions.  I have now developed a program that reads in info from a csv file and updates already existing records in my database.  I have enclosed the code below.  The good news is that it is working.  However, I used copy and paste and

Re: [Tutor] functions in Python

2006-04-18 Thread Payal Rathod
On Mon, Apr 17, 2006 at 10:31:04AM -0700, Danny Yoo wrote: > One view that's common is the idea that a function is a box that takes > an input and returns an output: Thanks a lot for the detailed help. Well, I have now got atleast basics of functions, will be doing some more reading on it in nex

[Tutor] Alan Gauld Tutorial - OOP

2006-04-18 Thread Payal Rathod
Hi, I am reading Alan's tut and have stuck on the OOP chapter. What does he mean by, | Objects are collections of data and functions that operate on that |data. These are bound together so that you can pass an object from one |part of your program and they automatically get access to not only

Re: [Tutor] Raw Bits! (Control characters ahoy!)

2006-04-18 Thread Alan Gauld
Hi Doug, Have you looked at the struct module which provides tools for encoding binary values into byte streams and decoding byte streams into binary data. However if you only need to inject some hex codes into a string you can use the chr() function, this works even for unprintable character

Re: [Tutor] Meaning of %g ?

2006-04-18 Thread Alan Gauld
>> in Python. I must do some tests with gcc to see what it does >> with %g, it may be the wierd behaviour is coming from there. Tried it and get the same behaviour. Tried the Borland C++ compiler and got the same behaviour. Tried my MIX K&R compiler and - it didn't work! - it's a pure DOS applic