Re: Obnoxious postings from Google Groups

2012-11-07 Thread Steven D'Aprano
On Wed, 07 Nov 2012 18:52:16 +1300, Gregory Ewing wrote:

 Steven D'Aprano wrote:
 The downside is that if spaces are not argument separators, then you
 need something else to be an argument separator. Or you need argument
 delimiters. Or strings need to be quoted. Programming languages do
 these things because they are designed to be correct. Shell do not
 because they are designed for lazy users and merely aim to be good
 enough.
 
 That's overly judgemental. 

Judgemental, sure. Overly judgemental? Not in my opinion.

Besides, to some degree, all progress depends on the lazy person. It's 
less work to have the computer do it than to do it yourself. 


 In the environment where shells originated,
 not being able to easily put spaces in file names wasn't considered a
 problem. File names weren't thought of as names in the natural language
 sense, but as identifiers in the programming sense.

What you say may be true, but the question is, *why* did they think this? 
The closest analogue to computer files are paper files, which have always 
been treated as names in the natural language sense, and spaces allowed.

Miss Jones, fetch me the Acme Television Company file!

sort of thing. And this is exactly why people want spaces in file names, 
and have to be trained or prevented from doing so. So why did early 
shells ignore the (implied) business requirement that files represent 
natural names and instead treat them as programming identifiers?

Because it was the easy thing to do.


 You don't complain that you can't put spaces in identifiers in a Python
 program, do you? 

I would if I could. But that would require the language to be... smarter? 
Less easy to use? *More* easy to use? It would require a major paradigm 
shift, and so I don't expect to treat identifiers as names, and use 
either CamelCase or names_with_underscores instead, even when the result 
is ugly.

But that's not a fixed law of nature. If Inform 7 can include spaces in 
identifiers, so could other languages.

http://www.ifwiki.org/index.php/Inform_7_for_Programmers/Part_1



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


chocolate moonpies

2012-11-07 Thread Constantine

chocolate moonpies 
http://www.google.com/search?hl=enq=chocolate+moonpies+site:vandaydiigkij.blogspot.combtnI=I%27m+Feeling+Lucky
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multi-dimensional list initialization

2012-11-07 Thread Jussi Piitulainen
Steven D'Aprano writes:
 On Wed, 07 Nov 2012 00:23:44 +, MRAB wrote:

  I prefer the term reference semantics.
 
 Oh good, because what the world needs is yet another name for the
 same behaviour.
 
 - call by sharing
 - call by object sharing
 - call by object reference
 - call by object
 - call by value, where values are references 
   (according to the Java community)
 - call by reference, where references refer to objects, not variables
   (according to the Ruby community)
 - reference semantics
 
 Anything else?
 
 http://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_sharing

Something else:

There's a call-by-* versus pass-by-* distinction, where the call-by-*
would be rather different from any of the above:

- call-by-value is what most languages now use: argument expressions
  are reduced to values before they are passed to the function /
  procedure / method / whatever.

- call-by-name was something Algol 60 had by default: something like
  evaluating the argument expression every time its value is needed

- call-by-need: argument expression is reduced to a value the first
  time its value is needed (if ever)

- call-by-lazy (increasingly silly terminology, and I don't quite have
  an idea what it means in contrast to call-by-need)

The modern confusions would then be mostly over the pass-by-* family,
invariably using call-by-value in the above sense. The terminology for
these tends to produce more heat than light, but I think the relevant
distinctions are mostly just these:

- can one modify the argument effectively [Python: yes]

- can one modify the parameter with abandon [Python: don't]

- can one swap [Python: no]

- possibly: is it expensive to pass large objects? [Python: no]

The actual rule in Scheme, Java, and Python is the same simple and
sane rule: what are passed are values (argument expressions are fully
evaluated before the actual call takes place), parameter passing does
not involve any (observable) copying, and the arguments are bound to
fresh variables (no aliasing of variables).

Different communities use different words. Sometimes they use the same
words about different things. Resulting in more heat than light :(

(I'd have a few more things in the something-else department, but this
is already much longer than I thought. Ends.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multi-dimensional list initialization

2012-11-07 Thread wxjmfauth
Le mercredi 7 novembre 2012 02:55:10 UTC+1, Steven D'Aprano a écrit :

 
 
 
 
 
 
 Two-dimensional arrays in Python using lists are quite rare. Anyone who 
 
 is doing serious numeric work where they need 2D arrays is using numpy, 
 
 not lists. There are millions of people using Python, so it's hardly 
 
 surprising that once or twice a year some newbie trips over this. But 
 
 it's not something that people tend to trip over again and again and 
 
 again, like C's assignment is an expression misfeature.
 
 




 from vecmat6 import *
 from vmio5 import *
Traceback (most recent call last):
  File eta last command, line 1, in module
ImportError: No module named vmio5
 from vmio6 import *
 from svdecomp6 import *
 mm = NewMat(3, 3)
 mm
[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]
 mm[0][0] = 1.0; mm[0][1] = 2.0; mm[0][2] = 3.0
 mm[1][0] = 11.0; mm[1][1] = 12.0; mm[1][2] = 13.0
 mm[2][0] = 21.0; mm[2][1] = 22.0; mm[2][2] = 23.0
 pr(mm, 'mm=')
mm=
(   1.0e+000  2.0e+000  3.0e+000 )
(   1.1e+001  1.2e+001  1.3e+001 )
(   2.1e+001  2.2e+001  2.3e+001 )
 aa, b, cc = SVDecomp(mm)
 pr(aa, 'aa=')
aa=
(  -8.08925e-002 -9.09280e-001  4.08248e-001 )
(  -4.77811e-001 -3.24083e-001 -8.16497e-001 )
(  -8.74730e-001  2.61114e-001  4.08248e-001 )
 pr(b, 'b=')
b=
(   4.35902e+001  1.37646e+000  1.93953e-016 )
 pr(cc, 'cc=')
cc=
(  -5.43841e-001  7.33192e-001  4.08248e-001 )
(  -5.76726e-001  2.68499e-002 -8.16497e-001 )
(  -6.09610e-001 -6.79492e-001  4.08248e-001 )
 bb = VecToDiagMat(b)
 cct = TransposeMat(cc)
 oo = MatMulMatMulMat(aa, bb, cct)
 pr(oo, 'aa * bb * cct=')
aa * bb * cct=
(   1.0e+000  2.0e+000  3.0e+000 )
(   1.1e+001  1.2e+001  1.3e+001 )
(   2.1e+001  2.2e+001  2.3e+001 )

 # or
 oo
[[0.9991, 1.9993, 2.9982],
[10.995, 11.99, 12.996],
[20.986, 21.975, 22.986]]



jmf

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


RE: Obnoxious postings from Google Groups

2012-11-07 Thread Kushal Kumaran
Prasad, Ramit ramit.pra...@jpmorgan.com writes:

 Steven D'Aprano wrote:
 
 On Tue, 06 Nov 2012 17:16:44 +, Prasad, Ramit wrote:
 
  To enter the newline, I typed Ctrl-Q to tell bash to treat the next
  character as a literal, and then typed Ctrl-J to get a newline.
 
  That sounds complicated, my version of bash lets me type
  'fooenterbar'enter for the same effect.
 
 Well, I learned something new about bash.
 
 On the other hand, the Ctrl-Q next-char-is-literal trick works for
 entering control characters that otherwise don't have a key on the
 keyboard.
 

 Would you mind elaborating on how this works? I know it's not a bash
 list, but I do not understand how ctrl-J is considered a literal.
 Obviously, I must have a different definition of literal. Where
 can I find a list of other literals? My Google-fu is being weak
 today. :(


It's a readline thing, when you've configured it to use emacs
keybindings.  You can look at the emacs manual about the quoted-insert
function if you want.  It's useful in emacs because people like to bind
ordinary keystrokes to do esoteric stuff (such as binding the TAB key to
insert appropriate amount of spaces), which means that you need a way to
override it (if you want to insert a literal TAB character, for
example).

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


Re: Multi-dimensional list initialization

2012-11-07 Thread Oscar Benjamin
On Nov 7, 2012 5:41 AM, Gregory Ewing greg.ew...@canterbury.ac.nz wrote:

 If anything is to be done in this area, it would be better
 as an extension of list comprehensions, e.g.

   [[None times 5] times 10]

 which would be equivalent to

   [[None for _i in xrange(5)] for _j in xrange(10)]

I think you're right that the meaning of list-int multiplication
can't/shouldn't be changed if this way.

A multidimensional list comprehension would be useful even for people who
are using numpy as it's common to use a list comprehension to initialise a
numpy array.

A more modest addition for the limited case described in this thread could
be to use exponentiation:

 [0] ** (2, 3)
[[0, 0, 0], [0, 0, 0]]

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


how-to use readline.set_completion_display_matches_hook()?

2012-11-07 Thread Jean-Pierre Miceli
Hi all,

I'm working on a tool which enable support of tab completion using the
readline modul.
And I have a problem with set_completion_display_matches_hook function

I've created a display hook function and registered it. It is called
and it prints the desire messages. But once it has completed,
readline/python does not display the prompt.
I've got to press the 'return' key to see the prompt again.
What should the display hook function do to return correctly and let
the prompt be displayed?

Example:
def completerHook(self, substitution, matches, longest_match_length):
print 
print Test of the display hook function
for i in range(len(matches)):
  print matches[i],

I use Python 2.7.3 and done some tests on Mac OS 10.7 (Lion) and
Ubuntu. I got the same issue on both system.

Thanks for your help
J-P
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multiprocessing help (Terry Reedy)

2012-11-07 Thread Apprentice3D


Sent from my iPad

On 2012-11-07, at 12:15 AM, python-list-requ...@python.org wrote:

 Re: multiprocessing help (Terry Reedy)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: clicking on turtle

2012-11-07 Thread Peter Otten
Nicolas Graner wrote:

 I have a problem with the standard turtle module. When a turtle has
 a custom shape of type compound, it doesn't seem to respond to click
 events. No problem with polygon shapes.
 
 Running python 3.2.3, turtle version 1.1b on Windows XP.
 
 Here is my test file:
 
 ##
 import turtle
 square = ((0,0),(0,20),(20,20),(20,0))
 turtle.addshape(sq1, square) # sq1 = polygon shape
 s = turtle.Shape(compound)
 s.addcomponent(square, red)
 turtle.addshape(sq2, s) # sq2 = compound shape
 t1 = turtle.Turtle(shape=sq1)
 t2 = turtle.Turtle(shape=sq2)
 t2.fd(20) # set the turtles side by side
 def click(x,y): print(click at,x,y)
 t1.onclick(click)
 t2.onclick(click)
 turtle.mainloop()
 ##
 
 When I run this and click on the black square (i.e. t1), the message
 click at... gets printed on the console. When I click on the red
 square (i.e. t2), nothing happens.
 
 Bug or feature?

I believe it's a bug. Please report it on http://bugs.python.org
As a quick-fix here's a monkey patch that seems to work:

import turtle

def _onclick(self, item, fun, num=1, add=None):
if isinstance(item, list):
for item in item:
self._onclick(item, fun, num, add)
return

if fun is None:
self.cv.tag_unbind(item, Button-%s % num)
else:
def eventfun(event):
x, y = (self.cv.canvasx(event.x)/self.xscale,
-self.cv.canvasy(event.y)/self.yscale)
fun(x, y)

self.cv.tag_bind(item, Button-%s % num, eventfun, add)

turtle.TurtleScreenBase._onclick = _onclick

square = ((0,0),(0,20),(20,20),(20,0))
turtle.addshape(sq1, square) # sq1 = polygon shape
s = turtle.Shape(compound)
s.addcomponent(square, red)
turtle.addshape(sq2, s) # sq2 = compound shape
t1 = turtle.Turtle(shape=sq1)
t2 = turtle.Turtle(shape=sq2)
t2.fd(20) # set the turtles side by side
def click(x,y): print(click at,x,y)
t1.onclick(click)
t2.onclick(click)
turtle.mainloop()


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


Re: how-to use readline.set_completion_display_matches_hook()?

2012-11-07 Thread Stefan H. Holek
On 07.11.2012, at 11:36, Jean-Pierre Miceli wrote:

 Hi all,
 
 I'm working on a tool which enable support of tab completion using the
 readline modul.
 And I have a problem with set_completion_display_matches_hook function
 
 I've created a display hook function and registered it. It is called
 and it prints the desire messages. But once it has completed,
 readline/python does not display the prompt.
 I've got to press the 'return' key to see the prompt again.
 What should the display hook function do to return correctly and let
 the prompt be displayed?
 
 Example:
 def completerHook(self, substitution, matches, longest_match_length):
print 
print Test of the display hook function
for i in range(len(matches)):
  print matches[i],
 
 I use Python 2.7.3 and done some tests on Mac OS 10.7 (Lion) and
 Ubuntu. I got the same issue on both system.

This always happens when you print newlines behind readline's back. To update 
the prompt area, you'd have to call rl_forced_update_display() which is AFAIK 
not exposed by the stdlib's readline bindings.

There is a more complete implementation of the GNU Readline APIs at 
http://pypi.python.org/pypi/rl. With rl you can fix the prompt by calling 
rl.readline.redisplay(force=True) after the hook has returned.

Hope this helps,
Stefan

-- 
Stefan H. Holek
ste...@epy.co.at

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


Re: Multi-dimensional list initialization

2012-11-07 Thread Joshua Landau
On 7 November 2012 11:11, Oscar Benjamin oscar.j.benja...@gmail.com wrote:

  On Nov 7, 2012 5:41 AM, Gregory Ewing greg.ew...@canterbury.ac.nz
 wrote:
 
  If anything is to be done in this area, it would be better
  as an extension of list comprehensions, e.g.
 
[[None times 5] times 10]
 
  which would be equivalent to
 
[[None for _i in xrange(5)] for _j in xrange(10)]

 I think you're right that the meaning of list-int multiplication
 can't/shouldn't be changed if this way.

 A multidimensional list comprehension would be useful even for people who
 are using numpy as it's common to use a list comprehension to initialise a
 numpy array.

 A more modest addition for the limited case described in this thread could
 be to use exponentiation:

  [0] ** (2, 3)
 [[0, 0, 0], [0, 0, 0]]

Hold on: why not just use multiplication?

 [0] * (2, 3)

is an error now, and it makes total sense. Additionally, it's not breaking
the no copy -- _ever_ rule because none of the lists existed before. The
values inside the list would be by reference, as before, so lst * (x,)
would be the same as lst * x if x is an integer.

*I* would use this a lot. This is the first thing on this thread that makes
a lot of sense to me.

We do have to think of the potential problems, though. There are definitely
some. For one, code that relies on lst * x throwing an error would break.
It may confuse others - although I don't see how.

But I don't see any big problems, so I really do like this idea.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multi-dimensional list initialization

2012-11-07 Thread Oscar Benjamin
On 7 November 2012 13:39, Joshua Landau joshua.landau...@gmail.com wrote:

 On 7 November 2012 11:11, Oscar Benjamin oscar.j.benja...@gmail.com wrote:

 A more modest addition for the limited case described in this thread could
 be to use exponentiation:

  [0] ** (2, 3)
 [[0, 0, 0], [0, 0, 0]]

 Hold on: why not just use multiplication?

 [0] * (2, 3)

 is an error now, and it makes total sense. Additionally, it's not breaking
 the no copy -- _ever_ rule because none of the lists existed before. The
 values inside the list would be by reference, as before, so lst * (x,) would
 be the same as lst * x if x is an integer.

The problem is that this operation is asymmetric. Currently int/list
multiplication is commutative so that:

['a', 'b'] * 2 == 2 * ['a', 'b']

If you use this kind of multiplication what happens to the other
cases? e.g. what do you give for:

 [0] * [2, 3]

 [2, 3] * [0]

 (2, 3) * [0]

 (2, 3) * (4, 5)

and so on. Although Python does not guarantee commutativity of
multiplication in general I think that since for lists it has always
been commutative it would be bad to change that.

Exponentiation is expected to be asymmetric and is currently unused so
there is no ambiguity. The problem is if someone has already
subclassed list and added an exponentiation method.


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


Re: Obnoxious postings from Google Groups

2012-11-07 Thread Grant Edwards
On 2012-11-06, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
 On Tue, 06 Nov 2012 11:51:03 -0500, GangGreene wrote:

 I have just finished a 251 line bash shell script that builds my linux
 distro from scratch.

 From scratch? So if you run it on bare metal with no OS, it works?

:-P

 But seriously -- bash is a mature, powerful shell. It works well for
 what it does. It has been designed to make it easy[1] to automate
 system admin tasks.

And even people who have been writing bourne/korn/bash shell sripts
for 30 years (crap, I'm old...) still occasionally (or even regularly)
fall into the spaces in filenames hole.  It's just too easy to type
$Var instead of $Var.

And not setting the nounset option can result in hours of fun trying
to find that one place where a variable name is mistyped...

 It would be astonishing if an experienced, competent bash 
 programmer couldn't write an installation tool in bash.

Indeed.  But when the good folks at RedHat sat down to write an
installation tool back in '95 or so, they chose Python.

 By comparison, few general purpose programming languages (with the
 obvious exception of perl) are designed for system administration as
 their primary purpose.

 But... how robust is your script? How many bugs does it contain?
 Chances are you will only use it a handful of times, on the same
 system. That's not a lot of testing to be sure that it is free of
 bugs, and robust against unexpected input.

 Hell, even widely used and distributed install scripts written by 
 companies with the resources of Ubuntu and Red Hat have a distressing
 tendency to break. Or worse, to behave in unexpected ways.

That's not really helping your argument, since RedHat's install
scripts have been written in Pyton since forever...

 In my opinion, control structures like for and if in bash are
 hard to use, hard to read, easy to get wrong, give cryptic error
 messages when you do get them wrong, and are ugly.  Tests are
 obfuscated, and as always, the fact that everything is text in bash
 means it is way harder than it needs to be to use rich, modern data 
 structures.

I think anybody who writes anything of substance in bash would have to
agree.  However when the task involves mainly manipulating files and
running other programs, the clumsy control structures are a small
enough price to pay for the ease with which bash deals with
manipulating files/paths/programs.

OTOH, you can use C shell or PHP and get the worst of both worlds...

-- 
Grant Edwards   grant.b.edwardsYow! I'm wet!  I'm wild!
  at   
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multi-dimensional list initialization

2012-11-07 Thread Ethan Furman
After this post the only credibility you have left (with me, anyway) is that you seem to be willing 
to learn.  So learn the way Python works before you try to reimplement it.


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


Re: Multi-dimensional list initialization

2012-11-07 Thread Ethan Furman

Oscar Benjamin wrote:
On Nov 7, 2012 5:41 AM, Gregory Ewing greg.ew...@canterbury.ac.nz 
mailto:greg.ew...@canterbury.ac.nz wrote:

 
  If anything is to be done in this area, it would be better
  as an extension of list comprehensions, e.g.
 
[[None times 5] times 10]
 
  which would be equivalent to
 
[[None for _i in xrange(5)] for _j in xrange(10)]

I think you're right that the meaning of list-int multiplication 
can't/shouldn't be changed if this way.


A multidimensional list comprehension would be useful even for people 
who are using numpy as it's common to use a list comprehension to 
initialise a numpy array.


A more modest addition for the limited case described in this thread 
could be to use exponentiation:


  [0] ** (2, 3)
[[0, 0, 0], [0, 0, 0]]


What would happen with

-- [{}] ** (2, 3)

or

-- [my_custom_container()] ** (2, 3)

?

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


RE: Multi-dimensional list initialization

2012-11-07 Thread Prasad, Ramit
Gregory Ewing wrote:
 
 Roy Smith wrote:
  Call by social network?  The called function likes the object.
  Depending on how it feels, it can also comment on some of the object's
  attributes.
 
 And then finds that it has inadvertently shared all its
 private data with other functions accessing the object.

And this is where Dihedral  (or whatever the bot is called)
tells you that Python has no private variables. :)


~Ramit


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Pickling a dictionary

2012-11-07 Thread Devashish Tyagi
So I want to store the current state of a InteractiveInterpreter Object in 
database. In order to achieve this I tried this

obj = InteractiveInterpreter()
local = obj.locals()
pickle.dump(local, open('obj.dump','rw'))

But I received an error say 
TypeError: can't pickle ellipsis objects

From what I understand this shouldn't occur as local is a dictionary. Any 
particular reason for this behaviour?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multi-dimensional list initialization

2012-11-07 Thread Oscar Benjamin
On Nov 7, 2012 3:55 PM, Ethan Furman et...@stoneleaf.us wrote:

 Oscar Benjamin wrote:

 A more modest addition for the limited case described in this thread
could be to use exponentiation:

   [0] ** (2, 3)
 [[0, 0, 0], [0, 0, 0]]


 What would happen with

 -- [{}] ** (2, 3)

The list being exponentiated does nothing with its elements. The
exponentiation just tells it to create a list of distinct lists. In this
case each element of each sublist is the same dict. However if you assign
to an element of the sublist (rather than into the dict) it replaces the
dict in that sublist and not the others.


 or

 -- [my_custom_container()] ** (2, 3)

Ditto

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


Re: Pickling a dictionary

2012-11-07 Thread Ian Kelly
On Wed, Nov 7, 2012 at 9:07 AM, Devashish Tyagi
devashishroc...@gmail.com wrote:
 So I want to store the current state of a InteractiveInterpreter Object in 
 database. In order to achieve this I tried this

 obj = InteractiveInterpreter()
 local = obj.locals()
 pickle.dump(local, open('obj.dump','rw'))

 But I received an error say
 TypeError: can't pickle ellipsis objects

 From what I understand this shouldn't occur as local is a dictionary. Any 
 particular reason for this behaviour?

The contents of the dictionary need to be pickleable as well.  You
probably have an ellipsis object in the dict somewhere.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pickling a dictionary

2012-11-07 Thread Peter Otten
Devashish Tyagi wrote:

 So I want to store the current state of a InteractiveInterpreter Object in
 database. In order to achieve this I tried this
 
 obj = InteractiveInterpreter()
 local = obj.locals()
 pickle.dump(local, open('obj.dump','rw'))

Assuming InteractiveInterpreter is imported from the code module the above 
will fail with a TypeError. Please copy-and paste code snippets to avoid 
guessing games.

 But I received an error say
 TypeError: can't pickle ellipsis objects
 
 From what I understand this shouldn't occur as local is a dictionary. Any
 particular reason for this behaviour?

For a dict to be pickled all its keys and values have to be pickled, too.

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


Re: Pickling a dictionary

2012-11-07 Thread Ian Kelly
On Wed, Nov 7, 2012 at 9:16 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Wed, Nov 7, 2012 at 9:07 AM, Devashish Tyagi
 devashishroc...@gmail.com wrote:
 So I want to store the current state of a InteractiveInterpreter Object in 
 database. In order to achieve this I tried this

 obj = InteractiveInterpreter()
 local = obj.locals()
 pickle.dump(local, open('obj.dump','rw'))

 But I received an error say
 TypeError: can't pickle ellipsis objects

 From what I understand this shouldn't occur as local is a dictionary. Any 
 particular reason for this behaviour?

 The contents of the dictionary need to be pickleable as well.  You
 probably have an ellipsis object in the dict somewhere.

By the way, if you use Python 3 and pickle protocol 3, then Ellipsis
*is* pickleable:

Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600
32 bit (Intel)] on win32
Type help, copyright, credits or license for more information.
 import pickle
 pickle.dumps(Ellipsis, protocol=pickle.HIGHEST_PROTOCOL)
b'\x80\x03cbuiltins\nEllipsis\nq\x00.'

Cheers,
Ian
-- 
http://mail.python.org/mailman/listinfo/python-list


Printing a text over an image

2012-11-07 Thread Martha Morrigan
Hi guys,

Using python, wxpython and sqlite in a windows system, Im trying to
print some certificates/diplomas/cards with a image at background with
the name of person/text over it.

I know the basic steps to print the text using win32print from Pywin32
but...:

1) I dont know how to add an image and set it to background.

   while .

.

# Query sqlite rows and collumn name and set the self.text for
each certificate

.

# Now send to printer

DC = win32ui.CreateDC()
DC.CreatePrinterDC(win32print.GetDefaultPrinter())

DC.SetMapMode(win32con.MM_TWIPS)

DC.StartDoc(Certificates Job)

DC.StartPage()

ux = 1000
uy = -1000
lx = 5500
ly = -55000

DC.DrawText(self.text, (ux, uy, lx, ly),win32con.DT_LEFT)

DC.EndPage()
DC.EndDoc()

This printer-code is inside a while loop calling each people name from
a sqlite database per check condition.


2) All the names of database was printed at same page... how i command
the printer to spit out 1 page per name from the database?


3) Any more simple approach or module to deals with printers (paper
and/or pdf) will be welcome.

Thanks in advance,

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


Re: Multi-dimensional list initialization

2012-11-07 Thread MRAB

On 2012-11-07 05:05, Steven D'Aprano wrote:

On Wed, 07 Nov 2012 00:23:44 +, MRAB wrote:


Incorrect.  Python uses what is commonly known as call-by-object, not
call-by-value or call-by-reference.  Passing the list by value would
imply that the list is copied, and that appends or removes to the list
inside the function would not affect the original list.  This is not
what Python does; the list inside the function and the list passed in
are the same list.  At the same time, the function does not have access
to the original reference to the list and cannot reassign it by
reassigning its own reference, so it is not call-by-reference semantics
either.


I prefer the term reference semantics.



Oh good, because what the world needs is yet another name for the same
behaviour.

- call by sharing
- call by object sharing
- call by object reference
- call by object
- call by value, where values are references
   (according to the Java community)
- call by reference, where references refer to objects, not variables
   (according to the Ruby community)
- reference semantics


Anything else?

http://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_sharing


The disadvantage of calling it call by ... is that it suggests that
you're just talking about calling functions.

What about binding in general, eg x = y? Does it make sense to still
call it call by ...?

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


Re: Pickling a dictionary

2012-11-07 Thread Devashish Tyagi
On Wednesday, 7 November 2012 21:57:05 UTC+5:30, Peter Otten  wrote:
 Devashish Tyagi wrote:
 
 
 
  So I want to store the current state of a InteractiveInterpreter Object in
 
  database. In order to achieve this I tried this
 
  
 
  obj = InteractiveInterpreter()
 
  local = obj.locals()
 
  pickle.dump(local, open('obj.dump','rw'))
 
 
 
 Assuming InteractiveInterpreter is imported from the code module the above 
 
 will fail with a TypeError. Please copy-and paste code snippets to avoid 
 
 guessing games.

Here is the code

from code import InteractiveInterpreter
import StringIO
import pickle

src = StringIO.StringIO()
inter = InteractiveInterpreter()
inter.runcode('a = 5')
local = inter.locals

pickle.dump(local,open('obj.dump','wb'))

Here is the error

Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib/python2.7/pickle.py, line 1370, in dump
Pickler(file, protocol).dump(obj)
  File /usr/lib/python2.7/pickle.py, line 224, in dump
self.save(obj)
  File /usr/lib/python2.7/pickle.py, line 286, in save
f(self, obj) # Call unbound method with explicit self
  File /usr/lib/python2.7/pickle.py, line 649, in save_dict
self._batch_setitems(obj.iteritems())
  File /usr/lib/python2.7/pickle.py, line 663, in _batch_setitems
save(v)
  File /usr/lib/python2.7/pickle.py, line 286, in save
f(self, obj) # Call unbound method with explicit self
  File /usr/lib/python2.7/pickle.py, line 649, in save_dict
self._batch_setitems(obj.iteritems())
  File /usr/lib/python2.7/pickle.py, line 663, in _batch_setitems
save(v)
  File /usr/lib/python2.7/pickle.py, line 306, in save
rv = reduce(self.proto)
  File /usr/lib/python2.7/copy_reg.py, line 70, in _reduce_ex
raise TypeError, can't pickle %s objects % base.__name__
TypeError: can't pickle ellipsis objects


 
 
 
  But I received an error say
 
  TypeError: can't pickle ellipsis objects
 
  
 
  From what I understand this shouldn't occur as local is a dictionary. Any
 
  particular reason for this behaviour?
 
 
 
 For a dict to be pickled all its keys and values have to be pickled, too.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pickling a dictionary

2012-11-07 Thread Ian Kelly
On Wed, Nov 7, 2012 at 10:40 AM, Devashish Tyagi
devashishroc...@gmail.com wrote:
 Here is the code

 from code import InteractiveInterpreter
 import StringIO
 import pickle

 src = StringIO.StringIO()
 inter = InteractiveInterpreter()
 inter.runcode('a = 5')
 local = inter.locals

 pickle.dump(local,open('obj.dump','wb'))

After calling runcode it seems that the __builtins__ dict containing
an 'Ellipsis' binding has been added to inter.locals.  You probably
don't want to include the contents of __builtins__ in your pickle
anyway, so just delete it:

del local['__builtins__']
pickle.dump(local, ...)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Printing a text over an image

2012-11-07 Thread Laurent Pointal
Martha Morrigan wrote:

 
 3) Any more simple approach or module to deals with printers (paper
 and/or pdf) will be welcome.

For pdf, you can take a look at ReportLab's Toolkit. I used it to build a 
trombinoscope (ie an employee directory with each member's photo on top of 
his name and room number).

http://www.reportlab.com/software/opensource/

Once created the pdf, you must find a solution to send it to the printer...

 
 Thanks in advance,
 
 Martha

A+
Laurent.

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


Re: creating size-limited tar files

2012-11-07 Thread Neil Cerutti
On 2012-11-07, andrea crotti andrea.crott...@gmail.com wrote:
 Simple problem, given a lot of data in many files/directories, I
 should create a tar file splitted in chunks = a given size.

 The simplest way would be to compress the whole thing and then split.

 At the moment the actual script which I'm replacing is doing a
 system('split..'), which is not that great, so I would like to do it
 while compressing.

 So I thought about (in pseudocode)

 while remaining_files:
 tar_file.addfile(remaining_files.pop())
 if size(tar_file) = limit:
  close(tar_file)
  tar_file = new_tar_file()


I have not used this module before, but what you seem to be
asking about is:

TarFile.gettarinfo().size

But your algorithm stops after the file is already too big.

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


Re: creating size-limited tar files

2012-11-07 Thread Alexander Blinne
I don't know the best way to find the current size, I only have a
general remark.
This solution is not so good if you have to impose a hard limit on the
resulting file size. You could end up having a tar file of size limit +
size of biggest file - 1 + overhead in the worst case if the tar is at
limit - 1 and the next file is the biggest file. Of course that may be
acceptable in many cases or it may be acceptable to do something about
it by adjusting the limit.

My Idea:
Assuming tar_file works on some object with a file-like interface one
could implement a transparent splitting file class which would have to
use some kind of buffering mechanism. It would represent a virtual big
file that is stored in many pieces of fixed size (except the last) and
would allow you to just add all files to one tar_file and have it split
up transparently by the underlying file-object, something like

tar_file = TarFile(SplittingFile(names='archiv.tar-%03d', chunksize=
chunksize, mode='wb'))
while remaining_files:
tar_file.addfile(remaining_files.pop())

and the splitting_file would automatically create chunks with size
chunksize and filenames archiv.tar-001, archiv.tar-002, ...

The same class could be used to put it back together, it may even
implement transparent seeking over a set of pieces of a big file. I
would like to have such a class around for general usage.

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


Re: Multi-dimensional list initialization

2012-11-07 Thread Andrew Robinson

Hi IAN!

On 11/06/2012 03:52 PM, Ian Kelly wrote:

On Tue, Nov 6, 2012 at 3:41 PM, Andrew Robinson

The objection is not nonsense; you've merely misconstrued it.  If
[[1,2,3]] * 4 is expected to create a mutable matrix of 1s, 2s, and
3s, then one would expect [[{}]] * 4 to create a mutable matrix of
dicts.  If the dicts are not copied, then this fails for the same
reason
:) The idea does create a multable list of dicts; just not a mutable 
list of different dicts.



  Q: How about if I use delegation to proxy a list?
  A: Oh no, they definitely won't be copied.

Give an example usage of why someone would want to do this.  Then we can
discuss it.

Seriously?  Read a book on design patterns.  You might start at SO:

http://stackoverflow.com/questions/832536/when-to-use-delegation-instead-of-inheritance
:)  I wasn't discarding the argument, I was asking for a use case to 
examine.


I know what a delegation *is*;  but I'm not spending lots of times 
thinking about this issue.

(Besides this thread just went more or less viral, and I can't keep up)

I have a book on design patterns -- in fact, the one called Design 
Patterns by Gamma, Helm, Johnson, Vlissides.  (Is it out of date 
already or something?)
Please link to the objection being proposed to the developers, and 
their reasoning for rejecting it. I think you are exaggerating. 

 From Google:

http://bugs.python.org/issue1408
http://bugs.python.org/issue12597
http://bugs.python.org/issue9108
http://bugs.python.org/issue7823

Note that in two out of these four cases, the reporter was trying to
multiply lists of dicts, not just lists of lists.

That's helpful. Thanks.  I'll look into these.


Besides, 2D arrays are *not* rare and people *have* to copy internals of
them very often.
The copy speed will be the same or *faster*, and the typing less -- and the
psychological mistakes *less*, the elegance more.

List multiplication is not potentially useful for copying 2D lists,
only for initializing them.  For copying an existing nested list,
you're still stuck with either copy.deepcopy() or a list
comprehension.


Yes, I totally agree.
But, as far as I know -- the primary use of list multiplication is 
initialization.
That was my point about the most compact notation ought to be for the 
most common case.

Initialization is a very common use case.

List comprehensions are appropriate for the other's.
Even D'Aprano thought the * operator was not a common operation; and I 
suppose that when compared to other operations done in a program 
(relative counting) he's correct; most programs are not primarily matrix 
or initialization oriented.





It's hardly going to confuse anyone to say that lists are copied with list
multiplication, but the elements are not.

Every time someone passes a list to a function, they *know* that the list is
passed by value -- and the elements are passed by reference.  People in
Python are USED to lists being the way to weird behavior that other
languages don't do.

Incorrect.  Python uses what is commonly known as call-by-object, not
call-by-value or call-by-reference.  Passing the list by value would
imply that the list is copied, and that appends or removes to the list
inside the function would not affect the original list.
Interesting, you avoided the main point lists are copied with list 
multiplication.


But, in any event:
_Pass_ by value (not call by value) is a term stretching back 30 years; 
eg: when I learned the meaning of the words.  Rewording it as Call by 
value is something that happened later, and the nuance is lost on those 
without a very wide programming knowledge *and* age.


In any event:
All objects in Python are based on pointers; all parameters passed to 
functions, etc, are *copies* of those pointers; (by pointer value).


I made the distinction between contents of the list and the list object 
itself for that reason; I gave an explicit correction to the _pass_ by 
value generalization by saying: (the elements are passed by reference).


The concept I gave, although archaically stated -- still correctly 
represents what actually happens in Python and can be seen from it's 
source code(s).


The point I am making is not generally true of everyone learning 
Python;  For some people obviously learn it from scratch.  But, for 
people who learn the language after a transition, this is a common FAQ; 
how do I modify the variables by reference and not by value; -- the 
answer is, you can't -- you must embed the return value in another 
object; parameters are always passed the *same* way.


Every function written, then, has to decide when objects are passed to 
it -- whether to modify or copy the object (internals) when modifying 
it.   That's all I meant.


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


Re: creating size-limited tar files

2012-11-07 Thread Roy Smith
In article 509ab0fa$0$6636$9b4e6...@newsspool2.arcor-online.net,
 Alexander Blinne n...@blinne.net wrote:

 I don't know the best way to find the current size, I only have a
 general remark.
 This solution is not so good if you have to impose a hard limit on the
 resulting file size. You could end up having a tar file of size limit +
 size of biggest file - 1 + overhead in the worst case if the tar is at
 limit - 1 and the next file is the biggest file. Of course that may be
 acceptable in many cases or it may be acceptable to do something about
 it by adjusting the limit.

If you truly have a hard limit, one possible solution would be to use 
tell() to checkpoint the growing archive after each addition.  If adding 
a new file unexpectedly causes you exceed your hard limit, you can 
seek() back to the previous spot and truncate the file there.

Whether this is worth the effort is an exercise left for the reader.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multi-dimensional list initialization

2012-11-07 Thread Ian Kelly
On Wed, Nov 7, 2012 at 12:51 PM, Andrew Robinson
andr...@r3dsolutions.com wrote:
 Interesting, you avoided the main point lists are copied with list
 multiplication.

It seems that each post is longer than the last.  If we each responded
to every point made, this thread would fill a book.

Anyway, your point was to suggest that people would not be confused by
having list multiplication copy lists but not other objects, because
passing lists into functions as parameters works in basically the same
way.  Except that it does not work the same way, because when lists
are passed into functions, they are not copied at all.  Nor are are
any of their contents copied, lists or not.  So actually I did address
this point with the call-by-object tangent; I just did not
explicitly link it back to your thesis.

 But, in any event:
 Pass by value (not call by value) is a term stretching back 30 years; eg:
 when I learned the meaning of the words.  Rewording it as Call by value is
 something that happened later, and the nuance is lost on those without a
 very wide programming knowledge *and* age.

Potayto, potahto.  The distinction that you're describing is between
strict versus non-strict evaluation strategies.  Hinging the
distinction on the non-descriptive words call and pass is lazy
terminology that should never have been introduced in the first place.

 In any event:
 All objects in Python are based on pointers; all parameters passed to
 functions, etc, are *copies* of those pointers; (by pointer value).

No, all parameters passed to functions are *objects*.  Python itself
has no concept of pointers.  What you describe is true as an
implementation detail for CPython but not necessarily true for other
implementations, and not true at all for an abstract
(implementation-independent) view of the language.

 I made the distinction between contents of the list and the list object
 itself for that reason; I gave an explicit correction to the pass by value
 generalization by saying: (the elements are passed by reference).

The elements are not passed anywhere.  Only the list object is passed
to the function, which is completely agnostic of the fact that the
list object happens to contain other objects.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: creating size-limited tar files

2012-11-07 Thread Andrea Crotti

On 11/07/2012 08:32 PM, Roy Smith wrote:

In article 509ab0fa$0$6636$9b4e6...@newsspool2.arcor-online.net,
  Alexander Blinne n...@blinne.net wrote:


I don't know the best way to find the current size, I only have a
general remark.
This solution is not so good if you have to impose a hard limit on the
resulting file size. You could end up having a tar file of size limit +
size of biggest file - 1 + overhead in the worst case if the tar is at
limit - 1 and the next file is the biggest file. Of course that may be
acceptable in many cases or it may be acceptable to do something about
it by adjusting the limit.

If you truly have a hard limit, one possible solution would be to use
tell() to checkpoint the growing archive after each addition.  If adding
a new file unexpectedly causes you exceed your hard limit, you can
seek() back to the previous spot and truncate the file there.

Whether this is worth the effort is an exercise left for the reader.


So I'm not sure if it's an hard limit or not, but I'll check tomorrow.
But in general for the size I could also take the size of the files and 
simply estimate the size of all of them,

pushing as many as they should fit in a tarfile.
With compression I might get a much smaller file maybe, but it would be 
much easier..


But the other problem is that at the moment the people that get our 
chunks reassemble the file with a simple:


cat file1.tar.gz file2.tar.gz  file.tar.gz

which I suppose is not going to work if I create 2 different tar files, 
since it would recreate the header in all of the them, right?
So or I give also a script to reassemble everything or I have to split 
in a more brutal way..


Maybe after all doing the final split was not too bad, I'll first check 
if it's actually more expensive for the filesystem (which is very very slow)

or it's not a big deal...
--
http://mail.python.org/mailman/listinfo/python-list


Re: Multi-dimensional list initialization

2012-11-07 Thread Andrew Robinson

On 11/06/2012 05:55 PM, Steven D'Aprano wrote:

On Tue, 06 Nov 2012 14:41:24 -0800, Andrew Robinson wrote:


Yes.  But this isn't going to cost any more time than figuring out
whether or not the list multiplication is going to cause quirks, itself.
  Human psychology *tends* (it's a FAQ!) to automatically assume the
purpose of the list multiplication is to pre-allocate memory for the
equivalent (using lists) of a multi-dimensional array.  Note the OP even
said 4d array.

I'm not entirely sure what your point is here. The OP screwed up -- he
didn't generate a 4-dimensional array. He generated a 2-dimensional
array. If his intuition about the number of dimensions is so poor, why
should his intuition about list multiplication be treated as sacrosanct?

Yes he did screw up.
There is a great deal of value in studying how people screw up, and 
designing interfaces which tend to discourage it.  Candy machine 
interfaces.



As they say, the only truly intuitive interface is the nipple.

No it's not -- that interface really sucks.  :)
Have you ever seen a cat trying to suck a human nipple -- ?
Or, have you ever asked a young child who was weaned early and doesn't 
remember nursing -- what a breast is for ?  Once the oral stage is left, 
remaining behavior must be re-learned.

  There are
many places where people's intuition about programming fail. And many
places where Fred's intuition is the opposite of Barney's intuition.
OK.  But that doesn't mean that *all* places have opposite intuition; 
Nor does it mean that one intuition which is statistically *always* 
wrong shouldn't be discouraged, or re-routed into useful behavior.


Take the candy machine,  if the items being sold are listed by number -- 
and the prices are also numbers; it's very easy to type in the price 
instead of the object number because one *forgets* that the numbers have 
different meaning and the machine can't always tell from the price, 
which object a person wanted (duplicate prices...); Hence a common 
mistake... people get the wrong item, by typing in the price.


By merely avoiding a numeric keypad -- the user is re-routed into 
choosing the correct item by not being able to make the mistake.


For this reason, Python tends to *like* things such as named parameters 
and occasionally enforces their use.  etc.



Even more exciting, there are places where people's intuition is
*inconsistent*, where they expect a line of code to behave differently
depending on their intention, rather than on the code. And intuition is
often sub-optimal: e.g. isn't it intuitively obvious that 42 + 1 should
give 43? (Unless it is intuitively obvious that it should give 421.)
I agree, and in places where an *exception* can be raised; it's 
appropriate to do so.

Ambiguity, like the candy machine, is *bad*.


So while I prefer intuitively obvious behaviour where possible, it is not
the holy grail, and I am quite happy to give it up.
where possible; OK, fine -- I agree.  I'm not happy to give it up; 
but I am willing.
I don't like the man hours wasted on ambiguous behavior; and I don't 
ever think that should make someone happy.



The OP's original construction was simple, elegant, easy to read and
very commonly done by newbies learning the language because it's
*intuitive*.  His second try was still intuitive, but less easy to read,
and not as elegant.

Yes. And list multiplication is one of those areas where intuition is
suboptimal -- it produces a worse outcome overall, even if one minor use-
case gets a better outcome.

I'm not disputing that [[0]*n]*m is intuitively obvious and easy. I'm
disputing that this matters. Python would be worse off if list
multiplication behaved intuitively.

How would it be worse off?

I can agree, for example, that in C -- realloc -- is too general.
One can't look at the line where realloc is being used, and decide if it is:
1) mallocing
2) deleting
3) resizing

Number (3) is the only non-redundant behavior the function provides.
There is, perhaps, a very clear reason that I haven't discovered why the 
extra functionality in list multiplication would be bad;  That reason is 
*not* because list multiplication is unable to solve all the copying 
problems in the word;  (realloc is bad, precisely because of that);  But 
a function ought to do at least *one* thing well.


Draw up some use cases for the multiplication operator (I'm calling on 
your experience, let's not trust mine, right?);  What are all the 
Typical ways people *Do* to use it now?


If those use cases do not *primarily* center around *wanting* an effect 
explicitly caused by reference duplication -- then it may be better to 
abolish list multiplication all together; and rather, improve the list 
comprehensions to overcome the memory, clarity, and speed pitfalls in 
the most common case of initializing a list.


For example, in initialization use cases; often the variable of a for 
loop isn't needed and all the initializers have parameters which only 
need to be 

Read number of CSV files

2012-11-07 Thread Smaran Harihar
Hi Guys,

I am able to read through a CSV File and fetch the data inside the CSV file
but I have a really big list of CSV files and I wish to do the same
particular code in all the CSV files.

Is there some way that I can loops through all these files, which are in a
single folder, and get my code to read the files?

-- 
Thanks  Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multi-dimensional list initialization

2012-11-07 Thread Joshua Landau
*Spoiler:* You've convinced me.

On 7 November 2012 14:00, Oscar Benjamin oscar.j.benja...@gmail.com wrote:

 On 7 November 2012 13:39, Joshua Landau joshua.landau...@gmail.com
 wrote:
  On 7 November 2012 11:11, Oscar Benjamin oscar.j.benja...@gmail.com
 wrote:
  A more modest addition for the limited case described in this thread
 could
  be to use exponentiation:
 
   [0] ** (2, 3)
  [[0, 0, 0], [0, 0, 0]]
 
  Hold on: why not just use multiplication?
 
  [0] * (2, 3)
 
  is an error now, and it makes total sense. Additionally, it's not
 breaking
  the no copy -- _ever_ rule because none of the lists existed before.
 The
  values inside the list would be by reference, as before, so lst * (x,)
 would
  be the same as lst * x if x is an integer.

 The problem is that this operation is asymmetric. Currently int/list
 multiplication is commutative so that:

 ['a', 'b'] * 2 == 2 * ['a', 'b']


I see. I agree that that is a valid point. Remember, though, that we could
just keep this behaviour:

[0] * (2, 3) == (2, 3) * [0]


 If you use this kind of multiplication what happens to the other
 cases? e.g. what do you give for:

  [0] * [2, 3]


Nothing. If you allowed lists to multiply this time, why not with your
suggestion? We should require a tuple and a list.


  [2, 3] * [0]


Same.


  (2, 3) * [0]


== [0] * (2, 3)


  (2, 3) * (4, 5)


Nothing.


 and so on. Although Python does not guarantee commutativity of
 multiplication in general I think that since for lists it has always
 been commutative it would be bad to change that.


Agreed


 Exponentiation is expected to be asymmetric and is currently unused so
 there is no ambiguity. The problem is if someone has already
 subclassed list and added an exponentiation method.


How is that a problem? They just wont get the functionality.


That said, losing:
[0] * (2, 3) == [0] * [2, 3]
would mean losing duck-typing in general. *Thus*, I fully agree with your
choice of exponentiation.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multi-dimensional list initialization

2012-11-07 Thread Andrew Robinson

On 11/06/2012 10:56 PM, Demian Brecht wrote:
My question was *not* based on what I perceive to be intuitive 
(although most of this thread has now seemed to devolve into that and 
become more of a philosophical debate), but was based on what I 
thought may have been inconsistent behaviour (which was quickly 
cleared up with None being immutable and causing it to *seem* that the 
behaviour was inconsistent to the forgetful mind).
I originally brought up intuitive; and I don't consider the word to 
mean an exclusive BEST way -- I meant it to mean easily guessed or 
understood.  An intelligent person can see when there may be more than 
one reasonable explanation -- ergo: I just called your OP intelligent, 
even if you were wrong; and D'Aprano ripped you for being wrong.


The debate is degenerating because people are _subjectively_ judging 
other people's intelligence.
The less intelligent a person is, the more black and white their 
judgements _tend_ to be.


As you touch on here, intuition is entirely subjective. If you're 
coming from a C/C++ background, I'd think that your intuition would be 
that everything's passed by value unless explicitly stated.

Yup -- that's my achillies heel and bias, I'm afraid.
I learned basic, then assembly, and then pascal, and then fortran77 with 
C (historically in that order)


In my view, pass by value vs. reference always exists at the 
hardware/CPU level regarless of the language; and regardless of whether 
the language hides the implementation details or not;


I'm an EE; I took software engineering to understand the clients who use 
my hardware, and to make my hardware drivers understandable to them by 
good programming practices.  An EE's perspective often lead to doing 
efficient things which are hard to understand;  That's why I look for a 
consensus (not a compromise) before implementing speed/memory 
improvements and ways to clarify what is being done.


Someone coming from another background (Lua perhaps?) would likely 
have entirely different intuition. 
Yes, they might be ignorant of what LUA is doing at the hardware level; 
even though it *is* doing it.



So while I prefer intuitively obvious behaviour where possible, it is not
the holy grail, and I am quite happy to give it up.

I fail to see where there has been any giving up on intuitiveness in the 
context of this particular topic. In my mind, intuitiveness is generally born 
of repetitiveness and consistency.
YES  I think a good synonym would be habit;  and when a habit is 
good -- it's called strength, or virtue; When it's bad it's called 
vice or sin or bad programming habit.  :)

Virtues don't waste people's time in debugging.

  As everything in Python is a reference, it would seem to me to be 
inconsistent to treat expressions such as [[obj]*4]*4 un-semantically 
(Pythonically speaking) and making it *less* intuitive. I agree that Python 
would definitely be worse off.
That's a fair opinion. I was pleasantly surprised when the third poster 
actually answered the WHY question with the idea that Python always 
copies by reference unless forced to do deep copy.  That's intuitive, 
and as a habit (not a requirement) Python implements things that way.


I've already raised the question about why one would want a multiplier 
at all, if it were found that the main desired use case never *wants* 
all objects to change together.


I laid out a potential modification of list comprensions; which, BTW, 
copy by re-instantiating rather than reference; so the paradigm of 
Python is wrong in that case  But, I think the modifications in that 
context can't be argued against as easily as list multiplication (For 
the same reason that comprehensions already break the copy by reference 
mold  )




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


Right solution to unicode error?

2012-11-07 Thread Anders
I've run into a Unicode error, and despite doing some googling, I
can't figure out the right way to fix it. I have a Python 2.6 script
that reads my Outlook 2010 task list. I'm able to read the tasks from
Outlook and store them as a list of objects without a hitch.  But when
I try to print the tasks' subjects, one of the tasks is generating an
error:

Traceback (most recent call last):
  File outlook_tasks.py, line 66, in module
my_tasks.dump_today_tasks()
  File C:\Users\Anders\code\Task List\tasks.py, line 29, in
dump_today_tasks
print task.subject
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in
position 42: ordinal not in range(128)

(where task.subject  was previously assigned the value of
task.Subject, aka the Subject property of an Outlook 2010 TaskItem)

From what I understand from reading online, the error is telling me
that the subject line  contains an en dash and that Python is trying
to convert to ascii and failing (as it should).

Here's where I'm getting stuck.  In the code above I was just printing
the subject so I can see whether the script is working properly.
Ultimately what I want to do is parse the tasks I'm interested in and
then create an HTML file containing those tasks.  Given that, what's
the best way to fix this problem?

BTW, if there's a clear description of the best solution for this
particular problem – i.e., where I want to ultimately display the
results as HTML – please feel free to refer me to the link. I tried
reading a number of docs on the web but still feel pretty lost.

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


Re: Multi-dimensional list initialization

2012-11-07 Thread Mark Lawrence

On 07/11/2012 22:02, Andrew Robinson wrote:




You're doing extremely well, you've overtaken Xah Lee as the biggest 
waste of space on this list.


--
Cheers.

Mark Lawrence.

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


Re: Read number of CSV files

2012-11-07 Thread Adnan Sadzak
Maybe os.listdir() can help You, and then go through files and do whatever
You want.


On Wed, Nov 7, 2012 at 11:11 PM, Smaran Harihar smaran.hari...@gmail.comwrote:

 Hi Guys,

 I am able to read through a CSV File and fetch the data inside the CSV
 file but I have a really big list of CSV files and I wish to do the same
 particular code in all the CSV files.

 Is there some way that I can loops through all these files, which are in a
 single folder, and get my code to read the files?

 --
 Thanks  Regards
 Smaran Harihar


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


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


Re: Multi-dimensional list initialization

2012-11-07 Thread Steven D'Aprano
On Wed, 07 Nov 2012 17:17:02 +, MRAB wrote:

 The disadvantage of calling it call by ... is that it suggests that
 you're just talking about calling functions.

*shrug*

There are already two synonyms for this, call by ... and pass by  
They are old, venerable terms dating back to Algol and possibly even 
older. All the way back to Fortran perhaps?


 What about binding in general, eg x = y? Does it make sense to still
 call it call by ...?

Sure, why not? The person who prepares beef tartare or sushimi is still 
called the cook.


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


Re: Multi-dimensional list initialization

2012-11-07 Thread Oscar Benjamin
On 7 November 2012 22:16, Joshua Landau joshua.landau...@gmail.com wrote:
 On 7 November 2012 14:00, Oscar Benjamin oscar.j.benja...@gmail.com wrote:
 On 7 November 2012 13:39, Joshua Landau joshua.landau...@gmail.com
 wrote:
  On 7 November 2012 11:11, Oscar Benjamin oscar.j.benja...@gmail.com
  wrote:
  A more modest addition for the limited case described in this thread
  could
  be to use exponentiation:
 
   [0] ** (2, 3)
  [[0, 0, 0], [0, 0, 0]]

 Exponentiation is expected to be asymmetric and is currently unused so
 there is no ambiguity. The problem is if someone has already
 subclassed list and added an exponentiation method.

 How is that a problem? They just wont get the functionality.

This is absolutely contrived but:
Library A defines a subclass of list that adds an exponentiation
operator thinking that it's okay to still use these objects as lists.
Library B has an API that expects a list and tries to use the list
copy-exponentiation on its input. A user passes a list type object
from library A into library B and hopefully gets an error but possibly
gets a subtle bug that is hard to track down.

It doesn't sound plausible to me but at least in principle there is a
backward compatibility problem.

 That said, losing:
 [0] * (2, 3) == [0] * [2, 3]
 would mean losing duck-typing in general. *Thus*, I fully agree with your
 choice of exponentiation.

Also there's no reason why tuples couldn't have the same
exponentiation operator (although for them it would be no different
from repeated multiplication).


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


RE: Right solution to unicode error?

2012-11-07 Thread Prasad, Ramit
Anders wrote:
 
 I've run into a Unicode error, and despite doing some googling, I
 can't figure out the right way to fix it. I have a Python 2.6 script
 that reads my Outlook 2010 task list. I'm able to read the tasks from
 Outlook and store them as a list of objects without a hitch.  But when
 I try to print the tasks' subjects, one of the tasks is generating an
 error:
 
 Traceback (most recent call last):
   File outlook_tasks.py, line 66, in module
 my_tasks.dump_today_tasks()
   File C:\Users\Anders\code\Task List\tasks.py, line 29, in
 dump_today_tasks
 print task.subject
 UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in
 position 42: ordinal not in range(128)
 
 (where task.subject  was previously assigned the value of
 task.Subject, aka the Subject property of an Outlook 2010 TaskItem)
 
 From what I understand from reading online, the error is telling me
 that the subject line  contains an en dash and that Python is trying
 to convert to ascii and failing (as it should).
 
 Here's where I'm getting stuck.  In the code above I was just printing
 the subject so I can see whether the script is working properly.
 Ultimately what I want to do is parse the tasks I'm interested in and
 then create an HTML file containing those tasks.  Given that, what's
 the best way to fix this problem?
 
 BTW, if there's a clear description of the best solution for this
 particular problem - i.e., where I want to ultimately display the
 results as HTML - please feel free to refer me to the link. I tried
 reading a number of docs on the web but still feel pretty lost.
 

You can always encode in a non-ASCII codec. 
`print task.subject.encode(encoding)` where encoding is something that
supports the characters you want e.g. latin1. 

The list of built in codecs can be found:
http://docs.python.org/library/codecs.html#standard-encodings


~Ramit



This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] sys.py3k

2012-11-07 Thread Chris Angelico
On Thu, Nov 8, 2012 at 5:35 AM, anatoly techtonik techto...@gmail.com wrote:
 I thought of sys.py3k check as an explicit way to guard the code that should
 be maintained extra carefully for Python 3 compatibility, so that you can
 grep the source for this constant and remove all the hacks (such as bytes to
 string conversion) required to maintain the compatibility when the time
 comes to switch.

I agree about greppability, it's a huge help. Hence the code comment;
as long as you're consistent and you pick a keyword long enough or
unusual enough to not occur anywhere else, you can easily do a find
across files or grep XYZ * to find them all. And if you put the
comment on the most significant line of code, line-based tools will be
more useful.

# Unideal:
# py3k
try:
reload
except NameError:
from imp import reload

# Better:
try: # py3k
reload
except NameError:
from imp import reload

# Best:
try:
reload # py3k
except NameError:
from imp import reload

# Also best:
try:
reload
except NameError:
from imp import reload # py3k

Taking just the line with the keyword py3k on it will tell you
exactly what that file is doing.

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


Invalid syntax

2012-11-07 Thread Smaran Harihar
Hi guys,

I am stuck in one of those non identifiable error location in the code. The
code keeps giving invalid syntax. This is my codehttp://dpaste.com/826792/
.

I am using the same code for another code and not sure why this is not
working. This is the traceback http://dpaste.com/826793/ that I am
getting.

Any idea where am I going wrong?

-- 
Thanks  Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: creating size-limited tar files

2012-11-07 Thread Oscar Benjamin
On 7 November 2012 21:52, Andrea Crotti andrea.crott...@gmail.com wrote:
 On 11/07/2012 08:32 PM, Roy Smith wrote:

 In article 509ab0fa$0$6636$9b4e6...@newsspool2.arcor-online.net,
   Alexander Blinne n...@blinne.net wrote:

 I don't know the best way to find the current size, I only have a
 general remark.
 This solution is not so good if you have to impose a hard limit on the
 resulting file size. You could end up having a tar file of size limit +
 size of biggest file - 1 + overhead in the worst case if the tar is at
 limit - 1 and the next file is the biggest file. Of course that may be
 acceptable in many cases or it may be acceptable to do something about
 it by adjusting the limit.

 But the other problem is that at the moment the people that get our chunks
 reassemble the file with a simple:

 cat file1.tar.gz file2.tar.gz  file.tar.gz

 which I suppose is not going to work if I create 2 different tar files,
 since it would recreate the header in all of the them, right?

Correct. But if you read the rest of Alexander's post you'll find a
suggestion that would work in this case and that can guarantee to give
files of the desired size.

You just need to define your own class that implements a write()
method and then distributes any data it receives to separate files.
You can then pass this as the fileobj argument to the tarfile.open
function:
http://docs.python.org/2/library/tarfile.html#tarfile.open


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


Re: Invalid syntax

2012-11-07 Thread Demian Brecht

On 2012-11-07, at 3:17 PM, Smaran Harihar smaran.hari...@gmail.com wrote:
 Any idea where am I going wrong?

Looks like you're missing a closing parenthesis:

w.record(collection[i][0], MAT[0], TSD[0], AnnTMin[0], ANNPREC[0], 
float(collection[i][2]), float(collection[i][1])

should be

w.record(collection[i][0], MAT[0], TSD[0], AnnTMin[0], ANNPREC[0], 
float(collection[i][2]), float(collection[i][1]))

Demian Brecht
@demianbrecht
http://demianbrecht.github.com




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


Re: Invalid syntax

2012-11-07 Thread R. Michael Weylandt
On Wed, Nov 7, 2012 at 11:17 PM, Smaran Harihar
smaran.hari...@gmail.com wrote:
 Hi guys,

 I am stuck in one of those non identifiable error location in the code. The
 code keeps giving invalid syntax. This is my code.

 I am using the same code for another code and not sure why this is not
 working. This is the traceback that I am getting.

 Any idea where am I going wrong?

If the dpaste link is correct, you're missing a close-parenthesis at
the end of the w.record line:

w.record(collection[i][0], MAT[0], TSD[0], AnnTMin[0], ANNPREC[0],
float(collection[i][2]), float(collection[i][1]) ## --- Hereabouts

Cheers,
Michael
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Right solution to unicode error?

2012-11-07 Thread Oscar Benjamin
On 7 November 2012 22:17, Anders aschneider...@asha.org wrote:

 Traceback (most recent call last):
   File outlook_tasks.py, line 66, in module
 my_tasks.dump_today_tasks()
   File C:\Users\Anders\code\Task List\tasks.py, line 29, in
 dump_today_tasks
 print task.subject
 UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in
 position 42: ordinal not in range(128)

 Here's where I'm getting stuck.  In the code above I was just printing
 the subject so I can see whether the script is working properly.
 Ultimately what I want to do is parse the tasks I'm interested in and
 then create an HTML file containing those tasks.  Given that, what's
 the best way to fix this problem?

Are you using cmd.exe (standard Windows terminal)? If so, it does not
support unicode and Python is telling you that it cannot encode the
string in a way that can be understood by your terminal. You can try
using chcp to set the code page to something that works with your
script.

If you are only printing it for debugging purposes you can just print
the repr() of the string which will be ascii and will come out fine in
your terminal. If you want to write it to a html file you should
encode the string with whatever encoding (probably utf-8) you use in
the html file. If you really just want your script to be able to print
unicode characters then you need to use something other than cmd.exe
(such as IDLE).


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


Re: Invalid syntax

2012-11-07 Thread Roy Smith
In article mailman.3404.1352330555.27098.python-l...@python.org,
 Demian Brecht demianbre...@gmail.com wrote:

 On 2012-11-07, at 3:17 PM, Smaran Harihar smaran.hari...@gmail.com wrote:
  Any idea where am I going wrong?
 
 Looks like you're missing a closing parenthesis:

What I find is useful in situations like this is to just let emacs 
auto-indent the code.  When it starts indenting (or coloring) 
differently than I would have expected, that's a clue that I've messed 
up some punctuation somewhere.

This doesn't only work in emacs.  Vim, eclipse, etc, all have similar 
syntax-coloring and auto-indenting features.  The same idea works with 
any of them.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multi-dimensional list initialization

2012-11-07 Thread Ian Kelly
On Wed, Nov 7, 2012 at 3:02 PM, Andrew Robinson
andr...@r3dsolutions.com wrote:
 Draw up some use cases for the multiplication operator (I'm calling on your
 experience, let's not trust mine, right?);  What are all the Typical ways
 people *Do* to use it now?

 If those use cases do not *primarily* center around *wanting* an effect
 explicitly caused by reference duplication -- then it may be better to
 abolish list multiplication all together; and rather, improve the list
 comprehensions to overcome the memory, clarity, and speed pitfalls in the
 most common case of initializing a list.

Why?  Just to get rid of an FAQ?

Here's one of the more interesting uses from my own code:

values = zip(samples, times * num_groups)
if len(values)  len(times) * num_groups:
# raise an error

Converting that multiplication to a generator expression would look like this:

values = zip(samples, (t for _ in range(num_groups) for t in times))

That's not particularly hairy, but I do assert that it is
substantially less readable, and more so because it loses the symmetry
with the following if condition.

The recipes in the itertools docs also include this example, which
notably depends on the list containing multiple references to the same
iterator:

def grouper(n, iterable, fillvalue=None):
Collect data into fixed-length chunks or blocks
# grouper(3, 'ABCDEFG', 'x') -- ABC DEF Gxx
args = [iter(iterable)] * n
return izip_longest(fillvalue=fillvalue, *args)

Replacing the list multiplication in that function with a list
comprehension would be awkward, as the obvious replacement of
[iter(iterable) for _ in range(n)] would produce different results.


 For example, in initialization use cases; often the variable of a for loop
 isn't needed and all the initializers have parameters which only need to be
 evaluated *once* (no side effects).

 Hence, there is an opportunity for speed and memory gains,while maintaining
 clarity and *consistency*.

 Some ideas of use cases:
 [ (0) in xrange(10) ]  # The function to create a tuple cache's the
 parameter '0', makes 10 (0)'s
 [ dict.__new__(dict) in xrange(10) ]  # dict.__new__, The dict parameter is
 cached -- makes 10 dicts.
 [ lambda x:(0) in xrange(10) ] # lambda caches (0), returns a *reference* to
 it multiple times.

How exactly do you propose to indicate to the compiler which parts of
the expressions are meant to be cached, and which are not?

 Bull.  Even in the last thread I noted the range() object produces
 special cases.
   range(0,5)[1]
 1
   range(0,5)[1:3]
 range(1, 3)

 What's the special case here? What do you think is copied?


 You take a slice of a range object, you get a new range object.

 You were'nt paying attention, OCCASIONALLY, get an integer, or a list.
 range(3)[2]
 2

 LK! That's not a range object, that's an integer.  Use Python 3.2 and
 try it.

Of course you got an integer.  You took an index of the range object,
not a slice.  The rule is that taking an index of a sequence returns
an element; taking a slice of a sequence returns a sub-sequence.  You
still have not shown any inconsistency here.

 Game programmers routinely use 2D lists to represent the screen layout;
 For example, they might use 'b' to represent a brick tile, and 'w' to
 represent a water tile.

In many cases it may be simpler to use a plain list of strings:

screen = [
s,
ssbss,
sbbbs,
b,
]

 py x = [{}]*5
 py x
 [{}, {}, {}, {}, {}]

 No, I showed what happed when you do {}*3;
 That *DOESN'T* work;  You aren't multiplying the dictionary, you are
 multiplying the LIST of dictionaries.  Very different things.
 You were complaining that my method doesn't multiply them -- well, gee --
 either mine DOES or python DOESN'T.  Double standards are *crap*.

No, he wasn't.  He was talking about multiplying lists of dicts, and
whether the dicts are then copied or not, just like every other QA
item in that dialogue was concerning whether item X in a list should
expect to be copied when the containing list is multiplied.

You are the only one talking about applying the multiplication
operator to dicts.

 Huh?
 I'm not yelling any more than you are.  Are ???YOU??? yelling?

Perhaps you're not aware that on the Internet, TYPING IN ALL CAPS is
commonly construed as SHOUTING.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Right solution to unicode error?

2012-11-07 Thread Andrew Berg
On 2012.11.07 17:27, Oscar Benjamin wrote:
 Are you using cmd.exe (standard Windows terminal)? If so, it does not
 support unicode
Actually, it does. Code page 65001 is UTF-8. I know that doesn't help
the OP since Python versions below 3.3 don't support cp65001, but I
think it's important to point out that the Windows command line system
(it is not unique to cmd) does in fact support Unicode.
-- 
CPython 3.3.0 | Windows NT 6.1.7601.17835
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Right solution to unicode error?

2012-11-07 Thread Steven D'Aprano
On Wed, 07 Nov 2012 14:17:42 -0800, Anders wrote:

 I've run into a Unicode error, and despite doing some googling, I can't
 figure out the right way to fix it. I have a Python 2.6 script that
 reads my Outlook 2010 task list. I'm able to read the tasks from Outlook
 and store them as a list of objects without a hitch.  But when I try to
 print the tasks' subjects, one of the tasks is generating an error:
 
 Traceback (most recent call last):
   File outlook_tasks.py, line 66, in module
 my_tasks.dump_today_tasks()
   File C:\Users\Anders\code\Task List\tasks.py, line 29, in
 dump_today_tasks
 print task.subject
 UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in
 position 42: ordinal not in range(128)


This error confuses me. Is that an exact copy and paste of the error, or 
have you edited it or reconstructed it? Because it seems to me that if 
task.subject is a unicode string, as it appears to be, calling print on 
it should succeed:

py s = u'ABC\u2013DEF'
py print s
ABC–DEF

What does type(task.subject) return?


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


Re: Multi-dimensional list initialization

2012-11-07 Thread Andrew Robinson

On 11/07/2012 05:39 AM, Joshua Landau wrote:



On 7 November 2012 11:11, Oscar Benjamin wrote:

On Nov 7, 2012 5:41 AM, Gregory Ewing  wrote:

 If anything is to be done in this area, it would be better
 as an extension of list comprehensions, e.g.

   [[None times 5] times 10]

 which would be equivalent to

   [[None for _i in xrange(5)] for _j in xrange(10)]

Oscar, I'm really in agreement with you;  I think that it's better to 
group all *special* array/list constructions into a single logical unit 
which will show up in the same part of the Python documentation.


A multidimensional list comprehension would be useful even for
people who are using numpy as it's common to use a list
comprehension to initialise a numpy array.

I hadn't paid that much attention; but I think that's true of people 
using the newer releases of Numpy.

A Very interesting point... Thank you for mentioning it.


A more modest addition for the limited case described in this
thread could be to use exponentiation:

 [0] ** (2, 3)
[[0, 0, 0], [0, 0, 0]]

I'm against over using the math operators, for the reason that matrix 
and vector algebra have meanings mathematicians desire (rightly) to 
maintain.  Numpy users might find matricies overloaded to do these 
things in the future -- and then it becomes unclear whether an 
initialization is happening or a mathematical operation. I think it best 
just not to set up an accident waiting to happen in the first place.



Hold on: why not just use multiplication?
 [0] * (2, 3)

Would you consider that better than [0].nest(2).nest(3) ? or [0].nest(2,3) ?
(I'm against multiplication, but I'm still interested in what you find 
attractive about it.)
We do have to think of the potential problems, though. There are 
definitely some. For one, code that relies on lst * x throwing an 
error would break. It may confuse others - although I don't see how.

Excellent observation:
People relying on an exception, would be in the try: operation.
So, since lst * int  does not cause an exception; they would need a 
reason to be concerned that someone passed in a list instead of an 
integer.  Semantically, the same KIND of result happens, lst is in some 
way duplicated; so if the result is accepted, it likely would work in 
place of an integer.
So, the concern would be where someone wanted to detect the difference 
between an integer and a list, so as to run some alternate algorithm.


Eg, say a vector multiply, or similar operation.  The design would want 
to shadow * and call a method to do the multiply; You'd have a fragment 
possibly like the following:


...
try: ret = map( lambda x: x*rightSide, leftSide )
except TypeError:  for i in rightSide: self.__mul__( rightSide, i ) 
# recursive call to __mul__

...

That's a common technique for type checking dating from earlier releases 
of Python, where the type attribute wasn't available.  It also works 
based on functionality, not specific type -- so objects which work 
alike (subclasses, alternate reinventions of the wheel) also can be handled.



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


Re: [Python-ideas] sys.py3k

2012-11-07 Thread Steven D'Aprano
On Thu, 08 Nov 2012 10:14:35 +1100, Chris Angelico wrote:

 On Thu, Nov 8, 2012 at 5:35 AM, anatoly techtonik techto...@gmail.com
 wrote:
 I thought of sys.py3k check ...

Chris, you regularly reply to the wrong mailing list, and you've just 
done it again. This is not python-ideas.



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


Re: [Python-ideas] sys.py3k

2012-11-07 Thread Chris Angelico
On Thu, Nov 8, 2012 at 10:56 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Thu, 08 Nov 2012 10:14:35 +1100, Chris Angelico wrote:

 On Thu, Nov 8, 2012 at 5:35 AM, anatoly techtonik techto...@gmail.com
 wrote:
 I thought of sys.py3k check ...

 Chris, you regularly reply to the wrong mailing list, and you've just
 done it again. This is not python-ideas.

Ack! Sorry all. I was sure I checked whoops.

Egg-on-face-ly yours...

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


Re: Invalid syntax

2012-11-07 Thread Smaran Harihar
Thanks a lot guys. Seriously when u get stuck on such issues it really
drives u nuts and that is when this awesome comes to the rescue.

This python mailing list rocks.

On Wed, Nov 7, 2012 at 4:31 PM, Roy Smith r...@panix.com wrote:

 In article mailman.3404.1352330555.27098.python-l...@python.org,
  Demian Brecht demianbre...@gmail.com wrote:

  On 2012-11-07, at 3:17 PM, Smaran Harihar smaran.hari...@gmail.com
 wrote:
   Any idea where am I going wrong?
 
  Looks like you're missing a closing parenthesis:

 What I find is useful in situations like this is to just let emacs
 auto-indent the code.  When it starts indenting (or coloring)
 differently than I would have expected, that's a clue that I've messed
 up some punctuation somewhere.

 This doesn't only work in emacs.  Vim, eclipse, etc, all have similar
 syntax-coloring and auto-indenting features.  The same idea works with
 any of them.
 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Thanks  Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multi-dimensional list initialization

2012-11-07 Thread Steven D'Aprano
Andrew, it appears that your posts are being eaten or rejected by my 
ISP's news server, because they aren't showing up for me. Possibly a side-
effect of your dates being in the distant past? So if you have replied to 
any of my posts, I haven't seen them.

In any case, I wanted to ask a question:


On Wed, 07 Nov 2012 14:01:19 -0700, Ian Kelly wrote:
 On Wed, Nov 7, 2012 at 12:51 PM, Andrew Robinson
 andr...@r3dsolutions.com wrote:

[...]

 But, in any event:
 Pass by value (not call by value) is a term stretching back 30 years;
 eg: when I learned the meaning of the words.  Rewording it as Call by
 value is something that happened later, and the nuance is lost on
 those without a very wide programming knowledge *and* age.

Every now and again I come across somebody who tries to distinguish 
between call by foo and pass by foo, but nobody has been able to 
explain the difference (if any) to me. When you CALL a function, you PASS 
values to it. Hence the two terms are effectively synonyms, and both 
refer to the evaluation strategy when binding arguments to parameters.

If you believe that is incorrect, can you point me to something 
explaining the difference?



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


Issues with python/libtcod

2012-11-07 Thread Graham Fielding




Hey, all. I'm trying to program a roguelike, using the wonderful tutorials 
written by João F. Henriques (a.k.a. Jotaf), but I've stumbled onto a bit of a 
problem setting up the game's inventory system, and I was hoping someone could 
help me out. Here's a code snippet, including the affected line. #def 
menu(header, options, width):
#if len(options)  26: raise ValueError('Cannot have a menu with more than 
26 options.')
 
#calculate total height for the header (after auto-wrap) and one line per 
option
#header_height = libtcod.console_height_left_rect(con, 0, 0, width, 
SCREEN_HEIGHT, header)
#height = len(options) + header_height
In a nutshell: def menu() is an all-encompassing 'menu processor' function -- 
it contains a standardized menu layout that can be called, from anywhere in the 
stack, to create a generic menu. When I launch the game to check things out, 
everything runs smoothly until I try to open the inventory window -- at which 
point, IDLE  tosses up an AttributeError:
File C:/Python Project/Roguelike.py, line 602, in module
player_action = handle_keys()
  File C:/Python Project/Roguelike.py, line 531, in handle_keys
chosen_item = inventory_menu('Press the key next to an item to use it, or 
any other to cancel.\n')
  File C:/Python Project/Roguelike.py, line 487, in inventory_menu
index = menu(header, options, INVENTORY_WIDTH)
  File C:/Python Project/Roguelike.py, line 447, in menu
header_height = libtcod.console_height_left_rect(con, 0, 0, width, 
SCREEN_HEIGHT, header)
AttributeError: 'module' object has no attribute 'console_height_left_rect' 
I've tried moving the entire def menu() function to various sections of the 
stack, I've changed its arguments manually, and I've even removed the affected 
line entirely to see if that would help; nothing seems to work, and it's only 
when def menu() is called that this happens. Anyone got any ideas what could be 
going flooey?-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multi-dimensional list initialization

2012-11-07 Thread Andrew Robinson

On 11/07/2012 01:01 PM, Ian Kelly wrote:

On Wed, Nov 7, 2012 at 12:51 PM, Andrew Robinson
andr...@r3dsolutions.com  wrote:

Interesting, you avoided the main point lists are copied with list
multiplication.

It seems that each post is longer than the last.  If we each responded
to every point made, this thread would fill a book.

It already is :)


Anyway, your point was to suggest that people would not be confused by
having list multiplication copy lists but not other objects, because
passing lists into functions as parameters works in basically the same
way.
Not quite; Although I wasn't clear;  The variable passed in is by 
*value* in contradistinction to the list which is by reference.  Python 
does NOT always default copy by reference *when it could*; that's the point.


Hence the programmer has to remember in  foo( x,y ), the names x and y 
when assigned to -- *DONT* affect the variables from which they came.  
But any object internals do affect the objects everywhere.


A single exception exists; My thesis is for a single exception as well 
-- I think Python allows that kind of thinking.

So actually I did address
this point with the call-by-object tangent; I just did not
explicitly link it back to your thesis.
My apology for not proof reading my statements for clarity.  It was 
definitely time for a nap back then.


Potayto, potahto. The distinction that you're describing is between 
strict versus non-strict evaluation strategies. Hinging the 
distinction on the non-descriptive words call and pass is lazy 
terminology that should never have been introduced in the first place.
I would do it again.  Other's have already begun to discuss terminology 
with you -- I won't double team you.




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


Re: Multi-dimensional list initialization

2012-11-07 Thread Oscar Benjamin
On 8 November 2012 00:00, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 Andrew, it appears that your posts are being eaten or rejected by my
 ISP's news server, because they aren't showing up for me. Possibly a side-
 effect of your dates being in the distant past? So if you have replied to
 any of my posts, I haven't seen them.

 In any case, I wanted to ask a question:


 On Wed, 07 Nov 2012 14:01:19 -0700, Ian Kelly wrote:
 On Wed, Nov 7, 2012 at 12:51 PM, Andrew Robinson
 andr...@r3dsolutions.com wrote:

 [...]

 But, in any event:
 Pass by value (not call by value) is a term stretching back 30 years;
 eg: when I learned the meaning of the words.  Rewording it as Call by
 value is something that happened later, and the nuance is lost on
 those without a very wide programming knowledge *and* age.

 Every now and again I come across somebody who tries to distinguish
 between call by foo and pass by foo, but nobody has been able to
 explain the difference (if any) to me. When you CALL a function, you PASS
 values to it. Hence the two terms are effectively synonyms, and both
 refer to the evaluation strategy when binding arguments to parameters.

 If you believe that is incorrect, can you point me to something
 explaining the difference?

Did you also miss MRAB's post above? It made sense to me.

MRAB wrote:
 The disadvantage of calling it call by ... is that it suggests that
 you're just talking about calling functions.

 What about binding in general, eg x = y? Does it make sense to still
 call it call by ...?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Right solution to unicode error?

2012-11-07 Thread Oscar Benjamin
On 7 November 2012 23:51, Andrew Berg bahamutzero8...@gmail.com wrote:
 On 2012.11.07 17:27, Oscar Benjamin wrote:
 Are you using cmd.exe (standard Windows terminal)? If so, it does not
 support unicode
 Actually, it does. Code page 65001 is UTF-8. I know that doesn't help
 the OP since Python versions below 3.3 don't support cp65001, but I
 think it's important to point out that the Windows command line system
 (it is not unique to cmd) does in fact support Unicode.

I have tried to use code page 65001 and it didn't work for me even if
I did use a version of Python (possibly 3.3 alpha) that claimed to
support it. It turned out that there were other Windows related
problems with using the codepage so that I had to do something like

chcp 65001  python myscript.py  chcp 2521

(It was important for all those commands to be on the same line) I'm
not on Windows right now and I can't remember all the details but I
seem to remember that even with that awkwardness and changing the font
it still didn't actually work.

If you know how to make it work, I'd be interested to know.


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


Re: Multi-dimensional list initialization

2012-11-07 Thread Joshua Landau
On 7 November 2012 23:55, Andrew Robinson andr...@r3dsolutions.com wrote:

  On 11/07/2012 05:39 AM, Joshua Landau wrote:

  A more modest addition for the limited case described in this thread
 could be to use exponentiation:

  [0] ** (2, 3)
 [[0, 0, 0], [0, 0, 0]]

  I'm against over using the math operators, for the reason that matrix
 and vector algebra have meanings mathematicians desire (rightly) to
 maintain.  Numpy users might find matricies overloaded to do these things
 in the future -- and then it becomes unclear whether an initialization is
 happening or a mathematical operation. I think it best just not to set up
 an accident waiting to happen in the first place.


I'm going to say right now that I'm very much fond of
the exponentiation proposal.

Multiplication on Numpy arrays is already completely disjoint to
multiplication on lists, and that is probably completely disjoint to all
sorts of mathematical meanings. I don't personally feel that anyone who
knows what [0] * 3 is would *assume* (although they may suppose)
that exponentiation will be a maths operator.

When I saw [0] ** (2, 3), I knew what it did before I read anything else. I
know I had the context of the posts above, so it isn't a fair comparison,
but it seems really obvious an extension. It's so closely linked to * (if
not for the ambiguities, I would have preferred multiplication) that it
makes total sense. Even if you think of 4 ** 5 as 4 * 4, 5 times, there
is a direct mental link to what is happening.

  Hold on: why not just use multiplication?

  [0] * (2, 3)

 Would you consider that better than [0].nest(2).nest(3) ? or [0].nest(2,3)
 ?
 (I'm against multiplication, but I'm still interested in what you find
 attractive about it.)


Yes.

Having [0] * 2 with a distinct but fundamentally the same (it's just gotten
extra dimensions) partner that is called in a very similar way is a good
thing.

I'd feel equally unhappy with 4 * 3 partnering with (4).pow(3)* as I
would with your .nest(2, 3) and I like the iterated ones even less because
I don't see it as obviously possible for them to even work.

[0].nest(2) - [[0], [0]] ?
[[0], [0]].nest(3) - [[0,0,0], [0,0,0]] ???
(what about 3d?)

* Even if you could write that as 4.pow(3) because floats didn't exist or
something.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multi-dimensional list initialization

2012-11-07 Thread Greg Ewing

On 08/11/12 12:06, Oscar Benjamin wrote:

On 7 November 2012 22:16, Joshua Landaujoshua.landau...@gmail.com  wrote:

That said, losing:
[0] * (2, 3) == [0] * [2, 3]
would mean losing duck-typing in general.


There are precedents for this kind of thing; the
string % operator treats tuples specially, for
example.

I don't think it's all that bad if you regard
the tuple as effectively part of the syntax.

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


Re: Multi-dimensional list initialization

2012-11-07 Thread Andrew Robinson

On 11/07/2012 03:39 PM, Ian Kelly wrote:
Why? Just to get rid of an FAQ? 

:-)


Here's one of the more interesting uses from my own code:

OK, and is this a main use case?  (I'm not saying it isn't I'm asking.)

Replacing the list multiplication in that function with a list 
comprehension would be awkward, as the obvious replacement of 
[iter(iterable) for _ in range(n)] would produce different results.


Yes. I have a thought on that.
How exactly do you propose to indicate to the compiler which parts of 
the expressions are meant to be cached, and which are not?


Exactly?
OK; Here's what I would consider a safe implementation -- but it could 
be improved later.
There is a special keyword which signals the new type of comprehension;  
A normal comprehension would say eg: '[ foo for i in xrange ]'; but when 
the 'for i in' is reduced to a specific keyword such as 'ini' (instead 
of problematic 'in') the caching form of list comprehension would start.


So, then, just like a comprehension -- the interpreter will begin to 
evaluate the code from the opening bracket '['; But anything other than 
a function/method will raise a type error (people might want to change 
that, but it's safe).


The interpreter then caches all functions/initialiser methods it comes 
into contact with.
Since every function/method has a parameter list (even if empty);  The 
interpreter would evaluate the parameter list on the first pass through 
the comprehension, and cache each parameter list with it's respective 
function.


When the 'ini' keyword is parsed a second time, Python would then 
evaluate each cached function on its cached parameter list; and the 
result would be stored in the created list.

This cached execution would be repeated as many times as is needed.

Now, for your example:

values = zip(samples, times * num_groups)
 if len(values)  len(times) * num_groups:
 # raise an error

Might be done with:

values = zip(   samples, [ lambda:times, ini xrange(num_groups) ]   )
if len(values)  len(times) * num_groups

The comma after the lambda is questionable, and this construction would 
be slower since lambda automatically invokes the interpreter; but it's 
correct.


If you could provide a built in which returns a reference to the 
parameter passed to it; that would run at max system speed; by default, 
all built-in object initializers are maximally fast.


The key difference is that the ini syntax evaluates the parameter lists 
only once; and the ini's purpose is for repeating an initialization of 
the same kind of object in multiple different places.


As an aside, how would you do the lambda inside a list comprehension?
[lambda:6 for i in xrange(10) ] # Nope.
Generic lists allow a spurrious comma, so that [  3,3,3, ] = [3,3,3] 
dropped;

[lambda:6, for i in xrange(10) ] # but this is no good.

I have to do:
def ref(): return 6
[ref(x) for i in xrange(10) ]

Of course you got an integer. You took an index of the range object, 
not a slice. The rule is that taking an index of a sequence returns an 
element; taking a slice of a sequence returns a sub-sequence. You 
still have not shown any inconsistency here.


Because it's an arbitrary rule which operates differently than the 
traditional idea shown in python docs?


slice.indices()  is *for* (QUOTE)representing the _set of indices_ 
specified by _range_(start, stop, step)

http://docs.python.org/2/library/functions.html#slice

There are examples of python doing this; use Google...  They use slice 
indices() to convert negative indexes into positive ones _compatible 
with range()_.


some_getitem_method_in_a_subclass_foo( self, range ):
ret=[]
for i in xrange( range.indices( len(self) ) ):
ret.append( self.thing[i] )
return ret

The return is equivalent to a range object in the sense that it is an 
iterator object, but it's not the same iterator object.  It will still 
work with legacy code since different iterators can be interchanged 
so long as they return the same values.


No, he wasn't. He was talking about multiplying lists of dicts, and 
whether the dicts are then copied or not, just like every other QA 
item in that dialogue was concerning whether item X in a list should 
expect to be copied when the containing list is multiplied.


I already told him several times before that what the answer was;
It doesn't copy anything except the list itself.

Then he asks, does it multiply dicts and no mention of it being inside 
a list.

He's browbeating a dead horse.

Perhaps you're not aware that on the Internet, TYPING IN ALL CAPS is 
commonly construed as SHOUTING. 

Sure, and people say:

THIS IS YELLING, AND I AM DOING IT HERE AS AN EXAMPLE.
This is STRESS.
This is SHOCK!

I don't recall typing any _full sentence_ in all caps, if I did, I'm 
awfully sorry.  I didn't mean it.
Yes, he is beginning to get condescendingly exasperating.  Everyone else 
seems to understand 85+% of what I say, correctly.  He doesn't; and now 

Re: Multi-dimensional list initialization

2012-11-07 Thread Steven D'Aprano
On Thu, 08 Nov 2012 00:30:53 +, Oscar Benjamin wrote:

 Every now and again I come across somebody who tries to distinguish
 between call by foo and pass by foo, but nobody has been able to
 explain the difference (if any) to me. When you CALL a function, you
 PASS values to it. Hence the two terms are effectively synonyms, and
 both refer to the evaluation strategy when binding arguments to
 parameters.

 If you believe that is incorrect, can you point me to something
 explaining the difference?
 
 Did you also miss MRAB's post above? It made sense to me.

You mean MRABs post which I replied to?

Yes, I must have missed it :-P

But seriously, no I didn't miss it. He doesn't give any evidence that 
there is a difference between call by ... and pass by ... when 
talking about binding arguments to formal parameters. His objection to 
call by ... is that it doesn't make it clear that the evaluation rules 
apply to simple binding/assignment as well as calling functions.



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


Re: Multi-dimensional list initialization

2012-11-07 Thread Steven D'Aprano
On Wed, 07 Nov 2012 16:24:22 -0800, Andrew Robinson wrote:

 On 11/07/2012 01:01 PM, Ian Kelly wrote:
[...]
 Anyway, your point was to suggest that people would not be confused by
 having list multiplication copy lists but not other objects, because
 passing lists into functions as parameters works in basically the same
 way.

 Not quite; Although I wasn't clear;  The variable passed in is by
 *value* in contradistinction to the list which is by reference.  Python
 does NOT always default copy by reference *when it could*; that's the
 point.

It isn't clear to me whether you are describing what you think Python 
*actually* does, versus what you wish it *would* do, or what it *could* 
do in some abstract hypothetical sense.

It certainly is not true that Python passes the variable by value, and 
lists by reference. Arguments are not passed to functions either by 
value or by reference.

There is a trivial test for pass-by-value semantics: does the value get 
copied? We can see that Python does not copy arguments:

py def test(x):
... print id(x)
... 
py spam = []
py print id(spam); test(spam)
3071264556
3071264556

The argument is not copied, therefore Python is not pass-by-value.

There is also an easy test for pass-by-reference semantics: can you write 
a procedure which, given two variables, swaps the contents of the 
variables? In Pascal, that is trivial.

procedure swap(var a: int, var b: int):
  var
tmp: int;
  begin
tmp := a;
a := b;
b := a;
  end;

swap(x, y);

(if I've remembered my Pascal syntax correctly).


In Python, you can swap two values like this:

a, b = b, a

but that's not sufficient. The test is to do the swap inside a function:

def swap(a, b):
return b, a

b, a = swap(a, b)

But that fails too, since the assignment is still taking place outside 
the function.

It turns out that there is no way in Python to write such a swap 
function. Tricks such as passing the variable names as strings, then 
using exec, are hacks and don't count. Python is not pass by reference 
either.



 Hence the programmer has to remember in  foo( x,y ), the names x and y
 when assigned to -- *DONT* affect the variables from which they came.
 But any object internals do affect the objects everywhere.

Ummm yes?

The programmer has to remember Python's execution model in order to 
correctly predict what Python will do. What's your point?


 A single exception exists; 

There is no such exception in Python. Python always uses the same 
argument passing (parameter binding) semantics.



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


Re: Multi-dimensional list initialization

2012-11-07 Thread Andrew Robinson

On 11/07/2012 04:00 PM, Steven D'Aprano wrote:

Andrew, it appears that your posts are being eaten or rejected by my
ISP's news server, because they aren't showing up for me. Possibly a side-
effect of your dates being in the distant past?
Date has been corrected since two days ago.  It will remain until a 
reboot

Ignorance, though, might be bliss...

Every now and again I come across somebody who tries to distinguish 
between call by foo and pass by foo, but nobody has been able to 
explain the difference (if any) to me.
I think the Call by foo came into vogue around the time of C++; Eg: 
It's in books like C++ for C programmers;  I never saw it used before 
then so I *really* don't know for sure...


I know Pass by value existed all the way back to the 1960's.  I see 
pass by in my professional books from those times and even most newer 
ones; but I only find Call by value in popular programming books of 
more recent times.  (Just my experience)  So -- I guess the reason is 
that when invoking a subroutine, early hardware often had an assembler 
mnemonic by the name call.


See for example: Intelx86 hardware books from the 1970's;

Most early processors (like the MC6809E, and 8080) allow both direct and 
indirect *references* to a function (C would call them function 
pointers); So, occasionally early assembly programs comment things like: 
; dynamic VESA libraries are called by value in register D.;  And they 
meant that register D is storing a function call address from two or 
more vesa cards.  It had little to do with the function's parameters, 
(which might be globals anyway)  (It procedural dynamic binding!)


Today, I don't know for sure -- so I just don't use it.
pass indicates a parameter of the present call; but not the present 
call itself.


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


Re: how-to use readline.set_completion_display_matches_hook()?

2012-11-07 Thread Jean-Pierre Miceli
Thanks,

I will try rl. 

Have a nice day
J-P

Le 7 nov. 2012 à 14:14, Stefan H. Holek a écrit :

 On 07.11.2012, at 11:36, Jean-Pierre Miceli wrote:
 
 Hi all,
 
 I'm working on a tool which enable support of tab completion using the
 readline modul.
 And I have a problem with set_completion_display_matches_hook function
 
 I've created a display hook function and registered it. It is called
 and it prints the desire messages. But once it has completed,
 readline/python does not display the prompt.
 I've got to press the 'return' key to see the prompt again.
 What should the display hook function do to return correctly and let
 the prompt be displayed?
 
 Example:
 def completerHook(self, substitution, matches, longest_match_length):
   print 
   print Test of the display hook function
   for i in range(len(matches)):
 print matches[i],
 
 I use Python 2.7.3 and done some tests on Mac OS 10.7 (Lion) and
 Ubuntu. I got the same issue on both system.
 
 This always happens when you print newlines behind readline's back. To update 
 the prompt area, you'd have to call rl_forced_update_display() which is AFAIK 
 not exposed by the stdlib's readline bindings.
 
 There is a more complete implementation of the GNU Readline APIs at 
 http://pypi.python.org/pypi/rl. With rl you can fix the prompt by calling 
 rl.readline.redisplay(force=True) after the hook has returned.
 
 Hope this helps,
 Stefan
 
 -- 
 Stefan H. Holek
 ste...@epy.co.at
 

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


Re: Multi-dimensional list initialization

2012-11-07 Thread Ian Kelly
On Wed, Nov 7, 2012 at 8:13 PM, Andrew Robinson
andr...@r3dsolutions.com wrote:
 OK, and is this a main use case?  (I'm not saying it isn't I'm asking.)

I have no idea what is a main use case.

 There is a special keyword which signals the new type of comprehension;  A
 normal comprehension would say eg: '[ foo for i in xrange ]'; but when the
 'for i in' is reduced to a specific keyword such as 'ini' (instead of
 problematic 'in') the caching form of list comprehension would start.

FYI, the Python devs are not very fond of adding new keywords.  Any
time a new keyword is added, existing code that uses that word as a
name is broken.  'ini' is particularly bad, because 1) it's not a
word, and 2) it's the name of a common type of configuration file and
is probably frequently used as a variable name in relation to such
files.

 So, then, just like a comprehension -- the interpreter will begin to
 evaluate the code from the opening bracket '['; But anything other than a
 function/method will raise a type error (people might want to change that,
 but it's safe).

 The interpreter then caches all functions/initialiser methods it comes into
 contact with.
 Since every function/method has a parameter list (even if empty);  The
 interpreter would evaluate the parameter list on the first pass through the
 comprehension, and cache each parameter list with it's respective function.

 When the 'ini' keyword is parsed a second time, Python would then evaluate
 each cached function on its cached parameter list; and the result would be
 stored in the created list.
 This cached execution would be repeated as many times as is needed.

 Now, for your example:

 values = zip(samples, times * num_groups)
 if len(values)  len(times) * num_groups:
 # raise an error

 Might be done with:

 values = zip(   samples, [ lambda:times, ini xrange(num_groups) ]   )

 if len(values)  len(times) * num_groups

 The comma after the lambda is questionable, and this construction would be
 slower since lambda automatically invokes the interpreter; but it's correct.

How is this any better than the ordinary list comprehension I already
suggested as a replacement?  For that matter, how is this any better
than list multiplication?  Your basic complaint about list
multiplication as I understand it is that the non-copying semantics
are unintuitive.  Well, the above is even less intuitive.  It is
excessively complicated and almost completely opaque.  If I were to
come across it outside the context of this thread, I would have no
idea what it is meant to be doing.

 As an aside, how would you do the lambda inside a list comprehension?

As a general rule, I wouldn't.  I would use map instead.

 [lambda:6 for i in xrange(10) ] # Nope.

Thak constructs a list of 10 functions and never calls them.  If you
want to actually call the lambda, then:

[(lambda: 6)() for i in range(10)]

or:

map(lambda i: 6, range(10))

But note that the former creates equivalent 10 functions and calls
each of them once, whereas the latter creates one function and calls
it ten times.

 Of course you got an integer. You took an index of the range object, not a
 slice. The rule is that taking an index of a sequence returns an element;
 taking a slice of a sequence returns a sub-sequence. You still have not
 shown any inconsistency here.


 Because it's an arbitrary rule which operates differently than the
 traditional idea shown in python docs?

 slice.indices()  is *for* (QUOTE)representing the set of indices specified
 by range(start, stop, step)
 http://docs.python.org/2/library/functions.html#slice

slice.indices() has nothing to do with it.  Indexing a sequence and
calling the .indices() method on a slice are entirely different
operations.  The slice.indices method is a utility method meant to be
called by __getitem__ implementations when doing slicing, not an
implementation of indexing.  When a sequence is indexed, there is no
slice.  That method is not related in any way to the semantics of
indexing a sequence.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: get weekday as week number in a month

2012-11-07 Thread Ian Kelly
On Thu, Nov 8, 2012 at 12:09 AM, Nikhil Verma varma.nikhi...@gmail.com wrote:
 What i want to know is if i convert it to

 date_object = datetime.strptime(' Friday November 9 2012 11:30PM', '%u %B %d
 %Y %I:%M%p' )

 It is giving me ValueError saying u is unsupported directive !

Use '%A' to match 'Friday', not '%u'.  The full list of directives can
be found at:

http://docs.python.org/2/library/time.html#time.strftime

 How can i get weekday as week number ?

Is this what you're looking for?

 datetime.strptime('Friday November 9 2012 11:30PM', '%A %B %d %Y 
 %I:%M%p').weekday()
4
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Immutability and Python

2012-11-07 Thread Thomas Rachel

Am 29.10.2012 16:20 schrieb andrea crotti:


Now on one hand I would love to use only immutable data in my code, but
on the other hand I wonder if it makes so much sense in Python.


You can have both. Many mutable types distinguish between them with 
their operators.


To pick up your example,


class NumWrapper(object):
def __init__(self, number):
self.number = number
def __iadd__(self, x):
self.number += x
return self
def __add__(self, x):
return NumWrapper(self.number + x)

So with

number += 1

you keep the same object and modify it, while with

number = number + 1

or

new_number = number + 1

you create a new object.



But more importantly normally classes are way more complicated than my
stupid example, so recreating a new object with the modified state might
be quite complex.

Any comments about this? What do you prefer and why?


That's why I generally prefer mutable objects, but it can depend.


Thomas

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


[issue15001] segmentation fault with del sys.module['__main__']

2012-11-07 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b256d054f229 by Hynek Schlawack in branch '3.2':
Issue #15001: fix segfault on del sys.module['__main__']
http://hg.python.org/cpython/rev/b256d054f229

New changeset 215297665098 by Hynek Schlawack in branch '3.3':
Issue #15001: fix segfault on del sys.module['__main__']
http://hg.python.org/cpython/rev/215297665098

New changeset 859ef54bdce2 by Hynek Schlawack in branch 'default':
Issue #15001: fix segfault on del sys.module['__main__']
http://hg.python.org/cpython/rev/859ef54bdce2

--
nosy: +python-dev

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



[issue15001] segmentation fault with del sys.modules['__main__']

2012-11-07 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
title: segmentation fault with del sys.module['__main__'] - segmentation fault 
with del sys.modules['__main__']

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



[issue14621] Hash function is not randomized properly

2012-11-07 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

Here's a demo patch (against Python 2.7) which counts hash value collisions and 
slot collisions. I had posted that in the original ticket where we discussed 
the hash problem (http://bugs.python.org/issue14621).

This avoids issues like attack 1 mentioned in 
http://mail.python.org/pipermail/python-dev/2012-January/115726.html

Attack 2 in that email can easily be worked around by reducing the collision 
limit to a smaller number.

Even better: An application could even dynamically adjust the maximum collision 
counts by catching the exception and setting a new upper limit depending on its 
knowledge of the field of application - warning the sysadmin of a potential 
problem and allowing her to take action. That way the application could start 
with a low safe maximum collision number of say 100 and then raise the limit in 
a controlled way.

BTW: When trying out new hash functions, you need to look not only at the 
performance of the hash function, but also (and more importantly) at the effect 
on dictionaries.

Just as reminder: The integer key problem is still open. Using the demo script 
http://bugs.python.org/file24300/integercollision.py, it's easy to keep Python 
going for minutes without any major effort.

I don't understand why we are only trying to fix the string problem and 
completely ignore other key types. Strings are easy to send to a web server, 
yes, but there are other applications out there which take input data from 
other sources/formats as well (e.g. csv files). And it's not unusual to convert 
input strings to integers to use them as dictionary keys, say item IDs or 
counts. So while the string keys may not cause a problem, the integer keys 
still might.

--
keywords: +patch
Added file: http://bugs.python.org/file27917/hash-attack-3.patch

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



[issue16413] Non cross-platform behavior of os.path.split

2012-11-07 Thread anatoly techtonik

anatoly techtonik added the comment:

I don't know about the differences. An expert is required.

--

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



[issue14621] Hash function is not randomized properly

2012-11-07 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 07.11.2012 09:34, Marc-Andre Lemburg wrote:
 
 Here's a demo patch (against Python 2.7) which counts hash value collisions 
 and slot collisions. I had posted that in the original ticket where we 
 discussed the hash problem (http://bugs.python.org/issue14621).

Sorry, wrong URL. The correct one is http://bugs.python.org/issue13703

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 07 2012)
 Python Projects, Consulting and Support ...   http://www.egenix.com/
 mxODBC.Zope/Plone.Database.Adapter ...   http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


::: Try our new mxODBC.Connect Python Database Interface for free ! 

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/

--

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



[issue14621] Hash function is not randomized properly

2012-11-07 Thread Giovanni Bajo

Giovanni Bajo added the comment:

Until it's broken with a yet-unknown attack, SipHash is a pseudo-random 
function and as such it does uniformly distribute values across the output 
space, and never leak any information on the key (the randomized seed). Being 
designed by cryptographers, it is likely that it doesn't turn out to be a 
fail like the solution that was just released (no offense intended, but it's 
been a large-scale PR failure).

As long as we don't introduce bias while reducing SipHash's output to fit the 
hash table size (so for instance, usage of modulus is not appropriate), then 
the hash function should behave very well.

Any data type can be supplied to SipHash, including numbers; you just need to 
take their (platform-dependent) memory representation and feed it to SipHash. 
Obviously it will be much much slower than the current function which used to 
be hash(x) = x (before randomization), but that's the price to pay to avoid 
security issues.

--

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



[issue16420] PEP 249 (DB-API 2.0) converted to reStructuredText

2012-11-07 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

For some reason, the roundup bot didn't pick up the check in, so here's the 
reference by hand:

http://hg.python.org/peps/rev/95a73d5a3af7
changeset:   4578:95a73d5a3af7
user:Marc-Andre Lemburg m...@egenix.com
date:Wed Nov 07 09:42:07 2012 +0100
summary:
  Issue #16420:
Convert PEP 249 (DB-API 2.0) to ReST format to allow linking to the
various parts.

The conversion was done mostly by Daniele Varrazzo.

--

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



[issue16420] PEP 249 (DB-API 2.0) converted to reStructuredText

2012-11-07 Thread Marc-Andre Lemburg

Changes by Marc-Andre Lemburg m...@egenix.com:


--
status: open - closed

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



[issue15001] segmentation fault with del sys.modules['__main__']

2012-11-07 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 4ebe1ede981e by Hynek Schlawack in branch '2.7':
Issue #15001: fix segfault on del sys.modules['__main__']
http://hg.python.org/cpython/rev/4ebe1ede981e

--

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



[issue15001] segmentation fault with del sys.modules['__main__']

2012-11-07 Thread Hynek Schlawack

Hynek Schlawack added the comment:

This should be fixed now, thanks to all who helped!

--
resolution:  - fixed
stage: commit review - committed/rejected
status: open - closed

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



[issue16425] minidom replaceChild(new_child, old_child) removes new_child even if in another document

2012-11-07 Thread Martin Kugler

New submission from Martin Kugler:

Calling doc.replaceChild(new_child, old_child) with new_child and old_child 
being similar nodes in two different documents results in new_child to be 
removed from its document instead of old_child being removed from doc.

Example:
new_child = get_element_x(doc_a)
old_child = get_element_x(doc_b)
parent = get_element_y(doc_b)
parent.replaceChild(new_child, old_child)

= new_child will be removed from doc_a. Instead old_child should be removed 
from doc_b.

--
components: XML
messages: 175057
nosy: Martin.Kugler
priority: normal
severity: normal
status: open
title: minidom replaceChild(new_child, old_child) removes new_child even if in 
another document
type: behavior
versions: Python 2.7

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



[issue16422] Decimal constants should be the same for py c module versions

2012-11-07 Thread Stefan Krah

Stefan Krah added the comment:

It would be possible to translate strings to integers; the infrastructure
is already there for pickling. The decision not to do that was actually
deliberate: Up to now no one has requested string constants for rounding
modes and I *suspect* that there's a performance penalty even though I
didn't measure it.


See Modules/_decimal/_decimal.c:1211 for the code that would need to
be called each time something like this occurs:

  context.rounding = ROUND_UP

--

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



[issue16421] importlib.machinery.ExtensionFileLoader cannot load several modules from the same shared object

2012-11-07 Thread Václav Šmilauer

Václav Šmilauer added the comment:

Attaching patch based on Andrew's review, agains latest hg (80291:859ef54bdce).

For the MSVC files, I copied what was there for _testcapimodule in PC/VS9.0 and 
PCbuild, and created two new UUIDs: one for _testimportmultiple itself 
(36D0C52C-DF4E-45D0-8BC7-E294C3ABC781; used in .sln, .vcproj and .vcxproj 
files), and one for _testimportmultiple.vcxproj.filters 
(1ec38ad9-1abf-4b80-8628-ac43ccba324b; used only once).

Please check that I did that correctly. (I am wondering how can one maintain 
such a build system.)

I also added myself to Misc/ACKS (and sent contributor agreement by mail), 
added the entry to Misc/NEWS.

--
components: +Extension Modules -Interpreter Core
type: enhancement - behavior
versions: +Python 3.5 -Python 3.4
Added file: http://bugs.python.org/file27918/many-modules-in-one-so_3.diff

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



[issue16424] regression: os.path.split('//hostname/foo/bar.txt')

2012-11-07 Thread anatoly techtonik

anatoly techtonik added the comment:

Does that mean that Py3's split() uses splitunc() instead of splitdrive()?

--

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



[issue16424] regression: os.path.split('//hostname/foo/bar.txt')

2012-11-07 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

No. splitunc() is deprecated.

http://docs.python.org/3/library/os.path.html#os.path.splitdrive
http://docs.python.org/3/library/os.path.html#os.path.splitunc

--

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



[issue16424] regression: os.path.split('//hostname/foo/bar.txt')

2012-11-07 Thread anatoly techtonik

anatoly techtonik added the comment:

Ok, so how to fix the regression?

--

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



[issue16426] RoundUp signature removal test (please ignore)

2012-11-07 Thread Marc-Andre Lemburg

New submission from Marc-Andre Lemburg:

As discussed on http://psf.upfronthosting.co.za/roundup/meta/issue491, I'm 
creating this ticket to test the roundup email interface.

--
assignee: lemburg
components: None
messages: 175063
nosy: lemburg
priority: normal
severity: normal
status: open
title: RoundUp signature removal test (please ignore)
type: behavior

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



[issue16426] RoundUp signature removal test (please ignore)

2012-11-07 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 07.11.2012 11:33, Marc-Andre Lemburg wrote:
 
 New submission from Marc-Andre Lemburg:
 
 As discussed on http://psf.upfronthosting.co.za/roundup/meta/issue491, I'm 
 creating this ticket to test the roundup email interface.

Email reply 1.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 07 2012)
 Python Projects, Consulting and Support ...   http://www.egenix.com/
 mxODBC.Zope/Plone.Database.Adapter ...   http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


::: Try our new mxODBC.Connect Python Database Interface for free ! 

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/

--

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



[issue16426] RoundUp signature removal test (please ignore)

2012-11-07 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 07.11.2012 11:34, M.-A. Lemburg wrote:
 On 07.11.2012 11:33, Marc-Andre Lemburg wrote:

 New submission from Marc-Andre Lemburg:

 As discussed on http://psf.upfronthosting.co.za/roundup/meta/issue491, I'm 
 creating this ticket to test the roundup email interface.
 
 Email reply 1.

Email reply 2.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 07 2012)
 Python Projects, Consulting and Support ...   http://www.egenix.com/
 mxODBC.Zope/Plone.Database.Adapter ...   http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


::: Try our new mxODBC.Connect Python Database Interface for free ! 

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/

--

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



[issue16426] RoundUp signature removal test (please ignore)

2012-11-07 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 07.11.2012 11:34, Marc-Andre Lemburg wrote:
 
 Marc-Andre Lemburg added the comment:
 
 On 07.11.2012 11:34, M.-A. Lemburg wrote:
 On 07.11.2012 11:33, Marc-Andre Lemburg wrote:

 New submission from Marc-Andre Lemburg:

 As discussed on http://psf.upfronthosting.co.za/roundup/meta/issue491, I'm 
 creating this ticket to test the roundup email interface.

 Email reply 1.
 
 Email reply 2.

Email reply 3.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 07 2012)
 Python Projects, Consulting and Support ...   http://www.egenix.com/
 mxODBC.Zope/Plone.Database.Adapter ...   http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


::: Try our new mxODBC.Connect Python Database Interface for free ! 

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/

--

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



[issue16426] RoundUp signature removal test (please ignore)

2012-11-07 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 07.11.2012 11:35, M.-A. Lemburg wrote:
 On 07.11.2012 11:34, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:34, M.-A. Lemburg wrote:
 On 07.11.2012 11:33, Marc-Andre Lemburg wrote:

 New submission from Marc-Andre Lemburg:

 As discussed on http://psf.upfronthosting.co.za/roundup/meta/issue491, I'm 
 creating this ticket to test the roundup email interface.

 Email reply 1.

 Email reply 2.
 
 Email reply 3.

Email reply 4.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 07 2012)
 Python Projects, Consulting and Support ...   http://www.egenix.com/
 mxODBC.Zope/Plone.Database.Adapter ...   http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


::: Try our new mxODBC.Connect Python Database Interface for free ! 

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/

--

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



[issue16426] RoundUp signature removal test (please ignore)

2012-11-07 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 07.11.2012 11:35, Marc-Andre Lemburg wrote:
 
 Marc-Andre Lemburg added the comment:
 
 On 07.11.2012 11:35, M.-A. Lemburg wrote:
 On 07.11.2012 11:34, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:34, M.-A. Lemburg wrote:
 On 07.11.2012 11:33, Marc-Andre Lemburg wrote:

 New submission from Marc-Andre Lemburg:

 As discussed on http://psf.upfronthosting.co.za/roundup/meta/issue491, 
 I'm creating this ticket to test the roundup email interface.

 Email reply 1.

 Email reply 2.

 Email reply 3.
 
 Email reply 4.

Email reply 5 with short sig.

--

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



[issue16426] RoundUp signature removal test (please ignore)

2012-11-07 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 07.11.2012 11:36, Marc-Andre Lemburg wrote:
 
 Marc-Andre Lemburg added the comment:
 
 On 07.11.2012 11:35, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:35, M.-A. Lemburg wrote:
 On 07.11.2012 11:34, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:34, M.-A. Lemburg wrote:
 On 07.11.2012 11:33, Marc-Andre Lemburg wrote:

 New submission from Marc-Andre Lemburg:

 As discussed on http://psf.upfronthosting.co.za/roundup/meta/issue491, 
 I'm creating this ticket to test the roundup email interface.

 Email reply 1.

 Email reply 2.

 Email reply 3.

 Email reply 4.
 
 Email reply 5 with short sig.

Email reply 6 with 3 line sig.

--

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



[issue16426] RoundUp signature removal test (please ignore)

2012-11-07 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 07.11.2012 11:37, M.-A. Lemburg wrote:
 On 07.11.2012 11:36, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:35, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:35, M.-A. Lemburg wrote:
 On 07.11.2012 11:34, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:34, M.-A. Lemburg wrote:
 On 07.11.2012 11:33, Marc-Andre Lemburg wrote:

 New submission from Marc-Andre Lemburg:

 As discussed on http://psf.upfronthosting.co.za/roundup/meta/issue491, 
 I'm creating this ticket to test the roundup email interface.

 Email reply 1.

 Email reply 2.

 Email reply 3.

 Email reply 4.

 Email reply 5 with short sig.
 
 Email reply 6 with 3 line sig.

Email reply 7 with 5 line sig.

--

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



[issue16426] RoundUp signature removal test (please ignore)

2012-11-07 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 07.11.2012 11:38, M.-A. Lemburg wrote:
 On 07.11.2012 11:37, M.-A. Lemburg wrote:
 On 07.11.2012 11:36, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:35, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:35, M.-A. Lemburg wrote:
 On 07.11.2012 11:34, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:34, M.-A. Lemburg wrote:
 On 07.11.2012 11:33, Marc-Andre Lemburg wrote:

 New submission from Marc-Andre Lemburg:

 As discussed on http://psf.upfronthosting.co.za/roundup/meta/issue491, 
 I'm creating this ticket to test the roundup email interface.

 Email reply 1.

 Email reply 2.

 Email reply 3.

 Email reply 4.

 Email reply 5 with short sig (1 line).

 Email reply 6 with 3 line sig.
 
 Email reply 7 with 5 line sig.

Email reply 8 with 7 line sig.

--

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



[issue16426] RoundUp signature removal test (please ignore)

2012-11-07 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 07.11.2012 11:39, Marc-Andre Lemburg wrote:
 
 Marc-Andre Lemburg added the comment:
 
 On 07.11.2012 11:38, M.-A. Lemburg wrote:
 On 07.11.2012 11:37, M.-A. Lemburg wrote:
 On 07.11.2012 11:36, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:35, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:35, M.-A. Lemburg wrote:
 On 07.11.2012 11:34, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:34, M.-A. Lemburg wrote:
 On 07.11.2012 11:33, Marc-Andre Lemburg wrote:

 New submission from Marc-Andre Lemburg:

 As discussed on 
 http://psf.upfronthosting.co.za/roundup/meta/issue491, I'm creating 
 this ticket to test the roundup email interface.

 Email reply 1.

 Email reply 2.

 Email reply 3.

 Email reply 4.

 Email reply 5 with short sig (1 line).

 Email reply 6 with 3 line sig.

 Email reply 7 with 5 line sig.
 
 Email reply 8 with 7 line sig.

Email reply 8 with 9 line sig.

--

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



[issue16426] RoundUp signature removal test (please ignore)

2012-11-07 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 07.11.2012 11:41, Marc-Andre Lemburg wrote:
 
 Marc-Andre Lemburg added the comment:
 
 On 07.11.2012 11:39, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:38, M.-A. Lemburg wrote:
 On 07.11.2012 11:37, M.-A. Lemburg wrote:
 On 07.11.2012 11:36, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:35, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:35, M.-A. Lemburg wrote:
 On 07.11.2012 11:34, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:34, M.-A. Lemburg wrote:
 On 07.11.2012 11:33, Marc-Andre Lemburg wrote:

 New submission from Marc-Andre Lemburg:

 As discussed on 
 http://psf.upfronthosting.co.za/roundup/meta/issue491, I'm creating 
 this ticket to test the roundup email interface.

 Email reply 1.

 Email reply 2.

 Email reply 3.

 Email reply 4.

 Email reply 5 with short sig (1 line).

 Email reply 6 with 3 line sig.

 Email reply 7 with 5 line sig.

 Email reply 8 with 7 line sig.
 
 Email reply 9 with 9 line sig.

Email reply 10 with 11 line sig.

-- 
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source  (#1, Nov 07 2012)
 Python Projects, Consulting and Support ...   http://www.egenix.com/
 mxODBC.Zope/Plone.Database.Adapter ...   http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/
::: Try our new mxODBC.Connect Python Database Interface for free ! 
   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/

--

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



[issue16426] RoundUp signature removal test (please ignore)

2012-11-07 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 07.11.2012 11:42, Marc-Andre Lemburg wrote:
 
 Marc-Andre Lemburg added the comment:
 
 On 07.11.2012 11:41, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:39, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:38, M.-A. Lemburg wrote:
 On 07.11.2012 11:37, M.-A. Lemburg wrote:
 On 07.11.2012 11:36, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:35, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:35, M.-A. Lemburg wrote:
 On 07.11.2012 11:34, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:34, M.-A. Lemburg wrote:
 On 07.11.2012 11:33, Marc-Andre Lemburg wrote:

 New submission from Marc-Andre Lemburg:

 As discussed on 
 http://psf.upfronthosting.co.za/roundup/meta/issue491, I'm creating 
 this ticket to test the roundup email interface.

 Email reply 1.

 Email reply 2.

 Email reply 3.

 Email reply 4.

 Email reply 5 with short sig (1 line).

 Email reply 6 with 3 line sig.

 Email reply 7 with 5 line sig.

 Email reply 8 with 7 line sig.

 Email reply 9 with 9 line sig.
 
 Email reply 10 with 11 line sig.

Email reply 11 with 10 line sig.

-- 
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source  (#1, Nov 07 2012)
 Python Projects, Consulting and Support ...   http://www.egenix.com/
 mxODBC.Zope/Plone.Database.Adapter ...   http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/
::: Try our new mxODBC.Connect Python Database Interface for free ! 
   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611

--

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



[issue16426] RoundUp signature removal test (please ignore)

2012-11-07 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 07.11.2012 11:43, Marc-Andre Lemburg wrote:
 
 Marc-Andre Lemburg added the comment:
 
 On 07.11.2012 11:42, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:41, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:39, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:38, M.-A. Lemburg wrote:
 On 07.11.2012 11:37, M.-A. Lemburg wrote:
 On 07.11.2012 11:36, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:35, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:35, M.-A. Lemburg wrote:
 On 07.11.2012 11:34, Marc-Andre Lemburg wrote:

 Marc-Andre Lemburg added the comment:

 On 07.11.2012 11:34, M.-A. Lemburg wrote:
 On 07.11.2012 11:33, Marc-Andre Lemburg wrote:

 New submission from Marc-Andre Lemburg:

 As discussed on 
 http://psf.upfronthosting.co.za/roundup/meta/issue491, I'm 
 creating this ticket to test the roundup email interface.

 Email reply 1.

 Email reply 2.

 Email reply 3.

 Email reply 4.

 Email reply 5 with short sig (1 line).

 Email reply 6 with 3 line sig.

 Email reply 7 with 5 line sig.

 Email reply 8 with 7 line sig.

 Email reply 9 with 9 line sig.

 Email reply 10 with 11 line sig.
 
 Email reply 11 with 10 line sig.

Email reply 12 with 9 line (excluding empty lines) sig.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 07 2012)
 Python Projects, Consulting and Support ...   http://www.egenix.com/
 mxODBC.Zope/Plone.Database.Adapter ...   http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/

::: Try our new mxODBC.Connect Python Database Interface for free ! 

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg

--

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



  1   2   >