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 
> > commands like forward, backward, right and left. My syntax is correct: 
> > pat.forward(100) is an example. Can you tell me what is wrong.
> On Windows, normal install, 
> C:\Users\Terry>py -3.9 -m turtle 
> C:\Users\Terry>py -3.9 -m turtledemo 
> both work. 
> 
> 
> -- 
> Terry Jan Reedy

Welcome to programming!!  Ain't it fun?!
-- 
https://mail.python.org/mailman/listinfo/python-list


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(100) is an example. Can you tell me what is wrong.


On Windows, normal install,
C:\Users\Terry>py -3.9 -m turtle
C:\Users\Terry>py -3.9 -m turtledemo
both work.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


RE: a simple question

2021-07-26 Thread Avi Gross via Python-list
In addition to the other requests for more info on a very ambiguous
question, let me add one. Did the message suggest something worked on an
earlier version and broke with a new version, or did they mean they just
started USING the current version and hoped the version number was
meaningful for 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:58 + (UTC), Glenn Wilson via Python-list
 declaimed the following:

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

No we can't. 

Please provide a cut (NOT a screen-grab image) of the error
traceback, an indication of what OS/hardware you are running upon, etc.
Maybe even which installer you downloaded (python.org, or some third-party
repackager: ActiveState, Anaconda, M$ app store)



-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/

--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


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.forward(100) is an example. Can you tell me what is wrong.


Python comes with "batteries included". However, if 'everything' was
made immediately-available, each of your program[me]s would be very
long. Accordingly, the 'batteries' are kept in what is called "The
Python Standard Library". To use a library it must be import-ed into
your code.

Docs describing the library are available on-line, specifically the
turtle module (and some examples of its use) can be found at:
https://docs.python.org/3/library/turtle.html

Have fun!
-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list


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 like forward, backward, right and left. My
> syntax is correct: pat.forward(100) is an example. Can you tell me
> what is wrong.
>      thanks, glenn

-- 
https://mail.python.org/mailman/listinfo/python-list


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, glenn
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2021-04-24 Thread Peter J. Holzer
On 2020-10-19 06:24:18 -, Mladen Gogala via Python-list wrote:
> On Mon, 19 Oct 2020 02:44:25 +, Stefan Ram wrote:
> > Mladen Gogala  writes:
> >>In Perl, there are no classes. 
> > 
> >   If there are no classes in Perl, then what does
> > 
> > bless REF,CLASSNAME 
> > 
> >   do?
> 
> bless \$ref will make the given reference a reference to the class. And 
> classes is Perl
> are called "modules". However, Perl classes are not the classes in the  real 
> sense. There 
> is no inheritance.

That's wrong. Perl classes have inheritance, and they always have had it
since they were introduced in Perl 5.0 (in 1994).


> You can have a similar thing in C: it's called "struct", it can do
> similar things like Perl modules.

Nope. C structs are data structures. Perl modules are primarily a way to
structure code.


> But C isn't object oriented. Inheritance is an essential
> characteristic of object orientation.

You can have that even in C. One of my first major C programs (back in
the 1980s) was object-oriented (including inheritance). I didn't even
know what "object oriented" meant back then, but the library we used for
the GUI stuff used that style so it felt natural to extend it to
"application level" objects.

> There were attempts to turn Perl into OO language with Moose
> (https://metacpan.org/pod/Moose)

Moose just adds syntactic sugar. It may be easier to read (especially
for people used to other OO languages) and save a bit of typing, but it
doesn't add anything you couldn't do in plain Perl5.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-19 Thread Eryk Sun
On 10/19/20, Grant Edwards  wrote:
> On 2020-10-19, Stephen Tucker  wrote:
>
>> For a neatish way to get a string to end with a single backslash, how
>> about
>>mystr = r"abc\ "[:-1]
>> (Note the space at the end of the rough-quoted string.)
>
> That's the first thing I thought of, though I would probably use a
> non-space character to avoid convusion when reading:
>
>mystr = r'abc\_'[:-1]

But it doesn't actually "end a raw string with a single backslash".
The compiler could be optimized for slicing string literals, but it's
not. For example:

>>> dis.dis(r"r'spam\eggs\_'[:-1]")
  1   0 LOAD_CONST   0 ('spam\\eggs\\_')
  2 LOAD_CONST   1 (None)
  4 LOAD_CONST   2 (-1)
  6 BUILD_SLICE  2
  8 BINARY_SUBSCR
 10 RETURN_VALUE

For comparison:

>>> dis.dis(r"r'spam\eggs' '\\'")
  1   0 LOAD_CONST   0 ('spam\\eggs\\')
  2 RETURN_VALUE
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-19 Thread Grant Edwards
On 2020-10-19, Stephen Tucker  wrote:

> For a neatish way to get a string to end with a single backslash, how about
>mystr = r"abc\ "[:-1]
> (Note the space at the end of the rough-quoted string.)

That's the first thing I thought of, though I would probably use a
non-space character to avoid convusion when reading:

   mystr = r'abc\_'[:-1]

--
Grant

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-19 Thread Stephen Tucker
For a neatish way to get a string to end with a single backslash, how about
   mystr = r"abc\ "[:-1]
(Note the space at the end of the rough-quoted string.)



Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Mon, Oct 19, 2020 at 9:26 AM Antoon Pardon  wrote:

>
>
> Op 13/10/20 om 15:14 schreef Serhiy Storchaka:
> > 13.10.20 11:52, Tony Flury via Python-list пише:
> >> I am trying to write a simple expression to build a raw string that ends
> >> in a single backslash. My understanding is that a raw string should
> >> ignore attempts at escaping characters but I get this :
> >>
> >>  >>> a = r'end\'
> >>File "", line 1
> >>  a = r'end\'
> >>^
> >> SyntaxError: EOL while scanning string literal
> >>
> >> I interpret this as meaning that the \' is actually being interpreted as
> >> a literal quote - is that a bug ?
> >
> > r'You can\'t end raw string literal with a single "\"'
> >
> > If backslash be true inner in a raw string, the above literal would end
> > after \'. It would be very hard to write a raw string containing both \'
> > and \", and even \''' and \""" (there are such strings in the stdlib).
> >
> > So you have problem either with trailing backslash, or with inner
> > backslash followed by quotes. Both problems cannot be solved at the same
> > time. Python parser works as it works because initially it was easier to
> > implement, and now this cannot be changed because it would break some
> > amount of correct code.
>
> IMO the way python does this is broken.
>
>  >>> st=r'You can\'t end raw string literal with a single "\"'
>  >>> print(st)
>
> Now either the \ is special or it is not.
>
> 1) If it is special, it should change how the ' is treated but not
> appear itself.
>
> 2) If it is not special, it should just appear and not change how the '
> is treated.
>
> What python does here is a combination of both. The \ appears and it
> changes how the ' is treated. That is IMO broken.
>
> --
> Antoon Pardon.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-19 Thread Antoon Pardon



Op 13/10/20 om 15:14 schreef Serhiy Storchaka:

13.10.20 11:52, Tony Flury via Python-list пише:

I am trying to write a simple expression to build a raw string that ends
in a single backslash. My understanding is that a raw string should
ignore attempts at escaping characters but I get this :

     >>> a = r'end\'
       File "", line 1
         a = r'end\'
       ^
    SyntaxError: EOL while scanning string literal

I interpret this as meaning that the \' is actually being interpreted as
a literal quote - is that a bug ?


r'You can\'t end raw string literal with a single "\"'

If backslash be true inner in a raw string, the above literal would end
after \'. It would be very hard to write a raw string containing both \'
and \", and even \''' and \""" (there are such strings in the stdlib).

So you have problem either with trailing backslash, or with inner
backslash followed by quotes. Both problems cannot be solved at the same
time. Python parser works as it works because initially it was easier to
implement, and now this cannot be changed because it would break some
amount of correct code.


IMO the way python does this is broken.

>>> st=r'You can\'t end raw string literal with a single "\"'
>>> print(st)

Now either the \ is special or it is not.

1) If it is special, it should change how the ' is treated but not 
appear itself.


2) If it is not special, it should just appear and not change how the ' 
is treated.


What python does here is a combination of both. The \ appears and it
changes how the ' is treated. That is IMO broken.

--
Antoon Pardon.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-19 Thread Chris Angelico
On Mon, Oct 19, 2020 at 5:26 PM Mladen Gogala via Python-list
 wrote:
> bless \$ref will make the given reference a reference to the class. And 
> classes is Perl
> are called "modules". However, Perl classes are not the classes in the  real 
> sense. There
> is no inheritance. You can have a similar thing in C: it's called "struct", 
> it can do
> similar things like Perl modules. But C isn't object oriented. Inheritance is 
> an
> essential characteristic of object orientation.

Funny thing about how languages "are" or "are not" object oriented
back in the day, I used to do SOM programming on OS/2, which was
entirely in C, and most definitely had all the features you'd expect
of object orientation. Inheritance, the ability to override your
parent's methods, the ability to call the parent's method during the
implementation of your own, etc, etc, etc. It was all done through
DLLs, so you could subclass someone else's class (a very common thing
was to subclass one of the standard classes and add a small amount of
functionality to it) without having the source code. So, yeah, I don't
think there's any fundamental in any language that says whether or not
you can do OOP.

There are features which make OOP easier, and some languages have more
of them than others do. That's about all you can really say.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-19 Thread Mladen Gogala via Python-list
On Mon, 19 Oct 2020 02:44:25 +, Stefan Ram wrote:

> Mladen Gogala  writes:
>>In Perl, there are no classes. 
> 
>   If there are no classes in Perl, then what does
> 
> bless REF,CLASSNAME 
> 
>   do?

bless \$ref will make the given reference a reference to the class. And classes 
is Perl
are called "modules". However, Perl classes are not the classes in the  real 
sense. There 
is no inheritance. You can have a similar thing in C: it's called "struct", it 
can do 
similar things like Perl modules. But C isn't object oriented. Inheritance is an
essential characteristic of object orientation.
There were attempts to turn Perl into OO language with Moose 
(https://metacpan.org/pod/Moose)
However, Moose is complex, tedious and rarely used. Perl6 is an OO language, 
but nobody uses 
it. The problem is CPAN and all the Perl5 modules which are not compatible with 
Perl6 or "Roku"
as it is known.



-- 
Mladen Gogala
Database Consultant
http://mgogala.byethost5.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-18 Thread Michael Torrie
On 10/18/20 5:37 PM, Mladen Gogala via Python-list wrote:
> On Sun, 18 Oct 2020 12:19:18 -0600, Michael Torrie wrote:
> 
>> Python certainly is procedural.  A script starts at the top and executes
>> through to the bottom and ends, barring any flow control in the middle.
>>  Like Perl you can use it in many different ways and paradigms including
>> OO if you desire.
> 
> That's not the point. 

But it is.

Yes I can see why this devolves so quickly for you! :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-18 Thread Mladen Gogala via Python-list
On Sun, 18 Oct 2020 12:19:18 -0600, Michael Torrie wrote:

> Python certainly is procedural.  A script starts at the top and executes
> through to the bottom and ends, barring any flow control in the middle.
>  Like Perl you can use it in many different ways and paradigms including
> OO if you desire.

That's not the point. In Python, regular expressions are a class. So are 
strings and lists. 
In Perl, there are no classes. Procedural paradigm means that you are modelling 
the real world
with the objects provided by the computer environment: strings, numbers, lists 
or hashes (known 
as "dictionaries" in Python). OO paradigm allows you to create objects and make 
them behave like 
in the real world. In other words, in OO paradighm, data and functions are 
related. The basic 
idea of the OO was to make code sharing much easier. However, things  do not 
always work as 
they should:

https://medium.com/better-programming/object-oriented-programming-the-trillion-dollar-disaster-92a4b666c7c7

https://towardsdatascience.com/object-oriented-programming-is-dead-wait-really-db1f1f05cc44

Of course, not everybody agrees. People never do:

https://techbeacon.com/app-dev-testing/object-oriented-programming-dead-not-long-shot

Sometimes, OO has its funny side:
https://www.wearethemighty.com/articles/that-time-the-australian-air-force-squared-off-against-missile-shooting-kangaroos

-- 
Mladen Gogala
Database Consultant
http://mgogala.byethost5.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-18 Thread Michael Torrie
On 10/18/20 11:07 AM, Mladen Gogala via Python-list wrote:
> The fundamental 
> difference between the two languages is that Perl is procedural while 
> Python is a fully OO language. Discussion of Perl vs Python necessarily
> devolves into the discussion of procedural vs OO paradigms.

Python certainly is procedural.  A script starts at the top and executes
through to the bottom and ends, barring any flow control in the middle.
 Like Perl you can use it in many different ways and paradigms including
OO if you desire.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-18 Thread Mladen Gogala via Python-list
On Sun, 18 Oct 2020 16:13:16 +0200, Peter J. Holzer wrote:

> 
> Ah, I see, that the sillyness of Perl's grammar-altering modules (which
> let you write Perl in Latin (with proper declensions and conjugations,
> of course) or Chinese) has found its way to Python 
>

To tell the truth, I only installed it to test whether it works. I am an
old Perl hack forced to learn Python by the market forces. I learned Perl 
in 1994 which means that it is my first love of a sort. The fundamental 
difference between the two languages is that Perl is procedural while 
Python is a fully OO language. Discussion of Perl vs Python necessarily
devolves into the discussion of procedural vs OO paradigms. And that has 
been decided long time ago, with the advent of Java over COBOL. Market
has spoken and I had to learn Python. So, I stopped worrying and learned 
to love Python. Any resemblance to the subtitle of "Dr. Strangelove" is 
purely accidental.
BTW, Visual Studio Code uses pylint to evaluate my adherence to PEP8 and
there is a "kite" extension with autocompletion. Nothing like that was ever
available for Perl. It certainly is easier to write Python scripts than to
write Perl scripts. I do sort of miss $_, @_ and $!. Python's argparse 
is supreme and much better than Getopt::Long.



-- 
Mladen Gogala
Database Consultant
http://mgogala.byethost5.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-18 Thread Peter J. Holzer
On 2020-10-17 21:03:26 -, Mladen Gogala via Python-list wrote:
> On Thu, 15 Oct 2020 21:30:15 +, Stefan Ram wrote:
> > Tony Flury  writes:
> >> >>> a = r'end' + chr(92)
> > 
> >   Or maybe,
> > 
> > a = r'''
> > end\
> > '''[ 1: -1 ]
> > 
> >   ? The first and the last line are messy, but in the middle,
> >   the intended string is clearly visible.
> 
> 
> You can use perl module for python.

Ah, I see, that the sillyness of Perl's grammar-altering modules (which
let you write Perl in Latin (with proper declensions and conjugations,
of course) or Chinese) has found its way to Python :-)


> It is installable by pip.
> Perl has no problems with handling backslashes.
> 
> https://pypi.org/project/perl/
> 
> What you need is something like this:
> 
> mgogala@umajor:~$ perl -e '$a="abcd";$a=~s/$/\\/; print "$a\n";'
> abcd\
> 
> Python has a problem with backslashes:
> 
> Python 3.8.5 (default, Jul 28 2020, 12:59:40) 
> [GCC 9.3.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import re
> >>> a="abcd"
> >>> b=re.sub('$',chr(28),a)
> >>> b
> 'abcd\x1c'
> 
> >>> b=re.sub('$',chr(0x41),a)
> >>> b
> 'abcdA'
> >>> b=re.sub('$','Z',a)
> >>> b
> 'abcdZ'
> >>> b=re.sub('$',chr(0x1C),a)
> >>> b
> 'abcd\x1c'
> >>> 
> 
> Any other character is shown as it should be, except backslash.

0x1C isn't a backslash, it's a control character (FS - File Separator).

0x5C is a backslash, but of course that doesn't work here either,
because the second argument to re.sub isn't a simple string: It contains
escape sequences to be interpreted, and a single \ isn't well-formed
(note that you doubled the \ in your Perl example, too).

b=re.sub('$', '', a)
or
b=re.sub('$', chr(0x5C)+chr(0x5C), a)

works just fine, as does 

b = a + chr(0x5C)

In all these cases, 
print(b) 
prints
abcd\
(with a single backslash at the end)

But simply typing "b" at the REPL produces
'abcd\\'
because prints the __repr__() of an object. Note that it also prints
single quotes, which are also not part of the string.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-17 Thread Mladen Gogala via Python-list
On Thu, 15 Oct 2020 21:30:15 +, Stefan Ram wrote:

> Tony Flury  writes:
>> >>> a = r'end' + chr(92)
> 
>   Or maybe,
> 
> a = r'''
> end\
> '''[ 1: -1 ]
> 
>   ? The first and the last line are messy, but in the middle,
>   the intended string is clearly visible.


You can use perl module for python. It is installable by pip.
Perl has no problems with handling backslashes.

https://pypi.org/project/perl/

What you need is something like this:

mgogala@umajor:~$ perl -e '$a="abcd";$a=~s/$/\\/; print "$a\n";'
abcd\

Python has a problem with backslashes:

Python 3.8.5 (default, Jul 28 2020, 12:59:40) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> a="abcd"
>>> b=re.sub('$',chr(28),a)
>>> b
'abcd\x1c'

>>> b=re.sub('$',chr(0x41),a)
>>> b
'abcdA'
>>> b=re.sub('$','Z',a)
>>> b
'abcdZ'
>>> b=re.sub('$',chr(0x1C),a)
>>> b
'abcd\x1c'
>>> 

Any other character is shown as it should be, except backslash.





-- 
Mladen Gogala
Database Consultant
http://mgogala.byethost5.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-15 Thread Serhiy Storchaka
15.10.20 22:16, Roland Müller via Python-list пише:
> I used the triple single quotes as delimiter:
> 
 s = r'''a single quote ', a double quote "'''
 s
> 
> 'a single quote \', a double quote "'

It does not help if the string contains both kinds of triple quotes

   You have to use triple quotes (''', """) for docstrings.

or contains one kind of triple quote and ends with a single quote of
other kind.

   a triple single quote ''', a single double quote "

Of course there are workarounds, but the fact that changing the current
rules will break existing code.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-15 Thread Roland Müller via Python-list


On 10/13/20 4:14 PM, Serhiy Storchaka wrote:

13.10.20 11:52, Tony Flury via Python-list пише:

I am trying to write a simple expression to build a raw string that ends
in a single backslash. My understanding is that a raw string should
ignore attempts at escaping characters but I get this :

     >>> a = r'end\'
       File "", line 1
         a = r'end\'
       ^
    SyntaxError: EOL while scanning string literal

I interpret this as meaning that the \' is actually being interpreted as
a literal quote - is that a bug ?

r'You can\'t end raw string literal with a single "\"'

If backslash be true inner in a raw string, the above literal would end
after \'. It would be very hard to write a raw string containing both \'
and \", and even \''' and \""" (there are such strings in the stdlib).

So you have problem either with trailing backslash, or with inner
backslash followed by quotes. Both problems cannot be solved at the same
time. Python parser works as it works because initially it was easier to
implement, and now this cannot be changed because it would break some
amount of correct code.


The only solution I have found is to do this :

     >>> a = r'end' + chr(92)
     >>> a
    'end\\'
     >>> list(a)
    ['e', 'n', 'd', '\\']

or


     >>> a = r'end\\'[:-1]
     >>> list(a)
    ['e', 'n', 'd', '\\']

Neither of which are nice.

You can also write r'end' '\\'. It is not too nice, but it looks nicer
to me then two other variants.


I used the triple single quotes as delimiter:

>>> s = r'''a single quote ', a double quote "'''
>>> s

'a single quote \', a double quote "'

BR,

Roland


--
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-13 Thread Serhiy Storchaka
13.10.20 11:52, Tony Flury via Python-list пише:
> I am trying to write a simple expression to build a raw string that ends
> in a single backslash. My understanding is that a raw string should
> ignore attempts at escaping characters but I get this :
> 
>     >>> a = r'end\'
>       File "", line 1
>         a = r'end\'
>       ^
>    SyntaxError: EOL while scanning string literal
> 
> I interpret this as meaning that the \' is actually being interpreted as
> a literal quote - is that a bug ?

r'You can\'t end raw string literal with a single "\"'

If backslash be true inner in a raw string, the above literal would end
after \'. It would be very hard to write a raw string containing both \'
and \", and even \''' and \""" (there are such strings in the stdlib).

So you have problem either with trailing backslash, or with inner
backslash followed by quotes. Both problems cannot be solved at the same
time. Python parser works as it works because initially it was easier to
implement, and now this cannot be changed because it would break some
amount of correct code.

> The only solution I have found is to do this :
> 
>     >>> a = r'end' + chr(92)
>     >>> a
>    'end\\'
>     >>> list(a)
>    ['e', 'n', 'd', '\\']
> 
> or
> 
> 
>     >>> a = r'end\\'[:-1]
>     >>> list(a)
>    ['e', 'n', 'd', '\\']
> 
> Neither of which are nice.

You can also write r'end' '\\'. It is not too nice, but it looks nicer
to me then two other variants.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-13 Thread Eryk Sun
On 10/13/20, Tony Flury via Python-list  wrote:
> I am trying to write a simple expression to build a raw string that ends
> in a single backslash. My understanding is that a raw string should
> ignore attempts at escaping characters but I get this :
>
>  >>> a = r'end\'
>File "", line 1
>  a = r'end\'
>^
> SyntaxError: EOL while scanning string literal

Since r'\'' represents a two-character string with a backslash and a
single quote, ending a raw string literal with an odd number of
backslashes requires adding the final backslash using implicit
string-literal concatenation. For example:

>>> r'some\raw\string''\\'
'some\\raw\\string\\'

Other ways to get the same result may operate at runtime instead of at
compile time.
-- 
https://mail.python.org/mailman/listinfo/python-list


Simple question - end a raw string with a single backslash ?

2020-10-13 Thread Tony Flury via Python-list
I am trying to write a simple expression to build a raw string that ends 
in a single backslash. My understanding is that a raw string should 
ignore attempts at escaping characters but I get this :


>>> a = r'end\'
  File "", line 1
    a = r'end\'
  ^
   SyntaxError: EOL while scanning string literal

I interpret this as meaning that the \' is actually being interpreted as 
a literal quote - is that a bug ?


If I try to escaped the backslash I get a different problem:

>>> a = r'end\\'
>>> a
   'end'
>>> print(a)
   end\\
>>> len(a)
   5
>>> list(a)
   ['e', 'n', 'd', '\\', '\\']

So you can see that our string (with the escaped backslash)  is now 5 
characters with two literal backslash characters


The only solution I have found is to do this :

>>> a = r'end' + chr(92)
>>> a
   'end\\'
>>> list(a)
   ['e', 'n', 'd', '\\']

or


>>> a = r'end\\'[:-1]
>>> list(a)
   ['e', 'n', 'd', '\\']

Neither of which are nice.



--
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question: how do I print output from .get() method

2018-05-30 Thread Rhodri James

On 30/05/18 06:51, Chris Angelico wrote:

On Wed, May 30, 2018 at 3:44 PM, MrMagoo2018  wrote:

Hello folks, imagine I have the code below and I am getting the "error" message 
when attempting to print() the output of 'sw_report'.
Can you suggest which method I should use to retrieve this? Is that a 
dictionary maybe?

from arista import arista
m = arista()
m.authenticate ("user","password")
sw_report = m.np.sw_report.get("swType="EOS",swMajorVersion="5.0")
print (sw_report)



That's not an error message. You asked Python to print it out, and it
printed it out. As it happens, the display isn't particularly useful,
but it's not an error.

What you have is a *generator object*, which is something you can
iterate over. I don't know about the arista library, so I don't know
what you'll get from that, but at its simplest, you could convert that
to a list:

print(list(sw_report))


Be aware that if you do this, you will exhaust the generator and won't 
be able to use it anywhere else.


>>> def foo():
... yield 1
... yield 2
... yield 3
...
>>> l = foo()
>>> print(l)

>>> print(list(l))
[1, 2, 3]
>>> print(list(l))
[]


--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question: how do I print output from .get() method

2018-05-29 Thread Chris Angelico
On Wed, May 30, 2018 at 3:44 PM, MrMagoo2018  wrote:
> Hello folks, imagine I have the code below and I am getting the "error" 
> message when attempting to print() the output of 'sw_report'.
> Can you suggest which method I should use to retrieve this? Is that a 
> dictionary maybe?
>
> from arista import arista
> m = arista()
> m.authenticate ("user","password")
> sw_report = m.np.sw_report.get("swType="EOS",swMajorVersion="5.0")
> print (sw_report)
> 

That's not an error message. You asked Python to print it out, and it
printed it out. As it happens, the display isn't particularly useful,
but it's not an error.

What you have is a *generator object*, which is something you can
iterate over. I don't know about the arista library, so I don't know
what you'll get from that, but at its simplest, you could convert that
to a list:

print(list(sw_report))

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Simple question: how do I print output from .get() method

2018-05-29 Thread MrMagoo2018
Hello folks, imagine I have the code below and I am getting the "error" message 
when attempting to print() the output of 'sw_report'. 
Can you suggest which method I should use to retrieve this? Is that a 
dictionary maybe?

from arista import arista
m = arista()
m.authenticate ("user","password")
sw_report = m.np.sw_report.get("swType="EOS",swMajorVersion="5.0")
print (sw_report)

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python re.search simple question

2014-12-08 Thread Denis McMahon
On Mon, 08 Dec 2014 12:22:37 +0530, Ganesh Pal wrote:

 pattern
 'Token-based migrations cannot be mixed with level-based: [prev 0 , now
 1]'

Because [] defines a character class in a regex, if you want literal 
[ and ] you need to escape them with backslash.

[prev 0 , now 1] - match any single character from the set prev0,now1 

\[prev 0 , now 1\] - match the actual text [prev 0 , now 1]

Try these:

re.search('[prev 0 , now 1]','p') # matches (p in prev0,now1 )

re.search('[prev 0 , now 1]','x') # doesn't match (x not in prev0,now1 )

re.search('\[prev 0 , now 1\]','p') # doesn't match

re.search('\[prev 0 , now 1\]','[prev 0 , now 1]') # matches

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Python re.search simple question

2014-12-07 Thread Ganesh Pal
Hi Folks ,

This  might seem to be very trivial question but iam breaking my head over
it for a while .

 My understanding is that re.search should search for the match anywhere in
the string .


why is re.search failing in the below case  ??

 pattern
'Token-based migrations cannot be mixed with level-based: [prev 0 , now 1]'
 text
' LogMessage {type NDMP_LOG_DBG} {msg_id 0} {msg The process id for NDMP
service is 0x9c216370} {associated_msg 0} {associated_msg_seq 0} Source
filer:DartOS  Error: Token-based migrations cannot be mixed with
level-based: [prev 0 , now 1]'

 if (re.search(pattern,text)):
...print Hi
... else:
... print BYE
...
BYE

Regards,
Ganesh
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python re.search simple question

2014-12-07 Thread Jussi Piitulainen
Ganesh Pal writes:

 why is re.search failing in the below case  ??

Your pattern, '... level-based: [prev 0 , now 1]', matches a literal
string '--- level-based: ' followed by 'p', 'r', 'e', 'v', ' ', '0',
..., or '1', none of which is the '[' found in your text at that
position.

Are you sure you need a regexp?

If you are, make your pattern r'... \[prev 0 , now 1\]'. The 'r' is
not a typo.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python re.search simple question

2014-12-07 Thread Shiyao Ma
On Dec 08 at 12:22 +0530, Ganesh Pal wrote:
 Hi Folks ,

 This  might seem to be very trivial question but iam breaking my head over
 it for a while .

  My understanding is that re.search should search for the match anywhere in
 the string .


 why is re.search failing in the below case  ??

  pattern
 'Token-based migrations cannot be mixed with level-based: [prev 0 , now 1]'

I sense a bad smell. Be sure to escape the bracket [ ]

  text
 ' LogMessage {type NDMP_LOG_DBG} {msg_id 0} {msg The process id for NDMP
 service is 0x9c216370} {associated_msg 0} {associated_msg_seq 0} Source
 filer:DartOS  Error: Token-based migrations cannot be mixed with
 level-based: [prev 0 , now 1]'

  if (re.search(pattern,text)):
 ...print Hi
 ... else:
 ... print BYE
 ...

so see here: https://bpaste.net/show/d2f1cf66a492 . It prints HI

/me always wishes code is sent without others doing some extra formatting 
before testing.

Hope that helps.




-- 
Shiyao Ma
http://introo.me
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python re.search simple question

2014-12-07 Thread Zachary Ware
On Mon, Dec 8, 2014 at 12:52 AM, Ganesh Pal ganesh1...@gmail.com wrote:
 Hi Folks ,

 This  might seem to be very trivial question but iam breaking my head over
 it for a while .

  My understanding is that re.search should search for the match anywhere in
 the string .


 why is re.search failing in the below case  ??

 pattern
 'Token-based migrations cannot be mixed with level-based: [prev 0 , now 1]'

Your pattern here contains a character class ([enoprvw 01,]).  You'll
need to escape the '[' character to make it literal.

Hope this helps,
-- 
Zach
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python re.search simple question

2014-12-07 Thread Jussi Piitulainen
Jussi Piitulainen writes:

 Ganesh Pal writes:
 
  why is re.search failing in the below case  ??
 
 Your pattern, '... level-based: [prev 0 , now 1]', matches a literal
 string '--- level-based: ' followed by 'p', 'r', 'e', 'v', ' ', '0',
 ..., or '1', none of which is the '[' found in your text at that
 position.
 
 Are you sure you need a regexp?
 
 If you are, make your pattern r'... \[prev 0 , now 1\]'. The 'r' is
 not a typo.

On the other hand, the '---' *is* a typo, meant to be an ellipsis
where I shortened your text. The shortened pattern would still match
it, but that's an accident: '.' has a special meaning in a regexp.

Sorry about that.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python re.search simple question

2014-12-07 Thread Ganesh Pal
Thanks guys , I escaped the '[' character and my issue is sloved ..  Thank
you guys u all rock :)

Regards,
Ganesh

On Mon, Dec 8, 2014 at 12:41 PM, Zachary Ware zachary.ware+pyl...@gmail.com
 wrote:

 On Mon, Dec 8, 2014 at 12:52 AM, Ganesh Pal ganesh1...@gmail.com wrote:
  Hi Folks ,
 
  This  might seem to be very trivial question but iam breaking my head
 over
  it for a while .
 
   My understanding is that re.search should search for the match anywhere
 in
  the string .
 
 
  why is re.search failing in the below case  ??
 
  pattern
  'Token-based migrations cannot be mixed with level-based: [prev 0 , now
 1]'

 Your pattern here contains a character class ([enoprvw 01,]).  You'll
 need to escape the '[' character to make it literal.

 Hope this helps,
 --
 Zach

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-08-24 Thread John Ladasky
On Saturday, August 23, 2014 6:10:29 AM UTC-7, explode...@gmail.com wrote:
 Can some one explain why this happens:
 
 True, False = False, True
 
 print True, False
 
 False True

Shush!  That's one of Python's most closely-guarded secrets!  Every politician 
on Earth will want to learn to program in Python after seeing that!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-08-24 Thread Chris Angelico
On Sun, Aug 24, 2014 at 3:55 PM, John Ladasky
john_lada...@sbcglobal.net wrote:
 Shush!  That's one of Python's most closely-guarded secrets!  Every 
 politician on Earth will want to learn to program in Python after seeing that!


Not really, the legal profession has known about this for centuries.

(Princess Zara, presenting Sir Bailey Barre, Q.C., M.P.)
 A complicated gentleman allow to present,
 Of all the arts and faculties the terse embodiment,
 He's a great arithmetician who can demonstrate with ease
 That two and two are three or five or anything you please;
 An eminent Logician who can make it clear to you
 That black is white--when looked at from the proper point of view;
 A marvelous Philologist who'll undertake to show
 That yes is but another and a neater form of no.

From Gilbert  Sullivan's Utopia, Ltd, dating back to 1893. Python 2
continues this excellent tradition of permitting truth to be redefined
at will, but Python 3 adopts the view of the narrow-minded pedant who
still believes that two and two makes four. It's an opinionated
language, and that helps you to avoid weirdnesses :)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Simple question

2014-08-23 Thread explodeandroid
Can some one explain why this happens:
True, False = False, True
print True, False
False True
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-08-23 Thread Chris Angelico
On Sat, Aug 23, 2014 at 11:10 PM,  explodeandr...@gmail.com wrote:
 Can some one explain why this happens:
 True, False = False, True
 print True, False
 False True

Well, the first line changes the meanings of the names True and
False, but doesn't change the things they point to. Those things
describe themselves the same way. Here's another thing you can do that
will look the same:

a, b = False, True
print a, b
False True

Fortunately, newer versions of Python don't let you reassign True and False.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-08-23 Thread Peter Otten
explodeandr...@gmail.com wrote:

 Can some one explain why this happens:
 True, False = False, True
 print True, False
 False True

You are using Python 2 where True/False are names that can be rebound. This 
is for backwards compatibility as Python didn't always have booleans and 
people made their own with

True = 1
False = 0

or similar.

In Python 3 True and False are keywords:

 True = False
  File stdin, line 1
SyntaxError: can't assign to keyword


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-08-23 Thread ElChino

explodeandr...@gmail.com wrote:


Can some one explain why this happens:
True, False = False, True
print True, False
False True


I assume the value of True and False can be falsified. Like the 'None'
object can be. So swapping their values and printing them is similar to:
 a = 0
 b = 1
 a, b = b, a
 print a, b

Except that True/False are initialised built-ins.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-04-16 Thread Chris Angelico
On Wed, Apr 16, 2014 at 1:19 PM, Kushal Kumaran
kushal.kuma...@gmail.com wrote:
Understandable. I currently am using two consoles (laptop at my right
hand, desktop in front of me), and every now and then I want to copy
and paste across them :) I mean, shared clipboard works just fine
across all my VM guests (and as I type that, Disney's cast is singing
Be our guest in my background music), it even works across remote
desktop, but for some reason, swinging my hands 90 degrees doesn't
transfer the clipboard. This strikes me as a major flaw in human
beings.


 You want synergy. http://synergy-foss.org/

Usually I want separate keyboard and mouse, so that I can be playing
Command  Conquer Renegade on one system while responding to emails on
the other (hold W so Havoc keeps walking, read through emails by
scrolling with right hand...); it's just the clipboard. It would, of
course, be possible to write a clipboard viewer program for whichever
platform - say, OS/2 - and have it connect via a TCP/IP socket to a
program on another system - say, a Linux box - that has a little
hidden window and puts stuff onto the clipboard. I will neither
confirm nor deny having actually done this...

*twiddles thumbs*

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Simple question

2014-04-15 Thread Phil Dobbin
Hi, all.

I've just started to learn Python (I'm reading Mark Lutz's 'Learning
Python' from O'Reilly)  I'm confused as to this part:

' 0.1 + 0.1 + 0.1 - 0.3
5.55111.'

Using 'import Decimal' you can get a much closer result i.e.
'Decimal('0.0')'

What I'm wondering is why the first calculation that arrives at
'5.55111...' is so far out?

Many thanks,

Cheers,

  Phil...

-- 
currently (ab)using
CentOS 6.5, Debian Squeeze  Wheezy, Fedora 19  20, OS X Snow Leopard,
RHEL 7, Ubuntu Precise  Saucy
GnuGPG Key : http://phildobbin.org/publickey.asc
Based in London, UK

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-04-15 Thread Zachary Ware
On Tue, Apr 15, 2014 at 1:18 PM, Phil Dobbin phildob...@gmail.com wrote:
 Hi, all.

 I've just started to learn Python (I'm reading Mark Lutz's 'Learning
 Python' from O'Reilly)  I'm confused as to this part:

 ' 0.1 + 0.1 + 0.1 - 0.3
 5.55111.'

 Using 'import Decimal' you can get a much closer result i.e.
 'Decimal('0.0')'

 What I'm wondering is why the first calculation that arrives at
 '5.55111...' is so far out?

First, note that the ... part of 5.55111... is very important
here, it's actually 5.55111...e-17 which means it's really
approximately 0.55111, which is really very close to
the answer you'd expect from a human.  To learn more about why Python
doesn't give 0.0, read this:
https://docs.python.org/3/tutorial/floatingpoint.html

Hope this helps,
-- 
Zach
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-04-15 Thread Chris Angelico
On Wed, Apr 16, 2014 at 4:18 AM, Phil Dobbin phildob...@gmail.com wrote:
 ' 0.1 + 0.1 + 0.1 - 0.3
 5.55111.'

 What I'm wondering is why the first calculation that arrives at
 '5.55111...' is so far out?

There's something you're not seeing here. In full, the output I see is:

 0.1 + 0.1 + 0.1 - 0.3
5.551115123125783e-17

See that bit at the end? e-17 means times ten to the -17th power -
that is, move the decimal point 17 places to the left. So the actual
value is:

 %50.50f%(0.1 + 0.1 + 0.1 - 0.3)
'0.5551115123125782702118158340454102'

It's not actually as far out as you think; in fact, that's incredibly
close to zero.

A full explanation of why floating point arithmetic does this can be
found in many places on the internet, but the main thing to note is
that it really isn't showing 5.5.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-04-15 Thread Joel Goldstick
On Apr 15, 2014 2:19 PM, Phil Dobbin phildob...@gmail.com wrote:

 Hi, all.

 I've just started to learn Python (I'm reading Mark Lutz's 'Learning
 Python' from O'Reilly)  I'm confused as to this part:

 ' 0.1 + 0.1 + 0.1 - 0.3
 5.55111.'

It's not. Look at the end of the result. It's scientific notation for a
very small number
 Using 'import Decimal' you can get a much closer result i.e.
 'Decimal('0.0')'

 What I'm wondering is why the first calculation that arrives at
 '5.55111...' is so far out?

 Many thanks,

 Cheers,

   Phil...

 --
 currently (ab)using
 CentOS 6.5, Debian Squeeze  Wheezy, Fedora 19  20, OS X Snow Leopard,
 RHEL 7, Ubuntu Precise  Saucy
 GnuGPG Key : http://phildobbin.org/publickey.asc
 Based in London, UK

 --
 https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-04-15 Thread Robert Kern

On 2014-04-15 19:18, Phil Dobbin wrote:

Hi, all.

I've just started to learn Python (I'm reading Mark Lutz's 'Learning
Python' from O'Reilly)  I'm confused as to this part:

' 0.1 + 0.1 + 0.1 - 0.3
5.55111.'

Using 'import Decimal' you can get a much closer result i.e.
'Decimal('0.0')'

What I'm wondering is why the first calculation that arrives at
'5.55111...' is so far out?


The `...` elides the exponent:

   0.1 + 0.1 + 0.1 - 0.3
  5.551115123125783e-17

If you copied that verbatim directly out of a book, that's just sloppy editing.

--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

--
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-04-15 Thread Phil Dobbin
On 15/04/2014 19:25, Zachary Ware wrote:

 On Tue, Apr 15, 2014 at 1:18 PM, Phil Dobbin phildob...@gmail.com wrote:
 Hi, all.

 I've just started to learn Python (I'm reading Mark Lutz's 'Learning
 Python' from O'Reilly)  I'm confused as to this part:

 ' 0.1 + 0.1 + 0.1 - 0.3
 5.55111.'

 Using 'import Decimal' you can get a much closer result i.e.
 'Decimal('0.0')'

 What I'm wondering is why the first calculation that arrives at
 '5.55111...' is so far out?
 
 First, note that the ... part of 5.55111... is very important
 here, it's actually 5.55111...e-17 which means it's really
 approximately 0.55111, which is really very close to
 the answer you'd expect from a human.  To learn more about why Python
 doesn't give 0.0, read this:
 https://docs.python.org/3/tutorial/floatingpoint.html
 
 Hope this helps,
 

Hi, Zach.

I saw the 'e-17' appended to the end but was unsure of its meaning (
quite a number of things are introduced in the book with clarification
of their meaning not forthcoming 'til later on).

Thank you for the link. It'll be very helpful.

Cheers,

  Phil...

-- 
currently (ab)using
CentOS 6.5, Debian Squeeze  Wheezy, Fedora 19  20, OS X Snow Leopard,
RHEL 7, Ubuntu Precise  Saucy
GnuGPG Key : http://phildobbin.org/publickey.asc
Based in London, UK


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-04-15 Thread Tim Chase
On 2014-04-15 19:18, Phil Dobbin wrote:
 I'm confused as to this part:
 
 ' 0.1 + 0.1 + 0.1 - 0.3  
 5.55111.'

 What I'm wondering is why the first calculation that arrives at
 '5.55111...' is so far out?

You omit one key detail in your , the e-17 which means that
is 5.55111... times 10^-17 which is a REALLY small number.  To
better show that, have it formatted to place:

   %55.55f % (0.1 + 0.1 + 0.1 - 0.3)
  '0.555111512312578270211815834045410156250'

For most engineering purposes, that's effectively zero.

It comes about because of how floating-point numbers are represented
internally.  You can read a lot more than anybody should want to
know at [1].  By using the Decimal module, you remove some of that
imprecision.

-tkc

[1] http://en.wikipedia.org/wiki/Ieee_float





-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-04-15 Thread Phil Dobbin
On 15/04/2014 19:30, Robert Kern wrote:

 On 2014-04-15 19:18, Phil Dobbin wrote:
 Hi, all.

 I've just started to learn Python (I'm reading Mark Lutz's 'Learning
 Python' from O'Reilly)  I'm confused as to this part:

 ' 0.1 + 0.1 + 0.1 - 0.3
 5.55111.'

 Using 'import Decimal' you can get a much closer result i.e.
 'Decimal('0.0')'

 What I'm wondering is why the first calculation that arrives at
 '5.55111...' is so far out?
 
 The `...` elides the exponent:
 
0.1 + 0.1 + 0.1 - 0.3
   5.551115123125783e-17
 
 If you copied that verbatim directly out of a book, that's just sloppy
 editing.
 

No, the ellipses are sloppy editing on my part done purely for brevity.
Unfortunately they elided the relevant part, the meaning of which was,
prior to these conversations, lost on me.

Thanks to all who replied.

Cheers,

  Phil...

-- 
currently (ab)using
CentOS 6.5, Debian Squeeze  Wheezy, Fedora 19  20, OS X Snow Leopard,
RHEL 7, Ubuntu Precise  Saucy
GnuGPG Key : http://phildobbin.org/publickey.asc
Based in London, UK


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-04-15 Thread Chris Angelico
On Wed, Apr 16, 2014 at 4:31 AM, Phil Dobbin phildob...@gmail.com wrote:
 I saw the 'e-17' appended to the end but was unsure of its meaning (
 quite a number of things are introduced in the book with clarification
 of their meaning not forthcoming 'til later on).

Recommendation: If you don't understand something, keep it there :)
You can just copy and paste from the Python interactive interpreter
(command line or IDLE) straight into the email; it'll be easier to
explain, that way.

This is *especially* true of tracebacks. You might not see the
difference, but to us, it's often hugely helpful to see the entire
exception report.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-04-15 Thread Phil Dobbin
On 15/04/2014 19:41, Chris Angelico wrote:

 On Wed, Apr 16, 2014 at 4:31 AM, Phil Dobbin phildob...@gmail.com wrote:
 I saw the 'e-17' appended to the end but was unsure of its meaning (
 quite a number of things are introduced in the book with clarification
 of their meaning not forthcoming 'til later on).
 
 Recommendation: If you don't understand something, keep it there :)
 You can just copy and paste from the Python interactive interpreter
 (command line or IDLE) straight into the email; it'll be easier to
 explain, that way.
 
 This is *especially* true of tracebacks. You might not see the
 difference, but to us, it's often hugely helpful to see the entire
 exception report.

Good advice.

Truth is I'm writing emails on my laptop  attempting Python on a
Desktop machine so I lazily copied by eye. My mistake.

Cheers,

  Phil...

-- 
currently (ab)using
CentOS 6.5, Debian Squeeze  Wheezy, Fedora 19  20, OS X Snow Leopard,
RHEL 7, Ubuntu Precise  Saucy
GnuGPG Key : http://phildobbin.org/publickey.asc
Based in London, UK


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-04-15 Thread Phil Dobbin
On 15/04/2014 20:07, Chris Angelico wrote:

 On Wed, Apr 16, 2014 at 5:02 AM, Phil Dobbin phildob...@gmail.com wrote:
 On 15/04/2014 19:41, Chris Angelico wrote:

 Recommendation: If you don't understand something, keep it there :)
 You can just copy and paste from the Python interactive interpreter
 (command line or IDLE) straight into the email; it'll be easier to
 explain, that way.

 This is *especially* true of tracebacks. You might not see the
 difference, but to us, it's often hugely helpful to see the entire
 exception report.

 Good advice.

 Truth is I'm writing emails on my laptop  attempting Python on a
 Desktop machine so I lazily copied by eye. My mistake.
 
 Understandable. I currently am using two consoles (laptop at my right
 hand, desktop in front of me), and every now and then I want to copy
 and paste across them :) I mean, shared clipboard works just fine
 across all my VM guests (and as I type that, Disney's cast is singing
 Be our guest in my background music), it even works across remote
 desktop, but for some reason, swinging my hands 90 degrees doesn't
 transfer the clipboard. This strikes me as a major flaw in human
 beings.

:-)

Couldn't agree more. Not enough thought put into that one whoever did it :-)

Cheers,

  Phil...

-- 
currently (ab)using
CentOS 6.5, Debian Squeeze  Wheezy, Fedora 19  20, OS X Snow Leopard,
RHEL 7, Ubuntu Precise  Saucy
GnuGPG Key : http://phildobbin.org/publickey.asc
Based in London, UK


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-04-15 Thread Chris Angelico
On Wed, Apr 16, 2014 at 5:02 AM, Phil Dobbin phildob...@gmail.com wrote:
 On 15/04/2014 19:41, Chris Angelico wrote:

 Recommendation: If you don't understand something, keep it there :)
 You can just copy and paste from the Python interactive interpreter
 (command line or IDLE) straight into the email; it'll be easier to
 explain, that way.

 This is *especially* true of tracebacks. You might not see the
 difference, but to us, it's often hugely helpful to see the entire
 exception report.

 Good advice.

 Truth is I'm writing emails on my laptop  attempting Python on a
 Desktop machine so I lazily copied by eye. My mistake.

Understandable. I currently am using two consoles (laptop at my right
hand, desktop in front of me), and every now and then I want to copy
and paste across them :) I mean, shared clipboard works just fine
across all my VM guests (and as I type that, Disney's cast is singing
Be our guest in my background music), it even works across remote
desktop, but for some reason, swinging my hands 90 degrees doesn't
transfer the clipboard. This strikes me as a major flaw in human
beings.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-04-15 Thread Kushal Kumaran


On April 16, 2014 12:37:53 AM GMT+05:30, Chris Angelico ros...@gmail.com 
wrote:
On Wed, Apr 16, 2014 at 5:02 AM, Phil Dobbin phildob...@gmail.com
wrote:
 On 15/04/2014 19:41, Chris Angelico wrote:

 Recommendation: If you don't understand something, keep it there :)
 You can just copy and paste from the Python interactive interpreter
 (command line or IDLE) straight into the email; it'll be easier to
 explain, that way.

 This is *especially* true of tracebacks. You might not see the
 difference, but to us, it's often hugely helpful to see the entire
 exception report.

 Good advice.

 Truth is I'm writing emails on my laptop  attempting Python on a
 Desktop machine so I lazily copied by eye. My mistake.

Understandable. I currently am using two consoles (laptop at my right
hand, desktop in front of me), and every now and then I want to copy
and paste across them :) I mean, shared clipboard works just fine
across all my VM guests (and as I type that, Disney's cast is singing
Be our guest in my background music), it even works across remote
desktop, but for some reason, swinging my hands 90 degrees doesn't
transfer the clipboard. This strikes me as a major flaw in human
beings.


You want synergy. http://synergy-foss.org/


-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
-- 
https://mail.python.org/mailman/listinfo/python-list


Simple % question

2014-02-11 Thread Scott W Dunning
I just have a simple question.  I don’t understand why 1%10  = 1?


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple % question

2014-02-11 Thread Ben Finney
Scott W Dunning swdunn...@cox.net writes:

 I just have a simple question.  I don’t understand why 1%10  = 1?

Have you read the documentation for that operator?
URL:http://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations

The language reference URL:http://docs.python.org/3/reference/ is the
place to look for official explanations of language features.

-- 
 \   “I met my girlfriend in Macy's; she was buying clothes, and I |
  `\   was putting Slinkies on the escalators.” —Steven Wright |
_o__)  |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple % question

2014-02-11 Thread Chris Angelico
On Wed, Feb 12, 2014 at 12:06 PM, Scott W Dunning swdunn...@cox.net wrote:
 I just have a simple question.  I don’t understand why 1%10  = 1?

The real question is: What do you expect that symbol to mean?

Its actual meaning is quite simple. In long division, dividing one
number by another looks like this:

 86528
  
31415 ) 2718281828
251320
--
 205081
 188490
 --
  165918
  157075
  --
88432
62830
-
256028
251320
--
  4708

(Monospaced font required here.)

2718281828 is the dividend; 31415 is the divisor. They're the numbers
we started with. At the top, we get the quotient, 86528, and down the
bottom, the remainder, 4708. Now let's ask Python about those numbers:

 2718281828 // 31415
86528
 2718281828 % 31415
4708

That's all it is. The // operator, when given two integers, will give
back an integer which is the quotient. The % operator (usually called
modulo), given the same two integers, gives you back the remainder.
With the dividend smaller than the divisor, your quotient is zero and
your remainder is the whole rest of the number; so 1 % 10 is 1. In
fact, 1 % anything greater than 1 will be 1.

Does that help?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple % question

2014-02-11 Thread Christopher Welborn

On 02/11/2014 07:06 PM, Scott W Dunning wrote:

I just have a simple question.  I don’t understand why 1%10  = 1?



 I think because 1 is evenly divisible by 10 exactly 0 times with a 1
remainder. I mean int(1 / 10) == 0, with a 1 remainder.
The same is true for all numbers leading up to 10.

for i in range(12):
print('{} % 10 == {}'.format(i, i % 10))

0 % 10 == 0
1 % 10 == 1
2 % 10 == 2
3 % 10 == 3
4 % 10 == 4
5 % 10 == 5
6 % 10 == 6
7 % 10 == 7
8 % 10 == 8
9 % 10 == 9
10 % 10 == 0
11 % 10 == 1

You can see that with the divmod() function also.



--
\¯\  /¯/\
 \ \/¯¯\/ / / Christopher Welborn (cj)
  \__/\__/ /  cjwelborn at live·com
   \__/\__/   http://welbornprod.com

--
https://mail.python.org/mailman/listinfo/python-list


Re: Simple % question

2014-02-11 Thread Rustom Mody
On Wednesday, February 12, 2014 6:36:17 AM UTC+5:30, Scott W Dunning wrote:
 I just have a simple question.  I don't understand why 1%10  = 1?

This is not really about python. See
http://en.wikipedia.org/wiki/Euclidean_division

Particularly the examples section and note that when you divide a by b you get 
a 
quotient -- q and remainder -- r.  In your case a is 1 b is 10.
Now see that wikipedia page
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple % question

2014-02-11 Thread Scott W Dunning
On Feb 11, 2014, at 6:51 PM, Christopher Welborn cjwelb...@live.com wrote:

 I think because 1 is evenly divisible by 10 exactly 0 times with a 1
 remainder. I mean int(1 / 10) == 0, with a 1 remainder.
 The same is true for all numbers leading up to 10.
 
Actually I think I get it now.  I think I was not really looking at it as 1/10 
more like the other way around.  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple % question

2014-02-11 Thread Chris Angelico
On Wed, Feb 12, 2014 at 2:30 PM, Scott W Dunning swdunn...@cox.net wrote:
 On Feb 11, 2014, at 6:36 PM, Chris Angelico ros...@gmail.com wrote:

 The real question is: What do you expect that symbol to mean?

 Its actual meaning is quite simple. In long division, dividing one
 number by another looks like this:

 Yeah I understand what the % means.  It just confused me that 1%10 was 1.  In 
 my thought process it just didn’t work.  1/10= .1 and I just didn’t see where 
 the remainder of 1 came in.


Ah, yes. When Python 2 - Python 3 changed the meaning of / the
meaning of % got tied instead to //. But if you think about it, with
the floating-point result you're describing there, it simply makes no
sense to even ask what the remainder is. So, if you're going to use %,
use //, and then it all makes sense.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple % question

2014-02-11 Thread Scott W Dunning
On Feb 11, 2014, at 6:36 PM, Chris Angelico ros...@gmail.com wrote:
 
 The real question is: What do you expect that symbol to mean?
 
 Its actual meaning is quite simple. In long division, dividing one
 number by another looks like this:

Yeah I understand what the % means.  It just confused me that 1%10 was 1.  In 
my thought process it just didn’t work.  1/10= .1 and I just didn’t see where 
the remainder of 1 came in.  


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-22 Thread Duncan Booth
Grant Edwards invalid@invalid.invalid wrote:

 [1] OK, so I'm am annoyed with them after my Google phone updated to
 Android 4.2 this afternoon and the lock-screen clock is now
 _physically_painful_ to look at.  However, I'm convinced that's
 not evil -- just a complete and utter lack of visual design
 ability.

You can select any other lock screen widget as the default, so why not 
download some more widgets from Play and choose something different. e.g. 
Beautiful Clock Widgets or HD Widgets but there are probably others.

To change the default lockscreen widget swipe left from the lockscreen 
until you get to a page with only a '+', add the new widget there, then 
long press that widget and drag it to be the rightmost page.

Then you should be sorted just so long as you don't have any friends with 
December birthdays.

-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-15 Thread rurpy
On 11/14/2012 04:07 PM, Steven D'Aprano wrote:
 On Wed, 14 Nov 2012 10:20:13 -0800, rurpy wrote:

I'll skip the issues already addressed by Joshua Landau.

[...]
 I don't understand why you suggest counting setup time for the 
 alternatives to Google Groups, but *don't* consider setup time for Google 
 Groups. You had to create a Google Account didn't you? You've either put 
 in your mobile phone number -- and screw those who don't have one -- or 
 you get badgered every time you sign in. You do sign in don't you?

Yes I sign in.  And I've never entered my mobile phone 
number and no I don't get badgered every time (I've not 
been asked when I logged in several times today and I 
just tried again to confirm.)  I have been asked in the
past and just ignore it -- click Save (or whatever the 
button is) with a blank text box.

As was pointed out, a large number of people already 
have Google accounts.  And creating an account at 
Google is not comparable to researching news readers, 
downloading and installing software, setting up an 
account, etc for someone who's never even heard of 
usenet before.  Subscribing to email is easier but 
it has its own problems (all those email you don't 
care about, the time delay (I've had to wait over 24 
hours for a response for some email lists), what to 
do when you're traveling, reading some groups via 
email but others by GG.  I've also had problems 
trying to post through Gmane and then there were 
Gmane's accessibly problems a few months ago, fixed 
now but for how long?

The OP had already found her way to GG and managed
to post.  So the incremental cost for her to *continue*
using GG is very low.  That's in comparision to
*changing* to a new posting method.

I'm not saying the Google is always easier than an 
alternative but for a significant number of people 
it is.  But most importantly it is *their* place to
say what is easier for them, not yours or mine.

[...] 
 Even if you are right that Google Groups is easier for some users, in my 
 opinion it is easy in the same way as the Dark Side of the Force. 
 Quicker, faster, more seductive, but ultimately destructive.

Well, that's the best example of FUD I've seen in this 
thread so far.  Congratulations.  ;-)

 As for best, that is clearly a matter of opinion. The very fact that
 someone would killfile an entire class of poster based on a some others'
 posts reeks of intolerance and group-think.
 
 Intolerance? Yes. But group-think? You believe that people are merely 
 copying the group's prejudice against Google Groups.

Please don't tell me what I believe, especially when 
you get it wrong.

 I don't think they 
 are. I think that the dislike against GG is group consensus based on the 
 evidence of our own eyes, not a mere prejudice. The use of Google Groups 
 is, as far as I can tell, the single most effective predictor of badly 
 written, badly thought out, badly formatted posts, and a common source of 
 spam.

Again you repeat Chris Angelo's mistake (if it's a 
mistake).  group's prejudice?  You've presented 
no evidence that the group as a whole or in large 
part (including many people who seldom if ever post) 
share your view.  Same with consensus.  A consensus 
of whom?  Are you saying there is a consensus among 
those who dislike GG posts that they dislike GG posts?

You say the dislike is not a mere prejudice and yet 
I can't help but wonder where the hard evidence is.  
I've not seen it posted though I could have easily 
missed it.

All the news/email tools I use make it a little work
to see where a post came from -- usually they'll be a 
button somewhere or a menu item to show the headers 
and one will scan those for the source.  While easy 
enough it is still (at least for me) much easier to 
simply skip a post based on the subject/poster or 
a quick peak at the contents.

So I've never had any inclination to look and have no 
idea how many crap posts come from GG.  Yet you claim
that a large percentage of this group has made the 
effort to do that.  (Or maybe there is an easier way
to check?)

However I can easily imagine how some could think 
they are checking...

 Oh man, what a crap post!  Let's check the headers.
 Yup, just as I thought, Google Groups.

But of course, our genius doesn't keep any records
and the cases where he is wrong don't make as much 
impression on his memory.  Further, he doesn't bother 
to check the headers on the non-crap posts.  Even a 
junior-high science student could see the problems
with this methodology.

And how many people actually do even that?  Some may
find it an offensive suggestion but there is such a 
thing as group psychology and there are people who
follow leaders.  (I suspect those people are all of 
us at least some of the time.)  Further people tend
to be convinced even more easily when they think 
everybody knows it.  So when a few of the more 
prolific and respected posters here start talking 
about the consensus is..., deprecated on this list
and make 

Re: Simple Question regarding running .py program

2012-11-15 Thread Mark Lawrence

On 15/11/2012 21:29, ru...@yahoo.com wrote:

All I'll say is that when I read something on gmane via Thunderbird on 
Windows Vista on any of the 25 Python mailing lists that I subscribe to, 
I don't want to read the double spaced crap that comes from G$.


I hence perceive a problem.

1) G$ are too interested in making huge profits and so have no interest 
in people who have to read the garbage that originates from them.
2) People who are too bone idle to get hold of any other mechanism that 
doesn't put the double spaced garbage in.


Any and all answers to this dilemma are welcome.

--
Cheers.

Mark Lawrence.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-15 Thread Grant Edwards
On 2012-11-15, Mark Lawrence breamore...@yahoo.co.uk wrote:
 On 15/11/2012 21:29, ru...@yahoo.com wrote:

 All I'll say is that when I read something on gmane via Thunderbird on 
 Windows Vista on any of the 25 Python mailing lists that I subscribe to, 
 I don't want to read the double spaced crap that comes from G$.

Doesn't Thunderbird have a scoring, blocking, or blacklisting facility
to allow you to hide/ignore those posts?  I have slrn hide all
postings with headers that contain a line that matches this
(case-insensitve) RE:

Message-ID: .*googlegroups.com

 I hence perceive a problem.

Indeed.

 1) G$ are too interested in making huge profits and so have no interest 
in people who have to read the garbage that originates from them.

While I generally find Google to be mostly non-evil[1] (at least when
compared to most other behmouth companies), their attitude regarding
Google Groups is notably awful.

 2) People who are too bone idle to get hold of any other mechanism that 
doesn't put the double spaced garbage in.

Or it could be they're too ignorant to know there's a problem.  Trying
to explain the problem and the available options is, IME, pointless.

Even if you can drag them along to the point where they understand
there's a problem and they can do something about it, as long as
people read and respond to their posts, they've got no motivation to
do so.

 Any and all answers to this dilemma are welcome.

I just gave up and now ignore posts from Google Groups.  I've decided
there's no point it trying to change either Google Groups itself or
the people who use it.  I occasionally see most/all of posts from GG
when they get quoted in followups, and never have I had occasion to
wish I hadn't missed a GG posting.

[1] OK, so I'm am annoyed with them after my Google phone updated to
Android 4.2 this afternoon and the lock-screen clock is now
_physically_painful_ to look at.  However, I'm convinced that's
not evil -- just a complete and utter lack of visual design
ability.

-- 
Grant
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-15 Thread rusi
On Nov 16, 2:29 am, ru...@yahoo.com wrote:
 But of course, our genius doesn't keep any records
 and the cases where he is wrong don't make as much
 impression on his memory.  Further, he doesn't bother
 to check the headers on the non-crap posts.  Even a
 junior-high science student could see the problems
 with this methodology.

Reminds of the difference between pop and educated statistics:
http://www.johndcook.com/blog/2008/10/20/nearly-everyone-is-above-average/

On the whole I agree with rurpy.
One small addition: GG allows spam posts to be marked as spam.

This feature costs a few seconds and can help everyone (if a few more
GG users would use it)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-15 Thread Chris Angelico
On Fri, Nov 16, 2012 at 3:10 PM, rusi rustompm...@gmail.com wrote:
 One small addition: GG allows spam posts to be marked as spam.

 This feature costs a few seconds and can help everyone (if a few more
 GG users would use it)

And Gmail lets you do the exact same thing, but I almost never need to
do it, because the filter is already pretty good. Though every once in
a while I go check the spambox and there's usually something that
technically shouldn't have been called spam (but even then, I've never
regretted missing it). And I'm sure you can get it with a newsreader
too, though I've not looked.

Spam filtering is nothing unique.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-15 Thread Chris Angelico
On Fri, Nov 16, 2012 at 5:37 PM, Chris Angelico ros...@gmail.com wrote:
 Spam filtering is nothing unique.


(Don't get me wrong though, that doesn't stop it from being a good
thing. It's just not a reason to use GG above all else.)

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-14 Thread Chris Angelico
On Wed, Nov 14, 2012 at 6:02 PM,  ru...@yahoo.com wrote:
 On 11/13/2012 11:02 PM, Chris Angelico wrote:
 To be more accurate: This is deprecated *by members of* this list. As
 there is no commanding/controlling entity here, it's up to each
 individual to make a decision - for instance, abusive users get
 killfiled rather than banned. The use of Google Groups to post is
 deprecated in the original sense of the word: strongly disapproved of.

 s/deprecated *by members of*/deprecated *by some members of*/

 (and accuracy could probably be increased further by replacing
 some with a few.)

I stand by what I said. Members, plural, of this list. I didn't say
all members of, ergo the word some is superfluous, yet not
needful, as Princess Ida put it.

In any case, the fact remains that a number of this list's best
responders have killfiled Google Groups posters as a whole.
Consequently, GG forces you to go to quite a bit of extra work AND
prevents your message from getting through to everyone. Why go to
extra work to get a worse result? I am therefore not going to
recommend Google Groups to anyone as a means of posting to
python-list/c.l.p, any more than I would recommend writing it on a
Post-It note and feeding it into your floppy drive.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-14 Thread rurpy
On 11/14/2012 06:35 AM, Chris Angelico wrote:
 On Wed, Nov 14, 2012 at 6:02 PM, rurpy wrote:
 On 11/13/2012 11:02 PM, Chris Angelico wrote:
 To be more accurate: This is deprecated *by members of* this list. As
 there is no commanding/controlling entity here, it's up to each
 individual to make a decision - for instance, abusive users get
 killfiled rather than banned. The use of Google Groups to post is
 deprecated in the original sense of the word: strongly disapproved of.

 s/deprecated *by members of*/deprecated *by some members of*/

 (and accuracy could probably be increased further by replacing
 some with a few.)
 
 I stand by what I said. Members, plural, of this list. I didn't say
 all members of, ergo the word some is superfluous, yet not
 needful, as Princess Ida put it.

Then you would have no problem I suppose with Australians
are racists because some Australians are racist and I
didn't say all?

I stand by what I said.  Using the passive voice to
give a false sense of authority, leaving out quantifiers 
when there are likely thousands of readers of this group 
perhaps a half dozen who've been vocal against GG, is 
not an accurate description.  

 In any case, the fact remains that a number of this list's best
 responders have killfiled Google Groups posters as a whole.
 Consequently, GG forces you to go to quite a bit of extra work AND
 prevents your message from getting through to everyone. Why go to
 extra work to get a worse result?

As a user of GG, Usenet and email lists I claim you 
are wrong.  GG does NOT require quite a bit of extra 
work.  If it did, I wouldn't use it.  For occasional 
posters, GG is EASIER.  (It would be even easier if 
Google would fix their execrable quoting behaviour 
but as I showed, it is easy to work around that.)
I think you are ignoring setup time and a number 
of other secondary factors, things that are very
significant to occasional posters, in your evaluation
of easy.

As for best, that is clearly a matter of opinion.
The very fact that someone would killfile an entire
class of poster based on a some others' posts reeks
of intolerance and group-think.  And since some of the 
anti-GG proponents are also among the most opinionated 
and argumentative participants here, their not reading
GG posts could be seen as an advantage.

As an aside, I've noticed that some those most vocal 
against GG have also been very vocal about this group
being inclusive.

If one observes that women post here (as a group) 
a lot less frequently then men, and if GG is easier 
for occasional posters, then the anti-GG attitude 
expressed here by a few would have the effect of 
disproportionately discriminating against women.

 I am therefore not going to
 recommend Google Groups to anyone as a means of posting to
 python-list/c.l.p, 

That's fine.  But when doing so please leave out the 
false metaphors...

 any more than I would recommend writing it on a
 Post-It note and feeding it into your floppy drive.

...such as posting here via GG is similar to feeding
post-its into a floppy drive.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-14 Thread Steven D'Aprano
On Wed, 14 Nov 2012 10:20:13 -0800, rurpy wrote:

 On 11/14/2012 06:35 AM, Chris Angelico wrote:
[...]
 I stand by what I said. Members, plural, of this list. I didn't say
 all members of, ergo the word some is superfluous, yet not needful,
 as Princess Ida put it.
 
 Then you would have no problem I suppose with Australians are racists
 because some Australians are racist and I didn't say all?

Speaking as an Australian, I wouldn't have a problem with that, because 
Australians *are* racist. To the degree that we can talk about a 
national character, the national character of Australia is racist, even 
if many Aussies aren't, and many more try not to be.

In any case, your example is provocative. Here's a less provocative 
version:

[paraphrase]
Then you would have no problem I suppose with People have two legs
because some people have two legs and I didn't say all?
[end paraphrase]



 As a user of GG, Usenet and email lists I claim you are wrong.  GG does
 NOT require quite a bit of extra work.  If it did, I wouldn't use it. 
 For occasional posters, GG is EASIER.  (It would be even easier if
 Google would fix their execrable quoting behaviour but as I showed, it
 is easy to work around that.) I think you are ignoring setup time and a
 number of other secondary factors, things that are very significant to
 occasional posters, in your evaluation of easy.

I don't understand why you suggest counting setup time for the 
alternatives to Google Groups, but *don't* consider setup time for Google 
Groups. You had to create a Google Account didn't you? You've either put 
in your mobile phone number -- and screw those who don't have one -- or 
you get badgered every time you sign in. You do sign in don't you?

For *really* occasional posters, they might not even remember their 
Google account details from one post to the next. So they have to either 
create a new account, or go through the process of recreating it. Why do 
you ignore these factors in *your* evaluation of easy?

We all do it -- when we talk about easy or difficult, we have an 
idealised generalised user in mind. Your idealised user is different from 
Chris' idealised user. You are both generalising. And that's *my* 
generalisation.

Even if you are right that Google Groups is easier for some users, in my 
opinion it is easy in the same way as the Dark Side of the Force. 
Quicker, faster, more seductive, but ultimately destructive.


 As for best, that is clearly a matter of opinion. The very fact that
 someone would killfile an entire class of poster based on a some others'
 posts reeks of intolerance and group-think.

Intolerance? Yes. But group-think? You believe that people are merely 
copying the group's prejudice against Google Groups. I don't think they 
are. I think that the dislike against GG is group consensus based on the 
evidence of our own eyes, not a mere prejudice. The use of Google Groups 
is, as far as I can tell, the single most effective predictor of badly 
written, badly thought out, badly formatted posts, and a common source of 
spam.

As for intolerance, you say that like it is that a bad thing. Why should 
people have to tolerate bad behaviour? Google Groups *encourages* bad 
behaviour. Should we tolerate spam because any spam filter might 
occasionally throw away a legitimate mail? Should we tolerate acid 
attacks on women because occasionally there might be some woman who 
actually deserves such a horrible fate? I don't think so. For many 
things, intolerance is a *good* thing, and many people here believe that 
intolerance for Google Groups is one of those cases.

You of course are free to make whatever arrangements to filter spam and 
use Google Groups as you like, but you equally must respect other 
people's right to control their own inbox by filtering away GG posters.

[...]
 As an aside, I've noticed that some those most vocal against GG have
 also been very vocal about this group being inclusive.

I call bullshit. If you are going to accuse people of being very vocal 
against minorities, you damn well better have some evidence to back up 
your claim.

And if you don't, I would expect a public apology for that slur.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-14 Thread rurpy
On Wednesday, November 14, 2012 4:07:53 PM UTC-7, Steven D'Aprano wrote:
 On Wed, 14 Nov 2012 10:20:13 -0800, rurpy wrote:
 [...]
  As an aside, I've noticed that some those most vocal against GG have
  also been very vocal about this group being inclusive.
 
 I call bullshit. If you are going to accuse people of being very vocal 
 against minorities, you damn well better have some evidence to back up 
 your claim.

 And if you don't, I would expect a public apology for that slur.

I wasn't very clear.  I should have written ...those most vocal 
against GG have also been very vocal *in favor* of this group being
inclusive.

In the next paragraph which you clipped I pointed out
the irony of that attitude versus one possible effect of 
advocating the blacklisting of GG posters:

  If one observes that women post here (as a group)
  a lot less frequently then men, and if GG is easier
  for occasional posters, then the anti-GG attitude
  expressed here by a few would have the effect of
  disproportionately discriminating against women.

Response to your other points will need to wait until
I have more time.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-14 Thread Joshua Landau
Steven, whilst I hold you in high regard, this post seems spurned by bias.

I would urge you to reconsider your *argument*, although your *position*
has merit.

On 14 November 2012 23:07, Steven D'Aprano 
steve+comp.lang.pyt...@pearwood.info wrote:

 On Wed, 14 Nov 2012 10:20:13 -0800, rurpy wrote:

  On 11/14/2012 06:35 AM, Chris Angelico wrote:
  I stand by what I said. Members, plural, of this list. I didn't say
  all members of, ergo the word some is superfluous, yet not needful,
  as Princess Ida put it.
 
  Then you would have no problem I suppose with Australians are racists
  because some Australians are racist and I didn't say all?

 Speaking as an Australian, I wouldn't have a problem with that, because
 Australians *are* racist. To the degree that we can talk about a
 national character, the national character of Australia is racist, even
 if many Aussies aren't, and many more try not to be.

 In any case, your example is provocative. Here's a less provocative
 version:

 [paraphrase]
 Then you would have no problem I suppose with People have two legs
 because some people have two legs and I didn't say all?
 [end paraphrase]


Ahem? Seriously?

With rounding, all people *do* have two legs. That's not fair. In fact, the
idea that most users of this list ban Google Groups is probably false.

Additionally, being provocative isn't actually  weakness of his argument,
although it is a distraction. He asked if you had a problem with it on
the basis that if it was a fair claim you would not, in order to show that
it was not a fair claim. That would *imply* his correctness.

How about this(?):
People have brown hair.

  As a user of GG, Usenet and email lists I claim you are wrong.  GG does
  NOT require quite a bit of extra work.  If it did, I wouldn't use it.
  For occasional posters, GG is EASIER.  (It would be even easier if
  Google would fix their execrable quoting behaviour but as I showed, it
  is easy to work around that.) I think you are ignoring setup time and a
  number of other secondary factors, things that are very significant to
  occasional posters, in your evaluation of easy.

 I don't understand why you suggest counting setup time for the
 alternatives to Google Groups, but *don't* consider setup time for Google
 Groups. You had to create a Google Account didn't you? You've either put
 in your mobile phone number -- and screw those who don't have one -- or
 you get badgered every time you sign in. You do sign in don't you?


That's not fair, either, on the basis that almost everyone has a Google
account. Additionally, who signs in manually any more [*wink*]?


 For *really* occasional posters, they might not even remember their
 Google account details from one post to the next. So they have to either
 create a new account, or go through the process of recreating it. Why do
 you ignore these factors in *your* evaluation of easy?


They might not remember their Email account either. This seems to be a
really contrived point.


 We all do it -- when we talk about easy or difficult, we have an
 idealised generalised user in mind. Your idealised user is different from
 Chris' idealised user. You are both generalising. And that's *my*
 generalisation.


All of this is really beside the point, anyway. He claimed the he used it
because *he* found it easier. And there was claim that there were good
reasons to use Google Groups. If you claim that his point is invalid
because it only talks about *his* idealised user, you've only invalidated
your own point.


 Even if you are right that Google Groups is easier for some users, in my
 opinion it is easy in the same way as the Dark Side of the Force.
 Quicker, faster, more seductive, but ultimately destructive.


How so?


   As for best, that is clearly a matter of opinion. The very fact that
  someone would killfile an entire class of poster based on a some others'
  posts reeks of intolerance and group-think.

 Intolerance? Yes. But group-think? You believe that people are merely
 copying the group's prejudice against Google Groups. I don't think they
 are. I think that the dislike against GG is group consensus based on the
 evidence of our own eyes, not a mere prejudice.


Consensus? Hrm...A synonym of consensus is unanimity. This argument's
existence basically disproves that.


 The use of Google Groups
 is, as far as I can tell, the single most effective predictor of badly
 written, badly thought out, badly formatted posts, and a common source of
 spam.

 As for intolerance, you say that like it is that a bad thing. Why should
 people have to tolerate bad behaviour? Google Groups *encourages* bad
 behaviour.


I think this is a valid thing to say. I agree largely because it's the
user's choice to read and reply to this list. Calling someone helpful in a
community intolerant because you think they could be nicer would be a bit
intolerant yourself.


 Should we tolerate spam because any spam filter might
 occasionally throw away a legitimate 

Re: Simple Question regarding running .py program

2012-11-14 Thread Steven D'Aprano
On Wed, 14 Nov 2012 23:07:53 +, Steven D'Aprano wrote:

 On Wed, 14 Nov 2012 10:20:13 -0800, rurpy wrote:
[...]
 [...]
 As an aside, I've noticed that some those most vocal against GG have
 also been very vocal about this group being inclusive.
 
 I call bullshit. If you are going to accuse people of being very vocal
 against minorities, you damn well better have some evidence to back up
 your claim.
 
 And if you don't, I would expect a public apology for that slur.

Ah, apparently I misread Rurpy's comment. I'm sorry, I was completely 
wrong to accuse Rurpy of accusing others of being opposed to including 
minorites in this group.

My apologies Rurpy, I don't know how I made that misreading.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-14 Thread Terry Reedy

On 11/13/2012 11:10 PM, Chris Angelico wrote:

On Wed, Nov 14, 2012 at 2:31 PM, Caroline Hou joyhou2...@gmail.com wrote:

Thank you Dave and everybody here for your helpful comments!This place is 
awesome! I found this group when I googled python-list. Seems like this is not 
the usual way you guys access the list?


There are several ways to communicate with this list.

* The comp.lang.python newsgroup - get a newsreader (there are plenty
around), and either connect to your ISP's news server (if they have
one that carries c.l.p) or to a public server, some of which cost
money.
* Use a news-to-web gateway such as Google Groups. That specific one
is deprecated on this list, as there's more noise than signal from
Google Groups.
* The mailing list python-list, delivered directly to your inbox many
times a day. This is what I personally use.


news.gmane.org group gmane.comp.python.general
many 'mail' programs such as Outlook Express or Thunderbird also handle news

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-14 Thread Terry Reedy

On 11/14/2012 2:02 AM, ru...@yahoo.com wrote:


On the other hand finding and configuring a newsreader
for someone whose never done it before, as you recommend,
is a major time consumer.


Use a mail/news program such as Thunderbird and the newsreader comes for 
free. Setting up a gmane account with Thunderbird was, as I remember 
rather easy, easier than setting up a mail account.


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-13 Thread Dave Angel
On 11/12/2012 09:45 PM, Caroline Hou wrote:
snip all the doublespaced quotes
 
 Hi Dave!
 
 thank you very much for your quick reply! I did manage to get the program run 
 from cmd.exe. 
 So does it mean that if I want to use python interactively,I should use the 
 interpreter,while if I just want to run a python program, I should use DOS 
 shell instead?

The DOS shell is one answer that settled both of your original
questions.  It's also how I run about 90% of the time.  But different
people have different preferences.

The interpreter is great for experimenting.  But if you have non-trivial
code (presumably written in a file), then you have to import it.  Which
means references to the stuff there are done with mymodule.myfunction.
That can get tiresome after a while.  And if you have to change the
source file, it's not always safe to reload it (so I never do).  If I've
imported something, and that something has changed, I quit the
interpreter and start it over.

When you're running the script as a whole from the DOS box, it's always
a clean start.

 Also, how could I edit my script? I have sth called IDLE installed along 
 with python. Is it the right place to write/edit my script?

Any text editor will do, but especially one with some knowledge of the
Python syntax.  Don't use Notepad.  I've never used IDLE (I use a
commercial one called Komodo IDE), so I can't say how good it is.  Many
people love IDLE, though.

The thing is, any IDE will require some setup (setting directory paths,
project settings, etc.), and some getting used to.  Some don't work very
well for GUI programs, others truncate traceback listings (maybe giving
you a GUI view of the same information).  Some apparently won't even let
you copy/paste a traceback into a mail message.  So it's very useful to
also get thoroughly acquainted with the cmd prompt.

 Sorry about these semi-idiot questions but it is really hard to find an 
 article or book that covers such basic stuffs! 

Nothing wrong with those questions.  Welcome to Python-list.

-- 

DaveA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-13 Thread Ramchandra Apte
On Tuesday, 13 November 2012 08:15:45 UTC+5:30, Caroline Hou  wrote:
 On Monday, 12 November 2012 21:25:08 UTC-5, Dave Angel  wrote:
 
  On 11/12/2012 09:02 PM, Caroline Hou wrote:
 
  
 
   Hi all!
 
  
 
  
 
  
 
   I just started learning Python by myself and I have an extremely simple 
   question now!
 
  
 
   I am in my Python interpreter now and I want to open/edit a program 
   called nobel.py. But when I typed  python nobel.py, it gave me a 
   SyntaxError:invalid syntax”( I've changed to the correct directory)what 
   should I do?
 
  
 
   I also want to run the program, but as I double-clicked the program, a 
   command window pops up and closes immediately. How can I see the result 
   of the program run?
 
  
 
   Could anyone help me please? I am pretty confused here...Thank you!
 
  
 
  
 
  
 
  It'd be nice to specify that you're running Windows, and also what
 
  
 
  version of the interpreter, although in this case the latter doesn't matter.
 
  
 
  
 
  
 
  
 
  
 
  Go to a shell (cmd.exe), change to the directory containing that script,
 
  
 
  and type the command as you did.
 
  
 
  
 
  
 
  On linux:  davea@think:~$ python nobel.py
 
  
 
  On Windows:   c:\mydir\myscript  python nobel.py
 
  
 
  
 
  
 
  If you're already in the python interpreter, then running python is
 
  
 
  useless -- it's already running.  In that case, you might want to use
 
  
 
  import.  However, I recommend against it at first, as it opens up some
 
  
 
  other problems you haven't experience with yet.
 
  
 
  
 
  
 
  When you say you double clicked the program', we have to guess you
 
  
 
  might have meant in MS Explorer.  If you do that, it launches a cmd, it
 
  
 
  runs the python system, and it closes the cmd.  Blame Windows for not
 
  
 
  reading your mind.  If you want the cmd window to stick around, you
 
  
 
  COULD end your program with an raw_input function call, but frequently
 
  
 
  that won't work.  The right answer is the first one above...   Open a
 
  
 
  shell (perhaps with a menu like  DOS BOX), change...
 
  
 
  
 
  
 
  That way, when the program finishes, you can see what happened, or
 
  
 
  didn't happen, and you can run it again using the uparrow key.
 
  
 
  
 
  
 
  BTW, you don't need to send email to both the python-list and to the
 
  
 
  newsgroup.  The newsgroup is automatically fed from the list.  But since
 
  
 
  you're posting from google groups, that's just one of the bugs.  Many
 
  
 
  folks here simply filter out everything from google groups, so your post
 
  
 
  is invisible to them.
 
  
 
 
 
  
 
  
 
  
 
  -- 
 
  
 
  
 
  
 
  DaveA
 
 
 
 Hi Dave!
 
 
 
 thank you very much for your quick reply! I did manage to get the program run 
 from cmd.exe. 
 
 So does it mean that if I want to use python interactively,I should use the 
 interpreter,while if I just want to run a python program, I should use DOS 
 shell instead?
 
 Also, how could I edit my script? I have sth called IDLE installed along 
 with python. Is it the right place to write/edit my script?
 
 Sorry about these semi-idiot questions but it is really hard to find an 
 article or book that covers such basic stuffs! 
 
 Thank you!
 
 
 
 Caroline Hou

IDLE is recommended for newbies like you because an IDE requires too much 
configuration.
When you start writing a big project, you can use an IDE.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-13 Thread Caroline Hou
On Tuesday, November 13, 2012 7:35:32 AM UTC-5, Ramchandra Apte wrote:
 On Tuesday, 13 November 2012 08:15:45 UTC+5:30, Caroline Hou  wrote:
 
  On Monday, 12 November 2012 21:25:08 UTC-5, Dave Angel  wrote:
 
  
 
   On 11/12/2012 09:02 PM, Caroline Hou wrote:
 
  
 
   
 
  
 
Hi all!
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
I just started learning Python by myself and I have an extremely simple 
question now!
 
  
 
   
 
  
 
I am in my Python interpreter now and I want to open/edit a program 
called nobel.py. But when I typed  python nobel.py, it gave me a 
SyntaxError:invalid syntax”( I've changed to the correct 
directory)what should I do?
 
  
 
   
 
  
 
I also want to run the program, but as I double-clicked the program, a 
command window pops up and closes immediately. How can I see the result 
of the program run?
 
  
 
   
 
  
 
Could anyone help me please? I am pretty confused here...Thank you!
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
   It'd be nice to specify that you're running Windows, and also what
 
  
 
   
 
  
 
   version of the interpreter, although in this case the latter doesn't 
   matter.
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
   Go to a shell (cmd.exe), change to the directory containing that script,
 
  
 
   
 
  
 
   and type the command as you did.
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
   On linux:  davea@think:~$ python nobel.py
 
  
 
   
 
  
 
   On Windows:   c:\mydir\myscript  python nobel.py
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
   If you're already in the python interpreter, then running python is
 
  
 
   
 
  
 
   useless -- it's already running.  In that case, you might want to use
 
  
 
   
 
  
 
   import.  However, I recommend against it at first, as it opens up some
 
  
 
   
 
  
 
   other problems you haven't experience with yet.
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
   When you say you double clicked the program', we have to guess you
 
  
 
   
 
  
 
   might have meant in MS Explorer.  If you do that, it launches a cmd, it
 
  
 
   
 
  
 
   runs the python system, and it closes the cmd.  Blame Windows for not
 
  
 
   
 
  
 
   reading your mind.  If you want the cmd window to stick around, you
 
  
 
   
 
  
 
   COULD end your program with an raw_input function call, but frequently
 
  
 
   
 
  
 
   that won't work.  The right answer is the first one above...   Open a
 
  
 
   
 
  
 
   shell (perhaps with a menu like  DOS BOX), change...
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
   That way, when the program finishes, you can see what happened, or
 
  
 
   
 
  
 
   didn't happen, and you can run it again using the uparrow key.
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
   BTW, you don't need to send email to both the python-list and to the
 
  
 
   
 
  
 
   newsgroup.  The newsgroup is automatically fed from the list.  But since
 
  
 
   
 
  
 
   you're posting from google groups, that's just one of the bugs.  Many
 
  
 
   
 
  
 
   folks here simply filter out everything from google groups, so your post
 
  
 
   
 
  
 
   is invisible to them.
 
  
 
   
 
  
 
  
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
   -- 
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
   DaveA
 
  
 
  
 
  
 
  Hi Dave!
 
  
 
  
 
  
 
  thank you very much for your quick reply! I did manage to get the program 
  run from cmd.exe. 
 
  
 
  So does it mean that if I want to use python interactively,I should use the 
  interpreter,while if I just want to run a python program, I should use DOS 
  shell instead?
 
  
 
  Also, how could I edit my script? I have sth called IDLE installed along 
  with python. Is it the right place to write/edit my script?
 
  
 
  Sorry about these semi-idiot questions but it is really hard to find an 
  article or book that covers such basic stuffs! 
 
  
 
  Thank you!
 
  
 
  
 
  
 
  Caroline Hou
 
 
 
 IDLE is recommended for newbies like you because an IDE requires too much 
 configuration.
 
 When you start writing a big project, you can use an IDE.

Thank you Dave and everybody here for your helpful comments!This place is 
awesome! I found this group when I googled python-list. Seems like this is not 
the usual way you guys access the list?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-13 Thread Chris Angelico
On Wed, Nov 14, 2012 at 2:31 PM, Caroline Hou joyhou2...@gmail.com wrote:
 Thank you Dave and everybody here for your helpful comments!This place is 
 awesome! I found this group when I googled python-list. Seems like this is 
 not the usual way you guys access the list?

There are several ways to communicate with this list.

* The comp.lang.python newsgroup - get a newsreader (there are plenty
around), and either connect to your ISP's news server (if they have
one that carries c.l.p) or to a public server, some of which cost
money.
* Use a news-to-web gateway such as Google Groups. That specific one
is deprecated on this list, as there's more noise than signal from
Google Groups.
* The mailing list python-list, delivered directly to your inbox many
times a day. This is what I personally use.

Try here:
http://mail.python.org/mailman/listinfo/python-list

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-13 Thread rurpy
On 11/13/2012 09:10 PM, Chris Angelico wrote:
 On Wed, Nov 14, 2012 at 2:31 PM, Caroline Hou wrote:
 Thank you Dave and everybody here for your helpful comments!This
 place is awesome! I found this group when I googled python-list.
 Seems like this is not the usual way you guys access the list?
 
 There are several ways to communicate with this list.
 [...]
 * Use a news-to-web gateway such as Google Groups. That
 specific one is deprecated on this list, as there's more
 noise than signal from Google Groups.

Caroline, Chris is mistaken about this, if for no other
reason than there is no authority here empowered to decide
to deprecate anything.  What Chris should have said is 
that there are some people on this list who don't like 
Google Groups for whatever reason and encourage others
to ignore posts from Google Groups.

How successful this boycott effort is is not clear.

I use Google Groups as it suits my needs better than
any of the alternatives, and so do many others.  Both 
of the other alternatives Chris mentioned involve too 
much setup or overhead for those who read/post here 
only occasionally.  GG fills this niche adequately 
if used with care.

If you do use Google Groups to post, there are a 
couple of things you should be careful of:

* You'll sometimes see a checkbox above the GG send
window that is a CC to the python mailing list 
(pytho...@python.org) which is checked by default.
Uncheck that before sending, or the list will get 
two copies of your message.  

* GG doesn't do a very good job in quoting the post 
you are replying to.  If you look at your recent 
post here:
  http://mail.python.org/pipermail/python-list/2012-November/635070.html
(or on GG) you will see lots and lots of lines empty 
save for the  quote markers.  This makes a post 
hard to read.

A way to avoid this is to remove the blank extra blank 
lines in the GG send window by hand before posting.

Alternatively, many email programs have a paste as 
quotation option when writing mail.  What I do is
to open a blank new email message, copy the original
post I'm replying to from GG, paste-as-quotation into
the new mail window, then copy and paste back into the
GG send window.  Pretty easy to do once you get used
to it.  

Hope this helps and provides a little more accurate 
info about posting from GG than has been provided so
far.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-13 Thread Chris Angelico
On Wed, Nov 14, 2012 at 4:08 PM,  ru...@yahoo.com wrote:
 On 11/13/2012 09:10 PM, Chris Angelico wrote:
 * Use a news-to-web gateway such as Google Groups. That
 specific one is deprecated on this list, as there's more
 noise than signal from Google Groups.

 Caroline, Chris is mistaken about this, if for no other
 reason than there is no authority here empowered to decide
 to deprecate anything.  What Chris should have said is
 that there are some people on this list who don't like
 Google Groups for whatever reason and encourage others
 to ignore posts from Google Groups.

 How successful this boycott effort is is not clear.

To be more accurate: This is deprecated *by members of* this list. As
there is no commanding/controlling entity here, it's up to each
individual to make a decision - for instance, abusive users get
killfiled rather than banned. The use of Google Groups to post is
deprecated in the original sense of the word: strongly disapproved of.

My own opinion on the matter is that if it takes as much effort as you
describe to use GG properly, it's wasting your time on a massive
scale. Surely it's easier to read and post email?

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-13 Thread rurpy
On 11/13/2012 11:02 PM, Chris Angelico wrote:
 On Wed, Nov 14, 2012 at 4:08 PM, rurpy wrote:
 On 11/13/2012 09:10 PM, Chris Angelico wrote:
 * Use a news-to-web gateway such as Google Groups. That
 specific one is deprecated on this list, as there's more
 noise than signal from Google Groups.

 Caroline, Chris is mistaken about this, if for no other
 reason than there is no authority here empowered to decide
 to deprecate anything.  What Chris should have said is
 that there are some people on this list who don't like
 Google Groups for whatever reason and encourage others
 to ignore posts from Google Groups.

 How successful this boycott effort is is not clear.
 
 To be more accurate: This is deprecated *by members of* this list. As
 there is no commanding/controlling entity here, it's up to each
 individual to make a decision - for instance, abusive users get
 killfiled rather than banned. The use of Google Groups to post is
 deprecated in the original sense of the word: strongly disapproved of.

s/deprecated *by members of*/deprecated *by some members of*/

(and accuracy could probably be increased further by replacing
some with a few.)

And again,

s/strongly disapproved of/strongly disapproved of by some/

I was objecting to your attempts to make it sound like a 
fact that GG posts were nearly universally condemned here, 
an error you repeat again above.

 My own opinion on the matter is that if it takes as much effort as you
 describe to use GG properly, it's wasting your time on a massive
 scale. Surely it's easier to read and post email?

that much effort?  Do you consider a couple of copy-
pastes to be that much effort?  wasting your time 
on a massive scale?  Sheesh, get a grip man, let's not
get silly.

On the other hand finding and configuring a newsreader 
for someone whose never done it before, as you recommend, 
is a major time consumer.  And signing up for python-list 
email, posting, dealing with several days' volume, and 
then signing off because one does not want to read it 
full time[*], is no picnic either compared to using GG.

Sorry, but there are *good* reasons for some people
to use GG whether you want to admit it or not.

==
[*] Actually, now that I think about it, IIRC one can sign
up for python-list email, and go into the mailman settings
and disable mail delivery, allowing one to post to the list 
via email yet read the list via GG, Gmane or whatever.
However, this is not going to be obvious to many occasional
posters, and is still a PITA compared to just posting from 
GG as our hypothetical user does for all the other groups 
he/she participates in.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-13 Thread rusi
On Nov 14, 12:02 pm, ru...@yahoo.com wrote:

 ==
 [*] Actually, now that I think about it, IIRC one can sign
 up for python-list email, and go into the mailman settings
 and disable mail delivery, allowing one to post to the list
 via email yet read the list via GG, Gmane or whatever.
 However, this is not going to be obvious to many occasional
 posters, and is still a PITA compared to just posting from
 GG as our hypothetical user does for all the other groups
 he/she participates in.

Yes this would be (for me) my most preferred option if I could figure
out a way of threading into a preexisting thread.
-- 
http://mail.python.org/mailman/listinfo/python-list


Simple Question regarding running .py program

2012-11-12 Thread Caroline Hou
Hi all!

I just started learning Python by myself and I have an extremely simple 
question now!
I am in my Python interpreter now and I want to open/edit a program called 
nobel.py. But when I typed  python nobel.py, it gave me a 
SyntaxError:invalid syntax”( I've changed to the correct directory)what should 
I do?
I also want to run the program, but as I double-clicked the program, a command 
window pops up and closes immediately. How can I see the result of the program 
run?
Could anyone help me please? I am pretty confused here...Thank you!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-12 Thread Dave Angel
On 11/12/2012 09:02 PM, Caroline Hou wrote:
 Hi all!

 I just started learning Python by myself and I have an extremely simple 
 question now!
 I am in my Python interpreter now and I want to open/edit a program called 
 nobel.py. But when I typed  python nobel.py, it gave me a 
 SyntaxError:invalid syntax”( I've changed to the correct directory)what 
 should I do?
 I also want to run the program, but as I double-clicked the program, a 
 command window pops up and closes immediately. How can I see the result of 
 the program run?
 Could anyone help me please? I am pretty confused here...Thank you!

It'd be nice to specify that you're running Windows, and also what
version of the interpreter, although in this case the latter doesn't matter.


Go to a shell (cmd.exe), change to the directory containing that script,
and type the command as you did.

On linux:  davea@think:~$ python nobel.py
On Windows:   c:\mydir\myscript  python nobel.py

If you're already in the python interpreter, then running python is
useless -- it's already running.  In that case, you might want to use
import.  However, I recommend against it at first, as it opens up some
other problems you haven't experience with yet.

When you say you double clicked the program', we have to guess you
might have meant in MS Explorer.  If you do that, it launches a cmd, it
runs the python system, and it closes the cmd.  Blame Windows for not
reading your mind.  If you want the cmd window to stick around, you
COULD end your program with an raw_input function call, but frequently
that won't work.  The right answer is the first one above...   Open a
shell (perhaps with a menu like  DOS BOX), change...

That way, when the program finishes, you can see what happened, or
didn't happen, and you can run it again using the uparrow key.

BTW, you don't need to send email to both the python-list and to the
newsgroup.  The newsgroup is automatically fed from the list.  But since
you're posting from google groups, that's just one of the bugs.  Many
folks here simply filter out everything from google groups, so your post
is invisible to them.
   

-- 

DaveA

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-12 Thread Caroline Hou
On Monday, 12 November 2012 21:25:08 UTC-5, Dave Angel  wrote:
 On 11/12/2012 09:02 PM, Caroline Hou wrote:
 
  Hi all!
 
 
 
  I just started learning Python by myself and I have an extremely simple 
  question now!
 
  I am in my Python interpreter now and I want to open/edit a program called 
  nobel.py. But when I typed  python nobel.py, it gave me a 
  SyntaxError:invalid syntax”( I've changed to the correct directory)what 
  should I do?
 
  I also want to run the program, but as I double-clicked the program, a 
  command window pops up and closes immediately. How can I see the result of 
  the program run?
 
  Could anyone help me please? I am pretty confused here...Thank you!
 
 
 
 It'd be nice to specify that you're running Windows, and also what
 
 version of the interpreter, although in this case the latter doesn't matter.
 
 
 
 
 
 Go to a shell (cmd.exe), change to the directory containing that script,
 
 and type the command as you did.
 
 
 
 On linux:  davea@think:~$ python nobel.py
 
 On Windows:   c:\mydir\myscript  python nobel.py
 
 
 
 If you're already in the python interpreter, then running python is
 
 useless -- it's already running.  In that case, you might want to use
 
 import.  However, I recommend against it at first, as it opens up some
 
 other problems you haven't experience with yet.
 
 
 
 When you say you double clicked the program', we have to guess you
 
 might have meant in MS Explorer.  If you do that, it launches a cmd, it
 
 runs the python system, and it closes the cmd.  Blame Windows for not
 
 reading your mind.  If you want the cmd window to stick around, you
 
 COULD end your program with an raw_input function call, but frequently
 
 that won't work.  The right answer is the first one above...   Open a
 
 shell (perhaps with a menu like  DOS BOX), change...
 
 
 
 That way, when the program finishes, you can see what happened, or
 
 didn't happen, and you can run it again using the uparrow key.
 
 
 
 BTW, you don't need to send email to both the python-list and to the
 
 newsgroup.  The newsgroup is automatically fed from the list.  But since
 
 you're posting from google groups, that's just one of the bugs.  Many
 
 folks here simply filter out everything from google groups, so your post
 
 is invisible to them.
 

 
 
 
 -- 
 
 
 
 DaveA

Hi Dave!

thank you very much for your quick reply! I did manage to get the program run 
from cmd.exe. 
So does it mean that if I want to use python interactively,I should use the 
interpreter,while if I just want to run a python program, I should use DOS 
shell instead?
Also, how could I edit my script? I have sth called IDLE installed along with 
python. Is it the right place to write/edit my script?
Sorry about these semi-idiot questions but it is really hard to find an article 
or book that covers such basic stuffs! 
Thank you!

Caroline Hou
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-12 Thread Terry Reedy

On 11/12/2012 9:45 PM, Caroline Hou wrote:


Also, how could I edit my script? I have sth called IDLE installed
along with python. Is it the right place to write/edit my script?


IDLE is one way to edit; I use it. When you want to run, hit F5 and 
stdout and stderr output goes to the shell window.


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Simple question about loading a .glade UI file

2011-06-21 Thread Anthony Papillion
Hi Everyone,

So I'm tackling designing a non-CLI program using Glade. I went through some
tutorials and it seems like I'm doing things right but I'm my UI won't load.
Python keeps griping about could not create glade XML object.

I have a .glade file called MainWindow.glade and my main window is called
(predictably) winMain. Here is the code I'm using to load it:

#!/usr/bin/env python
import sys
try:
import pygtk
pygtk.require(2.0)
except:
pass

try:
import gtk
import gtk.glade
except:
print GTK could not be loaded.
sys.exit(1)

class GMB:

def __init__(self):
self.gladefile = MainWindow.glade
 self.wTree = gtk.glade.XML(self.gladefile)
self.wTree.signal_autoconnect(self)
 self.window = self.wTree.get_widget(winMain)
if(self.window):
self.window.connect(destroy, gtk.main_quit)

def on_winMain_delete(self, widget, dummy):
gtk.main_quit()

if __name__ == __main__:
myGui = GMB()
gtk.main()

Is there any reason why I'd be getting this error from the code above? Both
the UI file and the source code file are in the same directory.

Thanks!
Anthony
-- 
http://mail.python.org/mailman/listinfo/python-list


Simple Question

2011-02-17 Thread uahmed
Why Tkinter on Linux dont support other format of logo picture except of
.xbm format ?
here logo Picture means an image which comes on top left of window .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple question about Queue.Queue and threads

2010-02-08 Thread Steven
On Feb 5, 7:45 am, Frank Millman fr...@chagford.com wrote:
 Hi all

 Assume you have a server process running, a pool of worker threads to
 perform tasks, and aQueue.Queue() to pass the tasks to the workers.

 In order to shut down the server cleanly, you want to ensure that the
 workers have all finished their tasks. I like the technique of putting a
 None onto thequeue, and have each worker check for None, put None back onto
 thequeue, and terminate itself.

 The main program would look something like this -

     q.put(None)
     for worker in worker_threads:
         worker.join()

 At this point you can be sure that each thread has completed its tasks and
 terminated itself.

 However, thequeueis not empty - it still has the final None in it.

 Is it advisable to finalise the cleanup like this? -

     while not q.empty():
         q.get()
         q.task_done()
     q.join()

 Or is this completely redundant?

 Thanks

 Frank Millman

Queue objects have support for this signaling baked in with
q.task_done and q.join.

After the server process has put all tasks into the queue, it can join
the queue itself, not the worker threads.

q.join()

This will block until all tasks have been gotten AND completed.  The
worker threads would simply do this:
task_data = q.get()
do_task(task_data)
q.task_done()

Using pairs of get and task_done you no longer need to send a signal.
Just exit the server process and the worker threads will die (assuming
of course, you set .setDaemon(True) before starting each worker
thread).

Steven Rumbalski
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple question about Queue.Queue and threads

2010-02-08 Thread Frank Millman

On Feb 8, 4:51 pm, Steven steven.rumbal...@fiserv.com wrote:


Queue objects have support for this signaling baked in with
q.task_done and q.join.

After the server process has put all tasks into the queue, it can join
the queue itself, not the worker threads.

q.join()

This will block until all tasks have been gotten AND completed.  The
worker threads would simply do this:
task_data = q.get()
do_task(task_data)
q.task_done()

Using pairs of get and task_done you no longer need to send a signal.
Just exit the server process and the worker threads will die (assuming
of course, you set .setDaemon(True) before starting each worker
thread).



Thanks, Steven.

This works perfectly in my scenario, and tidies up the code a bit.

Minor point - according to the 2.6 docs, .setDaemon(True) is the old API - 
the current way of specifying this is .daemon = True.


Thanks for the tip.

Frank


--
http://mail.python.org/mailman/listinfo/python-list


Simple question about Queue.Queue and threads

2010-02-05 Thread Frank Millman

Hi all

Assume you have a server process running, a pool of worker threads to 
perform tasks, and a Queue.Queue() to pass the tasks to the workers.


In order to shut down the server cleanly, you want to ensure that the 
workers have all finished their tasks. I like the technique of putting a 
None onto the queue, and have each worker check for None, put None back onto 
the queue, and terminate itself.


The main program would look something like this -

   q.put(None)
   for worker in worker_threads:
   worker.join()

At this point you can be sure that each thread has completed its tasks and 
terminated itself.


However, the queue is not empty - it still has the final None in it.

Is it advisable to finalise the cleanup like this? -

   while not q.empty():
   q.get()
   q.task_done()
   q.join()

Or is this completely redundant?

Thanks

Frank Millman


--
http://mail.python.org/mailman/listinfo/python-list


Re: Simple question about Queue.Queue and threads

2010-02-05 Thread Gabriel Genellina
En Fri, 05 Feb 2010 09:45:30 -0300, Frank Millman fr...@chagford.com  
escribió:


Assume you have a server process running, a pool of worker threads to  
perform tasks, and a Queue.Queue() to pass the tasks to the workers.


In order to shut down the server cleanly, you want to ensure that the  
workers have all finished their tasks. I like the technique of putting a  
None onto the queue, and have each worker check for None, put None back  
onto the queue, and terminate itself.


The main program would look something like this -

q.put(None)
for worker in worker_threads:
worker.join()

At this point you can be sure that each thread has completed its tasks  
and terminated itself.


However, the queue is not empty - it still has the final None in it.


Yes - but who cares? :)


Is it advisable to finalise the cleanup like this? -

while not q.empty():
q.get()
q.task_done()
q.join()

Or is this completely redundant?


I don't see what you gain by doing that.

On the other hand, you might check whether the queue contains exactly one  
item and it is None, just to be sure that all queued work has been done.


(BTW, I'd use a different sentinel instead of None; perhaps this could not  
happen in your current code, but it's easy to inadvertedly put a None in  
the queue, stopping all workers prematurely.)


--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


Re: Simple question about Queue.Queue and threads

2010-02-05 Thread Frank Millman

On Feb 6, 7:59 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote:
En Fri, 05 Feb 2010 09:45:30 -0300, Frank Millman fr...@chagford.com 
escribió:



[...]

 However, the queue is not empty - it still has the final None in it.

Yes - but who cares? :)



That was my point. I didn't think I needed to care, but I wanted to be sure 
I was not missing something.


I will just discard all the final cleanup code.



(BTW, I'd use a different sentinel instead of None; perhaps this could not 
happen in your current code, but it's easy to inadvertedly put a None in 
the queue, stopping all workers prematurely.)




Good advice.

Thanks, Gabriel

Frank


--
http://mail.python.org/mailman/listinfo/python-list


simple question about Dictionary type containing List objects

2009-07-13 Thread gganesh
Hi group,
I have a dict object like
emails={'mycontacts': [ 'x...@gmail.com, 'y...@gmail.com',
'z...@gmail.com'], 'myname':['gganesh']}
I need to get the lenght of the list mycontacts ,like
mycontacts_numbers=3
help me to solve
Thanks


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: simple question about Dictionary type containing List objects

2009-07-13 Thread Xavier Ho
On Mon, Jul 13, 2009 at 6:34 PM, gganesh ganesh@gmail.com wrote:

 Hi group,
 I have a dict object like
 emails={'mycontacts': [ 'x...@gmail.com, 'y...@gmail.com',
 'z...@gmail.com'], 'myname':['gganesh']}
 I need to get the lenght of the list mycontacts ,like
 mycontacts_numbers=3 http://mail.python.org/mailman/listinfo/python-list


 len(emails['mycontacts'])
3

HTH,

Ching-Yun Xavier Ho, Technical Artist

Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
Website: http://xavierho.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: simple question about Dictionary type containing List objects

2009-07-13 Thread Ulrich Eckhardt
gganesh wrote:
 I have a dict object like
 emails={'mycontacts': [ 'x...@gmail.com, 'y...@gmail.com',
 'z...@gmail.com'], 'myname':['gganesh']}
 I need to get the lenght of the list mycontacts ,like
 mycontacts_numbers=3

mycontacts = emails['mycontacts']
mycontacts_number = len(mycontacts)

A list doesn't change in behaviour when it is contained in a dictionary.

Uli

-- 
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

-- 
http://mail.python.org/mailman/listinfo/python-list


Simple question about accessing instance properties.

2009-05-21 Thread Lacrima
Hello!

I think I have a very simple question, but I can't understand how to
access object properties in a way described below.
For example I have an instance of any class:

 class Person:
def __init__(self):
self.name = 'John'
self.email = 'j...@example.com'
self.phone = '3453454'
 person = Person()

Then I have a list of person's properties represented as strings:
 prop_list = ['name', 'email', 'phone']

And my question is how to access person's properties using prop_list?
Do I have to somehow convert 'name', 'email', 'phone'?

With regards,
Max.
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   >