Unicode, stdout, and stderr

2014-07-22 Thread Frank Millman
Hi all

This is not important, but I would appreciate it if someone could explain 
the following, run from cmd.exe on Windows Server 2003 -

C:\python
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit 
(In
tel)] on win32
Type help, copyright, credits or license for more information.
 x = '\u2119'
 x  # this uses stderr
'\u2119'
 print(x)  # this uses stdout
Traceback (most recent call last):
  File stdin, line 1, in module
  File C:\Python34\lib\encodings\cp437.py, line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in 
position
0: character maps to undefined


It seems that there is a difference between writing to stdout and writing to 
stderr. My questions are -

1. What is the difference?

2. Is there an easy way to get stdout to behave the same as stderr?

Thanks

Frank Millman



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


Re: Network/multi-user program

2014-07-22 Thread Lele Gaifax
Monte Milanuk memila...@invalid.com writes:

 On 2014-07-21, Lele Gaifax l...@metapensiero.it wrote:
 Monte Milanuk memila...@invalid.com writes:
 How hard was it to migrate from a desktop app to what you have now?

 Well, basically I rewrote everything, there's nothing in common. The
 original application was written in Delphi, using Paradox tables, no
 i18n, no multiuser, no PDF printouts... On the other hand, with Python
 is far easier to get something working, and databasing with SQLAlchemy
 is a pleasure. On the frontend, ExtJS is impressive, even if it has its
 own drawbacks.

 Any hints/opinions on what those drawbacks might be?  I know literally
 almost nothing about JS.  I worked thru a short generic tutorial a couple
 years ago, but nothing like these libraries I see people talking about
 now like jquery, angular, ext, and so on.  Hence my hesitation at adding
 another learning curve on top of python and the various libraries needed
 for this first 'real' project.

I completely agree with Roy on the language itself, it has several
tricky parts that require some training to learn how to avoid, defects
that are inherent to language and to the syntax, that no framework or
library can really eliminate. There is a very good book by Douglas
Crockford, JS: the good parts that I recommend reading.

On the framework, ExtJS is the one I know better and its quite good and
powerful: it has a dual license, GPL for free software projects and a
commercial version, very good documentation and a lot of users. My main
complaint is about their (Sencha's) release policy which frankly sucks,
on both sides (free and commercial): they do not have a clear roadmap,
you report bugs in a forum and from then on you cannot know if and when
the bug gets fixed, or even released. They do not promise any kind of
backward compatibility, and several times they irremediably broke the
internal implementation of a few widgets I used from one minor version
to the next and eventually released a proper fix only for the commercial
version. They assert to have an extensive suite of unit and functional
tests, but sometime I have the doubt they do not run it as often as one
would expect :-)

On the other hand, it has good and extensive examples, so the learning
curve is not so steep (I'm clearly biased here, but I introduced several
young developers to that environment and that's what they said too).

Anyway, don't be scared: start on the Python side, laying down the
foundations of the application, the database model, the main business
logic, unit and functional tests, and so on. Any kind of frontend, be it
a traditional desktop application or a web based one will build on that.

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  | -- Fortunato Depero, 1929.

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


Re: Network/multi-user program

2014-07-22 Thread CHIN Dihedral

  almost nothing about JS.  I worked thru a short generic tutorial a couple
 
Please check Pyjs and Python with flash
in http://pyjs.org/examples/Space.html
for the front end part of GUI under a
browser.

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


Re: Unicode, stdout, and stderr

2014-07-22 Thread Lele Gaifax
Frank Millman fr...@chagford.com writes:

 Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit 
 (In
 tel)] on win32
 Type help, copyright, credits or license for more information.
 x = '\u2119'
 x  # this uses stderr
 '\u2119'
 print(x)  # this uses stdout
 Traceback (most recent call last):
   File stdin, line 1, in module
   File C:\Python34\lib\encodings\cp437.py, line 19, in encode
 return codecs.charmap_encode(input,self.errors,encoding_map)[0]
 UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in 
 position
 0: character maps to undefined


No, both statements actually emit noise on the standard output, but the
former prints the *repr* of the string, the latter tries to encode it to
CP437, which you console seems to be using.

One approach could be changing the code page (that is, the encoding)
of the terminal (see the chcp command), to select one that actually
have that glyph. But I'm really guessing here...

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  | -- Fortunato Depero, 1929.

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


Re: Top online steroid pharmacies - 2009 Best Site!

2014-07-22 Thread stuffstorehouse2014
GET A GOOD LOOKING AND SEXY BODY HERE

We are suppliers and whole sellers chemical supplements.
BEFORE WE SUPPLY TO YOU MAKE SURE YOU ARE NOT UNDER 18.

we supply chemical supplements such as HIGH QUALITY STEROID HORMONES, HGH ,SEX 
PILLS, HIGH QUALITY PAIN KILLERS, MEDICAL KUSH 

AND HIGH QUALITY KUSH, ACTIVIS PURPLE SYRUPS OF ALL CATEGORIES. we sell high 
quality KATAMIN, XANAX PILLS NEMBROTER and also some high quality weight loss 
products.

Text or call us on (407)-4852249
Email: stuffstorehouse2014(AT)gmail.com

We have agents located in the Germany , USA, Asia, and others.we sell high 
quality chemical supplements and at the best 

prices.
we provide prescriptions to body builders and to those who are novice in the 
field, we do prescription for free.

Text or call us on (407)-4852249
Email: stuffstorehouse2014(AT)gmail.com

we also supply chemical supplements and also top quality powder and crystals 
such as

-high quality 2ci and 2ce 2ci, 2CP 2CE ,2CB 2CD,FLY 2CC ,2CP 2CT21, 2CT4 
Meo-crystal and powder 5-Meo-DMT 4-Aco-DMT 4-Ho-MIPT 

5-Methylmethylone crystal and powder 5-Methylethylone 2-Methylbutylone 
5-Methylbutylone Butylone Eutylone Pentylone
-Grade(?.96) Mephedrone (2- methylamino 1-one
also known as 4-methylmethcathinone(4-MMC).We are one of the top suppliers in 
wholesale and retail of mephedrone and

Mephedrone crystal and powder
methedrone
Flephedrone
Mathedrone
Buphedrone
Ethedrone
Brephedrone

Mdma and BK mdma crystals and powder
methylone
butylone
NAPHYRONE
MBDB
Mdai

5-Methylmethylone crystal and powder
5-Methylethylone
2-Methylbutylone
5-Methylbutylone
Butylone
Eutylone
Pentylone

4-MEC large and small crystals
( (RS)-1-(4-methylphenyl)-
2-methylaminopropan-1-one ).
methamphetamine
detrophetamine
Ethcathinone
Methoxetamine
Dimethocaine

Dimethylcathinone crystal and powder
Diethylpropion
Methcathinone
Ethcathinone

3-MMC,3-MEC,3-EMC
3-EEC,4-EMC,4-EEC

3-MOMC,2-FMC,2-FEC,a-PVP
3-FMC,3-FEC,3-CMC, FPVP
3-BMC,N,N-DEMC,3,4-DMMC

4-MePPP,MOPPP, FPPP
MPBP,MPHP,MDPPP, MDPBP

Powder and crystals
AM 2201
AM2202
am1220
am122

compliments of 2ci and 2ce
2ci, 2CP
2CE ,2CB
2CD,FLY
2CC ,2CP
2CT21, 2CT4

compliments of jwh-
JWH-018 , JWH-250
JWH-018,JWH-073
JWH-200,JWH-250
JWH-240,jwh-350

compliments of Meo-crystal and powder
5-Meo-DMT
4-Aco-DMT
4-Ho-MIPT 4
Our quality is the best you can find around and we sell in small/large 
quantities with guaranteed discreet delivery in good 

time Shipping is done Via DHL TNT FedEx.Please Do Include Your Contact Number . 
All inquiries are welcomed at

Text or call us on (407)-4852249
Email: stuffstorehouse2014(AT)gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Network/multi-user program

2014-07-22 Thread Lele Gaifax
CHIN Dihedral dihedral88...@gmail.com writes:

  almost nothing about JS.  I worked thru a short generic tutorial a couple
 
 Please check Pyjs and Python with flash
 in http://pyjs.org/examples/Space.html
 for the front end part of GUI under a
 browser.


Yes, that's an option: I used Pyjamas (btw, did it survive the schism?)
to build one non trivial application, and while it allows using the
language we all know and love, it introduces one more step of
indirection between you and the actual code that the browser run, so in
the end I didn't repeat the experience.

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  | -- Fortunato Depero, 1929.

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


Re: Unicode, stdout, and stderr

2014-07-22 Thread Steven D'Aprano
On Tue, 22 Jul 2014 08:18:08 +0200, Frank Millman wrote:

 Hi all
 
 This is not important, but I would appreciate it if someone could
 explain the following, run from cmd.exe on Windows Server 2003 -
 
 C:\python
 Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32
 bit (In
 tel)] on win32
 Type help, copyright, credits or license for more information.
 x = '\u2119'
 x  # this uses stderr
 '\u2119'


What makes you think it uses stderr? To the best of my knowledge, it uses 
stdout.


 print(x)  # this uses stdout
 Traceback (most recent call last):
   File stdin, line 1, in module
   File C:\Python34\lib\encodings\cp437.py, line 19, in encode
 return codecs.charmap_encode(input,self.errors,encoding_map)[0]
 UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in
 position 0: character maps to undefined

I think your problem is that print tries to encode the string to your 
terminal's encoding, which appears to be CP-437 (MS DOS code page). Can 
you convince cmd.exe to use UTF-8? That should fix the problem. (Although 
apparently Window's handling of UTF-8 is buggy, so it will create many 
wonderful new problems, yay!)

http://stackoverflow.com/questions/388490/unicode-characters-in-windows-command-line-how

http://stackoverflow.com/questions/14109024/how-to-make-unicode-charset-in-cmd-exe-by-default

http://superuser.com/questions/269818/change-default-code-page-of-windows-console-to-utf-8



 It seems that there is a difference between writing to stdout and
 writing to stderr. 

I would be surprised if that were the case, but I don't have a Windows 
box to test it. Try this:


import sys
print(x, file=sys.stderr)  # I expect this will fail
print(repr(x), file=sys.stdout)  # I expect this will succeed



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


Re: Unicode, stdout, and stderr

2014-07-22 Thread Frank Millman

Lele Gaifax l...@metapensiero.it wrote in message 
news:87lhrl28ie.fsf@nautilus.nautilus...
 Frank Millman fr...@chagford.com writes:

 Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 
 bit
 (In
 tel)] on win32
 Type help, copyright, credits or license for more information.
 x = '\u2119'
 x  # this uses stderr
 '\u2119'
 print(x)  # this uses stdout
 Traceback (most recent call last):
   File stdin, line 1, in module
   File C:\Python34\lib\encodings\cp437.py, line 19, in encode
 return codecs.charmap_encode(input,self.errors,encoding_map)[0]
 UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in
 position
 0: character maps to undefined


 No, both statements actually emit noise on the standard output, but the
 former prints the *repr* of the string, the latter tries to encode it to
 CP437, which you console seems to be using.


Thanks, Lele, but I don't think that is quite right - see my separate 
response to Steven

Frank



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


Re: Unicode, stdout, and stderr

2014-07-22 Thread Frank Millman

Steven D'Aprano st...@pearwood.info wrote in message 
news:53ce0b96$0$29897$c3e8da3$54964...@news.astraweb.com...
 On Tue, 22 Jul 2014 08:18:08 +0200, Frank Millman wrote:

 Hi all

 This is not important, but I would appreciate it if someone could
 explain the following, run from cmd.exe on Windows Server 2003 -

 C:\python
 Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32
 bit (In
 tel)] on win32
 Type help, copyright, credits or license for more information.
 x = '\u2119'
 x  # this uses stderr
 '\u2119'


 What makes you think it uses stderr? To the best of my knowledge, it uses
 stdout.


This is from the docs on sys.stdxxx

sys.stdin
sys.stdout
sys.stderr

File objects used by the interpreter for standard input, output and errors:
  - stdin is used for all interactive input (including calls to input());
  - stdout is used for the output of print() and expression statements and 
for the prompts of input();
  - The interpreter's own prompts and its error messages go to stderr.


 It seems that there is a difference between writing to stdout and
 writing to stderr.

 I would be surprised if that were the case, but I don't have a Windows
 box to test it. Try this:


 import sys
 print(x, file=sys.stderr)  # I expect this will fail

It does not fail.

 print(repr(x), file=sys.stdout)  # I expect this will succeed


It fails.

The clue that led me to stderr is that the logging module displays unicode 
strings to the console without a problem. I delved into the source code, and 
found that it writes to stderr. When I changed mine to stderr, it also 
worked.

Frank



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


Re: Unicode, stdout, and stderr

2014-07-22 Thread Peter Otten
Frank Millman wrote:

 Hi all
 
 This is not important, but I would appreciate it if someone could explain
 the following, run from cmd.exe on Windows Server 2003 -
 
 C:\python
 Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32
 bit (In
 tel)] on win32
 Type help, copyright, credits or license for more information.
 x = '\u2119'
 x  # this uses stderr
 '\u2119'

No, both print to stdout, but just

 x

is passed to the display hook of the interactive interpreter. This applies 
repr() and  then tries to print the result. If this fails it makes another 
effort, roughly (the actual code is written in C)

sys.stdout.buffer.write(repr(x).encode(
sys.stdout.encoding, backslashreplace))


 print(x)  # this uses stdout
 Traceback (most recent call last):
   File stdin, line 1, in module
   File C:\Python34\lib\encodings\cp437.py, line 19, in encode
 return codecs.charmap_encode(input,self.errors,encoding_map)[0]
 UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in
 position
 0: character maps to undefined

 
 It seems that there is a difference between writing to stdout and writing
 to stderr. My questions are -
 
 1. What is the difference?
 
 2. Is there an easy way to get stdout to behave the same as stderr?

You could set the PYTHONIOENCODING environment variable with an error 
handler:

[simulating the behaviour you are seeing on a linux/utf-8 machine]

$ PYTHONIOENCODING=cp437 python3.4
Python 3.4.0rc1+ (default:16384988a526+, Mar 11 2014, 16:56:15) 
[GCC 4.8.1] on linux
Type help, copyright, credits or license for more information.
 \u2112
'\u2112'
 print(\u2112)
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/local/lib/python3.4/encodings/cp437.py, line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2112' in 
position 0: character maps to undefined
 

[the proposed fix]

$ PYTHONIOENCODING=cp437:backslashreplace python3.4
Python 3.4.0rc1+ (default:16384988a526+, Mar 11 2014, 16:56:15) 
[GCC 4.8.1] on linux
Type help, copyright, credits or license for more information.
 \u2112
'\u2112'
 print(\u2112)
\u2112


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


Re: Unicode, stdout, and stderr

2014-07-22 Thread Lele Gaifax
Frank Millman fr...@chagford.com writes:

 No, both statements actually emit noise on the standard output, but the
 former prints the *repr* of the string, the latter tries to encode it to
 CP437, which you console seems to be using.


 Thanks, Lele, but I don't think that is quite right - see my separate 
 response to Steven

Maybe sent as a private message? I do not see it, neither on the
newsgroup I'm reading, nor in the mailing list archives...

ciao, lele.

BTW: checking the mailing list, I somewhat appreciate that the usual
unicode spam(mer) doesn't reach the newsgroup anymore... :-)
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  | -- Fortunato Depero, 1929.

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


Re: Unicode, stdout, and stderr

2014-07-22 Thread Lele Gaifax
Frank Millman fr...@chagford.com writes:

 Steven D'Aprano st...@pearwood.info wrote in message 
 news:53ce0b96$0$29897$c3e8da3$54964...@news.astraweb.com...
 I would be surprised if that were the case, but I don't have a Windows
 box to test it. Try this:


 import sys
 print(x, file=sys.stderr)  # I expect this will fail

 It does not fail.

Effectively it does not, but for some reason it actually print the
repr() of the string.

 print(repr(x), file=sys.stdout)  # I expect this will succeed


 It fails.

This surprises me as well, why does it fail here?

 repr('\u2119')
'\u2119'
 print(repr('\u2119'))
Traceback ... UnicodeEncodeError ...

On GNU/Linux, I get:

 repr('\u2119')
'ℙ'
 print(repr('\u2119'))
'ℙ'

Uhm, it must be related to the fact that on Py3 the repr() of something
is a unicode object too, so the output machinery tries to encode it to
the output encoding Still, I miss the difference between stdout and
stderr (both are cp437, accordingly to sys.xxx.encoding).

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  | -- Fortunato Depero, 1929.

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


Re: Unicode, stdout, and stderr

2014-07-22 Thread Frank Millman

Lele Gaifax l...@metapensiero.it wrote in message 
news:87d2cx271o.fsf@nautilus.nautilus...
 Frank Millman fr...@chagford.com writes:

 No, both statements actually emit noise on the standard output, but the
 former prints the *repr* of the string, the latter tries to encode it to
 CP437, which you console seems to be using.


 Thanks, Lele, but I don't think that is quite right - see my separate
 response to Steven

 Maybe sent as a private message? I do not see it, neither on the
 newsgroup I'm reading, nor in the mailing list archives...


I can see it on gmane. Maybe just give it some time.

Frank



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


Re: Unicode, stdout, and stderr

2014-07-22 Thread Lele Gaifax
Peter Otten __pete...@web.de writes:

 No, both print to stdout, but just

 x

 is passed to the display hook of the interactive interpreter. This applies 
 repr() and  then tries to print the result. If this fails it makes another 
 effort, roughly (the actual code is written in C)

 sys.stdout.buffer.write(repr(x).encode(
 sys.stdout.encoding, backslashreplace))

Ah-moment!

Thanks,
ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  | -- Fortunato Depero, 1929.

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


Re: Unicode, stdout, and stderr

2014-07-22 Thread Frank Millman

Peter Otten __pete...@web.de wrote in message 
news:lql3am$2q7$1...@ger.gmane.org...
 Frank Millman wrote:

 Hi all

 This is not important, but I would appreciate it if someone could explain
 the following, run from cmd.exe on Windows Server 2003 -

 C:\python
 Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32
 bit (In
 tel)] on win32
 Type help, copyright, credits or license for more information.
 x = '\u2119'
 x  # this uses stderr
 '\u2119'

 No, both print to stdout, but just

 x

 is passed to the display hook of the interactive interpreter. This applies
 repr() and  then tries to print the result. If this fails it makes another
 effort, roughly (the actual code is written in C)

 sys.stdout.buffer.write(repr(x).encode(
sys.stdout.encoding, backslashreplace))



Thanks, Peter. Very interesting.

Out of interest, does the same thing happen when writing to sys.stderr?

Frank



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


Re: Network/multi-user program

2014-07-22 Thread Monte Milanuk
On 2014-07-22, Lele Gaifax l...@metapensiero.it wrote:
 On the other hand, it has good and extensive examples, so the learning
 curve is not so steep (I'm clearly biased here, but I introduced several
 young developers to that environment and that's what they said too).

Any experience with angular js?  Browsing the web showed a few mentions
of it vs. ext js.  Mostly I'm still at the curious stage on this...
either one is completely foreign to anything I've done before.

 Anyway, don't be scared: start on the Python side, laying down the
 foundations of the application, the database model, the main business
 logic, unit and functional tests, and so on. Any kind of frontend, be it
 a traditional desktop application or a web based one will build on that.

Well... thats part of where my lack of experience with js or complex
projects using anything other than just python is going to show:
initially I thought javascript was just for buttons/effects in the
client browser as thats all the trivial examples I looked at years ago
did.  The bits n pieces I'm seeing of these 'modern' javascript MVC
frameworks like sencha, angular, etc. is making me think that a lot of
the 'work' is moving from the server to the client via the javascript...
which just blurs the heck out of things and confuses me as to what
should be in the browser and what should be on the 'server'?  And where
the testing goes?  If more of the 'heavy lifting' is being done on the
client, is there a need for a full-service python framework like django
or would something lightweight like flask be more appropriate?  Again, I
know almost nothing about pyramid and where it falls into the mix.  I
can read the propaganda on their respective web sites, but that is
necessarily skewed. :/

Monte

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


Re: Network/multi-user program

2014-07-22 Thread Lele Gaifax
Monte Milanuk memila...@invalid.com writes:

 On 2014-07-22, Lele Gaifax l...@metapensiero.it wrote:
 On the other hand, it has good and extensive examples, so the learning
 curve is not so steep (I'm clearly biased here, but I introduced several
 young developers to that environment and that's what they said too).

 Any experience with angular js?  Browsing the web showed a few mentions
 of it vs. ext js.  Mostly I'm still at the curious stage on this...
 either one is completely foreign to anything I've done before.

Very, very little. I evaluated it quickly, but then my boss at the time
dictated the Pyjamas route...

 Anyway, don't be scared: start on the Python side, laying down the
 foundations of the application, the database model, the main business
 logic, unit and functional tests, and so on. Any kind of frontend, be it
 a traditional desktop application or a web based one will build on that.

 Well... thats part of where my lack of experience with js or complex
 projects using anything other than just python is going to show:
 initially I thought javascript was just for buttons/effects in the
 client browser as thats all the trivial examples I looked at years ago
 did.  The bits n pieces I'm seeing of these 'modern' javascript MVC
 frameworks like sencha, angular, etc. is making me think that a lot of
 the 'work' is moving from the server to the client via the javascript...
 which just blurs the heck out of things and confuses me as to what
 should be in the browser and what should be on the 'server'?  And where
 the testing goes?

Yes, that is effectively the fuzzy dichotomy you'll have to deal with.

From my point of view, I tend to see the JS frontend as the GUI library
that I use to draw the application, and I try to keep it separate from
the logic as much as I can. It does not matter if the GUI is written
in JS, GTK+, curses, NeXTstep or Delphi: it has been *always* a
nightmare to implement serious automatic tests on that side of all my
apps, and that's the main reason I keep complicated things on the
backend side. And you know, with Python even complicated things are
manageable.

 If more of the 'heavy lifting' is being done on the
 client, is there a need for a full-service python framework like django
 or would something lightweight like flask be more appropriate?  Again, I
 know almost nothing about pyramid and where it falls into the mix.  I
 can read the propaganda on their respective web sites, but that is
 necessarily skewed. :/

Even if I used some Django apps, I never developed anything with it: it
does not seem a good choice for the kind of applications I happen to
write. Its main selling point is the somewhat automatic CRUD view
generation, something I'm always going to implement in other ways
anyway. Its main no thank you point is the hassle with its son of a
minor god ORM.

I started using Flask for a couple of applications that at first
appeared to be very simple, but actually most of the time any
application seems simple enough at first but very quickly become
complicated enough to warrant a better infrastructure: after a few
weeks I retargeted them to Pyramid, which I find robust, well documented
and versatile.

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  | -- Fortunato Depero, 1929.

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


Re: Unicode, stdout, and stderr

2014-07-22 Thread Peter Otten
Frank Millman wrote:

 
 Peter Otten __pete...@web.de wrote in message
 news:lql3am$2q7$1...@ger.gmane.org...
 Frank Millman wrote:

 Hi all

 This is not important, but I would appreciate it if someone could
 explain the following, run from cmd.exe on Windows Server 2003 -

 C:\python
 Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32
 bit (In
 tel)] on win32
 Type help, copyright, credits or license for more information.
 x = '\u2119'
 x  # this uses stderr
 '\u2119'

 No, both print to stdout, but just

 x

 is passed to the display hook of the interactive interpreter. This
 applies
 repr() and  then tries to print the result. If this fails it makes
 another effort, roughly (the actual code is written in C)

 sys.stdout.buffer.write(repr(x).encode(
sys.stdout.encoding, backslashreplace))


 
 Thanks, Peter. Very interesting.
 
 Out of interest, does the same thing happen when writing to sys.stderr?

If you are asking about the fallback mechanism, that is specific to 
sys.displayhook in the interactive interpreter. 

But stdout and stderr do handle errors differently:

 import sys
 sys.stdout.errors
'strict'
 sys.stderr.errors
'backslashreplace'

So a codepoint written to stdout that cannot be encoded with stdout.encoding 
raises an error while a codepoint written to stderr that cannot be encoded 
with stderr.encoding is escaped.

Another way to make stdout more forgiving:

 import sys
 print(\u2119)
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/local/lib/python3.4/encodings/cp437.py, line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in 
position 0: character maps to undefined
 sys.stdout = open(1, mode=w, errors=xmlcharrefreplace, 
encoding=sys.stdout.encoding, closefd=False)
 print(\u2119)
#8473;


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


Re: Network/multi-user program

2014-07-22 Thread Chris Angelico
On Tue, Jul 22, 2014 at 5:54 PM, Monte Milanuk memila...@invalid.com wrote:
 Well... thats part of where my lack of experience with js or complex
 projects using anything other than just python is going to show:
 initially I thought javascript was just for buttons/effects in the
 client browser as thats all the trivial examples I looked at years ago
 did.  The bits n pieces I'm seeing of these 'modern' javascript MVC
 frameworks like sencha, angular, etc. is making me think that a lot of
 the 'work' is moving from the server to the client via the javascript...
 which just blurs the heck out of things and confuses me as to what
 should be in the browser and what should be on the 'server'?  And where
 the testing goes?  If more of the 'heavy lifting' is being done on the
 client, is there a need for a full-service python framework like django
 or would something lightweight like flask be more appropriate?  Again, I
 know almost nothing about pyramid and where it falls into the mix.  I
 can read the propaganda on their respective web sites, but that is
 necessarily skewed. :/

Lots of things getting messed in together here, so I'm going to start
right back at some basics. You probably know some of what I'm going to
say already, but I'm not sure exactly how much, so I'll just say it
anyway. Hopefully this won't be TOO long. :)

Communication between the server and the client is over HTTP.
(Usually. I'm ignoring SPDY and other protocols, and I'm also ignoring
the distinction with HTTPS, which just adds an encryption layer and
doesn't affect any of this.) HTTP is a stateless protocol, where the
client sends a request to the server and the server sends back a
response. Simple, and works really beautifully for the simple case
where you just want a page. If you go to
http://rosuav.com/hymns/LetHerGo2.png in your browser, it sends a
request GET /hymns/LetHerGo2.png to my server, and my server
responds with \x89PNG and about 100KB of PNG-encoded data, which
your browser then displays as an image. So far, so good.

For something more interactive, though, HTTP isn't really ideal. The
server can send back a frames-based page (either with FRAME or with
IFRAME), and then with links A HREF=... TARGET=... modify
specific parts of that page, but it's still pretty clunky, and it's
not going to look perfectly smooth. (I've built systems that do
exactly this; if your use-case happens to fit this, it can work. But
it's unusual to fit into that.) No, what you really want is two
things: First, a way to change what's on the page without throwing it
all away and fetching an entire new page; and second, a way for the
browser to talk to the server without throwing away its current page
and replacing it.

The first one fundamentally requires client-side scripting. You have
to have the server provide something executable which the client will
run. And that, in itself, adds another bunch of problems (security,
sandboxing, and stuff), which is why ECMAScript/JavaScript is the only
properly-supported language; there've been various attempts to get
another language supported across all browsers, but never successfully
enough to supplant JS. And due to backward-compatibility requirements
(a modern browser needs to be able to run JS code written in the 90s),
the language's worst design flaws (like UTF-16 strings) simply cannot
be changed. But the power is there for code to do whatever it likes to
the displayed page: remove stuff, add stuff, change styles, fiddle
with text, anything at all.

Fortunately, the second requirement is fairly easily covered. JS code
can issue additional HTTP requests to the server, and do whatever it
likes with the responses. The server still does whatever it does in
response to those requests, maybe some database changes or lookups, or
other work that can only be done on the server. And then it can send
back either preformatted HTML for the JS to insert into the page, or
enough information for the JS to build the content itself. (In some
cases, the server might send back nothing more than a flag saying
Success or Failure, and the JS does all the rest, possibly
including a retry loop.)

But there's still a fundamental disconnection between the web browser
and the database, which can be handled ONLY by the web server.
(Technically you could let the browser talk directly to the DBMS. If
you really need that, you know enough to know that I've been
simplifying quite a bit of this discussion.) To keep your server-side
code clean, especially as it gets bigger and more complex, you often
want to make use of a web framework like Django, Flask, etc, etc, etc.
You don't have to send back HTML from the server; if you have a
dedicated script request endpoint, you can send back a simpler form
of the information (maybe JSON, or plain text, or something), and
possibly you can have uglier error checking (eg if you get the
parameters wrong, it just spits back an HTTP 500 instead of
courteously telling you which one you omitted - 

Re: Unicode, stdout, and stderr

2014-07-22 Thread Frank Millman

Peter Otten __pete...@web.de wrote in message 
news:lql9oi$hlt$1...@ger.gmane.org...
 Frank Millman wrote:

[...]

 Out of interest, does the same thing happen when writing to sys.stderr?

 If you are asking about the fallback mechanism, that is specific to
 sys.displayhook in the interactive interpreter.

 But stdout and stderr do handle errors differently:

 import sys
 sys.stdout.errors
 'strict'
 sys.stderr.errors
 'backslashreplace'

 So a codepoint written to stdout that cannot be encoded with 
 stdout.encoding
 raises an error while a codepoint written to stderr that cannot be encoded
 with stderr.encoding is escaped.

 Another way to make stdout more forgiving:

 import sys
 print(\u2119)
 Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/local/lib/python3.4/encodings/cp437.py, line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
 UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in
 position 0: character maps to undefined
 sys.stdout = open(1, mode=w, errors=xmlcharrefreplace,
 encoding=sys.stdout.encoding, closefd=False)
 print(\u2119)
 #8473;


That's a lot of very useful information.

Thanks very much

Frank



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


Re: Network/multi-user program

2014-07-22 Thread Andrea D'Amore

On 2014-07-21 16:07:22 +, Monte Milanuk said:


So I guess I'm asking for advice or simplified examples of how to
go about connecting a client desktop app to a parent/master desktop app,
so I can get some idea of how big of a task I'm looking at here, and
whether that would be more or less difficult than trying to do the
equivalent job using a web framework.


For a similar need I went with a webapp using Flask and a minimal 
amount of js (that I don't know very well and therefore don't like very 
much :-) but the alternative that I considered was Dabo [1], I haven't 
checked how the client-server connection actually works with dabo tho' 
but I'm mentioning in case you're inclined to do so.


For the client part and different from the usual js framework I had a 
brief experience with Cappuccino [2], if you happen to know Cocoa it's 
pretty straightforward to use.


[1] http://dabodev.com/
[2] http://www.cappuccino-project.org/

--
Andrea

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


Removing xml element and strip extra space

2014-07-22 Thread varun bhatnagar
Hi,

I am trying to play around with python and xslt. I have an xml and I want
to transform it to another xml by deleting its one element. The xml is
pasted below:

?xml version=1.0 encoding=UTF-8?
testNode
nodeInfo
  nodePeriod nodeTime=6/
  nodeBase base=0 /
/nodeInfo
/testNode


I want to remove the nodeBase tag and this is how my xsl file looks like:

?xml version=1.0 encoding=UTF-8?
xsl:stylesheet version=1.0 xmlns:xsl=
http://www.w3.org/1999/XSL/Transform;
xsl:output method=xml indent=yes/

  xsl:template match=@*|node()
xsl:copy
  xsl:apply-templates select=@*|node()/
/xsl:copy
  /xsl:template


xsl:template match=/testNode/nodeInfo/nodeBase
/xsl:template

/xsl:stylesheet

When I execute it my output looks like this:

?xml version=1.0 encoding=UTF-8?
testNode
nodeInfo
*  nodePeriod nodeTime=6/*

*/nodeInfo*
/testNode

I want to strip the space between *nodePeriod* and */nodeInfo*
Can anyone suggest a way out to do that?

Thanks,
BR,
Varun
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Removing xml element and strip extra space

2014-07-22 Thread Monte Milanuk
On 2014-07-22, varun bhatnagar varun292...@gmail.com wrote:
 I want to strip the space between *nodePeriod* and */nodeInfo*
 Can anyone suggest a way out to do that?

Look at str.rstrip() - by default it removes trailing whitespace
including carriage returns.

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


Re: Removing xml element and strip extra space

2014-07-22 Thread varun bhatnagar
Hi,

Thank you so much for the suggestion.
I tried using the rstrip() function but that did not work. Still getting a
blank space between *nodePeriod* and */nodeInfo *as mentioned in the
above output xml file:

*nodePeriod nodeTime=6/*


* /nodeInfo*

Is there any other way through which this can be achieved? Can't this be
handled by xslt itself in some way?

Thanks,
BR,
Varun


On Tue, Jul 22, 2014 at 2:23 PM, Monte Milanuk memila...@invalid.com
wrote:

 On 2014-07-22, varun bhatnagar varun292...@gmail.com wrote:
  I want to strip the space between *nodePeriod* and */nodeInfo*
  Can anyone suggest a way out to do that?

 Look at str.rstrip() - by default it removes trailing whitespace
 including carriage returns.

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

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


Re: Removing xml element and strip extra space

2014-07-22 Thread Tim
On Tuesday, July 22, 2014 8:53:35 AM UTC-4, varun bhatnagar wrote:
 Hi,
 Thank you so much for the suggestion.
 I tried using the rstrip() function but that did not work. Still getting a 
 blank space between nodePeriod and /nodeInfo as mentioned in the above 
 output xml file:
 nodePeriod nodeTime=6/                                     
  /nodeInfo
 Is there any other way through which this can be achieved? Can't this be 
 handled by xslt itself in some way?
 
 Thanks,
 
 BR,
 Varun
 On Tue, Jul 22, 2014 at 2:23 PM, Monte Milanuk memi...@invalid.com wrote: 
 On 2014-07-22, varun bhatnagar varun...@gmail.com wrote: 
  I want to strip the space between *nodePeriod* and */nodeInfo*
  Can anyone suggest a way out to do that?
 Look at str.rstrip() - by default it removes trailing whitespace
 including carriage returns.
 --

Hi Varun,
The whitespace is part of your original xml; the xslt is only preserving that 
whitespace. Do you have any control over the construction of that original xml?

It looks like it has been tidied and whitespace perhaps added. I think you will 
get what you want if the original has the newlines removed:
?xml version=1.0 encoding=UTF-8?
testNode
nodeInfo
nodePeriod nodeTime=6/nodeBase base=0 //nodeInfo
/testNode

does that get you what you're looking for? Is the whitespace actually necessary 
in the original or problematic in the result?

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


Re: Removing xml element and strip extra space

2014-07-22 Thread varun bhatnagar
Hi Tim,

Thanks for replying.
No that is not the output I am looking for.

I just want to scrape out nodeBase base=0 /
But the way I have written my xsl file it is removing it but it is also
leaving a blank space there. I want my output to look like this:




*?xml version=1.0 encoding=UTF-8?testNodenodeInfonodePeriod
nodeTime=6/*

*/nodeInfo/testNode*

But in actual it is showing like this:

?xml version=1.0 encoding=UTF-8?
testNode
nodeInfo
nodePeriod nodeTime=6/
 *I want to
remove this space* :)
/nodeInfo
/testNode



On Tue, Jul 22, 2014 at 3:00 PM, Tim jtim.arn...@gmail.com wrote:

 On Tuesday, July 22, 2014 8:53:35 AM UTC-4, varun bhatnagar wrote:
  Hi,
  Thank you so much for the suggestion.
  I tried using the rstrip() function but that did not work. Still getting
 a blank space between nodePeriod and /nodeInfo as mentioned in the
 above output xml file:
  nodePeriod nodeTime=6/
   /nodeInfo
  Is there any other way through which this can be achieved? Can't this be
 handled by xslt itself in some way?
 
  Thanks,
 
  BR,
  Varun
  On Tue, Jul 22, 2014 at 2:23 PM, Monte Milanuk memi...@invalid.com
 wrote:
  On 2014-07-22, varun bhatnagar varun...@gmail.com wrote:
   I want to strip the space between *nodePeriod* and */nodeInfo*
   Can anyone suggest a way out to do that?
  Look at str.rstrip() - by default it removes trailing whitespace
  including carriage returns.
  --

 Hi Varun,
 The whitespace is part of your original xml; the xslt is only preserving
 that whitespace. Do you have any control over the construction of that
 original xml?

 It looks like it has been tidied and whitespace perhaps added. I think you
 will get what you want if the original has the newlines removed:
 ?xml version=1.0 encoding=UTF-8?
 testNode
 nodeInfo
 nodePeriod nodeTime=6/nodeBase base=0 //nodeInfo
 /testNode

 does that get you what you're looking for? Is the whitespace actually
 necessary in the original or problematic in the result?

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

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


Re: OT: usenet reader software

2014-07-22 Thread Anssi Saari
memilanuk memila...@gmail.com writes:

 I'm on Ubuntu (14.04 LTS, if it matters) and I've been using
 Thunderbird for a lng time... I've tinkered with slrn off and on
 over the years, tried pan occasionally due to recommendations... but I
 keep ending up back @ Thunderbird.  About the only thing it doesn't do
 that I really want is scoring/kill-files.  

I always thought Thuderbird was a lost cause especially with News but it
has some serious issues as a mail client too. Probably part of the
reason why it never caught on and development stopped. Pretty good and
nice to have a cross platform thing but they kept it an island, unable
to sync contacts to anything else. Well, the Mac version could at least
use the Mac addressbook but on Windows and Linux it's just WTF.

 Slrn has those, and I do use vim on occasion so that worked well
 enough... but when people *do* post links or html it didn't handle
 that stuff gracefully like Thunderbird.

I don't really know about about html and slrn since I don't see much of
it but links in a terminal application is usually something for the
terminal to handle. I run Gnus on a remote machine and use a local
terminal for display, Konsole in Linux and mintty in Windows. In both of
those terminals URLs are opened with a right click on the link and
selecting open link from the menu that pops up.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: usenet reader software

2014-07-22 Thread Anssi Saari
Marko Rauhamaa ma...@pacujo.net writes:

 Martin S shieldf...@gmail.com:

 Is there a point to still use Usenet? Last time I checked noise
 overwhelmed signal by a factor of something close to 542.

 Well, here you are at URL: news:comp.lang.python, in the middle of all
 that noise.

Besides, there's been a slight resurgence in comp.misc at least,
apparently some people got angry about something at slashdot and wanted
a more free forum, hence a bunch of posts there and some other groups
recently.

Other than that, I think most of the angry people and spammers have left
Usenet alone. All the better for those of us who stick with it but I
have to say the average age of people posting to comp.arch at least is
probably over 60... The only younger people around seem to be the kids
asking for people to do their homework.
-- 
https://mail.python.org/mailman/listinfo/python-list


testfixtures 4.0.0 Released!

2014-07-22 Thread Chris Withers

Hi All,

I'm pleased to announce the release of testfixtures 4.0.0. This is a new 
feature release with the following major changes:


- Moved from buildout to virtualenv for development.

- compare() will now work recursively on data structures for
  which it has registered comparers, giving more detailed feedback on
  nested data structures. Strict comparison will also be applied
  recursively.

- Official support for Python 3.4.

The package is on PyPI and a full list of all the links to docs, issue 
trackers and the like can be found here:


http://www.simplistix.co.uk/software/python/testfixtures

Any questions, please do ask on the Testing in Python list or on the 
Simplistix open source mailing list...


cheers,

Chris

--
Simplistix - Content Management, Batch Processing  Python Consulting
   - http://www.simplistix.co.uk
--
https://mail.python.org/mailman/listinfo/python-list


Re: Network/multi-user program

2014-07-22 Thread Grant Edwards
On 2014-07-21, Roy Smith r...@panix.com wrote:

 The truly sucky part of this picture is that javascript is a horrible 
 language,

I'm pretty sure that the real purpose of PHP is to make javascript
look like a good programming language.

-- 
Grant Edwards   grant.b.edwardsYow! RELATIVES!!
  at   
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Fastest I/O on Python ?

2014-07-22 Thread Orochi
Is there in any other input/output faster than (raw_input,input / print)
As I am trying to solve competitive Programs on codechef.com using python i was 
wondering if there is any other way to print and scan the inputs fast.


I have seen other people codes and there are using sys library(stdin and 
stdout) for I/O.

So I was thinking is there any other way to take input/output besides using 
'sys library'.

And also I had doubt about what is the difference between 
(raw_input,input/print) and (stdin/stdout)

Thank You.

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


Re: Fastest I/O on Python ?

2014-07-22 Thread Chris Angelico
On Wed, Jul 23, 2014 at 2:06 AM, Orochi kartikjagdal...@gmail.com wrote:
 Is there in any other input/output faster than (raw_input,input / print)
 As I am trying to solve competitive Programs on codechef.com using python i 
 was wondering if there is any other way to print and scan the inputs fast.

What do you mean by faster? Are you really seeing performance problems
with them, or are you actually looking for something like C's printf
and scanf, which do more than just output and input?

The print function (use either Python 3 or a future import) has some
good formatting facilities, and if you need more, you can do something
like this:

 print(The price is $%.2f per kilo. % 1.5)
The price is $1.50 per kilo.

However, there's no comparable feature for input. It's generally
easiest to take a string from (raw_)input and then parse it yourself,
maybe with a regular expression, or splitting it on whitespace, or
whatever else is appropriate.

But you'll really need to explain what you're actually having issues
with, before we can advise further.

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


Re: Fastest I/O on Python ?

2014-07-22 Thread emile

On 07/22/2014 09:06 AM, Orochi wrote:

Is there in any other input/output faster than (raw_input,input / print)


The limitation is with the device -- either the human typing in 
responses or the output device rendering the output.  If you have the 
option to read/write to disk that'd open up additional options.


Otherwise I'm not sure there's much to be gained.

Emile




As I am trying to solve competitive Programs on codechef.com using python i was 
wondering if there is any other way to print and scan the inputs fast.


I have seen other people codes and there are using sys library(stdin and 
stdout) for I/O.

So I was thinking is there any other way to take input/output besides using 
'sys library'.

And also I had doubt about what is the difference between 
(raw_input,input/print) and (stdin/stdout)

Thank You.




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


Re: Anything better than asyncio.as_completed() and asyncio.wait() to manage execution of large amount of tasks?

2014-07-22 Thread CHIN Dihedral
On Thursday, July 17, 2014 7:09:02 AM UTC+8, Maxime Steisel wrote:
 2014-07-15 14:20 GMT+02:00 Valery Khamenya khame...@gmail.com:
 
  Hi,
 
 
 
  both asyncio.as_completed() and asyncio.wait() work with lists only. No
 
  generators are accepted. Are there anything similar to those functions that
 
  pulls Tasks/Futures/coroutines one-by-one and processes them in a limited
 
  task pool?
 
 
 
 
 
 Something like this (adapted from as_completed) should do the work:
 
 
 
 import asyncio
 
 from concurrent import futures
 
 
 
 def parallelize(tasks, *, loop=None, max_workers=5, timeout=None):
 
 loop = loop if loop is not None else asyncio.get_event_loop()
 
 workers = []
 
 pending = set()
 
 done = asyncio.Queue(maxsize=max_workers)
 
 exhausted = False
 
 
 
 @asyncio.coroutine
 
 def _worker():
 
 nonlocal exhausted
 
 while not exhausted:
 
 try:
 
 t = next(tasks)
 
 pending.add(t)
 
 yield from t
 
 yield from done.put(t)
 
 pending.remove(t)
 
 except StopIteration:
 
 exhausted = True
 
 
 
 def _on_timeout():
 
 for f in workers:
 
 f.cancel()
 
 workers.clear()
 
 #Wake up _wait_for_one()
 
 done.put_nowait(None)
 
 
 
 @asyncio.coroutine
 
 def _wait_for_one():
 
 f = yield from done.get()
 
 if f is None:
 
 raise futures.TimeoutError()
 
 return f.result()
 
 
 
 workers = [asyncio.async(_worker()) for i in range(max_workers)]
 
 
 
 if workers and timeout is not None:
 
 timeout_handle = loop.call_later(timeout, _on_timeout)
 
 
 
 while not exhausted or pending or not done.empty():
 
 yield _wait_for_one()
 
 
 
 timeout_handle.cancel()

Well, I think you are missing the 
task managers as workers in your flow
of logics. 

I suggest a better version is 
with a global signal of 8 to 16 times clock of the normal worker pace in 
order to cope with ASYN events 
accordingly for the workers which colud be  decorated to yield, but not in the 
worker's funtions.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: usenet reader software

2014-07-22 Thread Martin S
Aye I found a couple of groups that are still active. Most of it seems to be a 
digital ghost town though. A bit sad, I was once actively involved in setting 
up the se. * hierarchy. 

/martin s

On 22 Jul 2014, Anssi Saari a...@sci.fi wrote:
Marko Rauhamaa ma...@pacujo.net writes:

 Martin S shieldf...@gmail.com:

 Is there a point to still use Usenet? Last time I checked noise
 overwhelmed signal by a factor of something close to 542.

 Well, here you are at URL: news:comp.lang.python, in the middle of
all
 that noise.

Besides, there's been a slight resurgence in comp.misc at least,
apparently some people got angry about something at slashdot and wanted
a more free forum, hence a bunch of posts there and some other groups
recently.

Other than that, I think most of the angry people and spammers have
left
Usenet alone. All the better for those of us who stick with it but I
have to say the average age of people posting to comp.arch at least is
probably over 60... The only younger people around seem to be the kids
asking for people to do their homework.

-- Sent with K-@ Mail - the evolution of emailing.-- 
https://mail.python.org/mailman/listinfo/python-list


Review my asyncio code

2014-07-22 Thread Yaşar Arabacı
Hi,

I am trying to learn how to utilize aysncio module. In order to do
that, I wrote a class that checks http status codes for all the pages
on a given domain (unless there is no internal link pointing to it of
course).

Since it is too long to paste here, I uploaded it to my github repo,
you can find it here;
https://github.com/yasar11732/python-scripts/blob/master/asyncio-scripts/validate_links.py

I was wondering if someone could review it and give me some pointers
if necessary.

The parts that I especially ask for guidance is firstly how I run my
tasks in lines 40-48

I am adding new tasks as I found unvisited links, in line 132.

The main problem I find with my code, but can't quite fix it yet, is
that run method is blocking. But if I don't use a method like that, I
don't know how I would guarantee that event loop is done.

I thought about making the whole RecursiveStatusChecker class a
Thread, but I am not sure how would Threads and asyncio work together.

My ultimate aim with a class like that was to start it at some time,
and check later whether or not new results are available or all the
tasks are finished.

Any help is appreciated.

-- 
http://ysar.net/
-- 
https://mail.python.org/mailman/listinfo/python-list


Herion, , Actavis promethazine codeine 16oz and 32oz available Ketamine Oxycontine Hydrocodone xanax and medicated marijuana US- free shipping and other related products for sell at competitive prices

2014-07-22 Thread ismeal shanshi



Herion,,Actavis promethazine codeine 16oz and 32oz available Ketamine 
Oxycontine Hydrocodone xanax and medicated marijuana US- free shipping and 
other related products for sell at competitive prices.We do world wide shipping


Herion,,Actavis promethazine codeine 16oz and 32oz available Ketamine 
Oxycontine Hydrocodone xanax and medicated marijuana US- free shipping and 
other related products for sell at competitive prices.We do world wide shipping 
to any clear 

address.Delivery is 100% safe due to our discreetness and experience.Try our 
quality and experience then have a story to tell 

another day.

Email Address:stuffstorehouse2014 (AT) gmail.com
CONTACT NUMBER: (407)-4852249 * Pleas text me only
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unicode, stdout, and stderr

2014-07-22 Thread Terry Reedy

On 7/22/2014 2:18 AM, Frank Millman wrote:

Hi all

This is not important, but I would appreciate it if someone could explain
the following, run from cmd.exe on Windows Server 2003 -

C:\python
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit
(In
tel)] on win32
Type help, copyright, credits or license for more information.

x = '\u2119'
x  # this uses stderr

'\u2119'

print(x)  # this uses stdout

Traceback (most recent call last):
   File stdin, line 1, in module
   File C:\Python34\lib\encodings\cp437.py, line 19, in encode
 return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in
position
0: character maps to undefined


On Windows, at least, the Idle gui generally handles unicode (certainly 
the BMP) much better than the interpreter command prompt interface.


 x = '\u2119'
 x
'ℙ'
 print(x)
ℙ

--
Terry Jan Reedy


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


Re: Removing xml element and strip extra space

2014-07-22 Thread Monte Milanuk
On 2014-07-22, varun bhatnagar varun292...@gmail.com wrote:
 I just want to scrape out nodeBase base=0 /
 But the way I have written my xsl file it is removing it but it is also
 leaving a blank space there. I want my output to look like this:

This is the part where a certain amount of example code showing what
you're doing would probably help people diagnose where the problem is...



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


Re: OT: usenet reader software

2014-07-22 Thread ismeal shanshi
Herion,,Actavis promethazine codeine 16oz and 32oz available Ketamine 
Oxycontine Hydrocodone xanax and medicated marijuana US- free shipping and 
other related products for sell at competitive prices.We do world wide shipping 
to any clear 

address.Delivery is 100% safe due to our discreetness and experience.Try our 
quality and experience then have a story to tell 

another day.

Email Address:stuffstorehouse2014 (AT) gmail.com
CONTACT NUMBER: (407)-4852249 * Pleas text me only
-- 
https://mail.python.org/mailman/listinfo/python-list


ANN: Wing IDE 5.0.8 released

2014-07-22 Thread Wingware

Hi,

Wingware has released version 5.0.8 of Wing IDE, our cross-platform 
integrated

development environment for the Python programming language.

Wing IDE includes a professional quality code editor with vi, emacs, 
visual studio,
and other key bindings, auto-completion, call tips, goto-definition, 
find uses, refactoring,
context-aware auto-editing, a powerful graphical debugger, version 
control, unit testing,

search, and many other features.  For details see http://wingware.com/

Changes in this minor release include:

Debug stack is accessible from the toolbar's Show Position icon
Added Step Over Statement and Step Over Block to step through code 
more rapidly
Added experimental selection-add-next-occurence command for 
creating multiple selections with next occurrences of text matching the 
current selection

Added step-over-line command to step over current physical line
Fix debugging with Stackless 2.7.8
Fix debugging 32-bit Python on OS X
About 34 other bug fixes; see the change log for details

For details see http://wingware.com/pub/wingide/5.0.8/CHANGELOG.txt

A summary of new features in Wing 5:

Native GUI on OS X and better overall OS-native look and feel
Draggable tools and editors
Configurable toolbar and editor  project context menus
Lockable editor splits and mode to open different files in each split
Sharable color palettes and syntax highlighting configurations
Auto-editing is on by default (except some operations that have a 
learning curve)
Optional Python Turbo completion (context-appropriate completion on 
all non-symbol keys)
Improved Source Assistant with PEP 287 docstring rendering and 
return types

Move debug program counter
Named file sets
New Project dialog
Sharable launch configurations and named entry points
Asynchronous I/O in Debug Probe and Python Shell
More control over unit testing environment
Initial preferences dialog for new users
Support for Python 3.4 and Stackless Python 2.7 and 3.3
Support for Django 1.6
Support for matplotlib on Anaconda and with MacOSX backend
Support for Maya 2015, MotionBuilder 2015, Nuke 8, and Source Filmmaker
Improved integrated and PDF documentation
Expanded and rewritten tutorial
Multiple selections
Debug stepping by physical line, statement, and block

For more information on what's new in Wing 5, see 
http://wingware.com/wingide/whatsnew


Free trial: http://wingware.com/wingide/trial
Downloads: http://wingware.com/downloads
Feature list: http://wingware.com/wingide/features
Sales: http://wingware.com/store/purchase
Upgrades: https://wingware.com/store/upgrade

Questions?  Don't hesitate to email us at supp...@wingware.com.

Thanks,

--

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com

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


Re: OT: usenet reader software

2014-07-22 Thread Neil D. Cerutti

On 7/22/2014 11:14 AM, Anssi Saari wrote:

I don't really know about about html and slrn since I don't see much of
it but links in a terminal application is usually something for the
terminal to handle. I run Gnus on a remote machine and use a local
terminal for display, Konsole in Linux and mintty in Windows. In both of
those terminals URLs are opened with a right click on the link and
selecting open link from the menu that pops up.


That is correct and the way slrn works. You set browser and/or 
guibrowser options in .slrnrc. With those set, SHIFT-G will troll an 
open message for web addresses, and you use up and down arrow to select 
the link you want from the generated list. Then it launches the browser 
you configured.


Getting the escaping, path, and syntax of the browser setting correct 
was a pain, but after that it worked great.


That said, I got tired of the inability to display most special 
characters correctly (slrn could only do as well the cmd.exe), and have 
switched to Thunderbird.


--
Neil Cerutti

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


Question about Pass-by-object-reference?

2014-07-22 Thread fl
Hi,
I learn Python function call on tutorial. There is a link on this subject.
http://robertheaton.com/2014/02/09/pythons-pass-by-object-reference-as-explained-by-philip-k-dick/

Although it explains clearly, the figure makes me puzzled.

Python is different. As we know, in Python, Object references are passed by 
value.

A function receives a reference to (and will access) the same object in memory 
as
used by the caller. However, it does not receive the box that the caller is
storing this object in; as in pass-by-value, the function provides its own box 
and
creates a new variable for itself. Let's try appending again:

On the figure, it shows that the result is [0, 1]  (Am I right on the figure?)


When I enter the command lines on my computer:
 list=[0]
 append(list)
 print(list)
[0]

How to understand my result and that figure?



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


Re: Question about Pass-by-object-reference?

2014-07-22 Thread Ned Batchelder

On 7/22/14 3:04 PM, fl wrote:

Hi,
I learn Python function call on tutorial. There is a link on this subject.
http://robertheaton.com/2014/02/09/pythons-pass-by-object-reference-as-explained-by-philip-k-dick/

Although it explains clearly, the figure makes me puzzled.

Python is different. As we know, in Python, Object references are passed by
value.

A function receives a reference to (and will access) the same object in memory 
as
used by the caller. However, it does not receive the box that the caller is
storing this object in; as in pass-by-value, the function provides its own box 
and
creates a new variable for itself. Let's try appending again:

On the figure, it shows that the result is [0, 1]  (Am I right on the figure?)



This is a topic that often confuses people new to Python.  The article 
you linked to seems very confusing to me.  My own take on how to explain 
it is here: http://nedbatchelder.com/text/names.html




When I enter the command lines on my computer:

list=[0]
append(list)
print(list)

[0]

How to understand my result and that figure?


You should have gotten [0, 1], you must have different code than was 
shown in the article.  I recommend putting the code into a .py file, and 
running it all at once.  Then if it doesn't do what you expect, you can 
show the entire .py file when asking for help.






Thanks,




--
Ned Batchelder, http://nedbatchelder.com

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


Re: Question about Pass-by-object-reference?

2014-07-22 Thread fl
On Tuesday, July 22, 2014 3:04:09 PM UTC-4, fl wrote:
Hi, 
Excuse me. I find that the OP misses some info. I rewrite it again:

I learn Python function call on tutorial. There is a link on this subject. 
http://robertheaton.com/2014/02/09/pythons-pass-by-object-reference-as-explained-by-philip-k-dick/
 

Although it explains clearly, the figure makes me puzzled. 

Python is different. As we know, in Python, Object references are passed by 
value. 

A function receives a reference to (and will access) the same object in memory 
as used by the caller. However, it does not receive the box that the caller is
storing this object in; as in pass-by-value, the function provides its own box 
and creates a new variable for itself. Let's try appending again: 

On the figure, I understand the figure about append function. Here is the lines:

When I enter the command lines on my computer: 
 def append(list):
... list.append(1)
... 
 list=[0]
 append(list)
 print(list)
[0, 1]



But I don't understand the reassign function result:

 def reassign(list):
... list=[0,1]
... 
 list=[0]
 reassign(list)
 print list
[0]

Questions:
1. From the tutorial explanation, both function append and reassign use 
pass-by-object-reference. Is it right?

2. The tutorial says: The caller doesn't care if you reassign the function's 
box. Different boxes, same content. about the reassign function. I don't
understand Different boxes, same content. It uses different boxes (I agree).
But the results are different for the caller ([0]) and the function reassign 
([0, 1]).


What is wrong with my understanding? 



Thanks a lot, 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about Pass-by-object-reference?

2014-07-22 Thread fl
On Tuesday, July 22, 2014 3:32:19 PM UTC-4, Ned Batchelder wrote:
 On 7/22/14 3:04 PM, fl wrote:
 it is here: http://nedbatchelder.com/text/names.html
  When I enter the command lines on my computer:
 I recommend putting the code into a .py file, and 
 running it all at once.  Then if it doesn't do what you expect, 
 Ned Batchelder, http://nedbatchelder.com


Thanks Ned. You give a great helpful link. And your advice on .ph file is the
key problem of my OP (Thus I rewrite my post again).

Your link makes complicate things much easier. I read it carefully.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Removing xml elemient and strip extra space

2014-07-22 Thread Joel Goldstick
On Jul 22, 2014 1:41 PM, Monte Milanuk memila...@invalid.com wrote:

 On 2014-07-22, varun bhatnagar varun292...@gmail.com wrote:
  I just want to scrape out nodeBase base=0 /
  But the way I have written my xsl file it is removing it but it is also
  leaving a blank space there. I want my output to look like this:

 This is the part where a certain amount of example code showing what
 you're doing would probably help people diagnose where the problem is...

You might look at beatifulsoup4


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


Re: Question about Pass-by-object-reference?

2014-07-22 Thread Peter Pearson
On Tue, 22 Jul 2014 12:34:51 -0700 (PDT), fl rxjw...@gmail.com wrote:
[snip]

 But I don't understand the reassign function result:

 def reassign(list):
 ...   list=[0,1]
 ... 
 list=[0]
 reassign(list)
 print list
 [0]

When you say def reassign(list), that means I'm defining a function
to which the caller will pass one object, and within this function I'm
going to refer to that object by the name 'list'.

Then, when you say list=[0,1], that means Create the object [0,1],
and assign to it the name 'list'.  At this point, there is no longer
any name that refers to the object that the caller passed.

You might have thought that list=[0,1] would modify the caller-passed
object, but that's not what happens.  That's not what = means.

-- 
To email me, substitute nowhere-spamcop, invalid-net.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about Pass-by-object-reference?

2014-07-22 Thread emile

On 07/22/2014 01:35 PM, Peter Pearson wrote:

On Tue, 22 Jul 2014 12:34:51 -0700 (PDT), fl rxjw...@gmail.com wrote:
[snip]


But I don't understand the reassign function result:


def reassign(list):

... list=[0,1]
...

list=[0]
reassign(list)
print list

[0]


When you say def reassign(list), that means I'm defining a function
to which the caller will pass one object, and within this function I'm
going to refer to that object by the name 'list'.

Then, when you say list=[0,1], that means Create the object [0,1],
and assign to it the name 'list'.  At this point, there is no longer
any name that refers to the object that the caller passed.

You might have thought that list=[0,1] would modify the caller-passed
object, but that's not what happens.  That's not what = means.



However, if that is the behavior you were after, you can get there.


def reassign(mylist):  # no reason to shadow the list builtin
mylist[:] = [0,1]

mylist = [1]
reassign(mylist)
mylist


Emile


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


Re: OT: usenet reader software

2014-07-22 Thread Monte Milanuk
On 2014-07-22, ismeal shanshi stuffstorehouse2...@gmail.com wrote:
 Herion,,Actavis promethazine codeine 16oz and 32oz available Ketamine 
 Oxycontine Hydrocodone xanax and medicated marijuana US- free shipping and 
 other related products for sell at competitive prices.We do world wide 
 shipping to any clear 

 address.Delivery is 100% safe due to our discreetness and experience.Try our 
 quality and experience then have a story to tell 

 another day.

 Email Address:stuffstorehouse2014 (AT) gmail.com
 CONTACT NUMBER: (407)-4852249 * Pleas text me only

Aaaannnd here we have a good example of why it would be really nice to
be able to filter/score based on the message *body*, not just the
headers. 8(

-- 
All right, breaks over.  Back on your heads! ;)

Reach me @ memilanuk at gmail dot com

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


Is it possible to install Python on a network?

2014-07-22 Thread roys2005

We are using Python in a large setup. Individual users are running Debian 
machines. When I want to install/upgrade Python for all users, I really want to
do it centrally rather than every user having to upgrade on their own.

Many software packages are installed this way. However, I could not figure out
any way to do this with Python.

How can I do this?

Thank you.

Koushik Roy

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


Re: OT: usenet reader software

2014-07-22 Thread Grant Edwards
On 2014-07-22, Monte Milanuk memila...@gmail.com wrote:
 On 2014-07-22, ismeal shanshi stuffstorehouse2...@gmail.com wrote:
 [drugs for sale]

 Aaaannnd here we have a good example of why it would be really nice
 to be able to filter/score based on the message *body*, not just the
 headers. 8(

slrn filtered that out just fine based on headers alone, thank you.

So, I didn't see it at all until you quoted the whole thing.

Here's the relevent slrn scoring rule:

Score:: =-
   Message-ID: .*googlegroups.com
 
-- 
Grant Edwards   grant.b.edwardsYow! Did I say I was
  at   a sardine?  Or a bus???
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is it possible to install Python on a network?

2014-07-22 Thread emile

On 07/22/2014 01:49 PM, roys2...@gmail.com wrote:


We are using Python in a large setup. Individual users are running Debian 
machines. When I want to install/upgrade Python for all users, I really want to
do it centrally rather than every user having to upgrade on their own.

Many software packages are installed this way. However, I could not figure out
any way to do this with Python.

How can I do this?



This is more a sysadmin than python issue.  And, debian itself has 
python dependencies, so you need to be careful you don't break it.


That said, we use a similar setup and have an aptitude repository with 
approved software that holds the approved source packages users can 
install.  Combining automated user system updating with a sole 
repository where only your versions are available should do it.


Emile



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


Re: OT: usenet reader software

2014-07-22 Thread Monte Milanuk
On 2014-07-22, Grant Edwards invalid@invalid.invalid wrote:
 On 2014-07-22, Monte Milanuk memila...@gmail.com wrote:
 On 2014-07-22, ismeal shanshi stuffstorehouse2...@gmail.com wrote:
 [drugs for sale]

 Aaaannnd here we have a good example of why it would be really nice
 to be able to filter/score based on the message *body*, not just the
 headers. 8(

 slrn filtered that out just fine based on headers alone, thank you.

 So, I didn't see it at all until you quoted the whole thing.

 Here's the relevent slrn scoring rule:

 Score:: =-
Message-ID: .*googlegroups.com
  

True... but what if I don't want to be quite that elitist and black-ball
every one posting via google groups?  Some mailing lists I read via
gmane *originate* on google groups (web2py list, for one).  Other people
posting from google groups are not malicious/trolls/jerks/spammers - and
honestly until I started using slrn again, I didn't understand what all
the fuss was about - gui news readers like Thunderbird handle the
messages from there just fine.  

Maybe slrn needs an upgrade to gracefully handle html formatted messages 
- good bad or otherwise, they're pretty much here to stay, kind of like 
google groups.  There are programs like lynx, elinks, etc. that can 
handle simple html via a cli program... so its not entirely beyond the 
realm of possibility.


-- 
All right, breaks over.  Back on your heads! ;)

Reach me @ memilanuk at gmail dot com

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


Re: OT: usenet reader software

2014-07-22 Thread Chris Angelico
On Wed, Jul 23, 2014 at 7:21 AM, Monte Milanuk memila...@gmail.com wrote:
 Other people
 posting from google groups are not malicious/trolls/jerks/spammers - and
 honestly until I started using slrn again, I didn't understand what all
 the fuss was about - gui news readers like Thunderbird handle the
 messages from there just fine.

Look at what happens when GG people reply to messages without
explicitly fixing the quoted text. It comes out all double-spaced.
That's not malice on their part, but eventually, some people just get
sick of it and blacklist all those posts, because it's just not worth
digging through the junk.

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


Why does not pprint work?

2014-07-22 Thread fl
Hi,

I read web tutorial at: 

http://nedbatchelder.com/blog/201308/names_and_values_making_a_game_board.html

I enter the example lines of that website:


import pprint
board = [ [0]*8 ] * 8
pprint(board)


It echos error with Python 2.7:

Traceback (most recent call last):
  File C:\Python27\Lib\SITE-P~1\PYTHON~2\pywin\framework\scriptutils.py, 
line 323, in RunScript
debugger.run(codeObject, __main__.__dict__, start_stepping=0)
  File C:\Python27\Lib\SITE-P~1\PYTHON~2\pywin\debugger\__init__.py, 
line 60, in run
_GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
  File C:\Python27\Lib\SITE-P~1\PYTHON~2\pywin\debugger\debugger.py, 
line 655, in run
exec cmd in globals, locals
  File C:\cygwin64\home\Jeff\Python_lesson\ppn.py, line 1, in module
import pprint
TypeError: 'module' object is not callable

It has similar error with Python 3.4.1.


Why does pprint not work?


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


Re: Why does not pprint work?

2014-07-22 Thread Chris Angelico
On Wed, Jul 23, 2014 at 7:42 AM, fl rxjw...@gmail.com wrote:
 I enter the example lines of that website:


 import pprint
 board = [ [0]*8 ] * 8
 pprint(board)

Flaw in the blog post: he didn't actually specify the import line.
What you actually want is this:

from pprint import pprint

Or use pprint.pprint(board), but you probably don't need anything else
from the module.

Ned, if you're reading this: Adding the import would make the post clearer. :)

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


Re: Why does not pprint work?

2014-07-22 Thread emile

On 07/22/2014 02:42 PM, fl wrote:

Hi,

I read web tutorial at:

http://nedbatchelder.com/blog/201308/names_and_values_making_a_game_board.html

I enter the example lines of that website:


import pprint
board = [ [0]*8 ] * 8
pprint(board)




pprint is a module name -- you need to invoke the pprint function from 
within the pprint module:


pprint.pprint(board)

or alternately,

from pprint import pprint

pprint(board)


or, as I sometime do

from pprint import pprint as pp

pp(board)



Emile


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


Re: OT: usenet reader software

2014-07-22 Thread Grant Edwards
On 2014-07-22, Monte Milanuk memila...@gmail.com wrote:
 On 2014-07-22, Grant Edwards invalid@invalid.invalid wrote:
 On 2014-07-22, Monte Milanuk memila...@gmail.com wrote:
 On 2014-07-22, ismeal shanshi stuffstorehouse2...@gmail.com wrote:
 [drugs for sale]

 Aaaannnd here we have a good example of why it would be really nice
 to be able to filter/score based on the message *body*, not just the
 headers. 8(

 slrn filtered that out just fine based on headers alone, thank you.

 So, I didn't see it at all until you quoted the whole thing.

 Here's the relevent slrn scoring rule:

 Score:: =-
Message-ID: .*googlegroups.com
  

 True... but what if I don't want to be quite that elitist and black-ball
 every one posting via google groups?  Some mailing lists I read via
 gmane *originate* on google groups (web2py list, for one).

There are one or two mailing lists that originate on GG, and I don't
apply the rule to those lists.

 Other people posting from google groups are not
 malicious/trolls/jerks/spammers -

True.  But if they persist in posting via  a well-known span-conduit
that's also famous for various other breakages, then I don't see how
they can be too surprised that not everybody sees their posts.

I occasionally disable that rule, and it's never seemed like I was
missing anything valuable.

 Maybe slrn needs an upgrade to gracefully handle html formatted messages 
 - good bad or otherwise, they're pretty much here to stay, kind of like 
 google groups.  There are programs like lynx, elinks, etc. that can 
 handle simple html via a cli program... so its not entirely beyond the 
 realm of possibility.

Even if they were nicely formatted, I'd still probably plonk GG posts
just to avoid the garbage.

-- 
Grant Edwards   grant.b.edwardsYow! An Italian is COMBING
  at   his hair in suburban DES
  gmail.comMOINES!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why does not pprint work?

2014-07-22 Thread fl
On Tuesday, July 22, 2014 5:51:07 PM UTC-4, emile wrote:
 On 07/22/2014 02:42 PM, fl wrote:
 pprint is a module name -- you need to invoke the pprint function from 
 within the pprint module:
 pprint.pprint(board)

Thanks. I am curious about the two pprint. Is it the first pprint the name of 
the
module? The second pprint is the function name?

Then, how can I list all the function of pprint?

And, is there a way to list the variables I create in Python?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why does not pprint work?

2014-07-22 Thread emile

On 07/22/2014 03:05 PM, fl wrote:

On Tuesday, July 22, 2014 5:51:07 PM UTC-4, emile wrote:

On 07/22/2014 02:42 PM, fl wrote:
pprint is a module name -- you need to invoke the pprint function from
within the pprint module:
pprint.pprint(board)


Thanks. I am curious about the two pprint. Is it the first pprint the name of 
the
module? The second pprint is the function name?


Yes.



Then, how can I list all the function of pprint?


use the dir builtin:

 dir (pprint)
['PrettyPrinter', '_StringIO', '__all__', '__builtins__', '__doc__', 
'__file__', '__name__', '_commajoin', '_id', '_len', '_perfcheck', 
'_recursion', '_safe_repr', '_sys', '_type', 'isreadable', 
'isrecursive', 'pformat', 'pprint', 'saferepr']





And, is there a way to list the variables I create in Python?


also dir:

 dir()
['__builtins__', '__doc__', '__name__', 'board', 'mylist', 'pprint', 
'reassign']



Emile


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


Re: Question about Pass-by-object-reference?

2014-07-22 Thread fl
On Tuesday, July 22, 2014 4:46:25 PM UTC-4, emile wrote:
 On 07/22/2014 01:35 PM, Peter Pearson wrote:
 def reassign(mylist):  # no reason to shadow the list builtin
  mylist[:] = [0,1]
 mylist = [1]
 reassign(mylist)
 mylist
 Emile

Thanks for your example. I do not find the explanation of [:] on line. Could you
explain it to me, or where can I find it on line?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why does not pprint work?

2014-07-22 Thread Chris Angelico
On Wed, Jul 23, 2014 at 8:05 AM, fl rxjw...@gmail.com wrote:
 On Tuesday, July 22, 2014 5:51:07 PM UTC-4, emile wrote:
 On 07/22/2014 02:42 PM, fl wrote:
 pprint is a module name -- you need to invoke the pprint function from
 within the pprint module:
 pprint.pprint(board)

 Thanks. I am curious about the two pprint. Is it the first pprint the name of 
 the
 module? The second pprint is the function name?

Correct. There's a module pprint which provides a function
pprint.pprint. It's like you can do this:
 import math
 math.sin(3.14/2)
0.996829318346

Or this:
 from math import sin
 sin(3.14/2)
0.996829318346

It's just that in this case, math and sin are both pprint.

 Then, how can I list all the function of pprint?

 import pprint
 help(pprint)

 And, is there a way to list the variables I create in Python?

Kinda. Try this:

 dir()

There'll be some in there that you didn't make, but that's a start.
You could also try vars() or globals(), which will give you their
values as well.

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


Re: Why does not pprint work?

2014-07-22 Thread Chris Kaynor
On Tue, Jul 22, 2014 at 3:17 PM, emile em...@fenx.com wrote:

 Then, how can I list all the function of pprint?


 use the dir builtin:

  dir (pprint)
 ['PrettyPrinter', '_StringIO', '__all__', '__builtins__', '__doc__',
 '__file__', '__name__', '_commajoin', '_id', '_len', '_perfcheck',
 '_recursion', '_safe_repr', '_sys', '_type', 'isreadable', 'isrecursive',
 'pformat', 'pprint', 'saferepr']


Another useful feature is the help function (can be used like
help(pprint) or just help() for interactive usage), which will also
provide the documentation for each item in addition to just the names.

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


Re: Question about Pass-by-object-reference?

2014-07-22 Thread Joel Goldstick
it copies the list


On Tue, Jul 22, 2014 at 6:17 PM, fl rxjw...@gmail.com wrote:

 On Tuesday, July 22, 2014 4:46:25 PM UTC-4, emile wrote:
  On 07/22/2014 01:35 PM, Peter Pearson wrote:
  def reassign(mylist):  # no reason to shadow the list builtin
   mylist[:] = [0,1]
  mylist = [1]
  reassign(mylist)
  mylist
  Emile

 Thanks for your example. I do not find the explanation of [:] on line.
 Could you
 explain it to me, or where can I find it on line?
 --
 https://mail.python.org/mailman/listinfo/python-list




-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about Pass-by-object-reference?

2014-07-22 Thread emile

On 07/22/2014 03:17 PM, fl wrote:

On Tuesday, July 22, 2014 4:46:25 PM UTC-4, emile wrote:

On 07/22/2014 01:35 PM, Peter Pearson wrote:
def reassign(mylist):  # no reason to shadow the list builtin
  mylist[:] = [0,1]
mylist = [1]
reassign(mylist)
mylist
Emile


Thanks for your example. I do not find the explanation of [:] on line.


It's covered in the tutorial in

https://docs.python.org/2/tutorial/introduction.html

look for the section on slice notation


Could you explain it to me, or where can I find it on line?


If you haven't already, you should work your way through the full 
tutorial if for no other reason that to be familiar with content others 
find beginners should be introduced to.


https://docs.python.org/2/tutorial/index.html

Emile



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


Re: Question about Pass-by-object-reference?

2014-07-22 Thread fl
On Tuesday, July 22, 2014 4:46:25 PM UTC-4, emile wrote:
 On 07/22/2014 01:35 PM, Peter Pearson wrote:
 def reassign(mylist):  # no reason to shadow the list builtin
  mylist[:] = [0,1]
 
 mylist = [1]
 reassign(mylist)
 mylist
 
 Emile

I have a new question on the code. When I run it in a file on PythonWin, 
'mylist'
does not echo anything on the screen. While I enter the command line by line,
'mylist' shows the result:

 mylist
[0, 1]


What mechanism is involved?

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


Re: Question about Pass-by-object-reference?

2014-07-22 Thread emile

On 07/22/2014 03:31 PM, fl wrote:


I have a new question on the code. When I run it in a file on PythonWin, 
'mylist'
does not echo anything on the screen. While I enter the command line by line,
'mylist' shows the result:


mylist

[0, 1]


What mechanism is involved?



As a convenience, the interactive prompt environment will display the 
value of a variable when entered on its own.


In scripts, you'd usually want to use print.

Emile



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


Re: Question about Pass-by-object-reference?

2014-07-22 Thread fl
On Tuesday, July 22, 2014 4:35:33 PM UTC-4, Peter Pearson wrote:
 On Tue, 22 Jul 2014 12:34:51 -0700 (PDT), fl r...@gmail.com wrote:
 When you say def reassign(list), that means I'm defining a function
 to which the caller will pass one object, and within this function I'm
 going to refer to that object by the name 'list'.
 
 
 
 Then, when you say list=[0,1], that means Create the object [0,1],

The above is what rebind? see below I cite.

 and assign to it the name 'list'.  At this point, there is no longer
 any name that refers to the object that the caller passed.

Here is I find on-line about Arguments are passed by assignment.
http://stackoverflow.com/questions/986006/python-how-do-i-pass-a-variable-by-reference

If you pass a mutable object into a method, the method gets a reference to 
that 
same object and you can mutate it to your heart's delight, but if you rebind the
reference in the method, the outer scope will know nothing about it, and after
you're done, the outer reference will still point at the original object.

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


Re: Question about Pass-by-object-reference?

2014-07-22 Thread Jerry Hill
On Tue, Jul 22, 2014 at 6:17 PM, fl rxjw...@gmail.com wrote:
 Thanks for your example. I do not find the explanation of [:] on line. Could 
 you
 explain it to me, or where can I find it on line?

It's pretty hard to find if you don't already know what's going on.

First, you need to know that mylst[i:j] refers to a slice of  the list
mylist.  Specifically, the items from the list starting with the
item at index i, up to but not including the item at index j.  If you
leave the i off (e.g., mylist[:j]) that's a slice from the start of
the list up to (but not including) the j-th item.  If you leave the
end position off, (e.g., mylist[i:]), that gets you the i-th item to
the end (including the last item).  If you leave off both indexes from
the slice, you get back the entire contents of the list.  So that's
what mylist[:] means.

Then you need to know that you can assign to the slice and it will
replace the old elements from the slice with the new ones.  You can
see that defined here, in the docs (second item in the table under
4.6.3. Mutable Sequence Types):

https://docs.python.org/3/library/stdtypes.html#mutable-sequence-types

So, when you so mylist[:] = [0,1] you're taking all of the contents of
the existing list, and replacing them with the contents of the list
[0,1].  That changes the existing list, it doesn't just assign a new
list to the name mylist.

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


Re: Question about Pass-by-object-reference?

2014-07-22 Thread emile

On 07/22/2014 04:00 PM, fl wrote:

On Tuesday, July 22, 2014 4:35:33 PM UTC-4, Peter Pearson wrote:

On Tue, 22 Jul 2014 12:34:51 -0700 (PDT), fl r...@gmail.com wrote:
When you say def reassign(list), that means I'm defining a function
to which the caller will pass one object, and within this function I'm
going to refer to that object by the name 'list'.



Then, when you say list=[0,1], that means Create the object [0,1],


The above is what rebind? see below I cite.


exactly.  assigning to a variable within a function makes that variable 
local to the function; assigning to the contents (as with [:]) changes 
the contents, but not the container variable, and as the container 
element was passed in you'll see the changed item outside the function.


Emile






and assign to it the name 'list'.  At this point, there is no longer
any name that refers to the object that the caller passed.


Here is I find on-line about Arguments are passed by assignment.
http://stackoverflow.com/questions/986006/python-how-do-i-pass-a-variable-by-reference

If you pass a mutable object into a method, the method gets a reference to that
same object and you can mutate it to your heart's delight, but if you rebind the
reference in the method, the outer scope will know nothing about it, and after
you're done, the outer reference will still point at the original object.

Thanks




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


Re: Question about Pass-by-object-reference?

2014-07-22 Thread Terry Reedy
When you call a function, Python binds function parameter names to 
argument objects in the function's local namespace, the same as in name 
assignments. Given


def f(a, b): pass

a call f(1, 'x') starts by executing

a, b = 1, 'x'

in the local namespace.  Nothing is being 'passed'.

--
Terry Jan Reedy

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


Re: Is it possible to install Python on a network?

2014-07-22 Thread roys2005

Emile, thanks for the quick response.

Does this mean Python cannot be or should not be installed at a central 
location?
If so, what is the root cause for this?

- Koushik

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


Re: testfixtures 4.0.0 Released!

2014-07-22 Thread Roy Smith
In article mailman.12182.1406042260.18130.python-l...@python.org,
 Chris Withers ch...@simplistix.co.uk wrote:
 
 - Moved from buildout to virtualenv for development.

I use virtualenv (and love it).  I've never used buildout.  Would you be 
willing to give a short synopsis of why you switched?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unicode, stdout, and stderr

2014-07-22 Thread Akira Li
Frank Millman fr...@chagford.com writes:

 Steven D'Aprano st...@pearwood.info wrote in message 
 news:53ce0b96$0$29897$c3e8da3$54964...@news.astraweb.com...
 On Tue, 22 Jul 2014 08:18:08 +0200, Frank Millman wrote:

 This is not important, but I would appreciate it if someone could
 explain the following, run from cmd.exe on Windows Server 2003 -

 C:\python
 Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32
 bit (In
 tel)] on win32
 Type help, copyright, credits or license for more information.
 x = '\u2119'
 x  # this uses stderr
 '\u2119'


 It seems that there is a difference between writing to stdout and
 writing to stderr.

 I would be surprised if that were the case, but I don't have a Windows
 box to test it. Try this:


 import sys
 print(x, file=sys.stderr)  # I expect this will fail

 It does not fail.
 print(repr(x), file=sys.stdout)  # I expect this will succeed

 It fails.

Check sys.stderr.errors attribute. Try

 import sys
 x = '\u2119'
 x.encode(sys.stderr.encoding, sys.stderr.errors) # succeed
 x.encode(sys.stdout.encoding, sys.stdout.errors) # fail

sys.stderr uses 'backslashreplace' error handler that is why you see
\u2119 instead of ℙ.

On Linux with utf-8 locale:

   print('\u2119')
  ℙ
   print(repr('\u2119'))
  'ℙ'
   print(ascii('\u2119'))
  '\u2119'
   '\u2119'
  'ℙ'
   repr('\u2119')
  'ℙ'
   ascii('\u2119')
  '\\u2119'

On Windows, try https://pypi.python.org/pypi/win_unicode_console

  C:\ pip install win-unicode-console
  C:\ py -i -m run

It is alpha but your feedback may improve it
https://github.com/Drekin/win-unicode-console/issues 

If you could also use a GUI console e.g.:

  C:\ py -3 -m idlelib

Or http://ipython.org/notebook.html

There are many other IDEs for Python e.g.,

http://stackoverflow.com/q/81584/what-ide-to-use-for-python


--
Akira

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


Re: Question about Pass-by-object-reference?

2014-07-22 Thread fl
On Tuesday, July 22, 2014 8:27:15 PM UTC-4, Terry Reedy wrote:
 When you call a function, Python binds function parameter names to 
 argument objects in the function's local namespace, the same as in name 
 assignments. Given
 def f(a, b): pass
 a call f(1, 'x') starts by executing
 a, b = 1, 'x'
 in the local namespace.  Nothing is being 'passed'.
 -- 
 Terry Jan Reedy

Thanks, but I don't understand your point yet. Could you give me another example
in which something is passed?




BTW, to a previous reply post. I have learned ':' in regular expression. But I 
am
still new to Python, I did not realize that it is the same ':' in the string
search/match.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about Pass-by-object-reference?

2014-07-22 Thread Ben Finney
fl rxjw...@gmail.com writes:

 On Tuesday, July 22, 2014 8:27:15 PM UTC-4, Terry Reedy wrote:
  When you call a function, Python binds function parameter names to
  argument objects in the function's local namespace, the same as in
  name assignments. […]
  Nothing is being 'passed'.

 Thanks, but I don't understand your point yet. Could you give me
 another example in which something is passed?

The point being made is that no values are is “passed” in a function
call. If you have learned that term from elsewhere, it doesn't apply
sensibly to Python.

When you have a function ‘foo’ defined to expect a parameter, and you
specify an object (say, the object you have access to by the reference
‘bar’)::

foo(bar)

What happens is that *the very same object* you're referring to by the
name ‘bar’ is then referenced by a *different* name inside the function
‘foo’. There is no passing; the same object gets a new local name
assigned to it, for use only within that function's code.

Function parameters aren't passed anywhere, they don't go anywhere, they
don't get cast or copied or anything else to the function. The function
gets to refer to the identical object by a name local in that function;
you can see what that parameter's name is by the definition of the
function.

-- 
 \   “Pray, v. To ask that the laws of the universe be annulled in |
  `\ behalf of a single petitioner confessedly unworthy.” —Ambrose |
_o__)   Bierce, _The Devil's Dictionary_, 1906 |
Ben Finney

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


Re: Question about Pass-by-object-reference?

2014-07-22 Thread Steven D'Aprano
On Tue, 22 Jul 2014 12:04:09 -0700, fl wrote:

 Hi,
 I learn Python function call on tutorial. There is a link on this
 subject.
 http://robertheaton.com/2014/02/09/pythons-pass-by-object-reference-as-
explained-by-philip-k-dick/
 
 Although it explains clearly, the figure makes me puzzled.


Here is my take on the same question:

http://import-that.dreamwidth.org/1130.html

Feedback is welcome.


 Python is different. As we know, in Python, Object references are
 passed by value.

I'm not sure who said that, but they weren't really being clear. The 
mention of passed by value is pointless, since it refers only to the 
implementation inside the interpreter, and not anything you can see using 
Python code. What it means is that under the hood, you have a mysterious 
thing called an object reference. That's just another way of saying 
reference to an object, which is usually implemented as a pointer. When 
the interpreter passes an argument to a function, it does so by making a 
copy of that pointer (hence passed by value). The copy still points to 
the same object.

I believe that for people thinking at the level of *Python code*, such 
descriptions aimed at the level of the underlying C code inside the 
interpreter add heat but no light. They simply cause more confusion than 
clarity.


-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why does not pprint work?

2014-07-22 Thread Ned Batchelder

On 7/22/14 5:49 PM, Chris Angelico wrote:

On Wed, Jul 23, 2014 at 7:42 AM, fl rxjw...@gmail.com wrote:

I enter the example lines of that website:


import pprint
board = [ [0]*8 ] * 8
pprint(board)


Flaw in the blog post: he didn't actually specify the import line.
What you actually want is this:

from pprint import pprint

Or use pprint.pprint(board), but you probably don't need anything else
from the module.

Ned, if you're reading this: Adding the import would make the post clearer. :)


Done.



ChrisA




--
Ned Batchelder, http://nedbatchelder.com

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


Re: A Pythonista Meets JavaScript™

2014-07-22 Thread Ben Finney
Ben Finney ben+pyt...@benfinney.id.au writes:

 Monte Milanuk memila...@invalid.com writes:

  I know literally almost nothing about JS.

 At the Melbourne Python Users's Group this year, I gave a presentation
 URL:http://vimeo.com/album/2855296/video/93691338 on my initial
 learnings of JavaScript™ (and ECMAScript) from a Python programmer's
 perspective.

Lele Gaifax l...@metapensiero.it writes:

 I completely agree with Roy on the language itself, it has several
 tricky parts that require some training to learn how to avoid,
 defects that are inherent to language and to the syntax, that no
 framework or library can really eliminate. There is a very good book
 by Douglas Crockford, JS: the good parts that I recommend reading.

Yes, in my talk above I leaned heavily on Doug Crockford's book
“JavaScript: The Good Parts”. He mkes an opinionated division between
the parts of the language to avoid, and the subset which can be used
happily as a good, functional language for building programs.

 On the framework, ExtJS is the one I know better and its quite good and
 powerful: it has a dual license, GPL for free software projects and a
 commercial version

Please note that the opposite of free software is not commercial
software. The GPL explicitly says “You may charge any price or no price
for each copy that you convey”, and I think we both agree the GPL is a
free-software license.

So free software *is* commercial software; software for a fee doesn't in
any way stop it from being free software.

The opposite of free software is proprietary software, and I agree that
some of the problems with ExtJS come from the fact that the current
copyright holder privileges the proprietary licensees at the expense of
the free-software licensees. They also exacerbate the confusion by
referring to their proprietary license as “commercial license”, ignoring
the fact that the GPL also explicitly condones commercial activity.

 My main complaint is about their (Sencha's) release policy which
 frankly sucks, on both sides (free and commercial): they do not have a
 clear roadmap, you report bugs in a forum and from then on you cannot
 know if and when the bug gets fixed, or even released.

That's a real shame. The same is true of MySQL, which while free
software is held under CLA to a single copyright holder. That copyright
holder (now Oracle) shows no interest in supporting the free-software
MySQL and as a result it has declined under their stewardship.

I'm sorry to hear the same – a free-software license available, but
supported far worse than the restrictive proprietary version – appears
to be happening to ExtJS.

 They assert to have an extensive suite of unit and functional tests,
 but sometime I have the doubt they do not run it as often as one would
 expect :-)

In the case of MySQL, the extensive test suite itself is suffering from
Oracle neglecting it in favour of the proprietary version: tests in
recent years have simply not appeared in the free-software code base,
and they're behind locked doors at Oracle. A sober warning against
entrusting a widely-deployed software project to any single copyright
holder.

-- 
 \“A right is not what someone gives you; it's what no one can |
  `\ take from you.” —Ramsey Clark |
_o__)  |
Ben Finney

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


Re: Is it possible to install Python on a network?

2014-07-22 Thread Dan Stromberg
On Tue, Jul 22, 2014 at 5:41 PM, roys2005 roys2...@gmail.com wrote:

 Emile, thanks for the quick response.

 Does this mean Python cannot be or should not be installed at a central 
 location?
 If so, what is the root cause for this?

Back when I was a sysadmin, I would install CPython to a few different
NFS filesystems for hundreds of machines to use (more than one
filesystem because we had about 5 *ix variants - you probably only
need 1). It's just a matter of ./configure --prefix=/where/ever 
make  make install once you have the build dependencies.

It worked fine, but if you symlink you get into trouble because Python
can't find it's default module path where it expects; symlinking can
require a wrapper that sets an environment variable - I believe it was
$PYTHONPATH.

Perhaps it would be appropriate to ask: Why are you wondering if it works?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is it possible to install Python on a network?

2014-07-22 Thread Ben Finney
roys2005 roys2...@gmail.com writes:

 Does this mean Python cannot be or should not be installed at a
 central location?

Can you explain better what you mean by this?

As stated, it doesn't make much sense to me: Any machine which supports
running Python can be central or distributed, but it can only be invoked
on the same machine. What does it mean *to you* to say “install Python
on a network”?

Perhaps you're asking not so much about installing, but *running*
Python. I don't see how you can run a program “on a network” except by
running the program *on one specific machine* and having that program
*communicate* over a network. Is that what you mean?

If not, you're going to need to explain what you are asking more
precisely.

-- 
 \ “Books and opinions, no matter from whom they came, if they are |
  `\ in opposition to human rights, are nothing but dead letters.” |
_o__)  —Ernestine Rose |
Ben Finney

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


Distributing python applications as a zip file

2014-07-22 Thread Steven D'Aprano
A little known feature of Python: you can wrap your Python application in 
a zip file and distribute it as a single file. The trick to make it 
runnable is to put your main function inside a file called __main__.py 
inside the zip file. Here's a basic example:

steve@runes:~$ cat __main__.py 
print(NOBODY expects the Spanish Inquisition!!!)

steve@runes:~$ zip appl __main__.py 
  adding: __main__.py (stored 0%)
steve@runes:~$ rm __main__.py 
steve@runes:~$ python appl.zip 
NOBODY expects the Spanish Inquisition!!!


On Linux, you can even hack the zip file to include a shebang line!


steve@runes:~$ cat appl
#!/usr/bin/env python
# This is a Python application stored in a ZIP archive.
steve@runes:~$ cat appl.zip  appl
steve@runes:~$ chmod u+x appl
steve@runes:~$ ./appl
NOBODY expects the Spanish Inquisition!!!


It's not quite self-contained, as you still need to have Python 
installed, but otherwise it's a good way to distribute a Python 
application as a single file that users can just copy and run.



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


Re: Why does not pprint work?

2014-07-22 Thread Chris Angelico
On Wed, Jul 23, 2014 at 12:26 PM, Ned Batchelder n...@nedbatchelder.com wrote:
 Ned, if you're reading this: Adding the import would make the post
 clearer. :)


 Done.

Thanks Ned!

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


Re: Distributing python applications as a zip file

2014-07-22 Thread Gary Herron

On 07/22/2014 09:23 PM, Steven D'Aprano wrote:

A little known feature of Python: you can wrap your Python application in
a zip file and distribute it as a single file. The trick to make it
runnable is to put your main function inside a file called __main__.py
inside the zip file. Here's a basic example:

steve@runes:~$ cat __main__.py
print(NOBODY expects the Spanish Inquisition!!!)

steve@runes:~$ zip appl __main__.py
   adding: __main__.py (stored 0%)
steve@runes:~$ rm __main__.py
steve@runes:~$ python appl.zip
NOBODY expects the Spanish Inquisition!!!


On Linux, you can even hack the zip file to include a shebang line!


steve@runes:~$ cat appl
#!/usr/bin/env python
# This is a Python application stored in a ZIP archive.
steve@runes:~$ cat appl.zip  appl
steve@runes:~$ chmod u+x appl
steve@runes:~$ ./appl
NOBODY expects the Spanish Inquisition!!!


It's not quite self-contained, as you still need to have Python
installed, but otherwise it's a good way to distribute a Python
application as a single file that users can just copy and run.





Really!  20 years of Pythoning, and I'd never seen this!  When was this 
introduced?


Gary Herron

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


Re: Question about Pass-by-object-reference?

2014-07-22 Thread Steven D'Aprano
On Wed, 23 Jul 2014 11:59:45 +1000, Ben Finney wrote:

 fl rxjw...@gmail.com writes:
 
 On Tuesday, July 22, 2014 8:27:15 PM UTC-4, Terry Reedy wrote:
  When you call a function, Python binds function parameter names to
  argument objects in the function's local namespace, the same as in
  name assignments. […]
  Nothing is being 'passed'.

 Thanks, but I don't understand your point yet. Could you give me
 another example in which something is passed?
 
 The point being made is that no values are is “passed” in a function
 call. If you have learned that term from elsewhere, it doesn't apply
 sensibly to Python.

Hmmm. I don't know that I like that. I think that these two sentences 
mean the same thing:

Call the function with x as argument.

Pass x to the function.

They both describe what is being done, only from slightly different 
points of view. In mathematics, to call a function is a completely 
abstract action. Magic happens, and a result is returned. But in 
programming languages, calling a function has concrete actions: certain 
things have to happen even before the function itself executes. What sort 
of things? Well, for starters, somehow the arguments need to be passed to 
the function, so that the function can tell the difference between being 
called with x as argument and being called with y as argument.

If you say nothing is being passed, then my response would be Oh, you 
aren't calling the function at all? Or just calling it with no arguments?

I maintain that treating call and pass as more-or-less the same thing 
is common terminology, used throughout both mathematics and computing, 
and there's no very little benefit to avoiding it in the case of Python.



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


Re: Question about Pass-by-object-reference?

2014-07-22 Thread Steven D'Aprano
On Tue, 22 Jul 2014 20:27:15 -0400, Terry Reedy wrote:

 When you call a function, Python binds function parameter names to
 argument objects in the function's local namespace, the same as in name
 assignments. Given
 
 def f(a, b): pass
 
 a call f(1, 'x') starts by executing
 
 a, b = 1, 'x'
 
 in the local namespace.  Nothing is being 'passed'.


If nothing is being passed, how does the function know to bind 1 and 'x' 
to names a and b, rather than (say) this?

a, b = 23, 'Surprise!


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


Re: Distributing python applications as a zip file

2014-07-22 Thread Chris Rebert
On Tue, Jul 22, 2014 at 9:23 PM, Steven D'Aprano st...@pearwood.info wrote:
 A little known feature of Python: you can wrap your Python application in
 a zip file and distribute it as a single file. The trick to make it
 runnable is to put your main function inside a file called __main__.py
 inside the zip file.
snip
 It's not quite self-contained, as you still need to have Python
 installed, but otherwise it's a good way to distribute a Python
 application as a single file that users can just copy and run.

And if you want something nearly completely self-contained (probably
modulo dynamic linking), it seems that there's PEX
(http://pex.readthedocs.org/en/latest/ ).

Cheers,
Chris
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue21597] Allow turtledemo code pane to get wider.

2014-07-22 Thread Terry J. Reedy

Terry J. Reedy added the comment:

For me, FLAT is about as mushy as the default, while SOLID actually looks like 
a divider. I find the sash easier to 'grab' and move. I plan to go with that. 
If it looks substantially worse on some other system, we could make the 
argument conditional on sys.platform or whatever.

I plan to do a 'final' review in the next day and either commit or post a 
revision for testing on non-Windows systems.

--
stage: patch review - commit review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21597
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21933] Allow the user to change font sizes with the text pane of turtledemo

2014-07-22 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I plan to commit the sash patch before reviewing this. I would wait until then 
to do a separate patch.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21933
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21933] Allow the user to change font sizes with the text pane of turtledemo

2014-07-22 Thread Terry J. Reedy

Terry J. Reedy added the comment:

MOUSEWHEEL should continue to scroll.
CONTROL+MOUSEWHEEL should change font size, as you said at the beginning.
At least on Windows, this seems pretty standard: Internet Explorer, Firefox, 
Notepad++, LibreOffice (and, I imagin, OpenOffice, and Word), Thunderbird.  The 
only exception I can find that has a font size setting but ignores ^wheel is 
Command Prompt, which breaks multiple UI rules.  Notepad does not allow font 
resizing.

Get ^wheel to work right and I would like to add it to Idle, where ^wheel 
scrolls along with wheel.

^+ and ^- are pretty standard also, though LibreOffice does not recognize them. 
Perhaps this is because it is explicit cross platform.

We can conditionally not bind wheel events on Mac setups where it fails. Does 
#10731 have enough info to do that? In not... I have not yet looked into 
generating key/mouse events from code, but perhaps it would be possible to 
generate a wheel event inside try: except and unbind if there is an exception.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21933
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21933] Allow the user to change font sizes with the text pane of turtledemo

2014-07-22 Thread Lita Cho

Lita Cho added the comment:

Sounds good. I can wait till the sash code gets incorporated in order to
add in the font code.

I would have to generate a MOUSEWHEEL event and see if it fails. I have
generated mouse clicks before. I'll try to see if I can generate a
MOUSEWHEEL event and if it errors, not bind to it. Although it might be
hard for me to test, as I just updated my tcl/tk.

I will also try to figure out how to bind to Ctrl+MOUSEWHEEL and not just
MOUSEWHEEL.

Lita

On Mon, Jul 21, 2014 at 11:35 PM, Terry J. Reedy rep...@bugs.python.org
wrote:


 Terry J. Reedy added the comment:

 MOUSEWHEEL should continue to scroll.
 CONTROL+MOUSEWHEEL should change font size, as you said at the beginning.
 At least on Windows, this seems pretty standard: Internet Explorer,
 Firefox, Notepad++, LibreOffice (and, I imagin, OpenOffice, and Word),
 Thunderbird.  The only exception I can find that has a font size setting
 but ignores ^wheel is Command Prompt, which breaks multiple UI rules.
  Notepad does not allow font resizing.

 Get ^wheel to work right and I would like to add it to Idle, where ^wheel
 scrolls along with wheel.

 ^+ and ^- are pretty standard also, though LibreOffice does not recognize
 them. Perhaps this is because it is explicit cross platform.

 We can conditionally not bind wheel events on Mac setups where it fails.
 Does #10731 have enough info to do that? In not... I have not yet looked
 into generating key/mouse events from code, but perhaps it would be
 possible to generate a wheel event inside try: except and unbind if there
 is an exception.

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue21933
 ___


--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21933
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21933] Allow the user to change font sizes with the text pane of turtledemo

2014-07-22 Thread Ned Deily

Ned Deily added the comment:

Lita, I tried the patch.  From the perspective of an OS X user, while I might 
expect that using the zoom gesture on a mousepad or using a mousewheel (the 
equivalent) to increase or decrease the font size, I would even more expect 
scrolling to work especially if scrollbars are present.  Clearly, scrolling is 
more important so, if it is not possible to bind Tk mousewheel events without 
affecting scrolling, I would abandon the mousewheel.  On OS X, the standard way 
to provide size adjustment (of fonts or images) is to provide Bigger or 
Smaller menu items with the standard keyboard shortcuts of 
Command-Shift-Equal (and Command-Equal) which is displayed as Command + (so 
the user on a US keyboard just presses the Command key and the =/+ key) and 
Command-Hyphen (Command -).  The Apple OS X Human Interface Guidelines go 
into more detail and you can see these shortcuts in action in many standard OS 
X applications (TextEdit, Mail, Safari, etc).  As it stands today, turtledemo 
does not 
 use the standard OS X menu bar where these commands would normally be placed.  
And that's a bit of a separate problem because since turtledemo doesn't change 
the root menu it defaults to a Tk-provided one which includes things Run 
Widget Demo under the file menu.  To be a proper OS X app, turtledemo should 
customize the menu, at least removing the widget demo item and then it could 
add the Bigger and Smaller menu items to a Format menu.  Actually, the 
turtledemo Examples and Help pulldown options would ideally also be available 
in the standard menu hierarchy.  I'm not suggesting that is a requirement but 
that's what I think an OS X user would expect and what the Apple HIG would 
require.

https://developer.apple.com/library/mac/documentation/userexperience/conceptual/applehiguidelines/KeyboardShortcuts/KeyboardShortcuts.html
https://developer.apple.com/library/mac/documentation/userexperience/conceptual/applehiguidelines/Menus/Menus.html

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21933
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21933] Allow the user to change font sizes with the text pane of turtledemo

2014-07-22 Thread Lita Cho

Lita Cho added the comment:

I completely agree about the mousewheel. However, would it make sense for
OS X to combine command with mousewheel? I have never seen that before. I
am not sure if I can bind the zoom gesture with tkinter, but I can find
out.

I also think the shortcuts are not intuitive as an OS X user, as command
should be used instead of Ctrl.

What I can do check the operating system and define the font shortcuts
accordingly. I am not sure about redefining the Menu shortcuts as that
seems like a separate issue.

On Mon, Jul 21, 2014 at 11:52 PM, Ned Deily rep...@bugs.python.org wrote:


 Ned Deily added the comment:

 Lita, I tried the patch.  From the perspective of an OS X user, while I
 might expect that using the zoom gesture on a mousepad or using a
 mousewheel (the equivalent) to increase or decrease the font size, I would
 even more expect scrolling to work especially if scrollbars are present.
  Clearly, scrolling is more important so, if it is not possible to bind Tk
 mousewheel events without affecting scrolling, I would abandon the
 mousewheel.  On OS X, the standard way to provide size adjustment (of fonts
 or images) is to provide Bigger or Smaller menu items with the standard
 keyboard shortcuts of Command-Shift-Equal (and Command-Equal) which is
 displayed as Command + (so the user on a US keyboard just presses the
 Command key and the =/+ key) and Command-Hyphen (Command -).  The Apple
 OS X Human Interface Guidelines go into more detail and you can see these
 shortcuts in action in many standard OS X applications (TextEdit, Mail,
 Safari, etc).  As it stands today, turtledemo does not use the standard OS
 X menu bar where these commands would normally be placed.  And that's a bit
 of a separate problem because since turtledemo doesn't change the root menu
 it defaults to a Tk-provided one which includes things Run Widget Demo
 under the file menu.  To be a proper OS X app, turtledemo should customize
 the menu, at least removing the widget demo item and then it could add the
 Bigger and Smaller menu items to a Format menu.  Actually, the turtledemo
 Examples and Help pulldown options would ideally also be available in the
 standard menu hierarchy.  I'm not suggesting that is a requirement but
 that's what I think an OS X user would expect and what the Apple HIG would
 require.


 https://developer.apple.com/library/mac/documentation/userexperience/conceptual/applehiguidelines/KeyboardShortcuts/KeyboardShortcuts.html

 https://developer.apple.com/library/mac/documentation/userexperience/conceptual/applehiguidelines/Menus/Menus.html

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue21933
 ___


--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21933
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22028] Python 3.4.1 Installer ended prematurely (Windows msi)

2014-07-22 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
nosy: +steve.dower, zach.ware

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22028
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22003] BytesIO copy-on-write

2014-07-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

See also issue15381.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22003
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21933] Allow the user to change font sizes with the text pane of turtledemo

2014-07-22 Thread Ned Deily

Ned Deily added the comment:

On OS X, the actions associated with trackpad gestures are controlled by the 
Trackpad panel of System Preferences.  The default settings map the pinch with 
two fingers gesture to Zoom in or out which Tk apps see as Mousewheel 
events: no programming needed!

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21933
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21970] Broken code for handling file://host in urllib.request.FileHandler.file_open

2014-07-22 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 4b98961748f1 by Senthil Kumaran in branch '3.4':
Fix localhost checking in FileHandler. Raised in #21970.
http://hg.python.org/cpython/rev/4b98961748f1

New changeset 2c660948bb41 by Senthil Kumaran in branch 'default':
Merge 3.4
http://hg.python.org/cpython/rev/2c660948bb41

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21970
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21970] Broken code for handling file://host in urllib.request.FileHandler.file_open

2014-07-22 Thread Senthil Kumaran

Senthil Kumaran added the comment:

I have addressed the mistake where req.host is self.get_names() was done 
instead of req.host in self.get_names() in the first commit as it was an 
obvious problem.

I will come up with patch/solution addressing the other behavior mentioned in 
this report.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21970
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21933] Allow the user to change font sizes with the text pane of turtledemo

2014-07-22 Thread Lita Cho

Lita Cho added the comment:

What really? That is so awesome! I will check that out!

However, I figure I still need to create separate bindings for Linux,
Windows and Mac, right? Or does Tkinter unify all the mousewheel events?

Lita

On Tue, Jul 22, 2014 at 12:18 AM, Ned Deily rep...@bugs.python.org wrote:


 Ned Deily added the comment:

 On OS X, the actions associated with trackpad gestures are controlled by
 the Trackpad panel of System Preferences.  The default settings map the
 pinch with two fingers gesture to Zoom in or out which Tk apps see as
 Mousewheel events: no programming needed!

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue21933
 ___


--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21933
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   3   >