Re: a simple question

2021-07-29 Thread Sean DiZazzo
On Tuesday, July 27, 2021 at 5:05:27 AM UTC-7, Terry Reedy wrote: > On 7/26/2021 6:19 PM, Glenn Wilson via Python-list wrote: > > I recently downloaded the latest version of python, 3.9.6. Everything works > > except, the turtle module. I get an error message every time , I use basic > > command

Re: a simple question

2021-07-27 Thread Terry Reedy
On 7/26/2021 6:19 PM, Glenn Wilson via Python-list wrote: I recently downloaded the latest version of python, 3.9.6. Everything works except, the turtle module. I get an error message every time , I use basic commands like forward, backward, right and left. My syntax is correct: pat.forward(10

RE: a simple question

2021-07-26 Thread Avi Gross via Python-list
the way they probably did not write proper code in the first place that loads the module(s) they need? -Original Message- From: Python-list On Behalf Of Dennis Lee Bieber Sent: Monday, July 26, 2021 9:46 PM To: python-list@python.org Subject: Re: a simple question On Mon, 26 Jul 2021 22:19

Re: a simple question

2021-07-26 Thread dn via Python-list
On 27/07/2021 10.19, Glenn Wilson via Python-list wrote: > I recently downloaded the latest version of python, 3.9.6. Everything works > except, the turtle module. I get an error message every time , I use basic > commands like forward, backward, right and left. My syntax is correct: > pat.forwa

Re: a simple question

2021-07-26 Thread Paul Bryan
It would help to know the error message you get every time. On Mon, 2021-07-26 at 22:19 +, Glenn Wilson via Python-list wrote: > I recently downloaded the latest version of python, 3.9.6. Everything > works except, the turtle module. I get an error message every time , > I use basic commands l

a simple question

2021-07-26 Thread Glenn Wilson via Python-list
I recently downloaded the latest version of python, 3.9.6. Everything works except, the turtle module. I get an error message every time , I use basic commands like forward, backward, right and left. My syntax is correct: pat.forward(100) is an example. Can you tell me what is wrong.      thanks

Re: This should be a simple question...

2009-03-09 Thread Tim Chase
Steven D'Aprano wrote: Tim Chase wrote: If the constants don't actually share any conceptual commonality, then SteveH is right, that they really should just be globals. Surely that's backwards? If the constants don't share any conceptual commonality, they should be kept independent in the func

Re: This should be a simple question...

2009-03-09 Thread Steven D'Aprano
Tim Chase wrote: > If the constants don't actually share any conceptual commonality, > then SteveH is right, that they really should just be globals. Surely that's backwards? If the constants don't share any conceptual commonality, they should be kept independent in the functions and not made glo

Re: This should be a simple question...

2009-03-08 Thread Steve Holden
Steven D'Aprano wrote: > Steve Holden wrote: > >> If x and b are meant to be global than bite the bullet and *make* them >> global. > > Well, there's global, and there's global. > > There's global to a few functions in a module, there's global to everything > in a module, and global to an entire

Re: This should be a simple question...

2009-03-06 Thread andrew cooke
Steven D'Aprano wrote: > Steve Holden wrote: > >> If x and b are meant to be global than bite the bullet and *make* them >> global. > > Well, there's global, and there's global. > > There's global to a few functions in a module, there's global to > everything > in a module, and global to an entire

Re: This should be a simple question...

2009-03-06 Thread Steven D'Aprano
Steve Holden wrote: > If x and b are meant to be global than bite the bullet and *make* them > global. Well, there's global, and there's global. There's global to a few functions in a module, there's global to everything in a module, and global to an entire application. They're not necessarily t

Re: This should be a simple question...

2009-03-06 Thread Terry Reedy
Neal Becker wrote: Maybe I'm missing something obvious here def A (...): #set a bunch of variables x = 1 b = 2 ... Do something with them def B (...): #set the same bunch of variables x = 1 b = 2 ... Do something with them I want to apply DRY, and extract out the common setti

Re: This should be a simple question...

2009-03-06 Thread Tim Chase
As Diez suggests, if you don't want to litter your global namespace, use a class: class Foo: x = 1 b = 2 @classmethod def A(cls, *args, **kwargs): do_stuff_with(Foo.x, Foo.b, args, kwargs) @classmethod def B(cls,*args, **kwargs): do_other_stuff_with(Foo.x, Fo

Re: This should be a simple question...

2009-03-06 Thread Steve Holden
Tim Chase wrote: >> Maybe I'm missing something obvious here >> >> def A (...): >> #set a bunch of variables >> x = 1 >> b = 2 >> ... >> >> Do something with them >> >> def B (...): >> #set the same bunch of variables >> x = 1 >> b = 2 >> ... >> >> Do something with them >> >> I wan

Re: This should be a simple question...

2009-03-06 Thread Tim Chase
Maybe I'm missing something obvious here def A (...): #set a bunch of variables x = 1 b = 2 ... Do something with them def B (...): #set the same bunch of variables x = 1 b = 2 ... Do something with them I want to apply DRY, and extract out the common setting of these variable

Re: This should be a simple question...

2009-03-06 Thread andrew cooke
Neal Becker wrote: > What if I had: > > my_obj = common_variables() > That set all these attributes, but then with function A I inject them into > A's scope (shouldn't be too hard to do, I think)? "DRY" is a shorthand for people to remember, but it's not a direct law. i am worried that you are tr

Re: This should be a simple question...

2009-03-06 Thread Neal Becker
Bruno Desthuilliers wrote: > Neal Becker a écrit : >> Maybe I'm missing something obvious here >> >> def A (...): >> #set a bunch of variables >> x = 1 >> b = 2 >> ... >> >> Do something with them >> >> def B (...): >> #set the same bunch of variables >> x = 1 >> b = 2 >> ... >>

Re: This should be a simple question...

2009-03-06 Thread Bruno Desthuilliers
Neal Becker a écrit : Maybe I'm missing something obvious here def A (...): #set a bunch of variables x = 1 b = 2 ... Do something with them def B (...): #set the same bunch of variables x = 1 b = 2 ... Do something with them I want to apply DRY, and extract out the common se

Re: This should be a simple question...

2009-03-06 Thread Diez B. Roggisch
Neal Becker schrieb: Maybe I'm missing something obvious here def A (...): #set a bunch of variables x = 1 b = 2 ... Do something with them def B (...): #set the same bunch of variables x = 1 b = 2 ... Do something with them I want to apply DRY, and extract out the common set

Re: This should be a simple question...

2009-03-06 Thread andrew cooke
if the values are related in meaning then it seems possible that they should be attributes on an object. in which case you would use an instance of the object in both cases and set the values in the objects constructor. if they are not related in meaning then you're not really repeating yourself

This should be a simple question...

2009-03-06 Thread Neal Becker
Maybe I'm missing something obvious here def A (...): #set a bunch of variables x = 1 b = 2 ... Do something with them def B (...): #set the same bunch of variables x = 1 b = 2 ... Do something with them I want to apply DRY, and extract out the common setting of these variables

Re: A Python newbie ask a simple question

2007-07-13 Thread Steve Holden
Jeff McNeil wrote: > The raw_input built-in returns a string. The '[0]' subscript returns > the first character in the user supplied response as strings support > indexing. > > [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin > Type "help", "copyright", "credits" or "license" for more info

Re: A Python newbie ask a simple question

2007-07-13 Thread Wayne Brehaut
On Fri, 13 Jul 2007 14:51:52 -0400, "Jeff McNeil" <[EMAIL PROTECTED]> wrote: >The raw_input built-in returns a string. The '[0]' subscript returns >the first character in the user supplied response as strings support >indexing. > >[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin >Type "hel

Re: A Python newbie ask a simple question

2007-07-13 Thread Christoph Haas
On Fri, Jul 13, 2007 at 06:35:16PM -, [EMAIL PROTECTED] wrote: > what does the statement "choice = raw_input(prompt)[0]" mean? I don't > know why there is a '[0]' in the statement. It calls the "raw_input" function with the argument of "prompt". That function returns a list and you are getting

Re: A Python newbie ask a simple question

2007-07-13 Thread Jeff McNeil
The raw_input built-in returns a string. The '[0]' subscript returns the first character in the user supplied response as strings support indexing. [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> mystr = "asdf" >>>

A Python newbie ask a simple question

2007-07-13 Thread xing93111
what does the statement "choice = raw_input(prompt)[0]" mean? I don't know why there is a '[0]' in the statement. Thank you very much -- http://mail.python.org/mailman/listinfo/python-list

Re: an "urgent" answer to a simple question

2006-07-25 Thread Tim Chase
> I need to install Python Imaging Library (PIL) - > imaging-1.1.5.tar.gz (source ) onto Suse Linux 10.1 system in > order for (latest) Scribus 1.3.3.2 to install and work. Not being a Suse user, I'm flying by the seat of my pants. My recommendation: Install debian, and use "apt-get install pytho

Re: A simple question

2006-03-04 Thread Tuvas
Ahh, that make sense! Thanks a ton! -- http://mail.python.org/mailman/listinfo/python-list

Re: A simple question

2006-03-04 Thread Ben Cartwright
Tuvas wrote: > Why is the output list [[0, 1], [0, 1]] and not [[0, > 1], [0, 0]]? And how can I make it work right? http://www.python.org/doc/faq/programming.html#how-do-i-create-a-multidimensional-list --Ben -- http://mail.python.org/mailman/listinfo/python-list

Re: A simple question

2006-03-04 Thread [EMAIL PROTECTED]
Skip answered why, but not how to make it work right: >>> x = [[0]*2 for x in range(2)] >>> x [[0, 0], [0, 0]] >>> x[0][1]=1 >>> x [[0, 1], [0, 0]] Cheers, n -- http://mail.python.org/mailman/listinfo/python-list

Re: A simple question

2006-03-04 Thread skip
>>> x=[[0]*2]*2 This replicates the references. It doesn't copy objects. This short transcript demonstrates that concept: >>> x = [[0, 0], [0, 0]] >>> map(id, x) [16988720, 16988160] >>> y = [[0]*2]*2 >>> y [[0, 0], [0, 0]] >>> map(id, y) [16988520, 16988520

A simple question

2006-03-04 Thread Tuvas
I know the answer is probably really simple to this, and I feel bad to even ask, but I can't find the answer anywhere... Let me show what happened, then ask the question. >>> x=[[0]*2]*2 >>> x [[0, 0], [0, 0]] >>> x[0][1]=1 >>> x [[0, 1], [0, 1]] >>> The question now. Why is the output list [[0,

Re: A simple question string.replace

2006-01-31 Thread bruno at modulix
Haibao Tang wrote: > I have a two-column data file like this > 1.12.3 > 2.211.1 > 4.31.1 > ... > Is it possible to substitue all '1.1' to some value else without using > re. I suppose that you don't want '11.1' to be affected. raw_data=""" 1.12.3 2.211.1 4.31.1 """ data =

Re: A simple question string.replace

2006-01-30 Thread I V
Haibao Tang wrote: > Is it possible to substitue all '1.1' to some value else without using > re. You could try: import sys values = sys.stdin.readline().split() while values: results = [] for value in values: if value != '1.1': results.append(value) else:

Re: A simple question string.replace

2006-01-30 Thread Emile van Sebille
"Haibao Tang" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I have a two-column data file like this > 1.12.3 > 2.211.1 > 4.31.1 > ... > Is it possible to substitue all '1.1' to some value else without using > re. > Yes -- data = """1.12.3 2.211.1 4.31.1"""

A simple question string.replace

2006-01-30 Thread Haibao Tang
I have a two-column data file like this 1.12.3 2.211.1 4.31.1 ... Is it possible to substitue all '1.1' to some value else without using re. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: a simple question about the third index in slice

2005-10-20 Thread Fredrik Lundh
someone wrote: > I cannot quite understand when the third index is a negative > number,like this: > a = '0123456789' > a[1:10:2] I know the index step is 2, so it will collect items from > offset 1, 3, 5, 7, 9 > but when a negative number come,like: > a[1::-1] answer '10', and a[1:10:-1] only answ

a simple question about the third index in slice

2005-10-20 Thread 700MHz
I cannot quite understand when the third index is a negative number,like this: a = '0123456789' a[1:10:2] I know the index step is 2, so it will collect items from offset 1, 3, 5, 7, 9 but when a negative number come,like: a[1::-1] answer '10', and a[1:10:-1] only answer '', what is the different b