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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
>> ...
>>
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
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
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
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
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
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
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
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"
>>>
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
> 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
Ahh, that make sense! Thanks a ton!
--
http://mail.python.org/mailman/listinfo/python-list
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
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
>>> 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
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,
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 =
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:
"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"""
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
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
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
38 matches
Mail list logo