Re: I hate you all

2013-04-06 Thread Michael Torrie
On 04/05/2013 11:36 PM, Timothy Madden wrote:
 I guess a discussion like this thread is the price to be paid for 
 relying solely on white space to delimit code blocks, like the python 
 syntax does.

I've always been taught that in Python using tabs, particularly in the
way that you use them (which, by the way, is the default way vim uses
them when in C++ mode) is fraught with difficulty.  So years ago I
dropped in c couple of lines in my vimrc file to use spaces instead of
tabs and use the PEP standard of 4 spaces.  Have never had any problem.

As for your problems, perhaps instead of coming on the list with a
poorly-thought-out subject line, and desire to simply argue, perhaps you
could run your code through a reformatter that would translate your tabs
into spaces using the tab stop that you desired.  Open the file in vim,
enter the following commands:

set sw=4
set ts=8
set et
set softtabstop=4
set ai
:retab

Then save the file.  Now it's pep-formatted with spaces and no tabs.
Problem solved.  Yes it doesn't address your concerns, but it is the
recommended solution for Python given the difficulties in mixing tabs
and spaces and different people's definition of tabs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I hate you all

2013-04-06 Thread Michael Torrie
On 04/05/2013 11:53 PM, Ian Kelly wrote:
 The new rules may look flexible at first sight, but the net effect they have
 is they push me to use non-default tab size (which is not good),
 
 What makes that not good?  There is no law anywhere that says tabs are
 8 characters.  That's just an arbitrary amount that looked appropriate
 to the people designing the first teletypes.

Ahh but assuming tabs are the equivalent of 8 spaces can save 7 bytes
per tab character in the source code!  Think of the savings.

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


Re: I hate you all

2013-04-06 Thread Steven D'Aprano
On Fri, 05 Apr 2013 23:59:18 -0600, Michael Torrie wrote:

 On 04/05/2013 11:53 PM, Ian Kelly wrote:
 The new rules may look flexible at first sight, but the net effect
 they have is they push me to use non-default tab size (which is not
 good),
 
 What makes that not good?  There is no law anywhere that says tabs are
 8 characters.  That's just an arbitrary amount that looked appropriate
 to the people designing the first teletypes.
 
 Ahh but assuming tabs are the equivalent of 8 spaces can save 7 bytes
 per tab character in the source code!  Think of the savings.

If we standardize on 1025 spaces per indent, and use tabs, we can save 
1KiB per indent. Let's see now... looking at a typical piece of code in 
my code base, I make it that the average line of code is indented about 
1.75 levels. (I use a lot of top-level functions, and few classes). With 
an average line length of 50 characters, plus indentation, we can reduce 
the size of a typical Python module by ninety-seven percent!

Of course, what we save in disk space, we lose in monitor size, but I'm 
sure that the price of 300 inch monitors will soon become quite 
affordable.



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


Re: I hate you all

2013-04-06 Thread Michael Torrie
On 04/05/2013 11:28 PM, Benjamin Kaplan wrote:
 http://www.xkcd.com/1172/

How did I ever miss this before?  That is truly awesome.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I hate you all

2013-04-06 Thread Ethan Furman

On 04/05/2013 10:36 PM, Timothy Madden wrote:


8-character tab stops should be the default. Debating that is I believe another 
topic, and compatibility with python2
should be enough to make that debate unnecessary.


Python 3 broke a lot of things.  Pull on your big-boy underwear and deal with 
it.



Thank you,


Saying 'thank you' does not mitigate you acting like an ass.


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


Re: I hate you all

2013-04-06 Thread Steven D'Aprano
On Sat, 06 Apr 2013 08:36:23 +0300, Timothy Madden wrote:

 8-character tab stops should be the default. Debating that is I believe
 another topic, and compatibility with python2 should be enough to make
 that debate unnecessary.

Compatibility with Python 2 is not a requirement. Python 3 exists to fix 
a bunch of design flaws and mistakes in Python 2. Among the changes:

- print and exec are now functions, not statements
- the dangerous input function is gone
- raw_input is renamed input
- the distinction between int and long is gone
- the second-string classic classes are gone
- strings are Unicode, not bytes
- division is done correctly
- the error-prone syntax of the except statement is fixed
- inconsistently named modules are fixed
- the plethora of similar dict methods is cleaned up
- map, filter, zip operate lazily rather than eagerly

and of course

- mixed spaces and tabs for indentation is gone


 You are right, to change the tab size means to change the meaning of the
 code, and that would be wrong. Can't argue with that.

I can argue with that. Changing tab size does *not* change the meaning of 
code, provided you *only* use tabs for indentation.

Using only tabs for indentation is fine. Whether you set your editor to 
display tabs as 2 columns, 4 columns, 8 columns, or a thousand columns 
will make not a whit of difference to the meaning of the code or the 
number of indent levels. This is the Killer Feature of tabs, and it is 
the primary reason why tabs rule and spaces suck for indentation.

(Alas, too many broken tools that can't handle tabs mean that the less-
good standard won.)

Using only spaces for indentation is also fine. Not as good as tabs, 
because if I use spaces, you're stuck reading my code in whatever poorly-
thought out indent I might choose. I've seen developers use *one* space. 
But using only spaces does work.

What does not work in general, is mixing the two. Don't mix them for 
indents, and you'll be fine.


 What I want is an option to use the tabs as I have used them in the
 past, with the default size.

You can continue to use tabs, so long as you don't mix them with spaces.


 Since ambiguity about the tab size
 appears to be the cause for new python 3 rules, I though of an option
 the make that size explicit. I still think users should somehow have a
 way to use a tab stop of their choice, but how this could be achieved
 properly is another problem.

Unnecessary complexity to solve a non-problem. Just pick one, tabs or 
spaces, and consistently use it in any one block of code. You don't even 
have to be consistent over an entire file.


 I guess a discussion like this thread is the price to be paid for
 relying solely on white space to delimit code blocks, like the python
 syntax does.

Mixing spaces and tabs for indentation is bad in brace languages too.

http://mailman.linuxchix.org/pipermail/programming/2004-August/001433.html


Maybe if we had smarter editors and smarter diffs and smarter tools in 
general, it wouldn't be a problem. But we don't, so it is.



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


Re: I hate you all

2013-04-06 Thread Timothy Madden

On 06.04.2013 08:53, Ian Kelly wrote:

On Fri, Apr 5, 2013 at 11:07 PM, Timothy Madden terminato...@gmail.com wrote:

[...]

So in other words, everybody must be forced to use 8-character tabs
because you want to be able to mix tabs and spaces.


People say I can use tabs all the way, just set them to the indent I want.

Well, I always had my indent independent of the tab size. Which is the way
it should be, after all, since one can indent with or without tabs, so
indent should not be tied to them.

But now I can not; python no longer lets me do that.


Honestly, I really don't understand why you *want* to do that.  If
your indentation is 4 characters, then that would be the natural tab
width to use.  If you're not going to tie your indent to your tabs,
then why even use tabs in the first place?


The new rules may look flexible at first sight, but the net effect they have
is they push me to use non-default tab size (which is not good),


What makes that not good?  There is no law anywhere that says tabs are
8 characters.  That's just an arbitrary amount that looked appropriate
to the people designing the first teletypes.


I am aware that 7 bytes per tab character (or 14/28, in UTF-16, UTF-32!) 
will not justify the time spent debating.


The reason I want to use tabs is that I think there is nothing wrong 
with them.


The reason why everybody should use 8-character tabs is so that I and 
the rest of the world can use `grep` / `findstr` on their code, and 
still see lines of code properly aligned in the terminal. Or to be able 
to print fragments of code as plain text only, and get the proper alignment.


But most importantly, the reason that tab size should be 8 is so that 
all of us people in this world can freely exchange formatted text like 
source code without having to first consider if will it look the same 
in their editor ? What tab size do they use ?


In other words, the solution to different people's definition of tabs 
is not to drop them, but only to get a common default. Which is already 
there: 8 columns between every tab stop.


What python 3 does is a different attitude, and that is:

everyone likes their own indent. Although I personally find it annoying, 
I am aware that many people use an indent of 2 spaces, some use even 3. 
Moreover, many C programers still like 8 spaces per indent.


So some development environments find it an advantage to use tabs only 
for indentation, and every programmer is then free to set the tab stop 
to their liking. Everyone will see the indent they like, with no changes 
in the byte stream for the file.


Why I think this is wrong is a little difficult for me explain. First, I 
admit this approach toward tabs has some value and is tempting for me, 
too. But it assumes everything, everywhere can configure tab sizes. 
Consoles and printers usually do not. Next, even if they can, most 
people, including all non-technical personal, never bother to change 
settings. Then this also assumes I change settings to my liking on 
several computers I use (maybe I work for several clients each with 
their computers, most people have a work computer and a home computer, 
maybe also a laptop and a tablet/smart device). Last, this is also not 
helpful if two sometimes use the same computer from time to time, and do 
not want to switch users all the time.


So this is not a very good approach, and I have the feeling that most 
python programmers and development environment prefer to use only spaces 
than to use variable tab sizes.


So the right solution remains a proper default setting for the tab size, 
and then we no longer have to drop tabs from source code files.


Thank you,
Timothy Madden
--
http://mail.python.org/mailman/listinfo/python-list


Re: I hate you all

2013-04-06 Thread Timothy Madden

On 06.04.2013 08:58, Michael Torrie wrote:
[...]

As for your problems, perhaps instead of coming on the list with a
poorly-thought-out subject line, and desire to simply argue, perhaps you
could run your code through a reformatter [...]


Hey, I was feeling frustrated ... ! It is how people feel when they no 
longer have a choice they used to have.


But I hear programmers should get used to the feeling: using code that 
you did not write is bound to trigger that reaction every so often.


Timothy Madden

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


Re: can anyone help me in developing a simple webpage in jinja2

2013-04-06 Thread Jan Riechers

On 06.04.2013 01:41, Satabdi Mukherjee wrote:

i am a rookie in python and i am trying to develop a simple webpage using 
jinja2.

can anyone please help me how to do that

i am trying in this way but showing invalid syntax error


[...]

 ul id=navigation
 {% for item in navigation %}
 lia href={{ item.href }}{{ item.caption }}/a/li
 {% endfor %}
 /ul

 h1My Webpage/h1
 {{ a_variable }}

[...]




Hello,

the jinja2 syntax is correct that way, see also this for reference for 
variable naming:

http://jinja.pocoo.org/docs/templates/index.html#variables

The invalid syntax is raised when? Can you post the error a bit more 
detailed, this will help giving you any advice.


If you know the code part raising the error and you post it, this will 
also help.


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


Re: can anyone help me in developing a simple webpage in jinja2

2013-04-06 Thread Chris Angelico
On Sat, Apr 6, 2013 at 6:15 PM, Jan Riechers janpet...@freenet.de wrote:
 The invalid syntax is raised when? Can you post the error a bit more
 detailed, this will help giving you any advice.

 If you know the code part raising the error and you post it, this will also
 help.

Agreed. But my guess would be the lack of colon on the for loop...
which would be highlighted by the error thrown.

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


Re: Run python script with ./

2013-04-06 Thread LubanWorks
I have test that wrapper, under Bash 4.1.2, ./myscript.py works, it doesn't
work under Bash 3.2.25, seems Bash relative.

http://stackoverflow.com/questions/15838183/run-python-script-with-dot-slash


On Fri, Apr 5, 2013 at 11:58 PM, Dylan Evans dy...@dje.me wrote:




 On Sat, Apr 6, 2013 at 1:04 AM, LubanWorks luban.wo...@gmail.com wrote:



 My question is:

 Why  when I use #!/home/luban/Linux/Python/2.7.3/bin/python at the
 beginning of myscript.py, *./*myscript.py can work,

 but if I use the wrapper #!/home/luban/bin/python in my python script, use
 *./*  to run the script, it cannot not work?


 Your shell will be trying to run your python script. The reason being that
 when you do #!/bin/sh in the wrapper the shell tries to execute $0 which in
 this case is the name of your python script.




 I had many scripts used #!/home/luban/bin/python when I only installed
 python  under #!/home/luban/ for Linux, they can run with ./, I don't want
 to change them,

 so, how to let ./ run the python script If I want to *KEEP* wrapper
 #!/home/luban/bin/python as the shebang line?


 Probably easier to use a symlink, or just use #!python and adjust your
 $PATH.



 Best Regards,
 Luban

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




 --
 The UNIX system has a command, nice ... in order to be nice to the other
 users. Nobody ever uses it. - Andrew S. Tanenbaum

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


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


Re: I hate you all

2013-04-06 Thread Joshua Landau
On 6 April 2013 07:56, Timothy Madden terminato...@gmail.com wrote:

 On 06.04.2013 08:53, Ian Kelly wrote:

 On Fri, Apr 5, 2013 at 11:07 PM, Timothy Madden terminato...@gmail.com
 wrote:

 [...]

 So in other words, everybody must be forced to use 8-character tabs
 because you want to be able to mix tabs and spaces.

  People say I can use tabs all the way, just set them to the indent I
 want.

 Well, I always had my indent independent of the tab size. Which is the
 way
 it should be, after all, since one can indent with or without tabs, so
 indent should not be tied to them.

 But now I can not; python no longer lets me do that.


 Honestly, I really don't understand why you *want* to do that.  If
 your indentation is 4 characters, then that would be the natural tab
 width to use.  If you're not going to tie your indent to your tabs,
 then why even use tabs in the first place?

  The new rules may look flexible at first sight, but the net effect they
 have
 is they push me to use non-default tab size (which is not good),


 What makes that not good?  There is no law anywhere that says tabs are
 8 characters.  That's just an arbitrary amount that looked appropriate
 to the people designing the first teletypes.


 I am aware that 7 bytes per tab character (or 14/28, in UTF-16, UTF-32!)
 will not justify the time spent debating.

 The reason I want to use tabs is that I think there is nothing wrong with
 them.


So use them


 The reason why everybody should use 8-character tabs is so that I and the
 rest of the world can use `grep` / `findstr` on their code, and still see
 lines of code properly aligned in the terminal. Or to be able to print
 fragments of code as plain text only, and get the proper alignment.


Oh thanks. I liked using my four character tabs, but I guess you *are* so
important that I'm going to have to change everything I do just for you.
It's obviously not good enough for you just to not mix tabs and spaces so
that we can both enjoy ourselves because that would make *you*, the holiest
of all, have to put some effort in. No, I totally understand and will now
go and change everything after Python is changed to break hundreds of files
of codes for you.


 But most importantly, the reason that tab size should be 8 is so that all
 of us people in this world can freely exchange formatted text like source
 code without having to first consider if will it look the same in their
 editor ? What tab size do they use ?


Hrm. Hrm. Hmmm.

H.

No, you're right: spaces are totally not for this in any way and that
no-one has ever made this point before and who the hell cares if you're
reading code with a different indent size anyway it's not like it affects
the actual code.

Yours frustratedly,

Joshua Landau



But seriously, please at least look like you've read other people's posts.
It doesn't matter what tabstop you use as long as you don't mix. If your
code depends on tab size then it's categorically wrong. Other people's tab
sizes are as valid. I use tabs because of the variation it lets me have - I
can switch tab sizes on the fly - and it's faster on dumb editors. So let
me do that.

But let us assume we were going to standardise on TAB == 8 SPACES. It would
*still* be bad to mix tabs and spaces. Hence you'd change Python in exactly
0 ways. So *what do you want from us*?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: JIT compilers for Python, what is the latest news?

2013-04-06 Thread Joshua Landau
On 5 April 2013 19:37, Devin Jeanpierre jeanpierr...@gmail.com wrote:

 On Fri, Apr 5, 2013 at 4:34 AM, John Ladasky john_lada...@sbcglobal.net
 wrote:
  On Thursday, April 4, 2013 7:39:16 PM UTC-7, MRAB wrote:
  Have you looked at Cython? Not quite the same, but still...
 
  I'm already using Numpy, compiled with what is supposed to be a fast
 LAPACK.  I don't think I want to attempt to improve on all the work that
 has gone into Numpy.

 There's no reason you can't use both cython and numpy. See:
 http://docs.cython.org/src/tutorial/numpy.html


Don't use this. Use memoryviews:
http://docs.cython.org/src/userguide/memoryviews.html. I have no idea why
that doc page isn't headed DEPRICATED by now.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: JIT compilers for Python, what is the latest news?

2013-04-06 Thread Joshua Landau
On 5 April 2013 03:29, John Ladasky john_lada...@sbcglobal.net wrote:

 I'm revisiting a project that I haven't touched in over a year.  It was
 written in Python 2.6, and executed on 32-bit Ubuntu 10.10.  I experienced
 a 20% performance increase when I used Psyco, because I had a
 computationally-intensive routine which occupied most of my CPU cycles, and
 always received the same data type.  (Multiprocessing also helped, and I
 was using that too.)

 I have now migrated to a 64-bit Ubuntu 12.10.1, and Python 3.3.  I would
 rather not revert to my older configuration.  That being said, it would
 appear from my initial reading that 1) Psyco is considered obsolete and is
 no longer maintained, 2) Psyco is being superseded by PyPy, 3) PyPy doesn't
 support Python 3.x, or 64-bit optimizations.

 Do I understand all that correctly?

 I guess I can live with the 20% slower execution, but sometimes my code
 would run for three solid days...


If you're not willing to go far, I've heard really, really good things
about Numba. I've not used it, but seriously:
http://jakevdp.github.io/blog/2012/08/24/numba-vs-cython/.

Also, PyPy is fine for 64 bit, even if it doesn't gain much from it. So
going back to 2.7 might give you that 20% back for almost free. It depends
how complex the code is, though.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a couple of questions: pickling objects and strict types

2013-04-06 Thread mblume
Am Sat, 06 Apr 2013 02:37:31 + schrieb Steven D'Aprano:
 [...]
  def __init__(self):
  self.events = {}
  self.components = []
  self.contents = []
  self.uid = uuid4().int
  self.events['OnLook'] = teventlet()
 
 
 Basically events don't get initialized like I'd like after I depickle
 objects.
 
 
 Correct, by default pickle does not call the __init__ method, it just
 reconstructs the instance. Basically, it takes a snapshot of the
 instance's internal state (the __dict__) and reconstructs from the
 snapshot.
 
 [...]

To the OP: Did you really mean
 self.events['OnLook'] = teventlet()
as opposed to:
 self.events['OnLook'] = teventlet

The first one executes teventlet and then assigns the result of the function to 
self.events['OnLook']. The second one assigns the function teventlet to the dict
entry (presumably so that it will be called when the objct detects the 'OnLook'
event). Unless the teventlet() function returns itself a function, an 'OnLook' 
event won't do anything useful during the remaining life time of the object, I 
think.

Regards
Martin




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


Re: Library to work with SSH public keys

2013-04-06 Thread Roy Smith
In article mailman.187.1365227369.3114.python-l...@python.org,
 Darren Spruell phatbuck...@gmail.com wrote:

 I'd like to work with user submitted/uploaded SSH public keys from
 Python. I'm trying to solve what I'd thought might be a simple need:
 given a user's OpenSSH formatted _public_ key (RSA, or DSA, or
 whatever), how do you obtain information about it such as: key type
 (e.g. ssh-rsa, etc.); bit length (e.g. 2048); key comment (e.g.
 user@hostname); key fingerprint? I've been fiddling with the Paramiko
 API and looked at PyCrypto (supports OpenSSH keys) and Twisted Conch
 but didn't see anything that looked like it did this.
 
 I'm looking for the equivalent to this:
 
 $ ssh-keygen -l -f tmp.key.pub
 2048 9b:31:06:6a:a4:79:97:33:d7:20:15:1f:cd:b4:86:4d dspruell@Sydney.local 
 (RSA)
 
 ...to get the attributes of the public key: key type, bit length,
 fingerprint and comment.
 
 Is there an SSH library capable of doing this from Python? Can break
 out to shell commands to parse them but I'd prefer not to.

The first hit on googling paramiko fingerprint got me this:

http://www.lag.net/paramiko/docs/paramiko.PKey-class.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I hate you all

2013-04-06 Thread Günther Dietrich
terminato...@gmail.com wrote:

[...]
 The def line has four spaces.  The for line then has a hard tab.
 This is ambiguous.  If the hard tab is assumed to have a width of four
 spaces, then they are at the same indentation level.  If it is assumed
 to have a width of eight spaces, then they are not.
[...]

The correct tab stop positions have always been at 8 character columns apart.
The ambiguity was introduced by editors that do not follow the default value 
set in hardware like printers or used by consoles and terminal emulators.

And now python forces me out of using any tab characters at all. I believe I 
should still have a choice, python should at lest give an option to set tab 
size, if the default of 8 is ambiguous now.

You know the Unix command 'expand'? If you used tabs representing eight 
columns consequently, use expand on your python scripts to convert tabs 
to spaces before running them.



Best regards,

Günther
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is operator versus id() function

2013-04-06 Thread Nobody
On Fri, 05 Apr 2013 06:49:14 -0700, Candide Dandide wrote:

 So, could someone please explain what exactly the is operator returns ?
 The official doc says :
 
 The ‘is‘ operator compares the identity of two objects; the id()
 function returns an integer representing its identity (currently
 implemented as its address). 

The docs are correct.

But an identity is only unique for the lifetime of the object, so
x is y and id(x)==id(y) are only equivalent if the lifetimes of
x and y overlap.

If the objects have disjoint lifetimes (i.e. one is created after the
other has been destroyed), then it's possible for id() to return the same
value for both objects, so id(x)==id(y) can return a false positive
result, as happened in your example.

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


Re: I hate you all

2013-04-06 Thread Nobody
On Fri, 05 Apr 2013 21:53:40 -0600, Ian Kelly wrote:

 8 characters is common, but no more correct than any other,

This is pure revisionism. 8-column tabs may never have been a significant
/de jure/ standard (although they have been that in many specific
domains), but they have been a significant /de facto/ standard for almost
as long as computers have existed.

Historically, software and hardware which assigns a meaning to a tab
character has come in two flavours:

1. Tab stops are every 8 columns; this cannot be changed.
2. Tab stops are configurable, defaulting to every 8 columns.

Creating software which, in the absence of both a good reason and an
explicit mechanism for communicating the configured value, treats them as
configurable is usually a consequence of a code now, think later
mentality (although there may have be a few cases where it was a
deliberate embrace, extend, extinguish tactic).

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


Re: I hate you all

2013-04-06 Thread Chris Angelico
On Sun, Apr 7, 2013 at 12:52 AM, Nobody nob...@nowhere.com wrote:
 Historically, software and hardware which assigns a meaning to a tab
 character has come in two flavours:

 1. Tab stops are every 8 columns; this cannot be changed.
 2. Tab stops are configurable, defaulting to every 8 columns.

3. Tab stops are measured in something other than characters.

With variable-width fonts, it's illogical to set tab stops in
characters. DeScribe Word Processor defined them in centimeters, way
back in the early... well, I didn't meet it till the 90s, but I don't
know how long it had been around before that.

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


Re: I hate you all

2013-04-06 Thread Timothy Madden

On 06.04.2013 13:17, Joshua Landau wrote:
[...]


Yours frustratedly,

Joshua Landau



But seriously, please at least look like you've read other people's
posts. It doesn't matter what tabstop you use as long as you don't mix.


When the default tab size is 8, than tab size does matter.

Because it is too much to use as indent size. If you still want to use 
tabs, you are now supposed to change tab size from the default. I 
believe using non-default tab size in a public environment like 
open-source code is bound to cause formatting problems for someone at 
some point.



If your code depends on tab size then it's categorically wrong. Other
people's tab sizes are as valid. I use tabs because of the variation it
lets me have - I can switch tab sizes on the fly - and it's faster on
dumb editors. So let me do that.

But let us assume we were going to standardise on TAB == 8 SPACES. It
would *still* be bad to mix tabs and spaces. Hence you'd change Python
in exactly 0 ways. So *what do you want from us*?


Well all previous (python 2) code is meant to work for a tab size of 8. 
You may call this categorically wrong, but it has been there a long 
while, is is still in use, and it sticks to the default.


Spaces-only can achieve compatibility between different people settings 
for formatted text like source code. But so does a common default for 
the tab size, and with that we do not have to limit ourselves to spaces 
only.


Now I understand python 3 people may already use tabs with a size of 4, 
as you said. Although I tried to show this is not good practice, (and 
that not many people do that, really, since most of them prefer to use 
all-spaces instead), still I do not expect the people to change their 
settings.


What I would expect is some option in python to make tabs work the way 
they used to. I want a choice for me to preserve my settings, the same 
way you want to preserve yours.


What I want should not be much to ask, since this is how python 2 used 
to do things.


I admit such a '--fixed-tabs' option, that will make tab stops be 8 
columns apart, and allow any number of spaces like in python 2, makes 
the code I write dependent on that option.


But the option will run all code written for the new python 3 way, and 
brings back some compatibility, so it is not that bad. And some people 
might actually want it.


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


Re: I hate you all

2013-04-06 Thread Timothy Madden

On 06.04.2013 17:20, Chris Angelico wrote:

On Sun, Apr 7, 2013 at 12:52 AM, Nobody nob...@nowhere.com wrote:

Historically, software and hardware which assigns a meaning to a tab
character has come in two flavours:

1. Tab stops are every 8 columns; this cannot be changed.
2. Tab stops are configurable, defaulting to every 8 columns.


3. Tab stops are measured in something other than characters.

With variable-width fonts, it's illogical to set tab stops in
characters. DeScribe Word Processor defined them in centimeters, way
back in the early... well, I didn't meet it till the 90s, but I don't
know how long it had been around before that.


Yes, but systems with variable-width fonts do not make the default for 
the tab size now.



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


[OT?]gmane not updating

2013-04-06 Thread breamoreboy
The gmane site is online but none of the Python lists I subscribe to have been 
updated for over 24 hours.  I fired off an email yesterday evening to larsi + 
gmane at gnus dot org but I've no idea whether there's anybody to read it, or 
even if it's actually been delivered :(  Is there anybody lurking who could 
stir the embers to get things rolling?

TIA.

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


Re: im.py: a python communications tool

2013-04-06 Thread Jake D
On Apr 5, 9:26 pm, Andrew Berg bahamutzero8...@gmail.com wrote:
 On 2013.04.05 20:07, Roy Smith wrote: I know this is off-topic, but I 
 encourage people to NOT invent their own
  licenses.

 Perhaps he meant this existing license:http://www.wtfpl.net/about/
 --
 CPython 3.3.0 | Windows NT 6.2.9200 / FreeBSD 9.1

Yep.  As a matter of fact, I did.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I hate you all

2013-04-06 Thread Roy Smith
In article mailman.200.1365258042.3114.python-l...@python.org,
 Chris Angelico ros...@gmail.com wrote:

 On Sun, Apr 7, 2013 at 12:52 AM, Nobody nob...@nowhere.com wrote:
  Historically, software and hardware which assigns a meaning to a tab
  character has come in two flavours:
 
  1. Tab stops are every 8 columns; this cannot be changed.
  2. Tab stops are configurable, defaulting to every 8 columns.
 
 3. Tab stops are measured in something other than characters.
 
 With variable-width fonts, it's illogical to set tab stops in
 characters. DeScribe Word Processor defined them in centimeters, way
 back in the early... well, I didn't meet it till the 90s, but I don't
 know how long it had been around before that.

What makes sense for a word processor and what makes sense for a 
programming language are two very different things.

Word processors are almost always working with blocks of running text, 
set in proportional fonts, often with multiple font sizes and styles.  
It is usually assumed that line breaks are ephemeral, i.e. as the text 
gets edited and reformatted, lines will re-flow.

Program text is almost always(*) displayed in a fixed-width font.  No 
font information is carried along with the program text at all; it is 
assumed the reader will pick a font and size of their own preference, 
with the only requirement being that it's monospaced.

(*) There was a fad about 10 or 15 years ago to print code samples in 
books in proportional fonts.  Prentice-Hall seemed to be particularly 
guilty of this.  Fortunately, common sense prevailed and everybody has 
gone back to monotype.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTPserver: how to access variables of a higher class?

2013-04-06 Thread Tom P

On 04/05/2013 02:27 PM, Dylan Evans wrote:

On 05/04/2013 9:09 PM, Tom P werot...@freent.dd wrote:


First, here's a sample test program:
code
import sys
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler

class MyRequestHandler(BaseHTTPRequestHandler, object):
 def do_GET(self):
 top_self = super(MyRequestHandler, self) # try to access

MyWebServer instance

 self.send_response(200)
 self.send_header('Content-type','text/html')
 self.end_headers()
 self.wfile.write(thanks for trying, but I'd like to get at

self.foo and self.bar)

 return

class MyWebServer(object):
 def __init__(self):
 self.foo = foo  # these are what I want to access from inside

do_GET

 self.bar = bar
 self.httpd = HTTPServer(('127.0.0.1', 8000), MyRequestHandler)
 sa = self.httpd.socket.getsockname()
 print Serving HTTP on, sa[0], port, sa[1], ...

 def runIt(self):
 self.httpd.serve_forever()

server = MyWebServer()
server.runIt()

/code

I want to access the foo and bar variables from do_GET, but I can't

figure out how. I suppose this is something to do with new-style vs.
old-style classes, but I lost for a solution.

Consider inheriting HTTPServer in MyWebServer which is passed to the
request handler.


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




I keep getting the same problem - if inherit from any of these classes 
in BaseHTTPServer and try to use super(class, self) to initiate the 
higher class, I get the error TypeError: must be type, not classobj - 
in other words, these are old-style classes.

That means that in this call -
self.httpd = MyHTTPServer(('127.0.0.1', 8000), MyRequestHandler)

there doesn't seem to be a way to define a
 class MyHTTPServer(HTTPServer)





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


Re: I hate you all

2013-04-06 Thread Neil Cerutti
On 2013-04-06, Roy Smith r...@panix.com wrote:
 (*) There was a fad about 10 or 15 years ago to print code
 samples in books in proportional fonts.  Prentice-Hall seemed
 to be particularly guilty of this.  Fortunately, common sense
 prevailed and everybody has gone back to monotype.

Bjarne Stroustrup likes it, and I agree with him that code is
even easier to read that way, especially in hard-copy.

But most tools have not caught up with the idea. I'll switch as
soon as vim supports it.

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


Re: I hate you all

2013-04-06 Thread Grant Edwards
On 2013-04-05, terminato...@gmail.com terminato...@gmail.com wrote:

[Mad that in 3.3 you can no longer use ambiguous mixtures of spaces
and tabs within a single indent level.]

My boss would refer to this as a failure to be bug-compatible with
the previous version.

Whether or not to maintain bug-compatibility when you bring out a new
version is one of the eternal debates.  No matter what you do, it's
going to annoy somebody...

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


Re: I hate you all

2013-04-06 Thread Grant Edwards
On 2013-04-06, Timothy Madden terminato...@gmail.com wrote:

 When the default tab size is 8, than tab size does matter.

There is no default size.  The size of a tab isn't even constant
across a line -- they're individually adjustable.  The tabs default 
to wherever they were left by the last person who used the typewriter.

All assumptions about the size or predictabilty of tabs are erroneous.

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


Re: I hate you all

2013-04-06 Thread rusi
On Apr 6, 8:01 pm, Roy Smith r...@panix.com wrote:
 What makes sense for a word processor and what makes sense for a
 programming language are two very different things.

 Word processors are almost always working with blocks of running text,
 set in proportional fonts, often with multiple font sizes and styles.
 It is usually assumed that line breaks are ephemeral, i.e. as the text
 gets edited and reformatted, lines will re-flow.

 Program text is almost always(*) displayed in a fixed-width font.  No
 font information is carried along with the program text at all; it is
 assumed the reader will pick a font and size of their own preference,
 with the only requirement being that it's monospaced.

 (*) There was a fad about 10 or 15 years ago to print code samples in
 books in proportional fonts.  Prentice-Hall seemed to be particularly
 guilty of this.  Fortunately, common sense prevailed and everybody has
 gone back to monotype.

Hmm…
One of my favourite books on programming is Intro to functional
programming by Bird and Wadler (1st edition Prentice Hall).
I always knew that part of why I liked the book was the beautifully
typeset code.
Now I know how this choice dates me!!
[It was published in 1988; I used it to teach from '89 onwards]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: im.py: a python communications tool

2013-04-06 Thread Jake D
On Apr 5, 8:52 pm, Demian Brecht demianbre...@gmail.com wrote:
 Thanks for sharing some of your work with the community. However...

 Speaking to the sharing aspect: Why would you post a block of code in an
 email? If you're looking for people to contribute, it would likely be a
 much better idea to post it on github (which was built for collaborative
 work).

 As for the code itself, if you /know/ it sucks and are advertising it as
 such, you're not really enticing people to work on it. In its current
 state, it looks like a non-extensible prototype, just poking around to see
 how you can achieve a p2p connectivity, without doing /any/ research
 (supporting modules, etc) or design before just starting to throw something
 together.

 I'd venture to say that the chances of actually getting anyone to
 contribute to this in its current state (especially purely over a mailing
 list) would be slim to none. People generally tend to want to see that
 there's actually effort and thought put into something before they put
 /their/ own time into it.

Jeez, harsh.  I __am__ putting this on github, and I __am__ coming
back to this program and working on it now.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I hate you all

2013-04-06 Thread Grant Edwards
On 2013-04-06, Ethan Furman et...@stoneleaf.us wrote:
 On 04/05/2013 10:36 PM, Timothy Madden wrote:

 8-character tab stops should be the default. Debating that is I believe 
 another topic, and compatibility with python2
 should be enough to make that debate unnecessary.

 Python 3 broke a lot of things.  Pull on your big-boy underwear and
 deal with it.

Python 3 requires that you wear _underwear_?

That seems entirely arbitrary, and violates the god-given rights of
telecommuters to write code wearing nothing but a bathrobe!

Hell, for all I know, there may be people who go into the office
without underwear. Though I think the lonely, unbathed, unshaven,
robe-wearing telecommuter will be the poster-child for the worldwide
campaign against the undwearist fascists trying to impose their
sartorial dictates on Python users.  Next, we need to pick a song...

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


Re: JIT compilers for Python, what is the latest news?

2013-04-06 Thread rusi
On Apr 5, 7:29 am, John Ladasky john_lada...@sbcglobal.net wrote:
 I guess I can live with the 20% slower execution, but sometimes my code would 
 run for three solid days...


Oooff! Do you know where your goal-posts are?
ie if your code were redone in (top-class) C or Fortran would it go
from 3 days to 2 days or 2 hours?
[The 'top-class' qualification is needed because it could also go from
3 days to 5!]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I hate you all

2013-04-06 Thread Grant Edwards
On 2013-04-06, Neil Cerutti ne...@norwich.edu wrote:
 On 2013-04-06, Roy Smith r...@panix.com wrote:
 (*) There was a fad about 10 or 15 years ago to print code
 samples in books in proportional fonts.  Prentice-Hall seemed
 to be particularly guilty of this.  Fortunately, common sense
 prevailed and everybody has gone back to monotype.

 Bjarne Stroustrup likes it, and I agree with him that code is
 even easier to read that way, especially in hard-copy.

I'd have to disagree.  There are too many times when things are easier
to read/maintain by visually aligning columns:

 * struct/array initializers

 * constant definitions

 * parallel/identical operations on multiple different variables

 * vertical alignment of a parameter lists in multi-line function calls

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


Re: I hate you all

2013-04-06 Thread Roy Smith
In article kjpffa$n35$4...@reader1.panix.com,
 Grant Edwards invalid@invalid.invalid wrote:

 On 2013-04-06, Ethan Furman et...@stoneleaf.us wrote:
  On 04/05/2013 10:36 PM, Timothy Madden wrote:
 
  8-character tab stops should be the default. Debating that is I believe 
  another topic, and compatibility with python2
  should be enough to make that debate unnecessary.
 
  Python 3 broke a lot of things.  Pull on your big-boy underwear and
  deal with it.
 
 Python 3 requires that you wear _underwear_?

Only at PyCon.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I hate you all

2013-04-06 Thread Roy Smith
In article kjpet5$n35$2...@reader1.panix.com,
 Grant Edwards invalid@invalid.invalid wrote:

 On 2013-04-05, terminato...@gmail.com terminato...@gmail.com wrote:
 
 [Mad that in 3.3 you can no longer use ambiguous mixtures of spaces
 and tabs within a single indent level.]
 
 My boss would refer to this as a failure to be bug-compatible with
 the previous version.
 
 Whether or not to maintain bug-compatibility when you bring out a new
 version is one of the eternal debates.  No matter what you do, it's
 going to annoy somebody...

I remember the first VAX was got.  We used some third-party serial card 
because it cost a small fraction of the official DEC version.  We had 
all sorts of trouble with it.  Eventually it turned out that the 
third-party card was operating correctly according to the DEC specs, but 
the driver had been written to work against genuine DEC hardware, which 
didn't follow their own published spec!

I vaguely remember it had to do with how the DMA processor dealt with 
odd-sized block transfers.  As I recall, there was a software patch to 
the driver which allowed it to work with the correctly implemented 
hardware, but I could be messing up most of the details.

Great machine, that VAX.  For only $100k, three or four people could 
play rogue at the same time!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I hate you all

2013-04-06 Thread Roy Smith
In article asasgofj03...@mid.individual.net,
 Neil Cerutti ne...@norwich.edu wrote:
 
 Bjarne Stroustrup likes it

This is supposed to impress me?

Yeah, most of the books I recall that used this were C++ books.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I hate you all

2013-04-06 Thread rusi
On Apr 6, 8:41 pm, Grant Edwards inva...@invalid.invalid wrote:
 On 2013-04-06, Neil Cerutti ne...@norwich.edu wrote:

  On 2013-04-06, Roy Smith r...@panix.com wrote:
  (*) There was a fad about 10 or 15 years ago to print code
  samples in books in proportional fonts.  Prentice-Hall seemed
  to be particularly guilty of this.  Fortunately, common sense
  prevailed and everybody has gone back to monotype.

  Bjarne Stroustrup likes it, and I agree with him that code is
  even easier to read that way, especially in hard-copy.

 I'd have to disagree.  There are too many times when things are easier
 to read/maintain by visually aligning columns:

  * struct/array initializers

  * constant definitions

  * parallel/identical operations on multiple different variables

  * vertical alignment of a parameter lists in multi-line function calls

 --
 Grant

I believe that it is at least possible to wish for the best of all
worlds.
http://nickgravgaard.com/elastictabstops/ (browser needs java)

Pragmatically I continue to use emacs with a fixed-width font.
Not claiming I am too happy with this choice. That includes a whole
lot of stuff, not just fonts
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I hate you all

2013-04-06 Thread Neil Cerutti
On 2013-04-06, Roy Smith r...@panix.com wrote:
 In article asasgofj03...@mid.individual.net,
  Neil Cerutti ne...@norwich.edu wrote:
  
 Bjarne Stroustrup likes it

 This is supposed to impress me?

Hehe. No!  But he's got enough clout to give the notion some
traction.

 Yeah, most of the books I recall that used this were C++ books.

Yes, that would be why I bet.

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


Re: Performance of int/long in Python 3

2013-04-06 Thread Serhiy Storchaka

04.04.13 00:57, Chris Angelico написав(ла):

On Thu, Apr 4, 2013 at 2:07 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:

On Thu, 04 Apr 2013 01:17:28 +1100, Chris Angelico wrote:


Probably, but it still has to scan the body of the string. It'd not be
too bad if it's all astral, but if it's all BMP, it has to scan the
whole string. In the max() case, it has to scan the whole string anyway,
as there's no other way to determine the maximum. I'm thinking here of
this function:

http://pike.lysator.liu.se/generated/manual/modref/ex/7.2_3A_3A/String/

width.html


It's implemented as a simple lookup into the header. (Pike strings, like
PEP 393 strings, are stored in the most compact way possible - 1, 2, or
4 bytes per character - with a conceptually similar header structure.)
Is this something that would be worth having available? Should I post an
issue about it?


I'm not really sure why I would want to know, apart from pure
intellectual curiosity, but sure, post a feature request. Be sure to
mention that Pike supports this feature.


http://bugs.python.org/issue17629 opened.


See also the discussion at 
http://comments.gmane.org/gmane.comp.python.ideas/15640 . I agree with 
rejection. This is an implementation detail and different Python 
implementations (including future CPython versions) can have different 
internal string implementations.



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


Re: JIT compilers for Python, what is the latest news?

2013-04-06 Thread Robert Kern

On 2013-04-05 09:39, John Ladasky wrote:

On Friday, April 5, 2013 1:27:40 AM UTC-7, Chris Angelico wrote:

1) Can you optimize your algorithms? Three days of processing is... a LOT.


Neural network training.  Yes, it takes a long time.  Still, it's not the most 
tedious code I run.  I also do molecular-dynamics simulations with GROMACS, 
those runs can take over a week!


2) Rewrite some key portions in C, possibly using Cython (as MRAB suggested).


And as I replied to MRAB, my limiting code is within Numpy.  I've taken care to 
look for ways that I might have been using Numpy itself inefficiently (and I 
did find a problem once: fixing it tripled my execution speed).  But I would 
like to think that Numpy itself, since it is already a C extension, should be 
optimal.


Well, Psyco obviously wasn't optimizing numpy. I believe the suggestion is to 
identify the key parts of the code that Psyco was optimizing to get you the 20% 
performance increase and port those to Cython.


--
Robert Kern

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

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


Re: [OT?]gmane not updating

2013-04-06 Thread Mark Lawrence

On 06/04/2013 15:51, breamore...@yahoo.co.uk wrote:

The gmane site is online but none of the Python lists I subscribe to have been 
updated for over 24 hours.  I fired off an email yesterday evening to larsi + 
gmane at gnus dot org but I've no idea whether there's anybody to read it, or 
even if it's actually been delivered :(  Is there anybody lurking who could 
stir the embers to get things rolling?

TIA.

Mark Lawrence



Forget it normal service has been resumed :)

--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: [OT?]gmane not updating

2013-04-06 Thread Neal Becker
breamore...@yahoo.co.uk wrote:

 The gmane site is online but none of the Python lists I subscribe to have been
 updated for over 24 hours.  I fired off an email yesterday evening to larsi +
 gmane at gnus dot org but I've no idea whether there's anybody to read it, or
 even if it's actually been delivered :(  Is there anybody lurking who could
 stir the embers to get things rolling?
 
 TIA.
 
 Mark Lawrence

Working again.  Funny how you come to rely on these things.  There is no 
alternative to gmane.

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


Re: JIT compilers for Python, what is the latest news?

2013-04-06 Thread Stefan Behnel
Joshua Landau, 06.04.2013 12:27:
 On 5 April 2013 03:29, John Ladasky wrote:
 I'm revisiting a project that I haven't touched in over a year.  It was
 written in Python 2.6, and executed on 32-bit Ubuntu 10.10.  I experienced
 a 20% performance increase when I used Psyco, because I had a
 computationally-intensive routine which occupied most of my CPU cycles, and
 always received the same data type.  (Multiprocessing also helped, and I
 was using that too.)

 I have now migrated to a 64-bit Ubuntu 12.10.1, and Python 3.3.  I would
 rather not revert to my older configuration.  That being said, it would
 appear from my initial reading that 1) Psyco is considered obsolete and is
 no longer maintained, 2) Psyco is being superseded by PyPy, 3) PyPy doesn't
 support Python 3.x, or 64-bit optimizations.

 Do I understand all that correctly?

 I guess I can live with the 20% slower execution, but sometimes my code
 would run for three solid days...
 
 If you're not willing to go far, I've heard really, really good things
 about Numba. I've not used it, but seriously:
 http://jakevdp.github.io/blog/2012/08/24/numba-vs-cython/.
 
 Also, PyPy is fine for 64 bit, even if it doesn't gain much from it. So
 going back to 2.7 might give you that 20% back for almost free. It depends
 how complex the code is, though.

I would guess that the main problem is rather that PyPy doesn't support
NumPy (it has its own array implementation, but that's about it). John
already mentioned that most of the heavy lifting in his code is done by NumPy.

Stefan


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


Error in Python NLTK

2013-04-06 Thread subhabangalore
Dear Group,

I was using a package named NLTK in Python. 

I was trying to write a code given in section 3.8 of 

http://docs.huihoo.com/nltk/0.9.5/guides/tag.html.

Here, in the  test = ['up', 'down', 'up'] if I put more than 3 values and 
trying to write the reciprocal codes, like,

sequence = [(t, None) for t in test] and print '%.3f' % 
(model.probability(sequence))

I am getting an error as, 

Traceback (most recent call last): File , line 1, in 
model.probability(sequence) File 
C:\Python27\lib\site-packages\nltk\tag\hmm.py, line 228, in probability 
return 2**(self.log_probability(self._transform.transform(sequence))) File 
C:\Python27\lib\site-packages\nltk\tag\hmm.py, line 259, in log_probability 
alpha = self._forward_probability(sequence) File 
C:\Python27\lib\site-packages\nltk\tag\hmm.py, line 694, in 
_forward_probability alpha[0, i] = self._priors.logprob(state) + \ File 
C:\Python27\lib\site-packages\nltk\probability.py, line 689, in logprob elif 
self._prob_dict[sample] == 0: return _NINF ValueError: The truth value of an 
array with more than one element is ambiguous. Use a.any() or a.all()

If any learned member may kindly assist me how may I solve the issue. 

Regards, 
Subhabrata.
-- 
http://mail.python.org/mailman/listinfo/python-list


[RELEASE] Python 2.7.4

2013-04-06 Thread Benjamin Peterson
I'm thrilled to announce the release of Python 2.7.4.

2.7.4 is the latest maintenance release in the Python 2.7 series. It includes
hundreds of bugfixes to the core language and standard library.

Downloads are at

http://python.org/download/releases/2.7.4/

As always, please report bugs to

http://bugs.python.org/

Several regressions found in the release candidate have been fixed. Many thanks
to those who tested the preview release.

There has recently been a lot of discussion about XML-based denial of service
attacks. Specifically, certain XML files can cause XML parsers, including ones
in the Python stdlib, to consume gigabytes of RAM and swamp the CPU. 2.7.4 does
not include any changes in Python XML code to address these issues. Interested
parties should examine the defusedxml package on PyPI:
https://pypi.python.org/pypi/defusedxml

This is a production release.

Best wishes,
Benjamin Peterson
2.7 Release Manager
(on behalf of all of Python 2.7's contributors)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I hate you all

2013-04-06 Thread Larry Hudson

On 04/05/2013 10:36 PM, Timothy Madden wrote:

[snip...]


8-character tab stops should be the default. Debating that is I believe another 
topic, and
compatibility with python2 should be enough to make that debate unnecessary.

As everyone keeps telling you -- there is NO default tab size.  Default implies there is an 
OFFICIAL definition, there is none.  There is, however, convention -- which is merely a common 
suggestion, without any force implied.



What I want is an option to use the tabs as I have used them in the past, with 
the default size.
Since ambiguity about the tab size appears to be the cause for new python 3 
rules, I though of
an option the make that size explicit. I still think users should somehow have 
a way to use a
tab stop of their choice, but how this could be achieved properly is another 
problem.

What you want and what you think are irrelevant.  The Python language (whatever version) is 
already defined.  If you want to use it, you have to accept it and adapt to what it is.  Live 
with it and move on.  Complaining about it is a complete waste of time -- it's NOT going to 
change just because YOU don't like it.


Frankly, with your continuing to rant about this subject is simply making yourself look like an 
obstinate fool.  I've enjoyed following this thread because I find your attitude so ridiculously 
amusing.[1]



I guess a discussion like this thread is the price to be paid for relying 
solely on white space
to delimit code blocks, like the python syntax does.


And in actual practice, that has been shown to be a Good Thing.


Thank you,
Timothy Madden


 -=- Larry -=-

[1].  I just turned 76 and definitely tend to be a curmudgeon, so sorry if I sound too 
insulting, but it is the way I feel.


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


[RELEASED] Python 3.2.4 and Python 3.3.1

2013-04-06 Thread Georg Brandl
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On behalf of the Python development team, I am pleased to announce the
final releases of Python 3.2.4 and 3.3.1.

Python 3.2.4 is the final regular maintenance release for the Python 3.2
series, while Python 3.3.1 is the first maintenance release for the 3.3
series.  Both releases include hundreds of bugfixes.

There has recently been a lot of discussion about XML-based denial of service
attacks. Specifically, certain XML files can cause XML parsers, including ones
in the Python stdlib, to consume gigabytes of RAM and swamp the CPU. These
releases do not include any changes in Python XML code to address these issues.
Interested parties should examine the defusedxml package on PyPI:
https://pypi.python.org/pypi/defusedxml

To download Python 3.2.4 or Python 3.3.1, visit:

http://www.python.org/download/releases/3.2.4/  or
http://www.python.org/download/releases/3.3.1/

respectively.  As always, please report bugs to

http://bugs.python.org/

Enjoy!

- -- 
Georg Brandl, Release Manager
georg at python.org
(on behalf of the entire python-dev team and all contributors)
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.19 (GNU/Linux)

iEYEARECAAYFAlFgiN8ACgkQN9GcIYhpnLAXxQCdHAd2lECpYfmYM4Wbd3I01es4
898AoKBDvHtgecD/PeVRKUrdQRSWGPJg
=K8RQ
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error in Python NLTK

2013-04-06 Thread Dave Angel

On 04/06/2013 03:56 PM, subhabangal...@gmail.com wrote:

Dear Group,

I was using a package named NLTK in Python.

I was trying to write a code given in section 3.8 of

http://docs.huihoo.com/nltk/0.9.5/guides/tag.html.

Here, in the  test = ['up', 'down', 'up'] if I put more than 3 values and 
trying to write the reciprocal codes, like,

 sequence = [(t, None) for t in test] and print '%.3f' % 
(model.probability(sequence))


This 'and' operator is going to try to interpret the previous list as a 
boolean.  Could that be your problem?  Why aren't you putting these two 
statements on separate lines?  And what version of Python are you using? 
 If 2.x, you should get a syntax error because print is a statement. 
If 3.x, you should get a different error because you don't put parens 
around the preint expression.




I am getting an error as,

Traceback (most recent call last): File , line 1, in model.probability(sequence) File 
C:\Python27\lib\site-packages\nltk\tag\hmm.py, line 228, in probability return 
2**(self.log_probability(self._transform.transform(sequence))) File C:\Python27\lib\site-packages\nltk\tag\hmm.py, 
line 259, in log_probability alpha = self._forward_probability(sequence) File 
C:\Python27\lib\site-packages\nltk\tag\hmm.py, line 694, in _forward_probability alpha[0, i] = 
self._priors.logprob(state) + \ File C:\Python27\lib\site-packages\nltk\probability.py, line 689, in logprob elif 
self._prob_dict[sample] == 0: return _NINF ValueError: The truth value of an array with more than one element is ambiguous. Use 
a.any() or a.all()

If any learned member may kindly assist me how may I solve the issue.



Your error display has been trashed, thanks to googlegroups.
http://wiki.python.org/moin/GoogleGroupsPython
Try posting with a text email message, since this is a text forum.

Your code is also sparse.  Why do you point us to fragments on the net, 
when you could show us the exact code you were running when it failed? 
I'm guessing you're running it from the interpreter, which can be very 
confusing once you have to ask for help.  Please put a sample of code 
into a file, run it, and paste into your text email both the contents of 
that file and the full traceback.  thanks.


The email address to post on this forum is  python-list@python.org


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


Re: [RELEASED] Python 3.2.4 and Python 3.3.1

2013-04-06 Thread cmcp
On Saturday, 6 April 2013 21:43:11 UTC+1, Georg Brandl  wrote:
 -BEGIN PGP SIGNED MESSAGE-
 
 Hash: SHA1
 
 
 
 On behalf of the Python development team, I am pleased to announce the
 
 final releases of Python 3.2.4 and 3.3.1.
 
The Python 3.3.1 Release page on python.org still says This is a preview 
release, and its use is not recommended in production settings.  I'm assuming 
this is just an oversight?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT?]gmane not updating

2013-04-06 Thread Grant Edwards
On 2013-04-06, Neal Becker ndbeck...@gmail.com wrote:

 Working again.  Funny how you come to rely on these things.  There is no 
 alternative to gmane.

I try not to think about that. I read this list via Usenet, but
there are a good dozen or so mailing lists for which I rely completely
on gmane.

-- 
Grant Edwards   grant.b.edwardsYow! Those people look
  at   exactly like Donnie and
  gmail.comMarie Osmond!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [RELEASED] Python 3.2.4 and Python 3.3.1

2013-04-06 Thread Georg Brandl
Am 06.04.2013 22:48, schrieb cmcp:
 On Saturday, 6 April 2013 21:43:11 UTC+1, Georg Brandl  wrote:
 -BEGIN PGP SIGNED MESSAGE-
 
 Hash: SHA1
 
 
 
 On behalf of the Python development team, I am pleased to announce the
 
 final releases of Python 3.2.4 and 3.3.1.
 
 The Python 3.3.1 Release page on python.org still says This is a preview
 release, and its use is not recommended in production settings.  I'm
 assuming this is just an oversight?

Yes.  Thanks for the report, it's fixed now.

Georg

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


Re: Error in Python NLTK

2013-04-06 Thread subhabangalore
On Sunday, April 7, 2013 2:14:41 AM UTC+5:30, Dave Angel wrote:
 On 04/06/2013 03:56 PM, subhabangal...@gmail.com wrote:
 
  Dear Group,
 
 
 
  I was using a package named NLTK in Python.
 
 
 
  I was trying to write a code given in section 3.8 of
 
 
 
  http://docs.huihoo.com/nltk/0.9.5/guides/tag.html.
 
 
 
  Here, in the  test = ['up', 'down', 'up'] if I put more than 3 values 
  and trying to write the reciprocal codes, like,
 
 
 
   sequence = [(t, None) for t in test] and print '%.3f' % 
  (model.probability(sequence))
 
 
 
 This 'and' operator is going to try to interpret the previous list as a 
 
 boolean.  Could that be your problem?  Why aren't you putting these two 
 
 statements on separate lines?  And what version of Python are you using? 
 
   If 2.x, you should get a syntax error because print is a statement. 
 
 If 3.x, you should get a different error because you don't put parens 
 
 around the preint expression.
 
 
 
 
 
  I am getting an error as,
 
 
 
  Traceback (most recent call last): File , line 1, in 
  model.probability(sequence) File 
  C:\Python27\lib\site-packages\nltk\tag\hmm.py, line 228, in probability 
  return 2**(self.log_probability(self._transform.transform(sequence))) File 
  C:\Python27\lib\site-packages\nltk\tag\hmm.py, line 259, in 
  log_probability alpha = self._forward_probability(sequence) File 
  C:\Python27\lib\site-packages\nltk\tag\hmm.py, line 694, in 
  _forward_probability alpha[0, i] = self._priors.logprob(state) + \ File 
  C:\Python27\lib\site-packages\nltk\probability.py, line 689, in logprob 
  elif self._prob_dict[sample] == 0: return _NINF ValueError: The truth value 
  of an array with more than one element is ambiguous. Use a.any() or a.all()
 
 
 
  If any learned member may kindly assist me how may I solve the issue.
 
 
 
 
 
 Your error display has been trashed, thanks to googlegroups.
 
  http://wiki.python.org/moin/GoogleGroupsPython
 
 Try posting with a text email message, since this is a text forum.
 
 
 
 Your code is also sparse.  Why do you point us to fragments on the net, 
 
 when you could show us the exact code you were running when it failed? 
 
 I'm guessing you're running it from the interpreter, which can be very 
 
 confusing once you have to ask for help.  Please put a sample of code 
 
 into a file, run it, and paste into your text email both the contents of 
 
 that file and the full traceback.  thanks.
 
 
 
 The email address to post on this forum is  python-list@python.org
 
 
 
 
 
 -- 
 
 DaveA

Thanks Dave for your kind suggestions. I am checking on them and if I get any 
questions I am sending the room in detailed manner. Regards,Subhabrata.
-- 
http://mail.python.org/mailman/listinfo/python-list


Finding The Best Deals For Hair Care

2013-04-06 Thread 23alagmy
Finding The Best Deals For Hair Care

http://natigtas7ab.blogspot.com/2013/03/finding-best-deals-for-hair-care.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Performance of int/long in Python 3

2013-04-06 Thread Chris Angelico
On Sat, Apr 6, 2013 at 8:09 PM, Serhiy Storchaka storch...@gmail.com wrote:
 04.04.13 00:57, Chris Angelico написав(ла):
 http://bugs.python.org/issue17629 opened.


 See also the discussion at
 http://comments.gmane.org/gmane.comp.python.ideas/15640 . I agree with
 rejection. This is an implementation detail and different Python
 implementations (including future CPython versions) can have different
 internal string implementations.

I really don't see why this means that there can't be a function in
sys, or something. I mean, other Pythons aren't expected to return the
exact same values from sys.getsizeof, are they? But clearly the weight
of opinion is against me, so fine, I don't care that much.

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


Re: I hate you all

2013-04-06 Thread Chris Angelico
On Sun, Apr 7, 2013 at 2:01 AM, Roy Smith r...@panix.com wrote:
 In article mailman.200.1365258042.3114.python-l...@python.org,
  Chris Angelico ros...@gmail.com wrote:

 On Sun, Apr 7, 2013 at 12:52 AM, Nobody nob...@nowhere.com wrote:
  Historically, software and hardware which assigns a meaning to a tab
  character has come in two flavours:
 
  1. Tab stops are every 8 columns; this cannot be changed.
  2. Tab stops are configurable, defaulting to every 8 columns.

 3. Tab stops are measured in something other than characters.

 With variable-width fonts, it's illogical to set tab stops in
 characters. DeScribe Word Processor defined them in centimeters, way
 back in the early... well, I didn't meet it till the 90s, but I don't
 know how long it had been around before that.

 What makes sense for a word processor and what makes sense for a
 programming language are two very different things.

Yes. I was just completing the set, since the heading didn't specify
*for programming languages*.

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


Re: The SOLUTION HTTPserver: how to access variables of a higher class

2013-04-06 Thread Tom P

On 04/05/2013 01:02 PM, Tom P wrote:

ok, after much experimenting it looks like the solution is as follows:

class MyWebServer(object):
def __init__(self):
  #  self.foo = foo  delete these from self
   # self.bar = bar
myServer = HTTPServer
myServer.foo = foo  #define foo,bar here
myServer.bar = bar

self.httpd = myServer(('127.0.0.1', 8000), MyRequestHandler)

Then, in the request handler:
class MyRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
ss=self.server
print ss.foo


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


The Story of Jesus and Mary in the Holy Quran

2013-04-06 Thread BV BV
The Story of Jesus and Mary in the Holy Quran

The following three part series consists entirely of verses from the
Holy Quran about Mary (Mother of
Jesus) including her birth, childhood, personal qualities, and the
miraculous birth of Jesus.
This part explores the life of the Prophet Jesus, his message,
miracles, his disciples and what is mentioned about them in the Holy
Quran.
This part explores the verses of the Holy Quran that talk about God’s
protection of Jesus, his followers, his second coming in this world
and what will happen to him on the day of resurrection.


http://www.islamhouse.com/p/409136


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


Re: Performance of int/long in Python 3

2013-04-06 Thread Ethan Furman

On 04/06/2013 02:24 PM, Chris Angelico wrote:

On Sat, Apr 6, 2013 at 8:09 PM, Serhiy Storchaka storch...@gmail.com wrote:

04.04.13 00:57, Chris Angelico написав(ла):

http://bugs.python.org/issue17629 opened.



See also the discussion at
http://comments.gmane.org/gmane.comp.python.ideas/15640 . I agree with
rejection. This is an implementation detail and different Python
implementations (including future CPython versions) can have different
internal string implementations.


I really don't see why this means that there can't be a function in
sys, or something. I mean, other Pythons aren't expected to return the
exact same values from sys.getsizeof, are they?


What it boils down to is:

  - it can easily be done by hand now
  - it's a very uncommon need

ergo:

  - it's not worth the time and on-going effort required

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


Cannot install readline in pythonbrew install of 3.3.0

2013-04-06 Thread Gene

Hi,

I hope someone can help with this problem with pythonbrew on my mac 
running OS X 10.8.3 with updated Xcode and CLT.


$PATH = 
/Users/Gene/.pythonbrew/bin:/Users/Gene/.pythonbrew/pythons/Python-3.3.0/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin


$PYTHONPATH = /Users/Gene/.pythonbrew/pythons/Python-3.3.0/lib

The python 3.3.0 install using pythonbrew was made with default options 
and seems to be working okay but when I easy_install readline per 
ipython recommend:


BTW, readline has been installed for the system python 2.7.3 on this Mac 
for over a year and works fine.


Switched to Python-3.3.0
easy_install readline
Searching for readline
Reading http://pypi.python.org/simple/readline/
Reading http://github.com/ludwigschwardt/python-readline
Reading http://www.python.org/
Best match: readline 6.2.4.1
Downloading 
http://pypi.python.org/packages/source/r/readline/readline-6.2.4.1.tar.gz#md5=578237939c81fdbc2c8334d168b17907

Processing readline-6.2.4.1.tar.gz
Writing 
/var/folders/51/k4qphs517k3c9dv55_23b6j8gp/T/easy_install-ypwvg6/readline-6.2.4.1/setup.cfg
Running readline-6.2.4.1/setup.py -q bdist_egg --dist-dir 
/var/folders/51/k4qphs517k3c9dv55_23b6j8gp/T/easy_install-ypwvg6/readline-6.2.4.1/egg-dist-tmp-9hwdkl
In file included from 
/Users/Ceti/.pythonbrew/pythons/Python-3.3.0/include/python3.3m/Python.h:112:0,

from Modules/3.x/readline.c:8:
/Users/Ceti/.pythonbrew/pythons/Python-3.3.0/include/python3.3m/modsupport.h:29:1: 
warning: ‘PyArg_ParseTuple’ is an unrecognized format function type 
[-Wformat=]
PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...) 
Py_FORMAT_PARSETUPLE(PyArg_ParseTuple, 2, 3);

^
/var/folders/51/k4qphs517k3c9dv55_23b6j8gp/T//ccEk88Hx.s:9:`_begidx(%rip)' 
is not a valid base/index expression
/var/folders/51/k4qphs517k3c9dv55_23b6j8gp/T//ccEk88Hx.s:10:bad 
register name `%rax)'
/var/folders/51/k4qphs517k3c9dv55_23b6j8gp/T//ccEk88Hx.s:20:`_endidx(%rip)' 
is not a valid base/index expression
/var/folders/51/k4qphs517k3c9dv55_23b6j8gp/T//ccEk88Hx.s:21:bad 
register name `%rax)'
/var/folders/51/k4qphs517k3c9dv55_23b6j8gp/T//ccEk88Hx.s:31:bad 
register name `%rdi'
/var/folders/51/k4qphs517k3c9dv55_23b6j8gp/T//ccEk88Hx.s:48:bad 
register name `%r15'


These bad register name errors stream for many pages then the install 
fails.


Here's the last line of the install:
error: Setup script exited with error: command 'gcc' failed with exit 
status 1


Any ideas?
Thanks,
Gene
--
http://mail.python.org/mailman/listinfo/python-list


Re: How do I tell if I'm running under IDLE?

2013-04-06 Thread Terry Jan Reedy

On 4/5/2013 5:30 AM, Steven D'Aprano wrote:


I'm looking for an official way to tell what interpreter (if any) is
running, or at least a not-too-horrible unofficial way.


The interpreters distributed by PSF identify themselves on startup, as 
least in interactive mode, by displaying a line like Python 3.3.0+ 
(default, Mar 30 2013, 17:36:11) [MSC v.1600 32 bit (Intel)] on win32
The version available as sys.version, sys.hexversion, and 
sys._version(). The platform is available as sys.platform. The compiler 
and compile date are not officially available.


But you seem not to be actually asking 'what interpreter is running' but 
'who started the interpreter' and 'is the interpreter i/o connected to a 
text-mode OS console or to a gui program, such as IDLE, more or less 
simulating an OS console.


There is no official way because it should not matter to a running 
program. It is the goal of at least some IDLE developers to make the 
connection to the IDLE shell as transparent as possible to Python code, 
so that it matters as little as possible*. This is one reason for the 
shift from running user code in the same process and interpreter 
instance as Idle to running user code in a separate process with its own 
interpreter instance.


* There are current tracker issues about making this true. We really do 
not want people to have to write conditional code, unless it is to work 
around a console problem if Idle is not being used ;-).


If you have an issue not already covered on the tracker, I am curious 
what it is.



Googling comes up with a number of hacks for detecting IDLE. Some of them
are terrible. For example, I can't believe that somebody actually
suggested this:

if len(sys.modules)  20:
 print running under IDLE


This is based on the fact that if running in the same process, there are 
a lot more imported modules and if running in a separate process, there 
are at least a few more imported modules to set up the rpc connection. I 
do not know that '20' is particularly reliable, even on startup.



This one is better, but still not exactly what I consider great:


Why not, if is works for all Idle versions so far? The irreducible 
effect of any non-OS-console environment is to override the normal i/o.



sys.stdin.__class__.__module__.startswith('idlelib')


'idlelib' in sys.stdin.__class__.__module__' is possibly more future-proof.


Ideally, I'd like to detect any arbitrary environment such as Spyder,
IPython, BPython, etc., but will settle for just IDLE.


I expect that looking as sys.stdin in someway should work for all.

--
Terry Jan Reedy


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


Re: How do I tell if I'm running under IDLE?

2013-04-06 Thread Mark Janssen
 (Apologies in advance if you get multiple copies of this. My Usenet
 connection seems to be having a conniption fit at the moment.)

 I'm looking for an official way to tell what interpreter (if any) is
 running, or at least a not-too-horrible unofficial way.

I was going to work on this IDLE TODO myself, but haven't got around
to it.  I think the best way is to use the tempfile module (to be
clear this is a fix within IDLE itself).

This is the whole procedure that should be necessary:

1) At IDLE startup check to see if there is an existing idle tempfile
and delete it, if so.
2) Create an IDLE temp file.
3) At IDLE shutdown, delete prior tempfile.

Now if anyone wants to see if IDLE is running, they only need to check
to see if the tempfile exists.

Hope that helps.  If you implement it, you can take the item off the
IDLE todo list too.

MarkJ
Tacoma, Washington
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I tell if I'm running under IDLE?

2013-04-06 Thread Dave Angel

On 04/06/2013 08:35 PM, Mark Janssen wrote:

(Apologies in advance if you get multiple copies of this. My Usenet
connection seems to be having a conniption fit at the moment.)

I'm looking for an official way to tell what interpreter (if any) is
running, or at least a not-too-horrible unofficial way.


I was going to work on this IDLE TODO myself, but haven't got around
to it.  I think the best way is to use the tempfile module (to be
clear this is a fix within IDLE itself).

This is the whole procedure that should be necessary:

1) At IDLE startup check to see if there is an existing idle tempfile
and delete it, if so.
2) Create an IDLE temp file.
3) At IDLE shutdown, delete prior tempfile.

Now if anyone wants to see if IDLE is running, they only need to check
to see if the tempfile exists.

Hope that helps.  If you implement it, you can take the item off the
IDLE todo list too.



Are you assuming then that there can be only one instance of IDLE ?  And 
that if a separate Python program is run, we should pretend that it's 
running under IDLE?



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


raw_input that able to do detect multiple input

2013-04-06 Thread Frank
Hi all, I would require advise on this question for function call interact:

the desire outcome:
interact()
Friends File: friends.csv
Command: f John Cleese
John Cleese: Ministry of Silly Walks, 421, 27 October
Command: f Michael Palin
Unknown friend Michael Palin
Command: f
Invalid Command: f
Command: a Michael Palin
Invalid Command: a Michael Palin
Command: a John Cleese, Cheese Shop, 5552233, 5 May
John Cleese is already a friend
Command: a Michael Palin, Cheese Shop, 5552233, 5 May
Command: f Michael Palin
Michael Palin: Cheese Shop, 5552233, 5 May
Command: e
Saving changes...
Exiting...

my code so far for interact:
#interact function
def interact(*arg):
open('friends.csv', 'rU')
d = load_friends('friends.csv')
print Friends File: friends.csv
s = raw_input(Please input something: )
command = s.split( , 1)
if f in command:
display_friends(command,load_friends('friends.csv'))
print command

#display friend function
def display_friends(name, friends_list):
Fname = name[0]
for item in friends_list:
if item[0] == Fname:
print item
break
else:
print False

Let say if i type in  f John Cleese  and after the line 6 , my value of 
command should be ['f', 'John Cleese']. Is there ways to extract out John 
Cleese as a input so that i could use it on my function call display_friends ?


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


Re: Performance of int/long in Python 3

2013-04-06 Thread Steven D'Aprano
On Sat, 06 Apr 2013 14:58:23 -0700, Ethan Furman wrote:

 On 04/06/2013 02:24 PM, Chris Angelico wrote:
 On Sat, Apr 6, 2013 at 8:09 PM, Serhiy Storchaka storch...@gmail.com
 wrote:
 04.04.13 00:57, Chris Angelico написав(ла):
 http://bugs.python.org/issue17629 opened.


 See also the discussion at
 http://comments.gmane.org/gmane.comp.python.ideas/15640 . I agree with
 rejection. This is an implementation detail and different Python
 implementations (including future CPython versions) can have different
 internal string implementations.

 I really don't see why this means that there can't be a function in
 sys, or something. I mean, other Pythons aren't expected to return the
 exact same values from sys.getsizeof, are they?
 
 What it boils down to is:
 
- it can easily be done by hand now

For some definition of easily.

if implementation == CPython:
if version  3.3:
if sys.maxunicode exists:
use it to decide whether this is a wide or narrow build
if a wide build: return 4
else: return 2
else:
???
elif version == 3.3:
scan the string, in some efficient or inefficient way
return 1, 2, 4 depending on the largest character you find
else:
???
else:
???



- it's a very uncommon need


Well, that at least is true. But then, needing to know the platform 
you're running under, the size of objects, the id of a object, the 
largest integer, the largest float, or the number of references seen by 
the garbage collector are also uncommon needs. What really matters is not 
how often you need it, but what you can do when you need it if you don't 
have it.



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


Re: I hate you all

2013-04-06 Thread Steven D'Aprano
On Sun, 07 Apr 2013 01:20:32 +1100, Chris Angelico wrote:

 On Sun, Apr 7, 2013 at 12:52 AM, Nobody nob...@nowhere.com wrote:
 Historically, software and hardware which assigns a meaning to a tab
 character has come in two flavours:

 1. Tab stops are every 8 columns; this cannot be changed. 2. Tab stops
 are configurable, defaulting to every 8 columns.
 
 3. Tab stops are measured in something other than characters.
 
 With variable-width fonts, it's illogical to set tab stops in
 characters. DeScribe Word Processor defined them in centimeters, way
 back in the early... well, I didn't meet it till the 90s, but I don't
 know how long it had been around before that.


Am I the only one here who has used a typewriter?

Tab stops were set manually, to a physical distance into the page, using 
a mechanical stop. This long predates the rule that tab stops are every 
8 characters.

If your editor doesn't support setting tab stops to at least single pixel 
resolution, it's not supporting tabs, it's supporting something else that 
it merely calls tabs.



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


Re: I hate you all

2013-04-06 Thread Steven D'Aprano
On Sat, 06 Apr 2013 11:01:04 -0400, Roy Smith wrote:

 In article mailman.200.1365258042.3114.python-l...@python.org,
  Chris Angelico ros...@gmail.com wrote:
 
 On Sun, Apr 7, 2013 at 12:52 AM, Nobody nob...@nowhere.com wrote:
  Historically, software and hardware which assigns a meaning to a tab
  character has come in two flavours:
 
  1. Tab stops are every 8 columns; this cannot be changed. 2. Tab
  stops are configurable, defaulting to every 8 columns.
 
 3. Tab stops are measured in something other than characters.
 
 With variable-width fonts, it's illogical to set tab stops in
 characters. DeScribe Word Processor defined them in centimeters, way
 back in the early... well, I didn't meet it till the 90s, but I don't
 know how long it had been around before that.
 
 What makes sense for a word processor and what makes sense for a
 programming language are two very different things.
 
 Word processors are almost always working with blocks of running text,
 set in proportional fonts, often with multiple font sizes and styles. It
 is usually assumed that line breaks are ephemeral, i.e. as the text gets
 edited and reformatted, lines will re-flow.

Word processors mostly use tabs for aligning text, e.g. in tables and 
lists. Exactly the same thing that tabs are used for in source code.

Large blocks of running text are irrelevant, because tabs are rarely used 
inside large blocks of running text.


 Program text is almost always(*) displayed in a fixed-width font.  No
 font information is carried along with the program text at all; it is
 assumed the reader will pick a font and size of their own preference,

And tab settings.

If you're going to complain that changing the tab settings will break the 
layout of the source code, so will changing the font and size.



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


Re: raw_input that able to do detect multiple input

2013-04-06 Thread Dave Angel

On 04/06/2013 09:03 PM, Frank wrote:

Hi all, I would require advise on this question for function call interact:

the desire outcome:
interact()
Friends File: friends.csv
Command: f John Cleese
John Cleese: Ministry of Silly Walks, 421, 27 October
Command: f Michael Palin
Unknown friend Michael Palin
Command: f
Invalid Command: f
Command: a Michael Palin
Invalid Command: a Michael Palin
Command: a John Cleese, Cheese Shop, 5552233, 5 May
John Cleese is already a friend
Command: a Michael Palin, Cheese Shop, 5552233, 5 May
Command: f Michael Palin
Michael Palin: Cheese Shop, 5552233, 5 May
Command: e
Saving changes...
Exiting...

my code so far for interact:
#interact function
def interact(*arg):
 open('friends.csv', 'rU')
 d = load_friends('friends.csv')
 print Friends File: friends.csv
 s = raw_input(Please input something: )
 command = s.split( , 1)
 if f in command:
 display_friends(command,load_friends('friends.csv'))
 print command

#display friend function
def display_friends(name, friends_list):
Fname = name[0]
for item in friends_list:
 if item[0] == Fname:
 print item
 break
 else:
 print False

Let say if i type in  f John Cleese  and after the line 6 , my value of command 
should be ['f', 'John Cleese']. Is there ways to extract out John Cleese as a input so that i could use it on 
my function call display_friends ?




Nothing about this message makes any sense to me. The function 
display_friends() has no body.  Code for load_friends() is missing.  You 
seem to be confusing variable names with literal strings. You open an 
input file friends.csv, but never use the file handle.  You store the 
return value of load_friends() in d, but never use it.  The desire 
outcome includes lots of stuff that this code won't be producing.


And I cannot understand the question you ask at the end.  However, one 
thing I see that's wrong is the user is apparently typing a leading and 
trailinb blank on the line.  If you want to strip out whitespace before 
and after, just use strip().



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


Re: HTTPserver: how to access variables of a higher class?

2013-04-06 Thread Dylan Evans
On Sun, Apr 7, 2013 at 1:05 AM, Tom P werot...@freent.dd wrote:

 On 04/05/2013 02:27 PM, Dylan Evans wrote:

 On 05/04/2013 9:09 PM, Tom P werot...@freent.dd wrote:


 First, here's a sample test program:
 code
 import sys
 from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler

 class MyRequestHandler(**BaseHTTPRequestHandler, object):
  def do_GET(self):
  top_self = super(MyRequestHandler, self) # try to access

 MyWebServer instance

  self.send_response(200)
  self.send_header('Content-**type','text/html')
  self.end_headers()
  self.wfile.write(thanks for trying, but I'd like to get at

 self.foo and self.bar)

  return

 class MyWebServer(object):
  def __init__(self):
  self.foo = foo  # these are what I want to access from inside

 do_GET

  self.bar = bar
  self.httpd = HTTPServer(('127.0.0.1', 8000), MyRequestHandler)
  sa = self.httpd.socket.getsockname(**)
  print Serving HTTP on, sa[0], port, sa[1], ...

  def runIt(self):
  self.httpd.serve_forever()

 server = MyWebServer()
 server.runIt()

 /code

 I want to access the foo and bar variables from do_GET, but I can't

 figure out how. I suppose this is something to do with new-style vs.
 old-style classes, but I lost for a solution.

 Consider inheriting HTTPServer in MyWebServer which is passed to the
 request handler.

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



 I keep getting the same problem - if inherit from any of these classes in
 BaseHTTPServer and try to use super(class, self) to initiate the higher
 class, I get the error TypeError: must be type, not classobj - in other
 words, these are old-style classes.
 That means that in this call -
 self.httpd = MyHTTPServer(('127.0.0.1', 8000), MyRequestHandler)

 there doesn't seem to be a way to define a
  class MyHTTPServer(HTTPServer)



You can call the __init__ method on the class as a workaround for it being
old style. This works on 2.7


from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler

class MyRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'text/plain')
self.end_headers()
self.wfile.write('Got foo? %s' % self.server.foo)


class MyWebServer(HTTPServer):
def __init__(self):
self.foo = 'foo'
HTTPServer.__init__(self, ('127.0.0.1', 8000), MyRequestHandler)
sa = self.socket.getsockname()
print Serving HTTP on, sa[0], port, sa[1]

def runit(self):
self.serve_forever()

server = MyWebServer()
server.runit()





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




-- 
The UNIX system has a command, nice ... in order to be nice to the other
users. Nobody ever uses it. - Andrew S. Tanenbaum
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Performance of int/long in Python 3

2013-04-06 Thread Ian Kelly
On Sat, Apr 6, 2013 at 7:29 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 For some definition of easily.

 if implementation == CPython:
 if version  3.3:
 if sys.maxunicode exists:
 use it to decide whether this is a wide or narrow build
 if a wide build: return 4
 else: return 2
 else:
 ???
 elif version == 3.3:
 scan the string, in some efficient or inefficient way
 return 1, 2, 4 depending on the largest character you find
 else:
 ???
 else:
 ???

None of which goes away if a char width function is added to 3.4 and
you still want to support earlier versions as this does.  It just adds
another if.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Performance of int/long in Python 3

2013-04-06 Thread Ian Kelly
On Sat, Apr 6, 2013 at 3:24 PM, Chris Angelico ros...@gmail.com wrote:
 On Sat, Apr 6, 2013 at 8:09 PM, Serhiy Storchaka storch...@gmail.com wrote:
 04.04.13 00:57, Chris Angelico написав(ла):
 http://bugs.python.org/issue17629 opened.


 See also the discussion at
 http://comments.gmane.org/gmane.comp.python.ideas/15640 . I agree with
 rejection. This is an implementation detail and different Python
 implementations (including future CPython versions) can have different
 internal string implementations.

 I really don't see why this means that there can't be a function in
 sys, or something. I mean, other Pythons aren't expected to return the
 exact same values from sys.getsizeof, are they? But clearly the weight
 of opinion is against me, so fine, I don't care that much.

If you want it, nobody is stopping you from writing it yourself as an
extension module.  But I don't think the use case is strong enough to
warrant the devs adding it and then having to maintain it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I hate you all

2013-04-06 Thread Roy Smith
In article 5160cc44$0$29995$c3e8da3$54964...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

 On Sun, 07 Apr 2013 01:20:32 +1100, Chris Angelico wrote:
 
  On Sun, Apr 7, 2013 at 12:52 AM, Nobody nob...@nowhere.com wrote:
  Historically, software and hardware which assigns a meaning to a tab
  character has come in two flavours:
 
  1. Tab stops are every 8 columns; this cannot be changed. 2. Tab stops
  are configurable, defaulting to every 8 columns.
  
  3. Tab stops are measured in something other than characters.
  
  With variable-width fonts, it's illogical to set tab stops in
  characters. DeScribe Word Processor defined them in centimeters, way
  back in the early... well, I didn't meet it till the 90s, but I don't
  know how long it had been around before that.
 
 
 Am I the only one here who has used a typewriter?
 
 Tab stops were set manually, to a physical distance into the page, using 
 a mechanical stop. This long predates the rule that tab stops are every 
 8 characters.

Yup.  I learned on a good old manual, with mechanical Tab Set and Tab 
Clear function.

Of course, on an 029, you set the tab stops by punching a drum card.

 If your editor doesn't support setting tab stops to at least single pixel 
 resolution, it's not supporting tabs, it's supporting something else that 
 it merely calls tabs.

Yup.  I use emacs.  M-X edit tab stops does that.  Like so much else 
about emacs, I haven't used that feature in years (gee, maybe decades), 
but it's nice to know it's there.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Performance of int/long in Python 3

2013-04-06 Thread Roy Smith
In article mailman.222.1365299932.3114.python-l...@python.org,
 Ian Kelly ian.g.ke...@gmail.com wrote:

 On Sat, Apr 6, 2013 at 7:29 PM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
  For some definition of easily.
 
  if implementation == CPython:
  if version  3.3:
  if sys.maxunicode exists:
  use it to decide whether this is a wide or narrow build
  if a wide build: return 4
  else: return 2
  else:
  ???
  elif version == 3.3:
  scan the string, in some efficient or inefficient way
  return 1, 2, 4 depending on the largest character you find
  else:
  ???
  else:
  ???
 
 None of which goes away if a char width function is added to 3.4 and
 you still want to support earlier versions as this does.  It just adds
 another if.

The same is true of any new feature.  That doesn't mean we shouldn't add 
new features.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I hate you all

2013-04-06 Thread Jason Friedman
 Am I the only one here who has used a typewriter?

 I used one.  And http://en.wikipedia.org/wiki/White-Out.  And
http://en.wikipedia.org/wiki/Correction_tape.

My wife typed her dissertation on this:
http://en.wikipedia.org/wiki/File:Hardwarewordprocessor.png.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cannot install readline in pythonbrew install of 3.3.0

2013-04-06 Thread Ned Deily
In article 5160bcbc.3030...@gmail.com, Gene spaceb...@gmail.com 
wrote:
 I hope someone can help with this problem with pythonbrew on my mac 
 running OS X 10.8.3 with updated Xcode and CLT.
[...] 
 The python 3.3.0 install using pythonbrew was made with default options 
 and seems to be working okay but when I easy_install readline per 
 ipython recommend:
[...]
 Any ideas?

pythonbrew does its own funky things above and beyond standard OS X 
Python installs.  Further, the PyPI readline distribution (which 
substitutes GNU readline for the OS X default BSD editline library) does 
its own funky things.  I don't use either so I'm copping out here and 
not going to try to debug what's going wrong when you try to use them 
together.  You *might* be better off just manually building and 
installing GNU readline in /usr/local and then use pythonbrew to rebuild 
Python 3.3 (3.3.1 was just released, BTW).  Otherwise, you could search 
the pythonbrew issue list and open an issue there, if necessary.  Or use 
a python.org 3.3 along with PyPI readline.  Or install ipython3.3, 
Python 3.3, and GNU readline from MacPorts or Homebrew.

https://github.com/utahta/pythonbrew/issues

-- 
 Ned Deily,
 n...@acm.org

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


Re: I hate you all

2013-04-06 Thread Dylan Evans
Then you see my point, unless you are being told what to use by a boss then
there are plenty of other languages you can choose from. Python is rigid
about it's format, that's just what it is and a lot of people like it but
if it's not your thing then some other language will probably suit you
better. However, if you are working for a company, or OSS project, you are
probably going to have your style dictated whatever language you use, for
example the 2 space indents (*shudder*) that google uses in c++
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Spaces_vs._Tabs#Spaces_vs._Tabs
(Interestingly
google use 4 space indents in python for compatibility with PEP-8
http://google-styleguide.googlecode.com/svn/trunk/pyguide.html?showone=Indentation#Indentation
)

You probably won't like everything in a project style but it's not about
being tyrannical, and it's not a bad thing to have restrictions at the
language level.

I work for a company with a load of lagacy c formatted as follows:

int many_many_globals;
int func(int iFoo,int iBar)
{
int var = 10;
if(iBar1)
{
var=iFoo+many_many_globals;
}
return var;
}

So i am pretty happy to adopt a language which defines a sane style.

This is a nice flame war you have stirred up.



On Sat, Apr 6, 2013 at 3:13 PM, terminato...@gmail.com wrote:

 On Saturday, April 6, 2013 7:28:55 AM UTC+3, Dylan Evans wrote:
  On Sat, Apr 6, 2013 at 7:41 AM,  termin...@gmail.com wrote:
 
  Hello
 
 
  I just tried python 3.3 with some simple script meant for unit test.
 
  How can python authors be so arrogant to impose their tabs and spaces
 options on me ? It should be my choice if I want to use tabs or not !
 
 
  Don't like it? Use ruby.


 Actually next on my list is perl. I know ruby is sexy, but taming the wild
 beast is what makes me feel like the real cowboy.
 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
The UNIX system has a command, nice ... in order to be nice to the other
users. Nobody ever uses it. - Andrew S. Tanenbaum
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: raw_input that able to do detect multiple input

2013-04-06 Thread Frank
Hi Dave,


Sorry for my unclear question.
I didn't use the  d = load_friends('friends.csv') now because I'm going use it 
for other function later on, I should have remove it first to avoid confusion.

This is the code for load_friends , add_info ,display_friends, save_friends 
function:

def load_friends(filename):
f = open(filename, 'rU')
for row in f:
return list (row.strip() for row in f)

def add_info(new_info, new_list):
# Persons name is the first item of the list
name = new_info[0]
# Check if we already have an item with that name
for item in new_list:
if item[0] == name:
print %s is already in the list % name
return False
# Insert the item into the list
new_list.append(new_info)
return True

def display_friends(name, friends_list):
Fname = name[0]
for item in friends_list:
if item[0] == Fname:
print item
break
else:
print False

def save_friends(friend_info, new_list):
with open(friend_info, 'w') as f:
for line in new_list:
f.write(line + '\n')


I will elaborate my question further  , when the user type the function call 
interact() this will appear :

interact() 
Friends File: friends.csv 

so after which the user would type in the command call maybe we call it  F 
John Cleese, the program need to know if the user input contain a f a or 
e at the first char and 

if 'f' it mean it would takes a name as an argument, prints out the information 
about that friend or prints an error message if the given name is notthe name 
of a friend in the database(friends.csv).

if a it would takes four arguments (comma separated) with information
about a person and adds that person as a friend. An error message is printed
if that person is already a friend.

if e it would ends the interaction and, if the friends information has been
updated, the information is saved to the friends.csv.

This is the example output 

Command: f John Cleese 
John Cleese: Ministry of Silly Walks, 421, 27 October 
Command: f Michael Palin 
Unknown friend Michael Palin 
Command: f 
Invalid Command: f 
Command: a Michael Palin 
Invalid Command: a Michael Palin 
Command: a John Cleese, Cheese Shop, 5552233, 5 May 
John Cleese is already a friend 
Command: a Michael Palin, Cheese Shop, 5552233, 5 May 
Command: f Michael Palin 
Michael Palin: Cheese Shop, 5552233, 5 May 
Command: e 
Saving changes... 
Exiting... 

So currently I think i had my other functions ready but I do not know how do i 
apply it into interact() 

my rough idea is :

def interact(*arg): 
open('friends.csv', 'rU') 
d = load_friends('friends.csv') 
print Friends File: friends.csv 
s = raw_input() 
command = s.split( , 1) 
if f in command: 
# invoke display_friends function 
print result
elif a in command:
# invoke add_info function
print result
elif e in command:
# invoke save_friends function
print result

My idea is to split the user command out to ['f', 'John Cleese'] and use the 
'F' to invoke my f in the if statement and then i would use the 
display_friends function to process 'John Cleese' but i'm not sure if i'm able 
to do it this way 




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


Re: raw_input that able to do detect multiple input

2013-04-06 Thread Dave Angel

On 04/06/2013 11:22 PM, Frank wrote:

Hi Dave,


Sorry for my unclear question.
I didn't use the  d = load_friends('friends.csv') now because I'm going use it 
for other function later on, I should have remove it first to avoid confusion.

This is the code for load_friends , add_info ,display_friends, save_friends 
function:

def load_friends(filename):
 f = open(filename, 'rU')
 for row in f:
 return list (row.strip() for row in f)


This is a mighty confusing way of skipping the first line.  You make it 
look like a loop, but it only executes once, since you have a return 
inside.  Besides, when you save the data, you don't put an extra header 
line at the top.  So it's not consistent.




def add_info(new_info, new_list):
 # Persons name is the first item of the list
 name = new_info[0]
 # Check if we already have an item with that name
 for item in new_list:
 if item[0] == name:
 print %s is already in the list % name
 return False
 # Insert the item into the list
 new_list.append(new_info)
 return True

def display_friends(name, friends_list):
 Fname = name[0]
 for item in friends_list:
 if item[0] == Fname:
 print item
 break
 else:
 print False

def save_friends(friend_info, new_list):
 with open(friend_info, 'w') as f:
 for line in new_list:
 f.write(line + '\n')


Now you've saved the data in a different file.  How does the next run of 
the program find it?





I will elaborate my question further  , when the user type the function call 
interact()


What user?  In what environment can a user enter function calls into 
your code?



this will appear :

interact()
Friends File: friends.csv

so after which the user would type in the command call maybe we call it  F John Cleese, the program need to 
know if the user input contain a f a or e at the first char and

if 'f' it mean it would takes a name as an argument, prints out the information 
about that friend or prints an error message if the given name is notthe name 
of a friend in the database(friends.csv).

if a it would takes four arguments (comma separated) with information
about a person and adds that person as a friend. An error message is printed
if that person is already a friend.

if e it would ends the interaction and, if the friends information has been
updated, the information is saved to the friends.csv.

This is the example output

Command: f John Cleese
John Cleese: Ministry of Silly Walks, 421, 27 October
Command: f Michael Palin
Unknown friend Michael Palin
Command: f
Invalid Command: f


Why is the command invalid?


Command: a Michael Palin
Invalid Command: a Michael Palin
Command: a John Cleese, Cheese Shop, 5552233, 5 May
John Cleese is already a friend


That's not the way the message is worded in the code


Command: a Michael Palin, Cheese Shop, 5552233, 5 May
Command: f Michael Palin
Michael Palin: Cheese Shop, 5552233, 5 May
Command: e
Saving changes...
Exiting...

So currently I think i had my other functions ready but I do not know how do i 
apply it into interact()

my rough idea is :

def interact(*arg):
 open('friends.csv', 'rU')
 d = load_friends('friends.csv')
 print Friends File: friends.csv
 s = raw_input()
 command = s.split( , 1)
 if f in command:


You don't really want in here.  You just want the first field to match 
f  So why not:

   if f == command[0]:


 # invoke display_friends function


In this function and in save_friends, there is no return value, so not 
clear what you mean by  'result'



 print result
 elif a in command:
 # invoke add_info function
 print result
 elif e in command:
 # invoke save_friends function
 print result

My idea is to split the user command out to ['f', 'John Cleese'] and use the 'F' to 
invoke my f in the if statement and then i would use the display_friends 
function to process 'John Cleese' but i'm not sure if i'm able to do it this way




It's all over but the debugging.  What's the real question?


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


Re: raw_input that able to do detect multiple input

2013-04-06 Thread Frank
Now you've saved the data in a different file.  How does the next run of 
the program find it? 


What user?  In what environment can a user enter function calls into 
your code? 
-The user will call the function out from IDLE

Why is the command invalid? 
-Because the user need to type out a name after the f

That's not the way the message is worded in the code 
- because if user type in  a John Cleese, Cheese Shop, 5552233, 5 May
it mean it would takes four arguments (comma separated) with information 
about a person and adds that person to my friends.csv. An error message is 
printed if that person is already a friend. Because the name John Cleese is 
already in my friends.csv that why it will prompt out John Cleese is already a 
friend

In this function and in save_friends, there is no return value, so not 
clear what you mean by  'result' 

e ends the interaction and, if the friends information has been
updated, the information is saved to the friends.csv , i think i used the wrong 
function for this.

The question I'm told to work on:
interact() is the top-level function that denes the text-base user interface
as described in the introduction.

Here is an example of what is expected from your program. The input is
everything after Command: on a line (and the initial friends.csv). Every-
thing else is output. Your output should be exactly the same as below for
the given input.

interact() 
Friends File: friends.csv 
Command: f John Cleese 
John Cleese: Ministry of Silly Walks, 421, 27 October 
Command: f Michael Palin 
Unknown friend Michael Palin 
Command: f 
Invalid Command: f 
Command: a Michael Palin 
Invalid Command: a Michael Palin 
Command: a John Cleese, Cheese Shop, 5552233, 5 May 
John Cleese is already a friend 
Command: a Michael Palin, Cheese Shop, 5552233, 5 May 
Command: f Michael Palin 
Michael Palin: Cheese Shop, 5552233, 5 May 
Command: e 
Saving changes... 
Exiting...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Performance of int/long in Python 3

2013-04-06 Thread Ian Kelly
On Sat, Apr 6, 2013 at 8:18 PM, Roy Smith r...@panix.com wrote:
 In article mailman.222.1365299932.3114.python-l...@python.org,
  Ian Kelly ian.g.ke...@gmail.com wrote:

 On Sat, Apr 6, 2013 at 7:29 PM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
  For some definition of easily.
 
  if implementation == CPython:
  if version  3.3:
  if sys.maxunicode exists:
  use it to decide whether this is a wide or narrow build
  if a wide build: return 4
  else: return 2
  else:
  ???
  elif version == 3.3:
  scan the string, in some efficient or inefficient way
  return 1, 2, 4 depending on the largest character you find
  else:
  ???
  else:
  ???

 None of which goes away if a char width function is added to 3.4 and
 you still want to support earlier versions as this does.  It just adds
 another if.

 The same is true of any new feature.  That doesn't mean we shouldn't add
 new features.

If you're interested in backward compatibility, then as noted the
feature doesn't really make things any simpler for you.  Otherwise,
the only implementation that matters from the above is the 3.3 one,
which isn't much more complex.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: raw_input that able to do detect multiple input

2013-04-06 Thread Dave Angel
(You forgot to separate the parts of my comments that you were quoting 
from your responses.  Any decent email program will do that for you 
automatically, inserting   in front of each quoted line.  Then you 
just hit enter a couple of times to type the new stuff right after the 
part you're quoting.)



On 04/07/2013 01:00 AM, Frank wrote:

Now you've saved the data in a different file.  How does the next run of
the program find it?


What user?  In what environment can a user enter function calls into
your code?
-The user will call the function out from IDLE


So the user is the programmer.  No end-user would be using IDLE to run a 
program.




Why is the command invalid?
-Because the user need to type out a name after the f


But that wouldn't be an invalid command, but invalid data



That's not the way the message is worded in the code
- because if user type in  a John Cleese, Cheese Shop, 5552233, 5 May
it mean it would takes four arguments (comma separated) with information
about a person and adds that person to my friends.csv. An error message is printed if that person 
is already a friend. Because the name John Cleese is already in my friends.csv that why it will 
prompt out John Cleese is already a friend


So fix the code, I just pointed out that the message was different.  The 
code says  print %s is already in the list % name


Yet you say the message needs to be:
 John Cleese is already a friend

One or the other is incorrect.



In this function and in save_friends, there is no return value, so not
clear what you mean by  'result'

e ends the interaction and, if the friends information has been
updated, the information is saved to the friends.csv , i think i used the wrong 
function for this.


No, just the wrong filename.  I assumed you were going to rename it 
afterwards, tut apparently not.




The question I'm told to work on:
interact() is the top-level function that denes the text-base user interface
as described in the introduction.



So if you call interact() in your program at the top-level, then a 
non-programmer can run the program directly from the terminal window.



Here is an example of what is expected from your program. The input is
everything after Command: on a line (and the initial friends.csv). Every-
thing else is output. Your output should be exactly the same as below for
the given input.

interact()
Friends File: friends.csv
Command: f John Cleese
John Cleese: Ministry of Silly Walks, 421, 27 October
Command: f Michael Palin
Unknown friend Michael Palin
Command: f
Invalid Command: f
Command: a Michael Palin
Invalid Command: a Michael Palin
Command: a John Cleese, Cheese Shop, 5552233, 5 May
John Cleese is already a friend
Command: a Michael Palin, Cheese Shop, 5552233, 5 May
Command: f Michael Palin
Michael Palin: Cheese Shop, 5552233, 5 May
Command: e
Saving changes...
Exiting...



You will also need to add an argument to the raw_input() to have it 
produce the output specified.



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


[issue17642] IDLE add font resizing hot keys

2013-04-06 Thread Raymond Hettinger

New submission from Raymond Hettinger:

Add the standard hot keys for resizing fonts (i.e. on a Mac, CMD-plus and 
CMD-minus).

--
components: IDLE
keywords: easy
messages: 186118
nosy: rhettinger
priority: normal
severity: normal
stage: needs patch
status: open
title: IDLE add font resizing hot keys
type: enhancement
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4

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



[issue13922] argparse handling multiple -- in args improperly

2013-04-06 Thread paul j3

paul j3 added the comment:

I am working on an alternative solution that moves the '--' removal to the 
consume_positionals() method, and only does it if there is a corresponding '-' 
in the arg_strings_pattern.

--

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



[issue17642] IDLE add font resizing hot keys

2013-04-06 Thread Edmond Burnett

Changes by Edmond Burnett eburn...@gmail.com:


--
nosy: +edmond.burnett

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



[issue17629] Expose string width to Python

2013-04-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

See also the discussion at 
http://comments.gmane.org/gmane.comp.python.ideas/15640 . I agree with 
rejection. This is an implementation detail and different Python 
implementations (including future CPython versions) can have different internal 
string implementations.

--
nosy: +serhiy.storchaka

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



[issue17620] Python interactive console doesn't use sys.stdin for input

2013-04-06 Thread Drekin

Drekin added the comment:

Sorry for typos.
• interactive console doesn't use sys.stdin for input, why?
• it uses sys.stdin.encoding, shouldn't it rather use sys.__stdin__.encoding if 
anything?
• input() and hence code.interact() uses sys.stdin

--

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



[issue17620] Python interactive console doesn't use sys.stdin for input

2013-04-06 Thread Georg Brandl

Changes by Georg Brandl ge...@python.org:


--
assignee:  - pitrou
nosy: +pitrou

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



[issue17642] IDLE add font resizing hot keys

2013-04-06 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' g.rod...@gmail.com:


--
nosy: +giampaolo.rodola

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



[issue17643] Expose weakref callback for introspection purposes.

2013-04-06 Thread Mark Dickinson

New submission from Mark Dickinson:

It would be nice to be able to access the callback of a weakref as an attribute 
on the weakref itself.  For example:

Python 3.4.0a0 (default:2bf154ca43c6+, Apr  6 2013, 13:31:29) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type help, copyright, credits or license for more information.
 import weakref
 x = {1, 2, 3}
 ref = weakref.ref(x, lambda ref: print(done))
 ref.__callback__
function lambda at 0x1004f56d0
 del x
done
 ref.__callback__  # Returns None

I encountered this while writing a tool to show graphs of Python objects and 
their references to each other:  I wanted to be able to annotate each edge of 
the graph.  For something like a function, it's easy to use introspection to 
compare the reference target with f.__code__, f.__annotations__, etc.  For a 
weakref, I couldn't find an easy way to retrieve the callback (or even 
determine whether there *was* a callback associated to the weakref).  One can 
do a gc.get_referents call and hope that if there's exactly one object 
returned it's the callback, but that won't work so well with weakref.ref 
subclasses.

Patch attached:  it has tests but no doc updates as yet.

--
components: Interpreter Core
files: weakref___callback__.patch
keywords: patch
messages: 186122
nosy: mark.dickinson
priority: normal
severity: normal
stage: patch review
status: open
title: Expose weakref callback for introspection purposes.
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file29685/weakref___callback__.patch

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



[issue15518] Provide test coverage for filecmp.dircmp.report methods.

2013-04-06 Thread Eli Bendersky

Eli Bendersky added the comment:

A lot of the code in the tests is devoted to building the tested directory tree 
and populating it ( _setUpDirectories and related functions). You keep building 
and deleting this tree for every running test.

I think that a better idea would be to just create this tree somewhere in 
Lib/test (look at the directories under it - we can add a new one, like 
filecmpdata/) and then refer to it in the tests. This will remove a huge amount 
of code and should also make it easier to understand what exactly the contents 
of this tree are. For example then I can use other system Linux tools to 
explore the directory and figure out what I'd expect the tests to do.

When test data is very small and contained, it makes sense to just create it 
while the test is running. But the patch has  120 LOC for that with functions 
calling other functions. For someone not intimately familiar with the tests, 
it's hard to follow which files get created and their contents.

Other comments:

* Don't use external functions with 'self' to serve essentially as methods. 
Test classes can derive from some common class that provides such 
functionality. [not sure this will be relevant after the above refactoring]
* If you do pretty much the same thing for every tearDown, also consider 
refactoring it into a base class.

--

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



[issue17643] Expose weakref callback for introspection purposes.

2013-04-06 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Sounds fine to me.

--
nosy: +pitrou

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



[issue17643] Expose weakref callback for introspection purposes.

2013-04-06 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Instead of a getset, I think you just use a read-only T_OBJECT member.

--
nosy: +benjamin.peterson

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



[issue13477] tarfile module should have a command line

2013-04-06 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


Added file: http://bugs.python.org/file29686/issue13477_v4.diff

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



[issue13477] tarfile module should have a command line

2013-04-06 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


Removed file: http://bugs.python.org/file29311/issue13477_v2.diff

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



[issue15596] pickle: Faster serialization of Unicode strings

2013-04-06 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Since protocol 0 is essentially dead in Python 3, I would like to propose 
something simpler and safer: only optimize the binary protocols. If noone beats 
me to it, I'll adapt Victor's patch for that.

--

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



[issue17625] IDLE regression -- Search and Replace Window doesn't automatically clear

2013-04-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 13e5664c5d19 by Benjamin Peterson in branch '3.2':
close search and replace dialog after it is used (closes #17625)
http://hg.python.org/cpython/rev/13e5664c5d19

New changeset 7746d238c4bb by Benjamin Peterson in branch '3.3':
close search and replace dialog after it is used (closes #17625)
http://hg.python.org/cpython/rev/7746d238c4bb

--

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



[issue17538] Document XML Vulnerabilties

2013-04-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f45902f8c7d7 by Christian Heimes in branch '3.2':
Issue 17538: Document XML vulnerabilties
http://hg.python.org/cpython/rev/f45902f8c7d7

--

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



[issue17550] --enable-profiling does nothing (shell syntax bug in configure.ac)

2013-04-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 2ab2a09901f9 by Georg Brandl in branch '3.3':
fix variable reference to fix --enable-profiling (closes #17550)
http://hg.python.org/cpython/rev/2ab2a09901f9

--
stage:  - committed/rejected

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



[issue17644] str.format() crashes

2013-04-06 Thread Anton Poldnev

New submission from Anton Poldnev:

Windows interpreter immediately crashes on this command:
 {[{}]}.format({{}: 5})

--
messages: 186130
nosy: poldnev
priority: normal
severity: normal
status: open
title: str.format() crashes
type: crash
versions: Python 3.3

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



[issue17644] str.format() crashes

2013-04-06 Thread Ezio Melotti

Ezio Melotti added the comment:

Confirmed on Linux too.  This only affects 3.3+, on 2.7/3.2 it returns '5'.

--
components: +Interpreter Core, Unicode
nosy: +eric.smith, ezio.melotti, haypo, serhiy.storchaka
priority: normal - high
stage:  - needs patch
versions: +Python 3.4

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



  1   2   >