[py3k] print function

Requires python >= 2.6.

authorRémi Cardona <remi.cardona@free.fr>
changesetaf4a07cbe03b
branchdefault
phasedraft
hiddenyes
parent revision#45a8c70803be [py3k] except as
child revision#8d3aabff9793 [py3k] import StringIO from six.moves
files modified by this revision
distributors.py
examples/chess.py
examples/conferences.py
examples/intervals.py
examples/knights.py
examples/menza.py
examples/menza2.py
examples/menza_brute_force.py
examples/money.py
examples/money2.py
examples/queens.py
examples/queens2.py
examples/queens3.py
examples/rooks.py
examples/sudoku.py
fd.py
fi.py
propagation.py
test/__profile__.py
# HG changeset patch
# User Rémi Cardona <remi.cardona@free.fr>
# Date 1423995430 -3600
# Sun Feb 15 11:17:10 2015 +0100
# Node ID af4a07cbe03b4be9772d315d169dbdf4140fecd1
# Parent 45a8c70803be99fea942f1d71ecbcdac32528333
[py3k] print function

Requires python >= 2.6.

diff --git a/distributors.py b/distributors.py
@@ -18,10 +18,12 @@
1 
2  """
3  distributors - part of Logilab's constraint satisfaction solver.
4  """
5 
6 +from __future__ import print_function
7 +
8  from six.moves import range
9  from logilab.constraint.interfaces import DistributorInterface
10  import math, random
11 
12  def make_new_domains(domains):
@@ -95,12 +97,12 @@
13      def _distribute(self, dom1, dom2):
14          """See AbstractDistributor"""
15          variable = self.findSmallestDomain(dom1)
16          values = dom1[variable].getValues()
17          if self.verbose:
18 -            print 'Distributing domain for variable', variable, \
19 -                  'at value', values[0]
20 +            print('Distributing domain for variable', variable,
21 +                  'at value', values[0])
22          dom1[variable].removeValues(values[1:])
23          dom2[variable].removeValue(values[0])
24          return (dom1[variable], dom2[variable])
25 
26 
@@ -116,12 +118,12 @@
27          variable = self.findSmallestDomain(dom1)
28          values = dom1[variable].getValues()
29          distval = random.choice(values)
30          values.remove(distval)
31          if self.verbose:
32 -            print 'Distributing domain for variable', variable, \
33 -                  'at value', distval
34 +            print('Distributing domain for variable', variable,
35 +                  'at value', distval)
36          dom1[variable].removeValues(values)
37          dom2[variable].removeValue(distval)
38          return (dom1[variable], dom2[variable])
39 
40 
@@ -150,11 +152,11 @@
41          nb_elts = max(1, len(values)*1./nb_subspaces)
42          slices = [(int(math.floor(index * nb_elts)),
43                     int(math.floor((index + 1) * nb_elts)))
44                    for index in range(nb_subspaces)]
45          if self.verbose:
46 -            print 'Distributing domain for variable', variable
47 +            print('Distributing domain for variable', variable)
48          modified = []
49          for (dom, (end, start)) in zip(args, slices) :
50              dom[variable].removeValues(values[:end])
51              dom[variable].removeValues(values[start:])
52              modified.append(dom[variable])
diff --git a/examples/chess.py b/examples/chess.py
@@ -15,10 +15,11 @@
53  #
54  # You should have received a copy of the GNU Lesser General Public License along
55  # with logilab-constraint. If not, see <http://www.gnu.org/licenses/>.
56  """Chess constraints and domains"""
57 
58 +from __future__ import print_function
59 
60  from logilab.constraint import fd
61  from logilab.constraint.propagation import AbstractConstraint, ConsistencyFailure
62 
63  class ChessDomain(fd.FiniteDomain):
@@ -71,9 +72,9 @@
64              dom2.removeValues([val for val in values2 if val not in keep2])
65          except ConsistencyFailure:
66              raise ConsistencyFailure('Inconsistency while applying %s' % \
67                                       repr(self))
68          except Exception:
69 -            print self, kwargs
70 +            print(self, kwargs)
71              raise
72          return maybe_entailed
73 
diff --git a/examples/conferences.py b/examples/conferences.py
@@ -14,10 +14,11 @@
74  # for more details.
75  #
76  # You should have received a copy of the GNU Lesser General Public License along
77  # with logilab-constraint. If not, see <http://www.gnu.org/licenses/>.
78 
79 +from __future__ import print_function
80 
81  # import Repository, ListDomain and MathematicConstraint
82  from logilab.constraint import *
83  variables = ('c01','c02','c03','c04','c05','c06','c07','c08','c09','c10')
84  values = [(room,slot)
@@ -49,17 +50,17 @@
85            ('c01','c03','c07','c08'))
86  for g in groups:
87      for conf1 in g:
88          for conf2 in g:
89              if conf2 > conf1:
90 -                print '%s[1] != %s[1]'%(conf1,conf2)
91 +                print('%s[1] != %s[1]'%(conf1,conf2))
92                  constraints.append(fd.make_expression((conf1,conf2),
93                                                        '%s[1] != %s[1]'%\
94                                                        (conf1,conf2)))
95 
96 
97  constraints.append(fd.AllDistinct(variables))
98 
99  r = Repository(variables,domains,constraints)
100  solutions = Solver().solve(r)
101 -print solutions
102 -print len(solutions)
103 +print(solutions)
104 +print(len(solutions))
diff --git a/examples/intervals.py b/examples/intervals.py
@@ -21,10 +21,11 @@
105 
106  """
107  Example problem with intervals
108  """
109 
110 +from __future__ import print_function
111 
112  from logilab.constraint import *
113  from logilab.constraint.distributors import *
114 
115  def intervals(size=5,verbose=0):
@@ -70,17 +71,17 @@
116              first = 1
117      count = 0
118      for sol in intervals(size,verbose):
119          count += 1
120          if display:
121 -            print sol
122 -            print '*'*80
123 +            print(sol)
124 +            print('*'*80)
125          if first:
126              break
127      if not display:
128 -        print 'Use -d option to display solutions'
129 -    print count,'solutions found.'
130 +        print('Use -d option to display solutions')
131 +    print(count,'solutions found.')
132 
133  if __name__ == '__main__':
134  ##     import hotshot
135  ##     p = hotshot.Profile('/tmp/queens.prof')
136  ##     p.runcall(main)
diff --git a/examples/knights.py b/examples/knights.py
@@ -20,10 +20,11 @@
137  """Knight tour problem:
138  Place n*n values on a checker so
139  that consecutive values are a knight's
140  move away from each other"""
141 
142 +from __future__ import print_function
143 
144  from logilab.constraint import *
145  from logilab.constraint.distributors import *
146 
147  def knight_tour(size=6,verbose=0):
@@ -88,11 +89,11 @@
148              # numbering should start from 1 ,not 0
149              intsquare = int(square[1:4]) + 1
150              board+='|%02s'%intsquare
151          board+='|\n'
152      board += '�'*(size*3+1)+'\n'
153 -    print board
154 +    print(board)
155 
156 
157  if __name__ == '__main__':
158      import sys,getopt
159      opts,args = getopt.getopt(sys.argv[1:],'dv')
@@ -108,7 +109,7 @@
160          elif o == '-v':
161              verbose += 2
162      count = 0
163      sol = knight_tour(size,verbose)
164      if display:
165 -        print 'Solution found:'
166 +        print('Solution found:')
167          draw_solution(sol,size)
diff --git a/examples/menza.py b/examples/menza.py
@@ -19,10 +19,12 @@
168  Solve a puzzle that got discussed on c.l.p. on october 2002
169 
170  ABC*DE=FGHIJ with all letters different and in domain [0,9]
171  """
172 
173 +from __future__ import print_function
174 +
175  from logilab.constraint import *
176  from logilab.constraint.propagation import BasicConstraint, ConsistencyFailure
177 
178  class DistinctDigits(BasicConstraint):
179      def __init__(self,variable):
@@ -78,14 +80,14 @@
180          elif o == '-d':
181              display = 1
182 
183 
184      r = create_problem()
185 -    print 'problem created. let us solve it.'
186 +    print('problem created. let us solve it.')
187      s = []
188      for sol in Solver().solve_all(r,verbose):
189          s.append(sol)
190          if display:
191              sol['c'] = sol['a']*sol['b']
192 -            print "%(a)s x %(b)s = %(c)s" % sol
193 +            print("%(a)s x %(b)s = %(c)s" % sol)
194      if not display:
195 -        print 'Found %d solutions'%len(s)
196 +        print('Found %d solutions'%len(s))
diff --git a/examples/menza2.py b/examples/menza2.py
@@ -19,10 +19,12 @@
197  Solve a puzzle that got discussed on c.l.p. on october 2002
198 
199  ABC*DE=FGHIJ with all letters different and in domain [0,9]
200  """
201 
202 +from __future__ import print_function
203 +
204  from logilab.constraint import *
205  from logilab.constraint.distributors import DichotomyDistributor
206  from logilab.constraint.propagation import BasicConstraint, ConsistencyFailure
207 
208  class DistinctDigits(BasicConstraint):
@@ -85,14 +87,14 @@
209              verbose += 1
210          elif o == '-d':
211              display = 1
212 
213      r = mensa()
214 -    print 'problem created. let us solve it.'
215 +    print('problem created. let us solve it.')
216      s = []
217      for sol in Solver().solve_all(r,verbose):
218          s.append(sol)
219          if display:
220              sol['c'] = sol['x']*sol['y']
221 -            print "%(x)s x %(y)s = %(c)s" % sol
222 +            print("%(x)s x %(y)s = %(c)s" % sol)
223      if not display:
224 -        print 'Found %d solutions'%len(s)
225 +        print('Found %d solutions'%len(s))
diff --git a/examples/menza_brute_force.py b/examples/menza_brute_force.py
@@ -14,10 +14,12 @@
226  # for more details.
227  #
228  # You should have received a copy of the GNU Lesser General Public License along
229  # with logilab-constraint. If not, see <http://www.gnu.org/licenses/>.
230 
231 +from __future__ import print_function
232 +
233  def menza():
234      sol = []
235      all_digits = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
236      for a in range(1000) :
237          for b in range(100) :
@@ -25,11 +27,11 @@
238              if c > 9999:
239                  digits = list("%.3d%.2d%.5d" % (a, b, c))
240                  digits.sort()
241                  if digits == all_digits :
242                      sol.append({'a': a, 'b': b})
243 -                    print "%.3d x %.2d = %.5d" % (a, b, c)
244 +                    print("%.3d x %.2d = %.5d" % (a, b, c))
245      return sol
246 
247  if __name__ == '__main__':
248      sol = menza()
249 -    print len(sol)
250 +    print(len(sol))
diff --git a/examples/money.py b/examples/money.py
@@ -15,10 +15,11 @@
251  # for more details.
252  #
253  # You should have received a copy of the GNU Lesser General Public License along
254  # with logilab-constraint. If not, see <http://www.gnu.org/licenses/>.
255 
256 +from __future__ import print_function
257 
258  from logilab.constraint import *
259 
260  def money(verbose=0):
261      """ SEND
@@ -50,15 +51,15 @@
262      s = Solver().solve_one(r, verbose)
263      return s
264 
265  def display_solution(d):
266      for s in d:
267 -        print '  SEND\t  \t','  %(s)d%(e)d%(n)d%(d)d'%s
268 -        print '+ MORE\t  \t','+ %(m)d%(o)d%(r)d%(e)d'%s
269 -        print '------\t-->\t','------'
270 -        print ' MONEY\t  \t',' %(m)d%(o)d%(n)d%(e)d%(y)d'%s
271 -        print
272 +        print('  SEND\t  \t','  %(s)d%(e)d%(n)d%(d)d'%s)
273 +        print('+ MORE\t  \t','+ %(m)d%(o)d%(r)d%(e)d'%s)
274 +        print('------\t-->\t','------')
275 +        print(' MONEY\t  \t',' %(m)d%(o)d%(n)d%(e)d%(y)d'%s)
276 +        print()
277 
278  if __name__ == '__main__':
279      import sys, getopt
280      opts, args = getopt.getopt(sys.argv[1:], 'dv')
281      verbose = 0
@@ -70,6 +71,6 @@
282              display = 1
283      sol = money(verbose)
284      if display:
285          display_solution([sol])
286      else:
287 -        print sol
288 +        print(sol)
diff --git a/examples/money2.py b/examples/money2.py
@@ -15,10 +15,11 @@
289  # for more details.
290  #
291  # You should have received a copy of the GNU Lesser General Public License along
292  # with logilab-constraint. If not, see <http://www.gnu.org/licenses/>.
293 
294 +from __future__ import print_function
295 
296  from logilab.constraint import *
297  from logilab.constraint.distributors import SplitDistributor
298 
299  def money(verbose=0):
@@ -47,19 +48,19 @@
300      r = Repository(variables, domains, constraints)
301      s = Solver(distributor=SplitDistributor(10)).solve_one(r, verbose)
302      return s
303 
304  def display_solution(d):
305 -    print '  SEND\t  \t','  %(s)d%(e)d%(n)d%(d)d'%d
306 -    print '+ MORE\t  \t','+ %(m)d%(o)d%(r)d%(e)d'%d
307 -    print '------\t-->\t','------'
308 -    print ' MONEY\t  \t',' %(m)d%(o)d%(n)d%(e)d%(y)d'%d
309 +    print('  SEND\t  \t','  %(s)d%(e)d%(n)d%(d)d'%d)
310 +    print('+ MORE\t  \t','+ %(m)d%(o)d%(r)d%(e)d'%d)
311 +    print('------\t-->\t','------')
312 +    print(' MONEY\t  \t',' %(m)d%(o)d%(n)d%(e)d%(y)d'%d)
313 
314  if __name__ == '__main__':
315 -    print 'WARNING!'
316 -    print 'This example takes looooooooooooooots of CPU to complete.'
317 -    print 'try money.py for a faster version.'
318 +    print('WARNING!')
319 +    print('This example takes looooooooooooooots of CPU to complete.')
320 +    print('try money.py for a faster version.')
321      import sys, getopt
322      opts, args = getopt.getopt(sys.argv[1:], 'dv')
323      verbose = 0
324      display = 0
325      for o,v in opts:
@@ -69,6 +70,6 @@
326              display = 1
327      sol = money(verbose)
328      if display:
329          display_solution(sol)
330      else:
331 -        print sol
332 +        print(sol)
diff --git a/examples/queens.py b/examples/queens.py
@@ -19,10 +19,11 @@
333  # with logilab-constraint. If not, see <http://www.gnu.org/licenses/>.
334  """N queens problem
335  The problem is solved with a EnumeratorDistributor splitting
336  the smallest domain in at most N subdomains."""
337 
338 +from __future__ import print_function
339 
340  from logilab.constraint import *
341  from logilab.constraint.distributors import *
342 
343 
@@ -73,11 +74,11 @@
344                  board+='|'+'�-'[(i+j)%2]
345              else:
346                  board+='|Q'
347          board+='|\n'
348      board += '�'*(size*2+1)
349 -    print board
350 +    print(board)
351 
352 
353  def main(args = None):
354      import sys,getopt
355      if args is None:
@@ -106,18 +107,18 @@
356 
357      count = 0
358      for sol in queens(size,verbose,distrib):
359          count += 1
360          if display:
361 -            print 'solution #%d'%count
362 +            print('solution #%d'%count)
363              draw_solution(sol)
364 -            print '*'*80
365 +            print('*'*80)
366          if first:
367              break
368      if not display:
369 -        print 'Use -d option to display solutions'
370 -    print count,'solutions found.'
371 +        print('Use -d option to display solutions')
372 +    print(count,'solutions found.')
373 
374  if __name__ == '__main__':
375  ##     import hotshot
376  ##     p = hotshot.Profile('/tmp/queens.prof')
377  ##     p.runcall(main)
diff --git a/examples/queens2.py b/examples/queens2.py
@@ -19,11 +19,11 @@
378  # with logilab-constraint. If not, see <http://www.gnu.org/licenses/>.
379  """N queens problem
380  The problem is solved with a EnumeratorDistributor splitting
381  the smallest domain in at most N subdomains."""
382 
383 -
384 +from __future__ import print_function
385 
386  from logilab.constraint import *
387  from logilab.constraint.distributors import *
388 
389  distributors = {
@@ -72,11 +72,11 @@
390                  board+='|'+'�-'[(i+j)%2]
391              else:
392                  board+='|Q'
393          board+='|\n'
394      board += '�'*(size*2+1)
395 -    print board
396 +    print(board)
397 
398 
399  def main(args = None):
400      import sys,getopt
401      if args is None:
@@ -104,21 +104,21 @@
402                  raise RuntimeError("Distributor must be one of %s" % ", ".join(distributors.keys()) )
403      count = 0
404      for sol in queens(size,verbose,distrib):
405          count += 1
406          if display:
407 -            print 'solution #%d'%count
408 +            print('solution #%d'%count)
409              draw_solution(sol)
410 -            print '*'*80
411 +            print('*'*80)
412          if first:
413              break
414      if not display:
415 -        print 'Use -d option to display solutions'
416 -    print count,'solutions found.'
417 +        print('Use -d option to display solutions')
418 +    print(count,'solutions found.')
419 
420 -    print "Domains copy:", fd.FiniteDomain._copy_count
421 -    print "Domains writes:", fd.FiniteDomain._write_count
422 +    print("Domains copy:", fd.FiniteDomain._copy_count)
423 +    print("Domains writes:", fd.FiniteDomain._write_count)
424 
425  if __name__ == '__main__':
426  ##     import hotshot
427  ##     p = hotshot.Profile('/tmp/queens.prof')
428  ##     p.runcall(main)
diff --git a/examples/queens3.py b/examples/queens3.py
@@ -19,11 +19,11 @@
429  # with logilab-constraint. If not, see <http://www.gnu.org/licenses/>.
430  """N queens problem
431  The problem is solved with a EnumeratorDistributor splitting
432  the smallest domain in at most N subdomains."""
433 
434 -
435 +from __future__ import print_function
436 
437  from logilab.constraint import *
438  from logilab.constraint.distributors import *
439  from chess import ChessDomain, QueensConstraint
440 
@@ -62,11 +62,11 @@
441                  board+='|'+'�-'[(i+j)%2]
442              else:
443                  board+='|Q'
444          board+='|\n'
445      board += '�'*(size*2+1)
446 -    print board
447 +    print(board)
448 
449 
450  def main(args = None):
451      import sys,getopt
452      if args is None:
@@ -88,18 +88,18 @@
453              first = 1
454      count = 0
455      for sol in queens(size,verbose):
456          count += 1
457          if display:
458 -            print 'solution #%d'%count
459 +            print('solution #%d'%count)
460              draw_solution(sol)
461 -            print '*'*80
462 +            print('*'*80)
463          if first:
464              break
465      if not display:
466 -        print 'Use -d option to display solutions'
467 -    print count,'solutions found.'
468 +        print('Use -d option to display solutions')
469 +    print(count,'solutions found.')
470 
471  if __name__ == '__main__':
472  ##     import hotshot
473  ##     p = hotshot.Profile('/tmp/queens.prof')
474  ##     p.runcall(main)
diff --git a/examples/rooks.py b/examples/rooks.py
@@ -19,11 +19,11 @@
475  # with logilab-constraint. If not, see <http://www.gnu.org/licenses/>.
476  """N queens problem
477  The problem is solved with a EnumeratorDistributor splitting
478  the smallest domain in at most N subdomains."""
479 
480 -
481 +from __future__ import print_function
482 
483  from logilab.constraint import *
484  from logilab.constraint.distributors import *
485 
486  def rooks(size=8,verbose=0):
@@ -63,11 +63,11 @@
487                  board+='|'+'�-'[(i+j)%2]
488              else:
489                  board+='|R'
490          board+='|\n'
491      board += '�'*(size*2+1)
492 -    print board
493 +    print(board)
494 
495 
496  def main(args = None):
497      import sys,getopt
498      if args is None:
@@ -89,18 +89,18 @@
499              first = 1
500      count = 0
501      for sol in rooks(size,verbose):
502          count += 1
503          if display:
504 -            print 'solution #%d'%count
505 +            print('solution #%d'%count)
506              draw_solution(sol)
507 -            print '*'*80
508 +            print('*'*80)
509          if first:
510              break
511      if not display:
512 -        print 'Use -d option to display solutions'
513 -    print count,'solutions found.'
514 +        print('Use -d option to display solutions')
515 +    print(count,'solutions found.')
516 
517  if __name__ == '__main__':
518  ##     import hotshot
519  ##     p = hotshot.Profile('/tmp/queens.prof')
520  ##     p.runcall(main)
diff --git a/examples/sudoku.py b/examples/sudoku.py
@@ -14,10 +14,11 @@
521  # for more details.
522  #
523  # You should have received a copy of the GNU Lesser General Public License along
524  # with logilab-constraint. If not, see <http://www.gnu.org/licenses/>.
525 
526 +from __future__ import print_function
527 
528  from logilab.constraint import *
529 
530 
531  # games found on http://www.websudoku.com/
@@ -94,12 +95,12 @@
532      return s
533 
534  def display_solution(d):
535      for i in range(9):
536          for j in range(9):
537 -            print d['v%02d_%02d'%(i,j)],
538 -        print
539 +            print(d['v%02d_%02d'%(i,j)], end=' ')
540 +        print()
541 
542  if __name__ == '__main__':
543      import sys, getopt
544      opts, args = getopt.getopt(sys.argv[1:], 'dv')
545      verbose = 0
@@ -111,6 +112,6 @@
546              display = 1
547      sol = sudoku(evil, verbose)
548      if display:
549          display_solution(sol)
550      else:
551 -        print sol
552 +        print(sol)
diff --git a/fd.py b/fd.py
@@ -25,10 +25,11 @@
553   * various BasicConstraint classes
554 
555  The Expression and BinaryExpression classes can be constructed using the
556  make_expression factory function.  """
557 
558 +from __future__ import print_function
559 
560  import operator
561 
562  from logilab.constraint.propagation import AbstractDomain, BasicConstraint, \
563                                             ConsistencyFailure, \
@@ -269,11 +270,11 @@
564 
565          except ConsistencyFailure:
566              raise ConsistencyFailure('Inconsistency while applying %s' % \
567                                       repr(self))
568          except Exception:
569 -            print self, kwargs
570 +            print(self, kwargs)
571              raise
572          return maybe_entailed
573 
574 
575  def make_expression(variables, formula, constraint_type=None):
diff --git a/fi.py b/fi.py
@@ -18,10 +18,11 @@
576  # with logilab-constraint. If not, see <http://www.gnu.org/licenses/>.
577  """Tools to work with finite interval domain interval and constraints
578 
579  """
580 
581 +from __future__ import print_function
582  from __future__ import division
583 
584 
585  from logilab.constraint.distributors import AbstractDistributor
586  from logilab.constraint.propagation import (AbstractDomain, ConsistencyFailure,
@@ -194,11 +195,11 @@
587 
588 
589      def _distribute(self, dom1, dom2):
590          variable = self.findSmallestDomain(dom1)
591          if self.verbose:
592 -            print 'Distributing domain for variable', variable
593 +            print('Distributing domain for variable', variable)
594          splitted = dom1[variable]
595          cpy1 = splitted.copy()
596          cpy2 = splitted.copy()
597 
598          self._split_values(cpy1, cpy2)
diff --git a/propagation.py b/propagation.py
@@ -14,19 +14,15 @@
599  # for more details.
600  #
601  # You should have received a copy of the GNU Lesser General Public License along
602  # with logilab-constraint. If not, see <http://www.gnu.org/licenses/>.
603  """The code of the constraint propagation algorithms"""
604 +from __future__ import print_function
605  from operator import mul as MUL
606  from time import strftime
607  from logilab.constraint.interfaces import DomainInterface, ConstraintInterface
608 
609 -def _default_printer(*msgs):
610 -    for msg in msgs[:-1]:
611 -        print msg,
612 -    print msgs[-1]
613 -
614  def quiet_printer(*args):
615      pass
616 
617  class ConsistencyFailure(Exception):
618      """The repository is not in a consistent state"""
@@ -35,11 +31,11 @@
619  class Repository(object):
620      """Stores variables, domains and constraints
621      Propagates domain changes to constraints
622      Manages the constraint evaluation queue"""
623 
624 -    def __init__(self, variables, domains, constraints = None, printer=_default_printer):
625 +    def __init__(self, variables, domains, constraints = None, printer=print):
626          # encode unicode
627          self._printer = printer
628 
629          for i, var in enumerate(variables):
630              if type(var) == type(u''):
@@ -229,11 +225,11 @@
631          return 1
632 
633  class Solver(object):
634      """Top-level object used to manage the search"""
635 
636 -    def __init__(self, distributor=None, printer=_default_printer):
637 +    def __init__(self, distributor=None, printer=print):
638          """if no distributer given, will use the default one"""
639          self.printer = printer
640          if distributor is None:
641              from logilab.constraint.distributors import DefaultDistributor
642              distributor = DefaultDistributor()
diff --git a/test/__profile__.py b/test/__profile__.py
@@ -14,10 +14,12 @@
643  # for more details.
644  #
645  # You should have received a copy of the GNU Lesser General Public License along
646  # with logilab-constraint. If not, see <http://www.gnu.org/licenses/>.
647 
648 +from __future__ import print_function
649 +
650  from logilab.constraint.propagation import *
651  from logilab.constraint import fd
652 
653 
654  def queens(size=8,verbose=0):
@@ -38,11 +40,11 @@
655                                                        'abs(%(q1)s[0]-%(q2)s[0]) != '
656                                                        'abs(%(q1)s[1]-%(q2)s[1])'%\
657                                                        {'q1':q1,'q2':q2}))
658      r = Repository(variables,domains,constraints)
659      s = Solver().solve(r,verbose)
660 -    print 'Number of solutions:',len(s)
661 +    print('Number of solutions:',len(s))
662 
663  if __name__ == '__main__':
664      import profile
665      profile.run('queens()','csp.prof')
666      import pstats