[Tutor] How to set PYTHONPATH

2006-11-06 Thread Eli Brosh
  How do i set the PYTHONPATH variable ? From answers to my query on "editing path" I realized that this is what should be done if i want to include another folder in the  Python search path.   I tried: import sys sys.path.append('additional path')   but it worked only at runtime and is forgotte

Re: [Tutor] is gotchas?

2006-11-06 Thread wesley chun
others already gave good responses, so mine are short. > 1)where do `is` and `==` yield the same results? "is" is object identity comparison while "==" is object value comparison > 2)where do they not yield the same results? they give different results when you have two different objects regar

Re: [Tutor] is gotchas?

2006-11-06 Thread Michael P. Reilly
On 11/6/06, Tim Johnson <[EMAIL PROTECTED]> wrote: * Kent Johnson <[EMAIL PROTECTED]> [061106 10:31]:>> In [9]: a=[1,2]>> In [10]: b=[1,2]  Hmmm! Hmmm!  Lookee here:  ## console session >>> a=[1,2]>>> b=[1,2]>>> a is bFalse>>> c='1'  ## one byte>>> d='1'  ## one byte>>> c is dTrue>>> c='1,2'>>> d='

Re: [Tutor] is gotchas?

2006-11-06 Thread Danny Yoo
c='1' ## one byte d='1' ## one byte c is d > True c='1,2' d='1,2' c is d > False > > The Hmmm! is emmitted because I'm thinking that if everything is an > object in python, then why does `c is d` evaluate to True when > the assigned value is 1 byte and evaluate to Fa

Re: [Tutor] Amazing power of Regular Expressions...

2006-11-06 Thread Jonathon Sisson
John, Thanks...I was a bit deep in a script trying to figure out why I kept getting global key errors (trying to make sure that re.compile and import re weren't run but once...doh?) when you responded. I guess that settles it, then...for this particular instance, '"J" in s' is indeed faster th

Re: [Tutor] Amazing power of Regular Expressions...

2006-11-06 Thread John Fouhy
On 07/11/06, Jonathon Sisson <[EMAIL PROTECTED]> wrote: > Just out of curiousity (since I really can't say myself), does the code > below import re each time it loops? I ran the same commands and saw > quite similar results (0.176 usec per loop for the first test and 0.993 > usec per loop for the

Re: [Tutor] Amazing power of Regular Expressions...

2006-11-06 Thread Jonathon Sisson
Just out of curiousity (since I really can't say myself), does the code below import re each time it loops? I ran the same commands and saw quite similar results (0.176 usec per loop for the first test and 0.993 usec per loop for the second test), and I was just curious if that import (and the

Re: [Tutor] is gotchas?

2006-11-06 Thread Pujo Aji
For small string object python has optimization method so it is really the same object!Cheers,pujoOn 11/7/06, Tim Johnson < [EMAIL PROTECTED]> wrote:* Kent Johnson < [EMAIL PROTECTED]> [061106 10:31]:>> In [9]: a=[1,2]>> In [10]: b=[1,2]  Hmmm! Hmmm!  Lookee here:  ## console session>>> a=[1,2]>>>

Re: [Tutor] is gotchas?

2006-11-06 Thread Tim Johnson
* Kent Johnson <[EMAIL PROTECTED]> [061106 10:31]: > > In [9]: a=[1,2] > > In [10]: b=[1,2] Hmmm! Hmmm! Lookee here: ## console session >>> a=[1,2] >>> b=[1,2] >>> a is b False >>> c='1' ## one byte >>> d='1' ## one byte >>> c is d True >>> c='1,2' >>> d='1,2' >>> c is d False The Hmmm

Re: [Tutor] (OT) Flame wars

2006-11-06 Thread Michael Sparks
On Monday 06 November 2006 22:52, Alan Gauld wrote: > I wasn't aware we were having a war, but I'm happy to desist :-) FWIW, I wasn't aware of one either. (Mind you I've often noticed what passes for plain speaking in the UK passes for vehement flame war elsewhere, so maybe that's it) Anyway, i

[Tutor] a line

2006-11-06 Thread linda.s
What does Pythonw -i test.py -i do in Mac machine? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] 3D rendered bar chart (made of glass)

2006-11-06 Thread János Juhász
Dear Guys, I have downloaded CGkit and Aqsis and tried the examples from it. I run the samples, like the torus with grass. It is simple fantastic. I would like to make some artistic visualization with the power of python and the beauty of a professional renderer. I think about colored semitransl

Re: [Tutor] numpy and python

2006-11-06 Thread Danny Yoo
[Danny] >> If you're using NumPy, then the correct package name for it is 'numpy', >> not 'Numeric'. >> >> from numpy import * [Linda] > I think the code is suing Numeric (is it called numpy now? if so, how > to make the change?) So it's not your code? If it's not your own code then, nail

[Tutor] Ruby Code Blocks vs. Python Lambdas

2006-11-06 Thread Carroll, Barry
Danny: > -Original Message- > Date: Mon, 6 Nov 2006 14:28:30 -0800 (PST) > From: Danny Yoo <[EMAIL PROTECTED]> > Subject: Re: [Tutor] (OT) Flame wars > To: Chris Hengge <[EMAIL PROTECTED]> > Cc: Tutor > Message-ID: <[EMAIL PROTECTED]> > Content-Type: TEXT/PLAIN; charset=US-ASCII; format=f

Re: [Tutor] (OT) Flame wars

2006-11-06 Thread Danny Yoo
On Mon, 6 Nov 2006, Chris Hengge wrote: > I may have just missed the point to your attempt to derail this > conversation =P Hi Chris, Ah! Are we talking about regular expressions anymore? No? Good. *grin* > Why do all that when you can just > > str = "Hello World" > print str * 2 Let

Re: [Tutor] (OT) Flame wars

2006-11-06 Thread Tim Johnson
* Alan Gauld <[EMAIL PROTECTED]> [061106 14:01]: > > The other advantage in Ruby is that the block can be arbitrarily > complex, not just a single expression as in a Python lambda. This > allows us to embed loops and all sorts, effectively adding new > command structures to the language in a way t

Re: [Tutor] First real script

2006-11-06 Thread Luke Paireepinart
Danny Yoo wrote: >> Do you know a better way to do this? >> [snip stuff] >> > > Hi Carlos, > > Here's one way to handle it. If you're familiar with modulo "clock" > arithmetic, you might want to apply it above. > Also, consider this example, Carlos: >>> aList = [1,2,3,4,5,6] >>> a,b,c =

Re: [Tutor] (OT) Flame wars

2006-11-06 Thread Luke Paireepinart
Chris Hengge wrote: > I may have just missed the point to your attempt to derail this > conversation =P Ah, well, don't worry. I didn't learn of lambda until I'd been using Python for a year or more. I was trying to pass arguments to callbacks in TKinter. one of the Pythonistas (Alan, Danny, Ken

Re: [Tutor] (OT) Flame wars

2006-11-06 Thread Alan Gauld
"Danny Yoo" <[EMAIL PROTECTED]> wrote > So let's try to squash this one now. There are more interesting > problems > to solve. Or other flame wars to fight. I wasn't aware we were having a war, but I'm happy to desist :-) > Let me see if we can do something constructive. I've been doing a > s

Re: [Tutor] First real script

2006-11-06 Thread Alan Gauld
"Danny Yoo" <[EMAIL PROTECTED]> wrote > Here's one way to handle it. If you're familiar with modulo "clock" > arithmetic, you might want to apply it above. Indeed, I should have thought of that. Good catch Danny. Alan G. ___ Tutor maillist - Tut

Re: [Tutor] numpy and python

2006-11-06 Thread linda.s
On 11/6/06, Danny Yoo <[EMAIL PROTECTED]> wrote: > > > On Mon, 6 Nov 2006, linda.s wrote: > > > I use Python 2.4 IDLE to open a py code which import numeric. > > I have installed both scipy and numpy into my c:\python24. However, it > > was still reported as: > > Hi Linda, > > We need more details.

Re: [Tutor] First real script

2006-11-06 Thread Alan Gauld
"Carlos" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Do you know a better way to do this? > >if i < A_Len-1: >a = A_List[i-1] >b = A_List[i] >c = A_List[i+1] >else: >a = A_List[i-1] >

Re: [Tutor] (OT) Flame wars

2006-11-06 Thread Chris Hengge
I may have just missed the point to your attempt to derail this conversation =PHowever.. Why do all that when you can just str = "Hello World"print str * 2(Maybe I missed some concept that this small example doesn't accuratly reflect) On 11/6/06, Danny Yoo <[EMAIL PROTECTED]> wrote: > Wow... I had

Re: [Tutor] First real script

2006-11-06 Thread Danny Yoo
> Do you know a better way to do this? > >if i < A_Len-1: > >a = A_List[i-1] >b = A_List[i] >c = A_List[i+1] > >else: > >a = A_List[i-1] >b = A_List[i] >c = A_List[0] Hi Carlos,

Re: [Tutor] (OT) Flame wars

2006-11-06 Thread Danny Yoo
> Wow... I had to click this e-mail just because I saw the first posts on the > mentioned thread and could see it turning for the worst.. Hi everyone, So let's try to squash this one now. There are more interesting problems to solve. Or other flame wars to fight. Let me see if we can do som

Re: [Tutor] First real script

2006-11-06 Thread Carlos
Hi again, Thanks for your comments they are really appreciated. Alan, yes you are right, there is no need to use S, A_Len works the same way. Beginner mistake The dictionary way seems to be way better than my idea, will give it a try. And Danny, your CA is very nice. Do you know a better way

Re: [Tutor] Amazing power of Regular Expressions...

2006-11-06 Thread John Fouhy
On 07/11/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > If anyone really cares which Python implementation is faster, the timeit > module is your friend. Assertions like "would probably be faster" or > "it's also quicker" don't hold much weight. In Python, if you want to > know what is faster, you m

Re: [Tutor] (OT) Flame wars (was: Amazing power of Regular Expressions...)

2006-11-06 Thread Chris Hengge
Wow... I had to click this e-mail just because I saw the first posts on the mentioned thread and could see it turning for the worst.. > I'm serious, if you think ^[0-9A-Za-z_.-]*$ is unclear and complex, go> away > and relearn regales.>> Michael.If this is your method to helping people, you should

[Tutor] (OT) Flame wars (was: Amazing power of Regular Expressions...)

2006-11-06 Thread Carroll, Barry
Greetings, all: > -Original Message- > Date: Mon, 6 Nov 2006 10:32:32 + > From: Michael Sparks <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Amazing power of Regular Expressions... > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset="iso-8859-1" >

Re: [Tutor] Amazing power of Regular Expressions...

2006-11-06 Thread Alan Gauld
"Michael Sparks" <[EMAIL PROTECTED]> wrote > A regex compiles to a jump table, and executes as a statemachine. Sometimes, but it depends on the implementation. If someone uses a C++ compiler that uses the standard library implememation of regex (like say the Microsoft Visual C++ version up till V

Re: [Tutor] Please help to debug this function.. it takes a date and num. of days and returns startdate and enddate (fwd)

2006-11-06 Thread Danny Yoo
[Forwarding to Tutor; busy at the moment] -- Forwarded message -- Date: Mon, 6 Nov 2006 18:41:54 + From: Asrarahmed Kadri <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] Please help to debug this function.. it takes a date and num. of days and re

Re: [Tutor] is gotchas?

2006-11-06 Thread Kent Johnson
Tim Johnson wrote: > I've been using python is 1.5* but haven't used `is` that much. > > 1)where do `is` and `==` yield the same results? > > 2)where do they not yield the same results? is tests for object identity - 'a is b' is true if a is the same object as b. There is no special method, no

Re: [Tutor] First real script

2006-11-06 Thread Alan Gauld
"Carlos" <[EMAIL PROTECTED]> wrote > Here is the code: > Note: Right now maya is not needed to run the code. > > import time > > #This is the initial state. You can put as many integers as you wish > A_List = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1] > > A_Len = len(A_List) > print 'A_List: ',A_Lis

[Tutor] is gotchas?

2006-11-06 Thread Tim Johnson
I've been using python is 1.5* but haven't used `is` that much. 1)where do `is` and `==` yield the same results? 2)where do they not yield the same results? 3)is there a special method for `is'. 4)Pointers to docs are welcome. thanks tim -- Tim Johnson <[EMAIL PROTECTED]> http://www.al

Re: [Tutor] Please help to debug this function.. it takes a date andnum. of days and returns startdate and enddate

2006-11-06 Thread Alan Gauld
"Asrarahmed Kadri" <[EMAIL PROTECTED]> wrote > Please test it, comment on the logic . I haven't tested it but here are some comments: > import string > import datetime > import traceback > > def dateCheck(date1,num_days): >flag = True >startdate = None >enddate = None > >if num_

Re: [Tutor] editing Path

2006-11-06 Thread Alan Gauld
> Eli Brosh schrieb: >> Hello. >> I am beginning to use python on windows. >> how can I add a path to Python search-list where I can store my >> python >> scripts ? As has been said there are two aspects. If you want your scripts to execute as programs you need to modify the PATH environment var

Re: [Tutor] executing script from script

2006-11-06 Thread Alan Gauld
"Eli Brosh" <[EMAIL PROTECTED]> wrote > I wish that my Python program will not be stored on a single file. > how can I call one python script from another ? As Kent says normally you don't call one script from another, instead you write a set of functions (or classes) that you put in one or mor

Re: [Tutor] First real script

2006-11-06 Thread Danny Yoo
On Mon, 6 Nov 2006, Carlos wrote: > This is my first script, I mean the first that I'm trying to do on my > own. Its a very simple Cellular Automata thing, the idea is that the > initial list A_List is rewritten based on some rules, in this case > Wolfram's rule 30. You can modify the list le

Re: [Tutor] Amazing power of Regular Expressions...

2006-11-06 Thread Kent Johnson
Alan Gauld wrote: > "Michael Sparks" <[EMAIL PROTECTED]> wrote >> >> That's equivalent to the regular expression: >>* ^[0-9A-Za-z_.-]*$ > > While using a dictionary is probably overkill, so is a regex. > A simple string holding all characters and an 'in' test would probably > be both easier to

Re: [Tutor] Please help to debug this function.. it takes a date and num. of days and returns startdate and enddate

2006-11-06 Thread Danny Yoo
On Mon, 6 Nov 2006, Asrarahmed Kadri wrote: > I have written a function that takes a date and an integer representing > the number of days. > > Please test it, comment on the logic . Hi Asrarahmed, You should be able to write your own tests too. You might want to look at: http://www.

Re: [Tutor] numpy and python

2006-11-06 Thread Danny Yoo
On Mon, 6 Nov 2006, linda.s wrote: > I use Python 2.4 IDLE to open a py code which import numeric. > I have installed both scipy and numpy into my c:\python24. However, it > was still reported as: Hi Linda, We need more details. What version of scipy and numpy did you install? Where did you

[Tutor] First real script

2006-11-06 Thread Carlos
Hello to all, This is my first script, I mean the first that I'm trying to do on my own. Its a very simple Cellular Automata thing, the idea is that the initial list A_List is rewritten based on some rules, in this case Wolfram's rule 30. You can modify the list length and its initial state, y

[Tutor] Please help to debug this function.. it takes a date and num. of days and returns startdate and enddate

2006-11-06 Thread Asrarahmed Kadri
Hi Folks,   I have written a function that takes a date and an integer representing the number of days.   Please test it, comment on the logic .   Here is the code:   """ The function takes two arguments, date and  number of days. It checks for the right format and if the format is okay, it calc

Re: [Tutor] executing script from script

2006-11-06 Thread Kent Johnson
Eli Brosh wrote: > Hello. > I wish that my Python program will not be stored on a single file. > how can I call one python script from another ? Put part of the script in a module that you import from another module. Read more here: http://docs.python.org/tut/node8.html Kent ___

Re: [Tutor] editing Path

2006-11-06 Thread Christopher Arndt
Eli Brosh schrieb: > Hello. > I am beginning to use python on windows. > how can I add a path to Python search-list where I can store my python > scripts ? > On IDLE the command *browse path* lets me to see the existing path but > not to edit it. Hello, you may be confusing* two different concept

Re: [Tutor] editing Path

2006-11-06 Thread Asrarahmed Kadri
Hi Eli,   You really dont have to edit the search path, because if all the files lie in the same-directory as the top-level file, then Python automatically includes that directory in its search path.   HTH, Regards, Asrarahmed  On 11/6/06, Eli Brosh <[EMAIL PROTECTED]> wrote: Hello. I am beginnin

[Tutor] numpy and python

2006-11-06 Thread linda.s
I use Python 2.4 IDLE to open a py code which import numeric. I have installed both scipy and numpy into my c:\python24. However, it was still reported as: from Numeric import * ImportError: No module named Numeric I got confused... ___ Tutor maillist

[Tutor] executing script from script

2006-11-06 Thread Eli Brosh
Hello. I wish that my Python program will not be stored on a single file. how can I call one python script from another ?   Thanks Eli___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] editing Path

2006-11-06 Thread Eli Brosh
Hello. I am beginning to use python on windows. how can I add a path to Python search-list where I can store my python scripts ? On IDLE the command browse path lets me to see the existing path but not to edit it.   thanks Eli___ Tutor maillist - Tut

Re: [Tutor] Amazing power of Regular Expressions...

2006-11-06 Thread Michael Sparks
On Monday 06 November 2006 01:08, Alan Gauld wrote: > While using a dictionary is probably overkill, so is a regex. No, in this case it's absolutely the right choice. > A simple string holding all characters and an 'in' test would probably > be both easier to read and faster. I'm stunned you th

Re: [Tutor] Wrong module name and line number in logging package.

2006-11-06 Thread Noufal Ibrahim
Noufal Ibrahim airtelbroadband.in> writes: > > Greetings everyone, >I'm using the python standard logging package for a personal project > of mine and have initialised it like so. > > logger = logging.getLogger("pydagogue") > handler = logging.StreamHandler() > handler.setFormatter(logging