Nanpy 0.4 - Use your Arduino board with Python

2012-10-04 Thread Andrea Stagi
Hi all,

I'm really glad to announce you Nanpy 0.4, an initial version of a
project born to help developers writing their Arduino programs using
Python! I started working on this project just a month ago, so you
could find bugs, missing things etc.. if you want to contribute,
here's the GitHub page: https://github.com/Octan/nanpy , you can find
the Pypi page here: http://pypi.python.org/pypi/nanpy

Actually Nanpy supports the main parts of OneWire, Lcd,
DallasTemperature, Stepper, Servo and basic Arduino's function
(digital and analog write, tone etc..) and runs without problems on a
Raspberry PI.

Long and more detailed description:

With Nanpy you can write your Arduino programs using Python,
communicating via serial port without sending hard-to-remember codes
or limiting you to use only one object: when you create an object in
Python it will be automatically created into your Arduino at runtime..
For example if you write something like

ds = DallasTemperature(5)

or

tone = Tone(13)

Nanpy creates the correct object into Arduino.. Also, you haven't to
take care of deallocation, Nanpy deallocates objects into Arduino as
soon as the correspondent Python objects get deleted. Look at the
examples to see how simple it is..
(https://github.com/Octan/nanpy/tree/master/examples) :)

I tried running Nanpy on a Raspberry board and it works great!!
(that's the result from one of my friends Twitter account
https://twitter.com/andreagrandi/status/251702684380434434 :) ). Also
you may use it in other devices suppoting Python and serial
communication, in a web service or simply for creating prototypes
faster, because you use Python and you don't have to flash the
firmware every time. Last but not least, firmware part of Nanpy is
Python-indipendent, so you can write another implementation of Nanpy
in any other language, for example Java, and see an Arduino controlled
via Android (ok, in this case we should use Android USB Host API and
USART, writing our own driver, because Android doesn't provide
anything to access device filest).

Do you like Nanpy? Contributions/suggestions/bug reporting/spreading
the project/beers/coffee are accepted :)

Thanks for your attention!

Best regards,

=.4.S.=

-- 
=.4ndrea.Stagi.=
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[ANN] MDP-3.3 released!

2012-10-04 Thread Tiziano Zito
We are glad to announce release 3.3 of the Modular toolkit for Data
Processing (MDP). This a bug-fix release, all current users are 
invited to upgrade. 

MDP is a Python library of widely used data processing algorithms
that can be combined according to a pipeline analogy to build more
complex data processing software. The base of available algorithms
includes signal processing methods (Principal Component Analysis,
Independent Component Analysis, Slow Feature Analysis),
manifold learning methods ([Hessian] Locally Linear Embedding),
several classifiers, probabilistic methods (Factor Analysis, RBM),
data pre-processing methods, and many others.

What's new in version 3.3?
--
 - support sklearn versions up to 0.12 
 - cleanly support reload
 - fail gracefully if pp server does not start
 - several bug-fixes and improvements

Resources
-
Download: http://sourceforge.net/projects/mdp-toolkit/files
Homepage: http://mdp-toolkit.sourceforge.net
Mailing list: http://lists.sourceforge.net/mailman/listinfo/mdp-toolkit-users

Acknowledgments
---
We thank the contributors to this release: Philip DeBoer, Yaroslav Halchenko.


The MDP developers,
Pietro Berkes
Zbigniew Jędrzejewski-Szmek
Rike-Benjamin Schuppner
Niko Wilbert
Tiziano Zito
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


ANN: Python Meeting Düsseldorf - 23.10.2012

2012-10-04 Thread eGenix Team: M.-A. Lemburg
[This announcement is in German since it targets a local user group
 meeting in Düsseldorf, Germany]


ANKÜNDIGUNG

 Python Meeting Düsseldorf

 http://pyddf.de/

   Ein Treffen von Python Enthusiasten und Interessierten
in ungezwungener Atmosphäre.

  Dienstag, 23.10.2012, 18:00 Uhr
Clara Schumann Raum
  DJH Düsseldorf


Diese Nachricht können Sie auch online lesen:
http://www.egenix.com/company/news/Python-Meeting-Duesseldorf-2012-10-23


EINLEITUNG

Das Python Meeting Düsseldorf (http://pyddf.de/) ist eine neue
lokale Veranstaltung in Düsseldorf, die sich an Python Begeisterte
in der Region wendet.

Wir starten bei den Treffen mit einer kurzen Einleitung und gehen
dann zu einer Reihe Kurzvorträgen (Lightning Talks) über, bei denen
die Anwesenden über neue Projekte, interessante Probleme und
sonstige Aktivitäten rund um Python berichten können.

Anschließend geht es in eine Gaststätte, um die Gespräche zu
vertiefen.

Einen guten Überblick über die Vorträge bietet unser YouTube-Kanal,
auf dem wir die Vorträge nach den Meetings veröffentlichen:

   http://www.youtube.com/pyddf/

Veranstaltet wird das Meeting von der eGenix.com GmbH, Langenfeld,
in Zusammenarbeit mit Clark Consulting  Research, Düsseldorf:

 * http://www.egenix.com/
 * http://www.clark-consulting.eu/


ORT

Für das Python Meeting Düsseldorf haben wir den Clara Schumann
Raum in der modernen Jugendherberge Düsseldorf angemietet:

Jugendherberge Düsseldorf
Düsseldorfer Str. 1
40545 Düsseldorf
Telefon: +49 211 557310
http://www.duesseldorf.jugendherberge.de

Die Jugendherberge verfügt über eine kostenpflichtige Tiefgarage (EUR
2,50 pro Stunde, maximal EUR 10,00). Es ist aber auch möglich per
Bus und Bahn anzureisen. Der Raum befindet sich im 1.OG links.


PROGRAMM

Das Python Meeting Düsseldorf nutzt eine Mischung aus Open Space
und Lightning Talks:

Die Treffen starten mit einer kurzen Einleitung. Danach geht es
weiter mit einer Lightning Talk Session, in der die Anwesenden
Kurzvorträge von fünf Minuten halten können.

Hieraus ergeben sich dann meisten viele Ansatzpunkte für
Diskussionen, die dann den Rest der verfügbaren Zeit in Anspruch
nehmen können.

Für 19:45 Uhr haben wir in einem nahegelegenen Restaurant Plätze
reserviert, damit auch das leibliche Wohl nicht zu kurz kommt.

Lightning Talks können vorher angemeldet werden, oder auch
spontan während des Treffens eingebracht werden. Ein Beamer mit
XGA Auflösung steht zur Verfügung. Folien bitte als PDF auf USB
Stick mitbringen.

Lightning Talk Anmeldung bitte formlos per EMail an i...@pyddf.de


KOSTENBETEILIGUNG

Das Python Meeting Düsseldorf wird von Python Nutzern für Python
Nutzer veranstaltet.

Da Tagungsraum, Beamer, Internet und Getränke Kosten produzieren,
bitten wir die Teilnehmer um einen Beitrag in Höhe von EUR 10,00
inkl. 19% Mwst.

Wir möchten alle Teilnehmer bitten, den Betrag in bar mitzubringen.


ANMELDUNG

Da wir nur für ca. 20 Personen Sitzplätze haben, möchten wir
bitten, sich per EMail anzumelden. Damit wird keine Verpflichtung
eingegangen. Es erleichtert uns allerdings die Planung.

Meeting Anmeldung bitte formlos per EMail an i...@pyddf.de


WEITERE INFORMATIONEN

Weitere Informationen finden Sie auf der Webseite des Meetings:

http://pyddf.de/

Mit freundlichen Grüßen,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Oct 04 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/

2012-09-27: Released eGenix PyRun 1.1.0 ...   http://egenix.com/go35
2012-09-26: Released mxODBC.Connect 2.0.1 ... http://egenix.com/go34
2012-09-25: Released mxODBC 3.2.1 ... http://egenix.com/go33
2012-10-23: Python Meeting Duesseldorf ... 19 days to go

   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/
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:

How to execute commands on a windows machine from a Linux machine

2012-10-04 Thread Shambhu Rajak
Here i have two questions,

1.   I want  to write a framework for Linux machine that can execute
commands on windows machine:

How to create a persistent shell between Linux and Windows machine.

2.   I require to extract windows disk management features, for eg:
Number of drives on that windows machine ,

volume size of the machine, to create a partition, all these storage stuffs.
I want to achieve all these features of windows machine, from linux.

-Shambhu

 

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


Re: How to execute commands on a windows machine from a Linux machine

2012-10-04 Thread Andrew Berg
On 2012.10.04 00:13, Shambhu Rajak wrote:
 Here i have two questions,
 
 1.   I want  to write a framework for Linux machine that can execute
 commands on windows machine:
 
 How to create a persistent shell between Linux and Windows machine.
 
 2.   I require to extract windows disk management features, for eg:
 Number of drives on that windows machine ,
 
 volume size of the machine, to create a partition, all these storage
 stuffs. I want to achieve all these features of windows machine, from linux.
If you must use Python, there are execnet and RPyC, which will allow you
to execute Python code remotely. Otherwise, there is Copssh, which has
an SSH server that runs on Windows.

http://codespeak.net/execnet/
http://rpyc.sourceforge.net/
https://www.itefix.no/i2/copssh
-- 
CPython 3.3.0 | Windows NT 6.1.7601.17835
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can somebody give me an advice about what to learn?

2012-10-04 Thread Steven D'Aprano
On Wed, 03 Oct 2012 21:47:33 -0700, Chris Rebert wrote:

 On Wed, Oct 3, 2012 at 11:31 AM, Wolfgang Keller felip...@gmx.net
 wrote:
 I'm really new to Usenet/Newsgroups, but... I'd like to learn some new
 programming language, because I learnt a bit of Perl though its OOP is
 ugly. So, after searching a bit, I found Python and Ruby, and both of
 they are cute. So, assuming you'll say me learn python, why should I
 learn it over Ruby?

 The point why Ruby was started (perceived deficit of
 object-orientation) has been remedied since Python 2.2.
 
 Not completely. At the least, there's arguably still the issue of len()
 and friends (vs. `.length` etc.), and also of `self` being explicit.

I'm not entirely sure which perceived deficit of object-orientation is 
being talked about, or why anyone but OOP purists would consider that a 
problem.

Python is *more* object-oriented than Java, and I don't hear anyone 
complaining that Java isn't object-oriented. Everything[1] in Python is 
an object. *Everything*. Ints are objects. Strings are objects. Arrays 
are objects. There's no distinction between boxed and unboxed ints, 
like in Java or Haskell -- Python just has ints, and they're always 
objects.

As for len() and friends, that's a red-herring. Just because the syntax 
is written len(x) instead of x.len() doesn't make Python less object-
oriented. It's just syntax: a + b is no less OO than a.plus(b).

Somebody might not *like* the syntax a + b, or len(x), but they 
should just say so, and not pretend that it isn't OO.

Likewise self. Explicit or implicit, how does that make a language less 
or more object-oriented? That's as foolish as saying that Python isn't 
object-oriented because you don't have to declare the type of variables:

x = (float)1.234

Again, there are arguments for and against explicit self, but explicit 
self is not OO is not a valid argument.

Being object-oriented has both costs and benefits. Java compromises on 
the idea of OOP for performance: native, non-object ints are faster than 
object ints. All these people complaining that Python isn't OO enough 
because you have to write self in method declarations, why aren't they 
complaining that Java isn't OO enough because ints are unboxed primitive 
types?



[1] Emphasis on the *thing* part. Control structures aren't things in 
that sense, they aren't values at all, they are actions that takes place 
during execution.


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


Re: fastest data structure for retrieving objects identified by (x, y) tuple?

2012-10-04 Thread Oscar Benjamin
On Oct 4, 2012 3:02 AM, Steven Dapos;Aprano 
steve+comp.lang.pyt...@pearwood.info wrote:
 # populate a random matrix using both dict and list
 adict = {}
 alist = [[None]*2400 for i in range(2400)]
 from random import randrange
 for i in range(1000):
 x = randrange(2400)
 y = randrange(2400)
 adict[(x, y)] = something
 alist[x][y] = something

 import sys
 print(sys.getsizeof(adict))
 print(sys.getsizeof(alist) + sum(sys.getsizeof(L) for L in alist))


 The actual sizes printed will depend on how sparse the matrices are, but
 for the same above (approximately half full), using Python 2.7, the
 figures I get are:

 adict: 24712
 alist: 23127324

I make it 0.02% full. If it was half full the dict might not have a memory
advantage.

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


Re: final question: logging to stdout and updating files

2012-10-04 Thread Ramchandra Apte
On Thursday, 4 October 2012 08:41:35 UTC+5:30, Littlefield, Tyler  wrote:
 pHello all:
 
 I've seen frameworks like django reload files when it detects that 
 
 they've been changed; how hard would it be to make my engine reload 
 
 files that it detects were changed? I'm also curious how hard it would 
 
 be to build in some error recovery. For example right now when an 
 
 exception occurs, the player is sometimes just left hanging. It's a lot 
 
 harder with Python for me, because I don't get the compile-time errors 
 
 that I would with c++ for example to know that I did something wrong; 
 
 while that's not always useful/and by far it doesn't catch everything, 
 
 it does help. I'm familiar with things like pychecker, but it seems to 
 
 be reporting a lot of issues that aren't issues. For example, I have a 
 
 world module which is the core of the engine; it handles players, as 
 
 well as keeps tracks of all rooms that are loaded in the game and that. 
 
 Because player and world would have circular imports, I just pass the 
 
 world object into player functions like logon/create. Pychecker tells me 
 
 that the world parameter (which is a local var at that point) shadows 
 
 the world variable in world; world is a singleton, so when you import 
 
 world it just has a world = World() at the bottom of the module.
 
 
 
 also: I have the following code:
 
  logging.basicConfig(filename=path.join(logs, mud.log), 
 
 level=logging.DEBUG)
 
  logger = logging.getLogger(__name__)
 
  logger.addHandler(logging.StreamHandler())
 
 I like it displaying to stderr since usually when I'm doing this I'm in 
 
 screen bouncing back and forth between the output and the tt++ session, 
 
 but right now I can't get a couple of things; I'm not sure how to set it 
 
 to log and all other messages to stderr as I did for the file, and I'd 
 
 like to use a rotating log handler so that it'll rotate when the files 
 
 are say above 16 KB or something. Is it possible to do something like 
 
 this; perhaps make it compress the file before it writes to disk, or 
 
 call a command to do so, so that it wouldn't hang the entire mud while 
 
 it compresses?
 
 Thanks, and sorry again for all the questions.
 
 
 
 -- 
 
 Take care,
 
 Ty
 
 http://tds-solutions.net
 
 The aspen project: a barebones light-weight mud engine:
 
 http://code.google.com/p/aspenmud
 
 He that will not reason is a bigot; he that cannot reason is a fool; he that 
 dares not reason is a slave.

I use pylint with NINJA IDE. NINJA IDE automatically shows common problems.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: final question: logging to stdout and updating files

2012-10-04 Thread Oscar Benjamin
On 4 October 2012 04:11, Littlefield, Tyler ty...@tysdomain.com wrote:
 pHello all:
 I've seen frameworks like django reload files when it detects that they've
 been changed; how hard would it be to make my engine reload files that it
 detects were changed?

I tend to think that it's better to reload things explicitly. But if
you do want to monitor your files for changes you can use something
like this:
http://packages.python.org/watchdog/

  I'm also curious how hard it would be to build in some
 error recovery. For example right now when an exception occurs, the player
 is sometimes just left hanging.

The general idea is to try and make state changes atomic. In other
words if an error occurs during an operation the previous state should
be kept or restored. A simple way to do this is to ensure that
anything that might generate an error is run before anything that
changes state e.g.:

def change_my_values(self, intvalue_string, floatvalue_string):
# Do all processing first (might generate errors)
iv = int(intvalue_string)
fv = float(floatvalue_string)
# Then change state
self.intvalue = iv
self.floatvalue = fv

In this simple case, you can get the same effect with:

def change_my_values(self, invalue_string, floatvalue_string):
self.intvalue, self.floatvalue = in(intvalue_string),
float(floatvalue_string)

A more sophisticated way might use something like:

oldstate = current_state()
try:
set_state(compute_new_state())
except:
restore_state(oldstate)
raise

Naturally this is quite tedious if you have to put try/except
everywhere, but this kind of exception handling can easily be factored
out into a context manager.

 It's a lot harder with Python for me,
 because I don't get the compile-time errors that I would with c++ for
 example to know that I did something wrong; while that's not always
 useful/and by far it doesn't catch everything, it does help.

Use unit tests.

  I'm familiar
 with things like pychecker, but it seems to be reporting a lot of issues
 that aren't issues.

You may find those useful but they are not a substitute for unit tests.

 For example, I have a world module which is the core of
 the engine; it handles players, as well as keeps tracks of all rooms that
 are loaded in the game and that. Because player and world would have
 circular imports, I just pass the world object into player functions like
 logon/create. Pychecker tells me that the world parameter (which is a local
 var at that point) shadows the world variable in world; world is a
 singleton, so when you import world it just has a world = World() at the
 bottom of the module.

I would let the main script import World and create the world instance
rather than placing a global variable in the world module.


 also: I have the following code:
 logging.basicConfig(filename=path.join(logs, mud.log),
 level=logging.DEBUG)
 logger = logging.getLogger(__name__)
 logger.addHandler(logging.StreamHandler())
 I like it displaying to stderr since usually when I'm doing this I'm in
 screen bouncing back and forth between the output and the tt++ session, but
 right now I can't get a couple of things; I'm not sure how to set it to log
 and all other messages to stderr as I did for the file, and I'd like to use
 a rotating log handler so that it'll rotate when the files are say above 16
 KB or something. Is it possible to do something like this; perhaps make it
 compress the file before it writes to disk, or call a command to do so, so
 that it wouldn't hang the entire mud while it compresses?

Use a standard system tool to manage your server logs. For example logrotate(8)
From the manpage:
'''
logrotate is designed to ease administration of systems that generate
large numbers of log files. It allows automatic rotation, compression,
removal, and mailing of log files. Each log file may be handled daily,
weekly, monthly, or when it grows too large.
'''

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


How to print html in python the normal way

2012-10-04 Thread ashishjain . ash
Hi,

I wrote a simple filter as:

@register.filter()
def html(value):
return 'pCheck/p'

when I use this filter in my template, it displays html as:

pCheck/p

I want to display as:

Check

am I missing something.

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


Re: How to print html in python the normal way

2012-10-04 Thread Chris Angelico
On Thu, Oct 4, 2012 at 9:24 PM,  ashishjain@gmail.com wrote:
 am I missing something.

The first thing you're missing is more detail in your question. My
crystal ball tells me you're using some kind of web framework and
viewing this in your browser. And my second crystal ball suggests that
it's probably Django. But is this correct? Lots more detail, please!

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


Re: Python-list Digest, Vol 109, Issue 20

2012-10-04 Thread Benjamin Jessup

On 10/4/2012 12:20 AM, python-list-requ...@python.org wrote:

How do you know that?

No offence, but if you can't even work out whether lookups in a dict or a
list are faster, I can't imagine why you think you can intuit what the
fastest way to retrieve the nearest neighbours would be.


Whats wrong with the test below?

# randomly select matrix coordinates to look-up
from random import randrange
test_coords = []
for i in range(1000):
x = randrange(2400);  y = randrange(2400); test_coords.append((x, 
y))


# build objects
class Object():pass
obj1 = Object(); obj2 = Object(); obj1.up = obj2

# build some test code
from timeit import Timer
setup = from __main__ import test_coords, obj1, obj2
t = Timer(for p in test_coords: obj = obj1.up, setup)

# run the test code
print(min(t.repeat(number=1, repeat=7)))
import platform
print(platform.python_version())

On my system, I get:
0.719622326348
2.7.1


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


Re: fastest data structure for retrieving objects identified by (x, y) tuple?

2012-10-04 Thread Benjamin Jessup

On 10/4/2012 12:20 AM, python-list-requ...@python.org wrote:

How do you know that?

No offence, but if you can't even work out whether lookups in a dict or a
list are faster, I can't imagine why you think you can intuit what the
fastest way to retrieve the nearest neighbours would be.


Whats wrong with the test below?

# randomly select matrix coordinates to look-up
from random import randrange
test_coords = []
for i in range(1000):
x = randrange(2400);  y = randrange(2400); test_coords.append((x, y))

# build objects
class Object():pass
obj1 = Object(); obj2 = Object(); obj1.up = obj2

# build some test code
from timeit import Timer
setup = from __main__ import test_coords, obj1, obj2
t = Timer(for p in test_coords: obj = obj1.up, setup)

# run the test code
print(min(t.repeat(number=1, repeat=7)))
import platform
print(platform.python_version())

On my system, I get:
0.719622326348
2.7.1


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


Re: How to print html in python the normal way

2012-10-04 Thread Ramchandra Apte
On Thursday, 4 October 2012 17:00:57 UTC+5:30, Chris Angelico  wrote:
 On Thu, Oct 4, 2012 at 9:24 PM,  ashishjain@gmail.com wrote:
 
  am I missing something.
 
 
 
 The first thing you're missing is more detail in your question. My
 
 crystal ball tells me you're using some kind of web framework and
 
 viewing this in your browser. And my second crystal ball suggests that
 
 it's probably Django. But is this correct? Lots more detail, please!
 
 
 
 ChrisA

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


Re: design question:game skill system

2012-10-04 Thread Ramchandra Apte
On Wednesday, 3 October 2012 14:19:57 UTC+5:30, Jean-Michel Pichavant  wrote:
 - Original Message -
 
  Hello all:
 
  I'm looking at a skill/perk system, where the player builds up his
 
  char
 
  by using perk points to add abilities.
 
  Each perk is under a category, and generally costs go up as you
 
  increase
 
  the perk.
 
  So I'm trying to figure something out; first, I'd really like the
 
  cost
 
  calculation and all of that to be dynamic, so that I don't have to
 
  write
 
  a calculateCost per object. I'd also like to be able to specify
 
  dependencies and say a level, as well as other factors before a
 
  player
 
  can obtain a perk and have them self documenting. The idea is that a
 
  player could do something like:
 
  data perk extended health
 
  and it would tell them they require health at 50 before they can
 
  purchase extended health, as well as the cost, the increase per level
 
  and the total overall cost.
 
  Any ideas on how to set this up would be really appreciated.
 
  Finally, I'm curious how to store and calculate these. I thought
 
  about
 
  using a uid per perk, then storing something like: {uid:level} on the
 
  player, but means that I have to lookup the name somehow still in the
 
  main perk database, then use that uid to check if the player has it.
 
  Are
 
  there better ways of storing skills? I'm also thinking about
 
  calculation; currently the CalculateMaxHp method would have to add up
 
  all the possible perks for health, then add stats and all that. That
 
  could get really rough on performance if it's called often; would
 
  something like a cache work, where you have something like:
 
  {attribute:dirty}? So if I call CalculateHealth, it checks for the
 
  dirty
 
  flag, and if it doesn't exist just returns the previous max HP, but
 
  if
 
  the dirty flag is set, it recalculates? Then anything modifying
 
  health
 
  (level gains, perks, stat increases/etc) would just set the dirty
 
  flag
 
  and call calculate?
 
  Thoughts/ideas would be welcome.
 
  Thanks,
 
 
 
 Hi,
 
 
 
 Again, do not think about performances before actually having an issue with 
 them. What's the point to optimize something that doesn't need it ?
 
 
 
 For your cache problem, google python memoize decorator for a bunch of 
 decorators that will allow you to cache your data without any effort.
 
 
 
 JM

True, but I always have an irresistible urge to optimize to every yoctosecond 
even if its absolutely useless to optimize.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to print html in python the normal way

2012-10-04 Thread Joel Goldstick
On Thu, Oct 4, 2012 at 9:11 AM, Ramchandra Apte maniandra...@gmail.com wrote:
 On Thursday, 4 October 2012 17:00:57 UTC+5:30, Chris Angelico  wrote:
 On Thu, Oct 4, 2012 at 9:24 PM,  ashishjain@gmail.com wrote:

  am I missing something.


You should look at the built in django tags, and learn about them
before writing your own

In this case, look here:
https://docs.djangoproject.com/en/dev/topics/templates/#filters


striptags

Strips all [X]HTML tags. For example:

{{ value|striptags }}

If value is bJoel/b buttonis/button a spanslug/span,
the output will be Joel is a slug.

Again, these are just a few examples; see the built-in filter
reference for the complete list.



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


Re: final question: logging to stdout and updating files

2012-10-04 Thread Ramchandra Apte
On Thursday, 4 October 2012 08:41:35 UTC+5:30, Littlefield, Tyler  wrote:
 pHello all:
 
 I've seen frameworks like django reload files when it detects that 
 
 they've been changed; how hard would it be to make my engine reload 
 
 files that it detects were changed? I'm also curious how hard it would 
 
 be to build in some error recovery. For example right now when an 
 
 exception occurs, the player is sometimes just left hanging. It's a lot 
 
 harder with Python for me, because I don't get the compile-time errors 
 
 that I would with c++ for example to know that I did something wrong; 
 
 while that's not always useful/and by far it doesn't catch everything, 
 
 it does help. I'm familiar with things like pychecker, but it seems to 
 
 be reporting a lot of issues that aren't issues. For example, I have a 
 
 world module which is the core of the engine; it handles players, as 
 
 well as keeps tracks of all rooms that are loaded in the game and that. 
 
 Because player and world would have circular imports, I just pass the 
 
 world object into player functions like logon/create. Pychecker tells me 
 
 that the world parameter (which is a local var at that point) shadows 
 
 the world variable in world; world is a singleton, so when you import 
 
 world it just has a world = World() at the bottom of the module.
 
 
 
 also: I have the following code:
 
  logging.basicConfig(filename=path.join(logs, mud.log), 
 
 level=logging.DEBUG)
 
  logger = logging.getLogger(__name__)
 
  logger.addHandler(logging.StreamHandler())
 
 I like it displaying to stderr since usually when I'm doing this I'm in 
 
 screen bouncing back and forth between the output and the tt++ session, 
 
 but right now I can't get a couple of things; I'm not sure how to set it 
 
 to log and all other messages to stderr as I did for the file, and I'd 
 
 like to use a rotating log handler so that it'll rotate when the files 
 
 are say above 16 KB or something. Is it possible to do something like 
 
 this; perhaps make it compress the file before it writes to disk, or 
 
 call a command to do so, so that it wouldn't hang the entire mud while 
 
 it compresses?
 
 Thanks, and sorry again for all the questions.
 
 
 
 -- 
 
 Take care,
 
 Ty
 
 http://tds-solutions.net
 
 The aspen project: a barebones light-weight mud engine:
 
 http://code.google.com/p/aspenmud
 
 He that will not reason is a bigot; he that cannot reason is a fool; he that 
 dares not reason is a slave.

Solution for the logging problem is to use to use 
logging.handlers.BaseRotatingHandler [0]
^0 http://docs.python.org/dev/library/logging.handlers.html#baserotatinghandler

Optimize code always even if it causes bugs - Ramchandra Apte, 2001-
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: Python Meeting Düsseldorf - 23.10.2012

2012-10-04 Thread eGenix Team: M.-A. Lemburg
[This announcement is in German since it targets a local user group
 meeting in Düsseldorf, Germany]


ANKÜNDIGUNG

 Python Meeting Düsseldorf

 http://pyddf.de/

   Ein Treffen von Python Enthusiasten und Interessierten
in ungezwungener Atmosphäre.

  Dienstag, 23.10.2012, 18:00 Uhr
Clara Schumann Raum
  DJH Düsseldorf


Diese Nachricht können Sie auch online lesen:
http://www.egenix.com/company/news/Python-Meeting-Duesseldorf-2012-10-23


EINLEITUNG

Das Python Meeting Düsseldorf (http://pyddf.de/) ist eine neue
lokale Veranstaltung in Düsseldorf, die sich an Python Begeisterte
in der Region wendet.

Wir starten bei den Treffen mit einer kurzen Einleitung und gehen
dann zu einer Reihe Kurzvorträgen (Lightning Talks) über, bei denen
die Anwesenden über neue Projekte, interessante Probleme und
sonstige Aktivitäten rund um Python berichten können.

Anschließend geht es in eine Gaststätte, um die Gespräche zu
vertiefen.

Einen guten Überblick über die Vorträge bietet unser YouTube-Kanal,
auf dem wir die Vorträge nach den Meetings veröffentlichen:

   http://www.youtube.com/pyddf/

Veranstaltet wird das Meeting von der eGenix.com GmbH, Langenfeld,
in Zusammenarbeit mit Clark Consulting  Research, Düsseldorf:

 * http://www.egenix.com/
 * http://www.clark-consulting.eu/


ORT

Für das Python Meeting Düsseldorf haben wir den Clara Schumann
Raum in der modernen Jugendherberge Düsseldorf angemietet:

Jugendherberge Düsseldorf
Düsseldorfer Str. 1
40545 Düsseldorf
Telefon: +49 211 557310
http://www.duesseldorf.jugendherberge.de

Die Jugendherberge verfügt über eine kostenpflichtige Tiefgarage (EUR
2,50 pro Stunde, maximal EUR 10,00). Es ist aber auch möglich per
Bus und Bahn anzureisen. Der Raum befindet sich im 1.OG links.


PROGRAMM

Das Python Meeting Düsseldorf nutzt eine Mischung aus Open Space
und Lightning Talks:

Die Treffen starten mit einer kurzen Einleitung. Danach geht es
weiter mit einer Lightning Talk Session, in der die Anwesenden
Kurzvorträge von fünf Minuten halten können.

Hieraus ergeben sich dann meisten viele Ansatzpunkte für
Diskussionen, die dann den Rest der verfügbaren Zeit in Anspruch
nehmen können.

Für 19:45 Uhr haben wir in einem nahegelegenen Restaurant Plätze
reserviert, damit auch das leibliche Wohl nicht zu kurz kommt.

Lightning Talks können vorher angemeldet werden, oder auch
spontan während des Treffens eingebracht werden. Ein Beamer mit
XGA Auflösung steht zur Verfügung. Folien bitte als PDF auf USB
Stick mitbringen.

Lightning Talk Anmeldung bitte formlos per EMail an i...@pyddf.de


KOSTENBETEILIGUNG

Das Python Meeting Düsseldorf wird von Python Nutzern für Python
Nutzer veranstaltet.

Da Tagungsraum, Beamer, Internet und Getränke Kosten produzieren,
bitten wir die Teilnehmer um einen Beitrag in Höhe von EUR 10,00
inkl. 19% Mwst.

Wir möchten alle Teilnehmer bitten, den Betrag in bar mitzubringen.


ANMELDUNG

Da wir nur für ca. 20 Personen Sitzplätze haben, möchten wir
bitten, sich per EMail anzumelden. Damit wird keine Verpflichtung
eingegangen. Es erleichtert uns allerdings die Planung.

Meeting Anmeldung bitte formlos per EMail an i...@pyddf.de


WEITERE INFORMATIONEN

Weitere Informationen finden Sie auf der Webseite des Meetings:

http://pyddf.de/

Mit freundlichen Grüßen,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Oct 04 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/

2012-09-27: Released eGenix PyRun 1.1.0 ...   http://egenix.com/go35
2012-09-26: Released mxODBC.Connect 2.0.1 ... http://egenix.com/go34
2012-09-25: Released mxODBC 3.2.1 ... http://egenix.com/go33
2012-10-23: Python Meeting Duesseldorf ... 19 days to go

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


Re: final question: logging to stdout and updating files

2012-10-04 Thread Steven D'Aprano
On Thu, 04 Oct 2012 06:34:28 -0700, Ramchandra Apte wrote:

 Optimize code always even if it causes bugs - Ramchandra Apte, 2001-

Well, you've just added yourself into my list of people whose advice 
should always be ignored.

That is *terrible* advice. But if you insist on following it, you can 
optimize *any* Python program to this:

# === start code ===
pass  # this line is optional
# === end code ===


There you go. The most heavily optimized, fastest Python program in 
existence. Sure, it has a few bugs, but boy is it fast!!!


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


Re: fastest data structure for retrieving objects identified by (x, y) tuple?

2012-10-04 Thread Steven D'Aprano
On Thu, 04 Oct 2012 08:21:13 -0400, Benjamin Jessup wrote:

 On 10/4/2012 12:20 AM, python-list-requ...@python.org wrote:
 How do you know that?

 No offence, but if you can't even work out whether lookups in a dict or
 a list are faster, I can't imagine why you think you can intuit what
 the fastest way to retrieve the nearest neighbours would be.
 
 Whats wrong with the test below?
[snip code]


I don't know. Is this a trick question? Is the answer, nothing is wrong?

It doesn't seem to be very useful code, but since I don't know what you 
think you are testing, I can't tell you whether you are doing it wrong or 
not.



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


Re: final question: logging to stdout and updating files

2012-10-04 Thread Chris Angelico
On Fri, Oct 5, 2012 at 12:00 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 That is *terrible* advice. But if you insist on following it, you can
 optimize *any* Python program to this:

 # === start code ===
 pass  # this line is optional
 # === end code ===


 There you go. The most heavily optimized, fastest Python program in
 existence. Sure, it has a few bugs, but boy is it fast!!!

Not many bugs though! I ran it in my Python 5.2.7 for GNU/Windows
256-bit (err, yeah, I borrowed Guido's time machine but had the silly
thing in reverse... oops) and it worked perfectly, except that
indentation has moved from significant to mandatory. When I added
the necessary 5 space indent at the beginning, it correctly created
world peace, ensured that Australia won the next Test Match, and then
printed Hello, world!\n to stdout. Unfortunately, a bug in your end
code comment meant that the peace it created was by wiping out all
life, but that's pretty minor in the scheme of things.

Optimization really is that important, folks!

ChrisA
may need to schedule surgical detongueing of his cheek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why is pylaucher in Python 3.3 being installed in Windows folder?

2012-10-04 Thread Piotr Dobrogost
On Oct 4, 6:30 am, Chris Rebert c...@rebertia.com wrote:
 Presumably because Program Files isn't part of the 
 $PATH.http://superuser.com/questions/124239/what-is-the-default-path-enviro...
 Contrast (from the PEP): However, the Windows directory is always on the 
 path.

I guess that's the reason indeed.

 Now, as for why the launcher must be on the $PATH…*shrugs*

Now, the question is why not put pylauncher together with python.exe
now, when 3.3 has an option to add Python's folder to the PATH? In
case there are more than one Python installed this would mean changing
pylauncher when changing active Python (via PATH modification). Maybe
that's undesired? If so then installing to Program Files and adding
its folder to PATH the same way Python's folder is added would be much
better than installing into Windows folder.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: final question: logging to stdout and updating files

2012-10-04 Thread Steven D'Aprano
On Wed, 03 Oct 2012 21:11:29 -0600, Littlefield, Tyler wrote:

 I've seen frameworks like django reload files when it detects that
 they've been changed; how hard would it be to make my engine reload
 files that it detects were changed? 

Oh, about as hard as writing a program.

What sort of files? What does your engine do? How does it do it? Without 
knowing the answers to these questions, how can we possibly tell you how 
hard it will be to reload them?

Detecting changed files is easy. If you google for python monitor 
directory and similar terms, you will find a metric tonne of solutions.

Having your engine reload files is entirely up to you: it's your engine, 
it will be as trivial or as difficult as you make it be.


 I'm also curious how hard it would be to build in some error recovery. 

How long is a piece of string? Again, that depends on you. If you design 
your application with error recovery in mind, it could be trivial. If you 
don't, it could be impossible.


 For example right now when an
 exception occurs, the player is sometimes just left hanging. It's a lot
 harder with Python for me, because I don't get the compile-time errors
 that I would with c++ for example to know that I did something wrong;
 while that's not always useful/and by far it doesn't catch everything,
 it does help. 

Sure, compiler-time checks can sometimes be useful. But in general, they 
tend to only detect the most trivial errors, syntax errors (Python does 
that too) and type errors.

In Python, the usual answer is to concentrate on writing good unit tests. 
Good unit tests will test far more than the compiler ever could, and will 
pay for themselves a hundred times over.


 I'm familiar with things like pychecker, but it seems to
 be reporting a lot of issues that aren't issues.

Pychecker, like other linters, don't just report fatal errors. They may 
also report *suspicious code* which may indicate an error, poor 
techniques, unused code, bad naming conventions, or other examples of 
poor style. You should be able to turn off such warnings.


 For example, I have a
 world module which is the core of the engine; it handles players, as
 well as keeps tracks of all rooms that are loaded in the game and that.
 Because player and world would have circular imports

Right there is a terrible *code smell*.

http://www.joelonsoftware.com/articles/Wrong.html

Maybe you have a good reason for a circular import, but alarm bells are 
ringing. Rather than having:

# world.py
import player

# player.py
import world

which leads to all sorts of complications, it is usually better to have a 
single module import both world and player and then combine them as 
needed.


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


Re: Combinations of lists

2012-10-04 Thread Steen Lysgaard
2012/10/4 Joshua Landau joshua.landau...@gmail.com:
 On 3 October 2012 21:15, Steen Lysgaard boxeakast...@gmail.com wrote:

 Hi,

 thanks for your interest. Sorry for not being completely clear, yes
 the length of m will always be half of the length of h.


 (Please don't top post)

 I have a solution to this, then.
 It's not short or fast, but it's a lot faster than yours.

 But first let me explain the most obvious optimization to your version of
 the code:

 combs = set()


 for a in permutations(range(len(h)),len(h)):
 comb = []
 for i in range(len(h)):
 comb.append(c[i][a[i]])
 comb.sort()

 frzn = tuple(comb)
 if frzn not in combs:
 combs.add(frzn)


  What I have done here is make your combs a set. This helps because you
 are searching inside it and that is an O(N) operation... for lists.
 A set can do the same in O(1). Simplez.

 first  = list(AABBCCDDEE)
 second = list(abcde)
 import itertools
 #
 # Generator, so ignoring case convention
 class force_unique_combinations:
 def __init__(self, lst, n):
 self.cache = set()
 self.internal_iter = itertools.combinations(lst, n)
 def __iter__(self):
 return self
 def __next__(self):
 while True:
 nxt = next(self.internal_iter)
 if not nxt in self.cache:
 self.cache.add(nxt)
 return nxt
 def combine(first, second):
 sletter = second[0]
 first_combinations = force_unique_combinations(first, 2)
 if len(second) == 1:
 for combination in first_combinations:
 yield [sletter+combination[0], sletter+combination[1]]
 else:
 for combination in first_combinations:
 first_ = first[:]
 first_.remove(combination[0])
 first_.remove(combination[1])
 prefix = [sletter+combination[0], sletter+combination[1]]
 for inner in combine(first_, second[1:]):
 yield prefix + inner


 This is quite naive, because I don't know how to properly implement
 force_unique_combinations, but it runs. I hope this is right. If you need
 significantly more speed your best chance is probably Cython or C, although
 I don't doubt 10x more speed may well be possible from within Python.


 Also, 8 Dihedral is a bot, or at least pretending like crazy to be one.

Great, I've now got a solution much faster than what I could come up with.
Thanks to the both of you.
And a good spot on 88... I could not for my life understand what he
(it) had written.

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


Re: Why is pylaucher in Python 3.3 being installed in Windows folder?

2012-10-04 Thread Ian Kelly
On Thu, Oct 4, 2012 at 8:41 AM, Piotr Dobrogost
p...@google-groups-2012.dobrogost.net wrote:
 Now, the question is why not put pylauncher together with python.exe
 now, when 3.3 has an option to add Python's folder to the PATH? In
 case there are more than one Python installed this would mean changing
 pylauncher when changing active Python (via PATH modification). Maybe
 that's undesired? If so then installing to Program Files and adding
 its folder to PATH the same way Python's folder is added would be much
 better than installing into Windows folder.

It shouldn't go in the Python folder.  There can be more than one
active Python installation, but there should really be only one active
pylauncher installation.  They should also be kept separate for
uninstallation.  So the launcher should have its own separate Program
Files folder.

I don't see why it's so important that the location be on the path in
the first place, though.  As I understand it this tool is primarily
intended to support the .py and .pyw file associations, and those are
best looked up in the registry, not on the path.  The only reason I
can see for having it on the path is for when you want to explicitly
invoke it on the command line, and for that we can either add the
Program Files location to the path or just let the user deal with
setting the path, as many Windows programs do.

 I raised this issue at http://bugs.python.org/issue16131

Unfortunately, with Python 3.3 already released, I suspect that it's
probably too late to change this.
-- 
http://mail.python.org/mailman/listinfo/python-list


How can I hide my stack frames in a TestCase subclass?

2012-10-04 Thread David Banks
I want to add a custom assert method to a TestCase subclass.  I tried to
copy my implementation from the unittest module so that it would match
the behaviour of the regular TestCase as closely as possible.  (I would
prefer to just delegate to self.assertEqual() but this causes even more
backtrace noise, see below.)  The unittest module seems to automatically
hide some internal details of its implementation when reporting failed
assertions.

  import unittest

  class MyTestCase(unittest.TestCase):
  def assertLengthIsOne(self, sequence, msg=None):
  if len(sequence) != 1:
  msg = self._formatMessage(msg, length is not one)
  raise self.failureException(msg)

  class TestFoo(MyTestCase):
  seq = (1, 2, 3, 4, 5)

  def test_stock_unittest_assertion(self):
  self.assertEqual(len(self.seq), 1)

  def test_custom_assertion(self):
  self.assertLengthIsOne(self.seq)


  unittest.main()

The output of this is as such:

  amoe@vuurvlieg $ python unittest-demo.py
  FF
  ==
  FAIL: test_custom_assertion (__main__.TestFoo)
  --
  Traceback (most recent call last):
File unittest-demo.py, line 16, in test_custom_assertion
  self.assertLengthIsOne(self.seq)
File unittest-demo.py, line 7, in assertLengthIsOne
  raise self.failureException(msg)
  AssertionError: length is not one

  ==
  FAIL: test_stock_unittest_assertion (__main__.TestFoo)
  --
  Traceback (most recent call last):
File unittest-demo.py, line 13, in test_stock_unittest_assertion
  self.assertEqual(len(self.seq), 1)
  AssertionError: 5 != 1

  --
  Ran 2 tests in 0.000s

  FAILED (failures=2)

Note that the custom assert method causes a stack trace with two frames,
one inside the method itself, whereas the stock unittest method only has
one frame, the relevant line in the user's code.  How can I apply this
frame-hiding behaviour to my own method?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: fastest data structure for retrieving objects identified by (x, y) tuple?

2012-10-04 Thread Thomas Rachel

Am 04.10.2012 03:58 schrieb Steven D'Aprano:

alist = [[None]*2400 for i in range(2400)]
from random import randrange
for i in range(1000):
 x = randrange(2400)
 y = randrange(2400)
 adict[(x, y)] = something
 alist[x][y] = something



The actual sizes printed will depend on how sparse the matrices are, but
for the same above (approximately half full),


I wouldn't consider 1000 of 576 half full...


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


Re: Why is pylaucher in Python 3.3 being installed in Windows folder?

2012-10-04 Thread Oscar Benjamin
On 4 October 2012 16:51, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Thu, Oct 4, 2012 at 8:41 AM, Piotr Dobrogost
 p...@google-groups-2012.dobrogost.net wrote:
 Now, the question is why not put pylauncher together with python.exe
 now, when 3.3 has an option to add Python's folder to the PATH? In
 case there are more than one Python installed this would mean changing
 pylauncher when changing active Python (via PATH modification). Maybe
 that's undesired? If so then installing to Program Files and adding
 its folder to PATH the same way Python's folder is added would be much
 better than installing into Windows folder.

 It shouldn't go in the Python folder.  There can be more than one
 active Python installation, but there should really be only one active
 pylauncher installation.  They should also be kept separate for
 uninstallation.  So the launcher should have its own separate Program
 Files folder.

 I don't see why it's so important that the location be on the path in
 the first place, though.  As I understand it this tool is primarily
 intended to support the .py and .pyw file associations, and those are
 best looked up in the registry, not on the path.  The only reason I
 can see for having it on the path is for when you want to explicitly
 invoke it on the command line, and for that we can either add the
 Program Files location to the path or just let the user deal with
 setting the path, as many Windows programs do.

Having them on PATH means that you can do:

 py script.py

and the effect will be analogous to (in a unix shell):

$ ./script.py

Of course the idea with the launcher is that you just do

 script.py

The difference - on my machine - between explicitly using invoking py
and allowing the file association to do it is that the latter breaks
when redirecting stdin (this is an old bug in Windows):

Q:\script.py  foo
Traceback (most recent call last):
  File Q:\script.py, line 5, in module
for line in sys.stdin:
IOError: [Errno 9] Bad file descriptor

Q:\py script.py  foo
LOTS OF STUFF


It would be good to be able to choose where to put the launchers.
Unless I missed something that wasn't an option in the installer. It
lets you choose the location of all the other files by choosing where
to put the Python folder. Also it's not as simple as just moving them
to where you want after install since they are associated with the
registry keys for running .py and .pyw files.

As it happens, since I don't have access to the WINDOWS folder on my
work machine, the installer did just put them into the Python33 folder
(which is fine with me).


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


Re: Can somebody give me an advice about what to learn?

2012-10-04 Thread Wolfgang Keller
  The point why Ruby was started (perceived deficit of
  object-orientation) has been remedied since Python 2.2.
  
  Not completely. At the least, there's arguably still the issue of
  len() and friends (vs. `.length` etc.), and also of `self` being
  explicit.
 
 I'm not entirely sure which perceived deficit of object-orientation
 is being talked about, or why anyone but OOP purists would consider
 that a problem.

Yukihiro Matsumoto did. I myself never perceived any lack of
object-orientation with Python, since I've learned programming with
Pascal anyway. ;- 

I just wanted to point out that given the state of Python today, no one
would probably consider starting Ruby any more.

Sincerely,

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


notmm is dead!

2012-10-04 Thread Etienne Robillard
Dear list,

Due to lack of energy and resources i'm really sad to announce the removal of 
notmm from pypi and bitbucket. I deleted
also my account from bitbucket as it was not really useful for me. notmm will 
continue to be accessible from my master
site at http://gthc.org/dist/notmm until the server get down, as I cannot find 
money to pay for the hosting of notmm.org,
neither anyone to encourage the project so it can grow further.  

I have tried to develop a coherent extension for Django using the open source 
model but I'm afraid to have been
bitten by its failure to encourage a free market over one dictated by profit 
and the use of cheap tricks to compete unfairly
with perhaps too much openness. I always will also continue to love and use 
free softwares but sadly it seems asking for a little
fairness is too much asked to competitors dedicated in stealing and subverting 
my work for their own advantages...

I therefore refuse to continue any longer being mocked by competitors asking 
excessive prices for having a broken Internet dictated by
a few companies and decide the content I should be visiting. 

Shall you have anything you wish saying I'll be open to discuss further on this 
list. I wish also to thanks the supporters
of the project who have invested time and energy into my business and 
dedication to the notmm project. 

Best wishes,

Etienne 

-- 
Etienne Robillard
Green Tea Hackers Club
Fine Software Carpentry For The Rest Of Us!
http://gthc.org/
e...@gthcfoundation.org

If a free society cannot help the many who are poor, it cannot save the few 
who are rich. -John F. Kennedy
-- 
http://mail.python.org/mailman/listinfo/python-list


Anybody know what's up with Gmane?

2012-10-04 Thread Mark Lawrence
Good evening all,

I read some 20 Python mailing lists through Gmane using Thunderbird on Windows 
but nothing new has arrived for almost 24 hours, hence why I've reluctantly 
resorted to Google groups to try and find out what is going on.  Looking 
directly at http://news.gmane.org/gmane.comp.python.general shows the last post 
was the Steven D'Aprano thread titled Emulating C++ namespaces with ChainMap 
and metaclass trickery on 3 Oct at 20:26.

I've tried flagging this up but obviously with no success.  Anyone any ideas on 
how to sort this out?

Kindest regards.

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


Re: Combinations of lists

2012-10-04 Thread 88888 Dihedral
On Thursday, October 4, 2012 11:12:41 PM UTC+8, Steen Lysgaard wrote:
 2012/10/4 Joshua Landau joshua.landau...@gmail.com:
 
  On 3 October 2012 21:15, Steen Lysgaard boxeakast...@gmail.com wrote:
 
 
 
  Hi,
 
 
 
  thanks for your interest. Sorry for not being completely clear, yes
 
  the length of m will always be half of the length of h.
 
 
 
 
 
  (Please don't top post)
 
 
 
  I have a solution to this, then.
 
  It's not short or fast, but it's a lot faster than yours.
 
 
 
  But first let me explain the most obvious optimization to your version of
 
  the code:
 
 
 
  combs = set()
 
 
 
 
 
  for a in permutations(range(len(h)),len(h)):
 
  comb = []
 
  for i in range(len(h)):
 
  comb.append(c[i][a[i]])
 
  comb.sort()
 
 
 
  frzn = tuple(comb)
 
  if frzn not in combs:
 
  combs.add(frzn)
 
 
 
 
 
   What I have done here is make your combs a set. This helps because you
 
  are searching inside it and that is an O(N) operation... for lists.
 
  A set can do the same in O(1). Simplez.
 
 
 
  first  = list(AABBCCDDEE)
 
  second = list(abcde)
 
  import itertools
 
  #
 
  # Generator, so ignoring case convention
 
  class force_unique_combinations:
 
  def __init__(self, lst, n):
 
  self.cache = set()
 
  self.internal_iter = itertools.combinations(lst, n)
 
  def __iter__(self):
 
  return self
 
  def __next__(self):
 
  while True:
 
  nxt = next(self.internal_iter)
 
  if not nxt in self.cache:
 
  self.cache.add(nxt)
 
  return nxt
 
  def combine(first, second):
 
  sletter = second[0]
 
  first_combinations = force_unique_combinations(first, 2)
 
  if len(second) == 1:
 
  for combination in first_combinations:
 
  yield [sletter+combination[0], sletter+combination[1]]
 
  else:
 
  for combination in first_combinations:
 
  first_ = first[:]
 
  first_.remove(combination[0])
 
  first_.remove(combination[1])
 
  prefix = [sletter+combination[0], sletter+combination[1]]
 
  for inner in combine(first_, second[1:]):
 
  yield prefix + inner
 
 
 
 
 
  This is quite naive, because I don't know how to properly implement
 
  force_unique_combinations, but it runs. I hope this is right. If you need
 
  significantly more speed your best chance is probably Cython or C, although
 
  I don't doubt 10x more speed may well be possible from within Python.
 
 
 
 
 
  Also, 8 Dihedral is a bot, or at least pretending like crazy to be one.
 
 
 
 Great, I've now got a solution much faster than what I could come up with.
 
 Thanks to the both of you.
 
 And a good spot on 88... I could not for my life understand what he
 
 (it) had written.
 
 
 
 /Steen

If an unique order is defined, then it is trivial to solve this problem
without any recursions. 


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


sum function

2012-10-04 Thread mike20007
Hi All,

I am new to python and am getting the data from hbase. 
I am trying to do sum on the column as below


scanner = client.scannerOpenWithStop(tab, 10, 1000, [cf:col1])
total = 0.0
r = client.scannerGet(scanner)
while r:
  for k in (r[0].columns):
total += float(r[0].columns[k].value)
  r = client.scannerGet(scanner)

print total

Do you know of better (faster) way to do sum?

Any thoughts please?

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


Re: sum function

2012-10-04 Thread Ian Kelly
On Thu, Oct 4, 2012 at 2:52 PM,  mike20...@gmail.com wrote:
 scanner = client.scannerOpenWithStop(tab, 10, 1000, [cf:col1])
 total = 0.0
 r = client.scannerGet(scanner)
 while r:
   for k in (r[0].columns):
 total += float(r[0].columns[k].value)
   r = client.scannerGet(scanner)

 print total

 Do you know of better (faster) way to do sum?

scanner = client.scannerOpenWithStop(tab, 10, 1000, [cf:col1])
next_r = itertools.partial(client.scannerGet, scanner)
total = sum(float(col.value) for r in iter(next_r, None) for col in
r.itervalues())
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sum function

2012-10-04 Thread Ian Kelly
On Thu, Oct 4, 2012 at 3:04 PM, Ian Kelly ian.g.ke...@gmail.com wrote:
 scanner = client.scannerOpenWithStop(tab, 10, 1000, [cf:col1])
 next_r = itertools.partial(client.scannerGet, scanner)
 total = sum(float(col.value) for r in iter(next_r, None) for col in
 r.itervalues())

That should be functools above, not itertools. :-P
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sum function

2012-10-04 Thread Mike
I get below error

NameError: name 'functools' is not defined

Thanks

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


Re: sum function

2012-10-04 Thread Mike
Thanks Ian for the quick reply.

I get the below error.

NameError: name 'itertools' is not defined

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


Re: sum function

2012-10-04 Thread Dave Angel
On 10/04/2012 05:29 PM, Mike wrote:
 I get below error

 NameError: name 'functools' is not defined


functools is a module in the standard library. You need to import it.

import functools



-- 

DaveA

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


Re: sum function

2012-10-04 Thread Chris Angelico
On Fri, Oct 5, 2012 at 7:29 AM, Mike mike20...@gmail.com wrote:
 I get below error

 NameError: name 'functools' is not defined

 Thanks

functools is a module:

import functools

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


RE: Experimental Python-based shell

2012-10-04 Thread Prasad, Ramit
(A little quoting manipulation to make it easier to read with
appropriate context.)

  On Wed, Oct 3, 2012 at 11:25 AM, Amirouche Boubekki 
  amirouche.boube...@gmail.com wrote:
 
 2012/10/3 Jonathan Hayward jonathan.hayw...@pobox.com
   The chief benefit besides the searching, so far, is that you can use Py3k 
   mixed with shell commands as the
   scripting language--so script in Python instead of bash.
  
   When using Python for scripting, Python lines are indented by an extra 
   tab (or four spaces) while shell-like
   commands are not indented. So:
 
   cjsh     for index in range(10):
    echo %(index)d
   
   0
   1
   2
[snip]
  
   Echo could (and maybe should) be a built-in, but it isn't. The output is 
   os.system()'ed to bash, which echoes
   based on a command that includes the value of a Python variable. The 
   implementation is a bit crude, but it is
  reasonably powerful.
   
   I have other things on the agenda, like making it able to run scripts and 
   doing fuzzy matching, but for now
   those are the main two attractions.
  

  Is it possible to drop completly the bash syntax and use some python 
  library (I saw it on github) that wraps
  bash commands with python functions or the other around making it possible 
  to call python functions with a bash-
  like syntax. The syntax you are talking about seems strange.
  
  Regards,
  
  Amirouche

Jonathan Hayward wrote:
 I am open to suggestions and patches. I don't think the syntax strange, 
 though: it offers a clear and distinct
 way to differentiate Python and shell commands, and shell commands can access 
 Python variables when specified.
 And it is a simple rule, without footnotes needed.

I need more footnotes. :) Does every shell command not have indentation? 
How can you tell if the shell command is supposed to be in the loop or after
the loop?

for index in range(10):
# do something
echo %(index)d

Is the above equivalent to Python pseudo-code solution A or B?

Solution A,
for index in range(10):
#do something
Popen('echo', file_path)

Solution B,
for index in range(10):
#do something
Popen('echo', file_path)

How do I make achieve the other solution?


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: final question: logging to stdout and updating files

2012-10-04 Thread Prasad, Ramit
Chris Angelico wrote:
 Sent: Thursday, October 04, 2012 9:28 AM
 To: python-list@python.org
 Subject: Re: final question: logging to stdout and updating files
 
 On Fri, Oct 5, 2012 at 12:00 AM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
  That is *terrible* advice. But if you insist on following it, you can
  optimize *any* Python program to this:
 
  # === start code ===
  pass  # this line is optional
  # === end code ===
 
 
  There you go. The most heavily optimized, fastest Python program in
  existence. Sure, it has a few bugs, but boy is it fast!!!
 
 Not many bugs though! I ran it in my Python 5.2.7 for GNU/Windows
 256-bit (err, yeah, I borrowed Guido's time machine but had the silly
 thing in reverse... oops) and it worked perfectly, except that
 indentation has moved from significant to mandatory. When I added
 the necessary 5 space indent at the beginning, it correctly created
 world peace, ensured that Australia won the next Test Match, and then
 printed Hello, world!\n to stdout. Unfortunately, a bug in your end
 code comment meant that the peace it created was by wiping out all
 life, but that's pretty minor in the scheme of things.

Python is a product for Americans! ;) It should ensure America
wins the Test Matchwait, do we even have a cricket team?

 
 Optimization really is that important, folks!
 
 ChrisA
 may need to schedule surgical detongueing of his cheek

Think we could get a group rate for c.l.p?

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: notmm is dead!

2012-10-04 Thread Etienne Robillard
Thanks, but I tried all that and don't have much energy for continuing. If 
you're
serious about open source then maybe you can forward the thread to 
django-developers
and get some fundings to pay for a minimalistic fee to get the project 
maintained
by someone else, otherwise I'd prefer sticking with more profitable activities.

E

On Fri, 5 Oct 2012 08:23:05 +1000
Chris Angelico ros...@gmail.com wrote:

 On Fri, Oct 5, 2012 at 8:11 AM, Etienne Robillard animelo...@gmail.com 
 wrote:
  For $399 i give you the current source code and you can do whatever you 
  like with it, including
  putting in github or sf. i think to have lost too many time already with 
  further
  maintaining the open source version without getting a penny out of it.
 
 Like I said, I'm not personally interested; but perhaps say that to
 the django list and someone'll bite. But if you're really tired of it,
 then just post the source code and someone may end up taking your
 project to places you never had the energy to.
 
 anecdote
 There was - and, incidentally, still kinda is - a project called Gmud,
 a 32-bit (but Win32s compatible) Windows MUD client. Its author asked
 people to send him money if they liked and used the program - $US20 I
 think - but almost nobody ever did. For years, Gmud was the
 recommended Windows client for Threshold RPG, and yet still something
 like *four* people ever sent the author money. So the author threw the
 source out to the world and said I'm done, have fun.
 
 Enter the Threshold RPG community. Gmud has been extremely popular (in
 fact, some people still use it today), in spite of some limitations
 that may have been reasonable a few years ago, but are ridiculous now,
 like a fixed 500-line scrollback buffer. So some of the people there
 ask me to grab the source, tweak a few things, and recompile. I'm a
 geek, I do these sorts of things.
 
 Well, it turned out to be not that simple, for a few reasons. But
 eventually, after a near-complete rewrite, I produced a new MUD client
 that uses the same look and feel as Gmud, as an acknowledged
 derivative. RosMud++ is now the officially recommended Windows client
 for Threshold, and it would never have happened if Gmud's source
 hadn't been given away.
 /anecdote
 
 It's really hard to make money off software, these days. Which is a
 pity, because there's lots of good software that'd be worth money. I
 do see your pain. :( This is part of why my newest MUD client, Gypsum,
 is open-sourced from the very beginning.
 
 ChrisA


-- 
Etienne Robillard
Green Tea Hackers Club
Fine Software Carpentry For The Rest Of Us!
http://gthc.org/
e...@gthcfoundation.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: notmm is dead!

2012-10-04 Thread Chris Angelico
On Fri, Oct 5, 2012 at 9:13 AM, Etienne Robillard animelo...@gmail.com wrote:
 Thanks, but I tried all that and don't have much energy for continuing. If 
 you're
 serious about open source then maybe you can forward the thread to 
 django-developers
 and get some fundings to pay for a minimalistic fee to get the project 
 maintained
 by someone else, otherwise I'd prefer sticking with more profitable 
 activities.

Apologies to all for the non sequitur, Etienne and I were indulging in
an off-list conversation. I don't mind it being public (there's
nothing secret in it), but it may be a tad confusing to those who just
got the tail end of that!

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


Re: fastest data structure for retrieving objects identified by (x,y) tuple?

2012-10-04 Thread Steven D'Aprano
On Thu, 04 Oct 2012 18:11:28 +0200, Thomas Rachel wrote:

 Am 04.10.2012 03:58 schrieb Steven D'Aprano:
 alist = [[None]*2400 for i in range(2400)] from random import randrange
 for i in range(1000):
  x = randrange(2400)
  y = randrange(2400)
  adict[(x, y)] = something
  alist[x][y] = something
 
 The actual sizes printed will depend on how sparse the matrices are,
 but for the same above (approximately half full),
 
 I wouldn't consider 1000 of 576 half full...

Doh! I obviously can't multiply...

I mean, well done, that was a deliberate test to see who was paying 
attention, and you passed! 

:)


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


Re: notmm is dead!

2012-10-04 Thread Etienne Robillard
Err not exactly.. :)

Firstly notmm is still ISC licensed and available from here 
http://gthc.org/notmm/dist/.

Secondly i don't want to leave it to the hands of people without I can get a 
single dime for the work did, however some peoples
don't seem to get this point yet..

My apologies if you feel this removal was rude anyways. Feel free to contact me 
again
if you need further clarification or would like to take over maintainership of 
a branch
for a minimal fee.

Kind regards,

Etienne

On 05 Oct 2012 00:22:06 GMT
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

 On Thu, 04 Oct 2012 14:10:46 -0400, Etienne Robillard wrote:
 
  Dear list,
  
  Due to lack of energy and resources i'm really sad to announce the
  removal of notmm from pypi and bitbucket. 
 
 Well that's just rude. Even if you don't intend to maintain the software 
 any more, why are you removing it from pypi? Since you say you are a fan 
 of Open Source software, just flag it as unmaintained and leave it for 
 somebody else to pick up.
 
 If you are going to abandon the project, release it on PyPI with a dual 
 MIT and GPL licence, and let it be taken over by somebody else.
 
 If you were looking for sympathy here, starting off by removing your 
 project from free hosting, then complaining that you can't pay for the 
 non-free hosting, was NOT the right way to do so.
 
 By the way, the latest version of notmm (0.4.4) has an empty licence 
 file. No licence means that everyone using it is unlicenced and therefore 
 infringing your copyright.
 
 
 
 -- 
 Steven
 -- 
 http://mail.python.org/mailman/listinfo/python-list


-- 
Etienne Robillard
Green Tea Hackers Club
Fine Software Carpentry For The Rest Of Us!
http://gthc.org/
e...@gthcfoundation.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sum function

2012-10-04 Thread Mike
On Thursday, October 4, 2012 5:40:26 PM UTC-4, Dave Angel wrote:
 On 10/04/2012 05:29 PM, Mike wrote:
 
  I get below error
 
 
 
  NameError: name 'functools' is not defined
 
 
 
 
 
 functools is a module in the standard library. You need to import it.
 
 
 
 import functools
 
 
 
 
 
 
 
 -- 
 
 
 
 DaveA

I imported functools. Now I get the below error please.


Traceback (most recent call last):
  File test.py, line 16, in module
total = sum(float(col.value) for r in iter(next_r, None) for col in 
r.itervalues()) 
  File test.py, line 16, in genexpr
total = sum(float(col.value) for r in iter(next_r, None) for col in 
r.itervalues()) 
AttributeError: 'list' object has no attribute 'itervalues'

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


Re: notmm is dead!

2012-10-04 Thread Ian Kelly
On Thu, Oct 4, 2012 at 6:22 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 By the way, the latest version of notmm (0.4.4) has an empty licence
 file. No licence means that everyone using it is unlicenced and therefore
 infringing your copyright.

It's an ISC license.  The notmm-0.4.4/LICENSE file is a link to the
notmm-0.4.4/notmm-0.4.4-rc7/LICENSE file, unless your archiver fails
to reconstruct the link when untarring, in which case the former ends
up as an empty file (but the latter is still present).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: notmm is dead!

2012-10-04 Thread Etienne Robillard
You probably have a old tarball or something... 

$ wget http://gthc.org/dist/notmm/notmm-0.4.4.tar.gz
$ md5sum notmm-0.4.4.tar.gz
dff1b2ec5373b5157cf79d57169a336e  notmm-0.4.4.tar.gz

Cheers,
Etienne

On Thu, 4 Oct 2012 18:46:18 -0600
Ian Kelly ian.g.ke...@gmail.com wrote:

 On Thu, Oct 4, 2012 at 6:22 PM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
  By the way, the latest version of notmm (0.4.4) has an empty licence
  file. No licence means that everyone using it is unlicenced and therefore
  infringing your copyright.
 
 It's an ISC license.  The notmm-0.4.4/LICENSE file is a link to the
 notmm-0.4.4/notmm-0.4.4-rc7/LICENSE file, unless your archiver fails
 to reconstruct the link when untarring, in which case the former ends
 up as an empty file (but the latter is still present).
 -- 
 http://mail.python.org/mailman/listinfo/python-list


-- 
Etienne Robillard
Green Tea Hackers Club
Fine Software Carpentry For The Rest Of Us!
http://gthc.org/
e...@gthcfoundation.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sum function

2012-10-04 Thread Ian Kelly
On Thu, Oct 4, 2012 at 6:40 PM, Mike mike20...@gmail.com wrote:
 Traceback (most recent call last):
   File test.py, line 16, in module
 total = sum(float(col.value) for r in iter(next_r, None) for col in 
 r.itervalues())
   File test.py, line 16, in genexpr
 total = sum(float(col.value) for r in iter(next_r, None) for col in 
 r.itervalues())
 AttributeError: 'list' object has no attribute 'itervalues'

r.itervalues() should have been r[0].columns.itervalues(), I
think.  It's hard to test code against an API that you don't have. :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Anybody know what's up with Gmane?

2012-10-04 Thread Ned Deily
In article 4509cf54-a71d-44cc-90a5-0abd7c6a8...@googlegroups.com,
 Mark Lawrence breamore...@yahoo.co.uk wrote:
 I read some 20 Python mailing lists through Gmane using Thunderbird on 
 Windows but nothing new has arrived for almost 24 hours, hence why I've 
 reluctantly resorted to Google groups to try and find out what is going on.  
 Looking directly at http://news.gmane.org/gmane.comp.python.general shows the 
 last post was the Steven D'Aprano thread titled Emulating C++ namespaces 
 with ChainMap and metaclass trickery on 3 Oct at 20:26.
 
 I've tried flagging this up but obviously with no success.  Anyone any ideas 
 on how to sort this out?

There were problems on one of the gmane servers.  The problem was fixed 
as of about three hours ago and things should be returning to normal.

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

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


Re: How can I hide my stack frames in a TestCase subclass?

2012-10-04 Thread Peter Otten
David Banks wrote:

 I want to add a custom assert method to a TestCase subclass.  I tried to
 copy my implementation from the unittest module so that it would match
 the behaviour of the regular TestCase as closely as possible.  (I would
 prefer to just delegate to self.assertEqual() but this causes even more
 backtrace noise, see below.)  The unittest module seems to automatically
 hide some internal details of its implementation when reporting failed
 assertions.
 
   import unittest
 
   class MyTestCase(unittest.TestCase):
   def assertLengthIsOne(self, sequence, msg=None):
   if len(sequence) != 1:
   msg = self._formatMessage(msg, length is not one)
   raise self.failureException(msg)
 
   class TestFoo(MyTestCase):
   seq = (1, 2, 3, 4, 5)
 
   def test_stock_unittest_assertion(self):
   self.assertEqual(len(self.seq), 1)
 
   def test_custom_assertion(self):
   self.assertLengthIsOne(self.seq)
 
 
   unittest.main()
 
 The output of this is as such:
 
   amoe@vuurvlieg $ python unittest-demo.py
   FF
   ==
   FAIL: test_custom_assertion (__main__.TestFoo)
   --
   Traceback (most recent call last):
 File unittest-demo.py, line 16, in test_custom_assertion
   self.assertLengthIsOne(self.seq)
 File unittest-demo.py, line 7, in assertLengthIsOne
   raise self.failureException(msg)
   AssertionError: length is not one
 
   ==
   FAIL: test_stock_unittest_assertion (__main__.TestFoo)
   --
   Traceback (most recent call last):
 File unittest-demo.py, line 13, in test_stock_unittest_assertion
   self.assertEqual(len(self.seq), 1)
   AssertionError: 5 != 1
 
   --
   Ran 2 tests in 0.000s
 
   FAILED (failures=2)
 
 Note that the custom assert method causes a stack trace with two frames,
 one inside the method itself, whereas the stock unittest method only has
 one frame, the relevant line in the user's code.  How can I apply this
 frame-hiding behaviour to my own method?

Move MyTestCase in a separate module and define a global variable 

__unittest = True

$ cat mytestcase.py 
import unittest

__unittest = True

class MyTestCase(unittest.TestCase):
def assertLengthIsOne(self, sequence, msg=None):
if len(sequence) != 1:
msg = self._formatMessage(msg, length is not one)
raise self.failureException(msg)

$ cat mytestcase_demo.py 
import unittest
from mytestcase import MyTestCase

class TestFoo(MyTestCase):
seq = (1, 2, 3, 4, 5)

def test_stock_unittest_assertion(self):
self.assertEqual(len(self.seq), 1)

def test_custom_assertion(self):
self.assertLengthIsOne(self.seq)

if __name__ == __main__:
unittest.main()

$ python mytestcase_demo.py 
FF
==
FAIL: test_custom_assertion (__main__.TestFoo)
--
Traceback (most recent call last):
  File mytestcase_demo.py, line 11, in test_custom_assertion
self.assertLengthIsOne(self.seq)
AssertionError: length is not one

==
FAIL: test_stock_unittest_assertion (__main__.TestFoo)
--
Traceback (most recent call last):
  File mytestcase_demo.py, line 8, in test_stock_unittest_assertion
self.assertEqual(len(self.seq), 1)
AssertionError: 5 != 1

--
Ran 2 tests in 0.000s

FAILED (failures=2)
$ 


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


Re: Anybody know what's up with Gmane?

2012-10-04 Thread Terry Reedy

On 10/4/2012 3:03 PM, Mark Lawrence wrote:

 I read some 20 Python mailing lists through Gmane using Thunderbird
 on Windows but nothing new has arrived for almost 24 hours, hence why
 I've reluctantly resorted to Google groups to try and find out what
 is going on.  Looking directly at
 http://news.gmane.org/gmane.comp.python.general shows the last post
 was the Steven D'Aprano thread titled Emulating C++ namespaces with
 ChainMap and metaclass trickery on 3 Oct at 20:26.

 I've tried flagging this up but obviously with no success.  Anyone
 any ideas on how to sort this out?

This is the longest outage I remember, but it is back up now. I am 
reading and replying via gmane.


--
Terry Jan Reedy

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


Re: Experimental Python-based shell

2012-10-04 Thread Terry Reedy

Indexing Python code is ugly. I suggest prefixing non-Python with $.

On 10/3/2012 1:24 PM, Jonathan Hayward wrote:

I am open to suggestions and patches. I don't think the syntax strange,
though: it offers a clear and distinct way to differentiate Python and
shell commands, and shell commands can access Python variables when
specified. And it is a simple rule, without footnotes needed.


--
Terry Jan Reedy

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


Re: + in regular expression

2012-10-04 Thread Mark Lawrence

On 04/10/2012 04:01, contro opinion wrote:

str=  gg
x1=re.match(\s+,str)
x1

_sre.SRE_Match object at 0xb7354db0

x2=re.match(\s{6},str)
x2

_sre.SRE_Match object at 0xb7337f38

x3=re.match(\s{6}+,str)

Traceback (most recent call last):
   File stdin, line 1, in module
   File /usr/lib/python2.6/re.py, line 137, in match
 return _compile(pattern, flags).match(string)
   File /usr/lib/python2.6/re.py, line 245, in _compile
 raise error, v # invalid expression
sre_constants.error: multiple repeat




why the  \s{6}+  is not a regular pattern?





Why are you too lazy to do any research before posting a question?

--
Cheers.

Mark Lawrence.

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


Re: unit testing class hierarchies

2012-10-04 Thread Terry Reedy

On 10/3/2012 5:33 AM, Oscar Benjamin wrote:

On 3 October 2012 02:20, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:


But surely, regardless of where that functionality is defined, you still
need to test that both D1 and D2 exhibit the correct behaviour? Otherwise
D2 (say) may break that functionality and your tests won't notice.

Given a class hierarchy like this:

class AbstractBaseClass:
 spam = spam

class D1(AbstractBaseClass): pass
class D2(D1): pass


I write tests like this:

class TestD1CommonBehaviour(unittest.TestCase):
 cls = D1
 def testSpam(self):
  self.assertTrue(self.cls.spam == spam)
 def testHam(self):
  self.assertFalse(hasattr(self.cls, 'ham'))

class TestD2CommonBehaviour(TestD1CommonBehaviour):
 cls = D2


That's an excellent idea. I wanted a convenient way to run the same
tests on two classes in order to test both a pure python and a
cython-accelerator module implementation of the same class.


Python itself has same issue with testing Python and C coded modules. It 
has the additional issue that the Python class by default import the C 
version, so additional work is needed to avoid that and actually test 
the python code.


For instance, heapq.test_heapq.py has

...
py_heapq = support.import_fresh_module('heapq', blocked=['_heapq'])
c_heapq = support.import_fresh_module('heapq', fresh=['_heapq'])
...
class TestHeap(TestCase):
module = None
... multiple test methods for functions module.xxx

class TestHeapPython(TestHeap):
module = py_heapq

@skipUnless(c_heapq, 'requires _heapq')
class TestHeapC(TestHeap):
module = c_heapq
...
def test_main(verbose=None):
test_classes = [TestModules, TestHeapPython, TestHeapC,

# TestHeap is omitted from the list and not run directly

--
Terry Jan Reedy

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


Re: sum function

2012-10-04 Thread Mike

I agree with you, Ian. Thanks for all the help.  Now I get the below error.

  File test.py, line 17, in module
total = sum(float(col.value) for r in iter(next_r, None) for col in 
r[0].columns.itervalues())
  File test.py, line 17, in genexpr
total = sum(float(col.value) for r in iter(next_r, None) for col in 
r[0].columns.itervalues())

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


Re: Re: + in regular expression

2012-10-04 Thread Evan Driscoll

On 10/04/2012 04:59 PM, Mark Lawrence wrote:

why the  \s{6}+  is not a regular pattern?






Why are you too lazy to do any research before posting a question?


Errr... what?

I'm only somewhat familiar with the extra stuff that languages provide 
in their regexs beyond true regular expressions and simple extensions, 
but I was surprised to see the question because I too would have 
expected that to work. (And match any sequence of whitespace characters 
whose length is a multiple of six.) I reskimmed the documentation of the 
re module and didn't see anything that would prohibit it. I looked at 
several of the results of a Google search for the multiple repeat error, 
and didn't really find any explanation beyond because you can't do it 
or here's a regex that works. (Well, OK, I did see a mention of + 
being a possessive quantifier which Python doesn't support. But that 
still doesn't explain why my expectation isn't what happened.)


In what way is that an unreasonable question?

Evan

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


Re: notmm is dead!

2012-10-04 Thread Michael Torrie
On 10/04/2012 05:13 PM, Etienne Robillard wrote:
 Thanks, but I tried all that and don't have much energy for continuing. If 
 you're
 serious about open source then maybe you can forward the thread to 
 django-developers
 and get some fundings to pay for a minimalistic fee to get the project 
 maintained
 by someone else, otherwise I'd prefer sticking with more profitable 
 activities.

Nothing in the existing license prevents someone from taking the latest
source and posting it back on Pypi as an unmaintained package.  Isn't
that correct?

What are you referring to when you say minimalistic fee.  Would this
be a fee you require for transferring copyright assignment?  I know of
no fee necessary for a new maintainer to take over should one wish to.
Copyright assignment is not strictly necessary.

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


RE: + in regular expression

2012-10-04 Thread Saroo Jain
x3=re.match(\s{6}+,str)

instead use
x3=re.match(\s{6,},str)

This serves the purpose. And also give some food for thought for why the first 
one throws an error.

Cheers,
Saroo

-Original Message-
From: Python-list 
[mailto:python-list-bounces+saroo_jain=infosys@python.org] On Behalf Of 
Mark Lawrence
Sent: Friday, October 05, 2012 3:29 AM
To: python-list@python.org
Subject: Re: + in regular expression

On 04/10/2012 04:01, contro opinion wrote:
 str=  gg
 x1=re.match(\s+,str)
 x1
 _sre.SRE_Match object at 0xb7354db0
 x2=re.match(\s{6},str)
 x2
 _sre.SRE_Match object at 0xb7337f38
 x3=re.match(\s{6}+,str)
 Traceback (most recent call last):
File stdin, line 1, in module
File /usr/lib/python2.6/re.py, line 137, in match
  return _compile(pattern, flags).match(string)
File /usr/lib/python2.6/re.py, line 245, in _compile
  raise error, v # invalid expression
 sre_constants.error: multiple repeat


 why the  \s{6}+  is not a regular pattern?




Why are you too lazy to do any research before posting a question?

-- 
Cheers.

Mark Lawrence.

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

 CAUTION - Disclaimer *
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are 
not 
to copy, disclose, or distribute this e-mail or its contents to any other 
person and 
any such actions are unlawful. This e-mail may contain viruses. Infosys has 
taken 
every reasonable precaution to minimize this risk, but is not liable for any 
damage 
you may sustain as a result of any virus in this e-mail. You should carry out 
your 
own virus checks before opening the e-mail or attachment. Infosys reserves the 
right to monitor and review the content of all messages sent to or from this 
e-mail 
address. Messages sent to or from this e-mail address may be stored on the 
Infosys e-mail system.
***INFOSYS End of Disclaimer INFOSYS***
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Experimental Python-based shell

2012-10-04 Thread Terry Reedy

On 10/3/2012 4:22 PM, Terry Reedy wrote:

Indexing Python code is ugly. I suggest prefixing non-Python with $.


Indenting, meaning indenting the Python header lines but not non-Python 
lines.



On 10/3/2012 1:24 PM, Jonathan Hayward wrote:

I am open to suggestions and patches. I don't think the syntax strange,
though: it offers a clear and distinct way to differentiate Python and
shell commands, and shell commands can access Python variables when
specified. And it is a simple rule, without footnotes needed.





--
Terry Jan Reedy

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


Embedded Python 3 porting issues when passing FILE* to PyRun_SimpleFile() in Windows mixed-compiler environment

2012-10-04 Thread Deron Meranda
Hi.  I'm trying to convert a large C application that embeds Python so it works 
with Python 3, and am running into an new API limitation I can't solve.  I have 
a report from Windows users that there is a crashing problem occurring with 
calls to PyRun_SimpleFile (and similar functions).  This appears to happen when 
people are using a Python DLL compiled with one compiler (e.g., MicroSoft's) 
and the application with another compiler (e.g., MinGW/gcc).

The basic problem is that C type (FILE*) is not defined by the Windows OS, but 
instead is specific to the compiler and its associated runtime-environment. So 
therefore it is not safe to pass a FILE* across DLL boundaries.  However many 
of the Python C API functions only accept a FILE*.

Under Python 2 a work-around was used by calling the PyFile_FromString() then 
PyFile_AsFile(), to effectively get the underlying fopen() to occur inside the 
Python DLL so that an incompatible FILE* is not passed across the DLL boundary.

However many of those PyFile functions, including PyFile_FromFile(), were 
removed from the Python 3 API.  So how can one safely call PyRun_SimpleFile() 
in Python 3 in Windows where different compilers could be used?

Thanks
-- 
Deron Meranda
http://deron.meranda.us/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: + in regular expression

2012-10-04 Thread Ian Kelly
On Thu, Oct 4, 2012 at 9:44 PM, Saroo Jain saroo_j...@infosys.com wrote:
 x3=re.match(\s{6}+,str)

 instead use
 x3=re.match(\s{6,},str)

 This serves the purpose. And also give some food for thought for why the 
 first one throws an error.

That matches six or more spaces, not multiples of six spaces.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: + in regular expression

2012-10-04 Thread Cameron Simpson
On 03Oct2012 21:17, Ian Kelly ian.g.ke...@gmail.com wrote:
| On Wed, Oct 3, 2012 at 9:01 PM, contro opinion contropin...@gmail.com wrote:
|  why the  \s{6}+  is not a regular pattern?
| 
| Use a group: (?:\s{6})+

Yeah, it is probably a precedence issue in the grammar.
(\s{6})+ is also accepted.
-- 
Cameron Simpson c...@zip.com.au

Disclaimer: ERIM wanted to share my opinions, but I wouldn't let them.
- David Wiseman dwise...@erim.org
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue16125] open accepts arbitrary mode strings as long as they contain U

2012-10-04 Thread Robert Xiao

New submission from Robert Xiao:

This issue affects Python 2.5 through 2.7, but not Python 3.

open accepts basically anything for the second argument, so long as it either 
starts with r, w, or a, or contains U somewhere in the string. Therefore, the 
following are all legal in Python 2.7.3:

 open('/tmp/a', 'wail')
open file '/tmp/a', mode 'wail' at 0x100468ed0
 open('/tmp/a', 'PAIL')
open file '/tmp/a', mode 'PAIL' at 0x100468270
 open('/tmp/a', 'rabid')
open file '/tmp/a', mode 'rabid' at 0x100468ed0
 open('/tmp/a', 'alpha[]')
open file '/tmp/a', mode 'alpha[]' at 0x100468270
 open('/tmp/a', 'raw')
open file '/tmp/a', mode 'raw' at 0x100468270

Because the mode string is literally a copy of the passed-in mode, it is not 
clear at all what the mode of the file actually is. For example, in the last 
case, I cannot write to the file even though the mode contains 'w', because the 
mode is actually 'r'. 

I think there are two ways to fix this: either fix the whole mode parsing logic 
in Objects/fileobject.c to resemble that in Modules/_io/fileio.c from Python 3 
(which does proper validation), or just build and store the calculated mode 
(e.g. rb) so it's at least possible to determine the file mode.

--
components: IO
messages: 171922
nosy: nneonneo
priority: normal
severity: normal
status: open
title: open accepts arbitrary mode strings as long as they contain U
versions: Python 2.6, Python 2.7

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



[issue16125] open accepts arbitrary mode strings as long as they contain U

2012-10-04 Thread Robert Xiao

Changes by Robert Xiao nneon...@gmail.com:


--
type:  - behavior

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



[issue16125] open accepts arbitrary mode strings as long as they contain U

2012-10-04 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti, pitrou
stage:  - needs patch
versions:  -Python 2.6

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



[issue16126] PyErr_Format format mismatch in _testcapimodule.c

2012-10-04 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

PyErr_Format in Modules/_testcapimodule.c uses illegal format specifier (%s) 
for Py_ssize_t argument. It causes crash:

import _testcapi
_testcapi.parse_tuple_and_keywords( (), {}, b'', [42])

--
components: Extension Modules, Tests
files: testcapi_error_format_mismatch.patch
keywords: 3.3regression, patch
messages: 171923
nosy: storchaka
priority: normal
severity: normal
status: open
title: PyErr_Format format mismatch in _testcapimodule.c
type: crash
versions: Python 3.3, Python 3.4
Added file: 
http://bugs.python.org/file27409/testcapi_error_format_mismatch.patch

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



[issue16127] Correct mentions of narrow build in documentation and comments

2012-10-04 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

In some places in the documentation and in the comments still left incorrect 
mention of the narrow build. Suggested patch fixes this.

--
assignee: docs@python
components: Documentation, Unicode
files: doc_narrow_build.patch
keywords: patch
messages: 171924
nosy: docs@python, ezio.melotti, storchaka
priority: normal
severity: normal
status: open
title: Correct mentions of narrow build in documentation and comments
type: enhancement
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file27410/doc_narrow_build.patch

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



[issue16125] open accepts arbitrary mode strings as long as they contain U

2012-10-04 Thread Kushal Das

Kushal Das added the comment:

I am working on patch for this.

--
nosy: +kushaldas

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



[issue16098] Bisect optimization in heapq.nsmallest is never used

2012-10-04 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Just so you know, in CPython the bisect version of nsmallest() isn't  called at 
all.  Instead, the C implementation is used and it employs the heap based 
algorithm rather than the bisect algorithm.

Instead of mucking with code that call nsmallest(), I'll likely just update 
nsmallest() at some point to use the same algorithm as the code for nlargest(). 
 That with bring the C code and pure Python code fully in-sync.

--

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



[issue16009] Json error messages could provide more information about the error

2012-10-04 Thread Michele Orrù

Michele Orrù added the comment:

Since AFAIK json.loads runs through every simil-str object, I think that a 
repr() is fine here. What do you think?

--
nosy: +maker

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



[issue16125] open accepts arbitrary mode strings as long as they contain U

2012-10-04 Thread Kushal Das

Kushal Das added the comment:

Patch to update mode parsing of open call. All tests seem to be running ok.
File changed: Objects/fileobject.c

--
keywords: +patch
Added file: http://bugs.python.org/file27411/open_mode2.patch

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



[issue16113] Add SHA-3 (Keccak) support

2012-10-04 Thread Christian Heimes

Christian Heimes added the comment:

Hello Björn,

thanks for the information. Your package didn't turn up on Google when I 
started with my experiment. Perhaps it's too new?

Your code and mine have lots of similarities. I was amused when I saw that you 
had the same issue with the block size attribute. At first I set it to 200 
(1600 / 8) but eventually I didn't implement it.

My code does everything in C with a separate constructor for each flavor of 
SHA-3. It's compatible to Python 2.6 to 3.4 and uses the optimized code for 32 
and 64bit platforms.

Oh, and my code is now working properly. Feel free to review the module. I'll 
upload the test code later.

--

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



[issue8800] add threading.RWLock

2012-10-04 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Ok, here is a new patch.  It takes into account various comments and 
suggestions:
1) The interface is java-like. a single RWLock instance only has attributes 
reader_lock and writer_lock.
2) Since the owning array needs only be process local, the same semantics can 
be used for multiprocessing.  Multiprocessing version only does minimal 
patching of the threading classes, similarly to Barrier.  There is 
implementation coupling between threading and multiprocessing but that is 
probably ok.
3) Test are there, except that the final tests in the multiprocessing, those 
that used to rely on data gathered in lists, are nerfed.  Not sure how to 
gather data when multiprocessing
4) I also didn't get the manager tests to work.  I don't know what managers 
are or what they are supposed to do, and why they use proxy objects.  I 
attempted to create a proxy object in managers.py but it failed the tests.  
Also, I am unsure if it is sufficient to proxy only the RWLock object, or if 
the _ReaderLock and _WriterLock instances that are returned should be proxied 
too.

Documentation i stole from Java.
The locking policy is the same as the RecursiveReaderWiterLock from java, i.e. 
readers wait for writers, but otherwise no preference.  Recursion is provided 
for readers and writers, but not upgrade/downgrade.

Again, this is not intended to be final code, particularly I would like help 
and suggestions for the multiprocessing tests and the manager code.

Also, while I strongly prefer RWLock, or ReaderWriterLock, or something 
similar, basically because it fits with our already java-ized threading module 
and the terminology from everywhere else in the field today, I'm not going to 
be enormously difficult about it.

cheers!

--
Added file: http://bugs.python.org/file27412/rwlock.patch

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



[issue15488] Closed files keep their buffer alive

2012-10-04 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 4141c36954cd by Jesus Cea in branch 'default':
Closes #15488: Closed files keep their buffer alive
http://hg.python.org/cpython/rev/4141c36954cd

--
nosy: +python-dev
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

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



[issue15488] Closed files keep their buffer alive

2012-10-04 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
keywords: +patch
Added file: http://bugs.python.org/file27413/53aa92a70127.diff

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



[issue15513] Correct __sizeof__ support for pickle

2012-10-04 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

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



[issue15475] Correct __sizeof__ support for itertools

2012-10-04 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

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



[issue15528] Better support for finalization with weakrefs

2012-10-04 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

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



[issue14574] SocketServer doesn't handle client disconnects properly

2012-10-04 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Clearly, the finish call is intended to be called, and I think the 
documentation is in error.
However, the finish call should also be able to cope with the connection having 
been reset and handle such errors as may occur.

--

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



[issue8912] `make patchcheck` should check the whitespace of .c/.h files

2012-10-04 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

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



[issue15550] Trailing white spaces

2012-10-04 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

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



[issue15464] ssl: add set_msg_callback function

2012-10-04 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

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



[issue14574] SocketServer doesn't handle client disconnects properly

2012-10-04 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Please consider the attached patch and see if it solves the issue.

--
keywords: +patch
Added file: http://bugs.python.org/file27414/socketserver.patch

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



[issue16112] platform.architecture does not correctly escape argument to /usr/bin/file

2012-10-04 Thread Jesús Cea Avión

Jesús Cea Avión added the comment:

This is security risk, but I can't think about any platform.architecture() 
use that would use a untrusted parameter. Nevertheless os.popen() has been 
deprecated for ages. I take care of this.

--
assignee:  - jcea
nosy: +jcea
versions:  -Python 2.6, Python 3.1, Python 3.5

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



[issue16128] hashable documentation error

2012-10-04 Thread Max

New submission from Max:

http://docs.python.org/dev/glossary.html?highlight=hashable says:

Objects which are instances of user-defined classes are hashable by default; 
they all compare unequal, and their hash value is their id().

Since x == x returns True by default, so they all compare unequal isn't quite 
right.

In addition, both the above paragraph and 
http://docs.python.org/dev/reference/datamodel.html?highlight=__eq__#object.__hash__
 say:

User-defined classes have __eq__() and __hash__() methods by default; with 
them, all objects compare unequal (except with themselves) and x.__hash__() 
returns an appropriate value such that x == y implies both that x is y and 
hash(x) == hash(y).

This is correct, but may leave some confusion with the reader about what 
happens to a subclass of a built-in class (which doesn't use the default 
behavior, but instead simply inherits the parent's __hash__ and __eq__).

--
assignee: docs@python
components: Documentation
messages: 171935
nosy: docs@python, max
priority: normal
severity: normal
status: open
title: hashable documentation error
type: enhancement
versions: Python 3.2

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



[issue16112] platform.architecture does not correctly escape argument to /usr/bin/file

2012-10-04 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c73b90b6dadd by Jesus Cea in branch '2.7':
Closes #16112: platform.architecture does not correctly escape argument to 
/usr/bin/file
http://hg.python.org/cpython/rev/c73b90b6dadd

New changeset 6c830b657900 by Jesus Cea in branch '3.2':
Closes #16112: platform.architecture does not correctly escape argument to 
/usr/bin/file
http://hg.python.org/cpython/rev/6c830b657900

New changeset 3112bf7e0ecb by Jesus Cea in branch '3.3':
MERGE: Closes #16112: platform.architecture does not correctly escape argument 
to /usr/bin/file
http://hg.python.org/cpython/rev/3112bf7e0ecb

New changeset cd026866b333 by Jesus Cea in branch 'default':
MERGE: Closes #16112: platform.architecture does not correctly escape argument 
to /usr/bin/file
http://hg.python.org/cpython/rev/cd026866b333

--
nosy: +python-dev
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

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



[issue16112] platform.architecture does not correctly escape argument to /usr/bin/file

2012-10-04 Thread Jesús Cea Avión

Jesús Cea Avión added the comment:

I have a bootstrap problem with python 2.7. Backout that patch, for now.

--
resolution: fixed - 
status: closed - open

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



[issue16129] No good way to set 'PYTHONIOENCODING' when embedding python.

2012-10-04 Thread Campbell Barton

New submission from Campbell Barton:

note, I was asked to report this issue, posted on the py dev mailing list: see 
- http://code.activestate.com/lists/python-dev/118015/

---

We've run into an issue recently with blender3d on ms-windows where we
want to enforce the encoding is UTF-8 with the embedded python
interpreter.
(the encoding defaults to cp437).

I naively thought setting the environment variable before calling
Py_Initialize() would work, but the way python DLL loads, it gets its
own environment variables that cant be modified directly [1].
eg, _putenv(PYTHONIOENCODING=utf-8:surrogateescape);

We had bug reports by windows users not able to export files because
the stdout errors on printing paths with unsupported encoding. [2],[3]

---

Of course we could distribute blender with a bat file launcher that
sets env variables, or ask the user to set their env variable - but I
dont think this is really a good option.

I tried overriding the stderr  stdout, but this caused another bug on exiting, 
giving an assert in MSVCR90.DLL's write.c (called from python32_d.dll):
_VALIDATE_CLEAR_OSSERR_RETURN((_osfile(fh)  FOPEN), EBADF, -1);

import sys, io
sys.__stdout__ = sys.stdout =
io.TextIOWrapper(io.open(sys.stdout.fileno(), wb, -1),
encoding='utf-8', errors='surrogateescape', newline=\n,
line_buffering=True)
sys.__stderr__ = sys.stderr =
io.TextIOWrapper(io.open(sys.stderr.fileno(), wb, -1),
encoding='utf-8', errors='surrogateescape', newline=\n,
line_buffering=True)



IMHO either of these solutions would be fine.

* have a PyOS_PutEnv() function, gettext has gettext_putenv() to
workaround this problem.

* manage this the same as Py_GetPythonHome(), which can be defined by
the embedding application to override the default.


[1] 
http://stackoverflow.com/questions/5153547/environment-variables-are-different-for-dll-than-exe
[2] http://projects.blender.org/tracker/index.php?func=detailaid=32750
[3] http://projects.blender.org/tracker/index.php?func=detailaid=31555

--
components: Windows
messages: 171938
nosy: ideasman42
priority: normal
severity: normal
status: open
title: No good way to set 'PYTHONIOENCODING' when embedding python.
versions: Python 3.4

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



[issue16112] platform.architecture does not correctly escape argument to /usr/bin/file

2012-10-04 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d6d908dc11f2 by Jesus Cea in branch '2.7':
Closes #16112: platform.architecture does not correctly escape argument to 
/usr/bin/file. Solve a 2.7 bootstrap issue
http://hg.python.org/cpython/rev/d6d908dc11f2

--
resolution:  - fixed
status: open - closed

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



[issue16112] platform.architecture does not correctly escape argument to /usr/bin/file

2012-10-04 Thread Jesús Cea Avión

Jesús Cea Avión added the comment:

Thanks for bringing this up and for your patch.

--
resolution: fixed - 
status: closed - open

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



[issue16112] platform.architecture does not correctly escape argument to /usr/bin/file

2012-10-04 Thread STINNER Victor

STINNER Victor added the comment:

I did a similar commit two years ago, but I reverted it because I failed to 
find a solution for the bootstrap issue.

changeset:   60673:7c90ac194e40
branch:  legacy-trunk
parent:  60664:d7d5c76545fb
user:Victor Stinner victor.stin...@haypocalc.com
date:Sun Apr 18 09:07:49 2010 +
files:   Lib/platform.py
description:
platform: use subprocess.Popen() instead of os.popen() in _syscmd_file()

 * Popen() avoids ugly shell escape: target.replace('', '\\')
 * Use proc.communicate() instead of f.stdout.read()
 * Get output from stdout by splitting with :  instead of splitting by spaces
   to support filename with spaces

--
nosy: +haypo

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



[issue16112] platform.architecture does not correctly escape argument to /usr/bin/file

2012-10-04 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
resolution:  - fixed
status: open - closed

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



[issue16129] No good way to set 'PYTHONIOENCODING' when embedding python.

2012-10-04 Thread STINNER Victor

STINNER Victor added the comment:

See also issue #15216.

--
nosy: +haypo

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



[issue16009] Json error messages could provide more information about the error

2012-10-04 Thread R. David Murray

R. David Murray added the comment:

A repr of what?

--

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



[issue16112] platform.architecture does not correctly escape argument to /usr/bin/file

2012-10-04 Thread STINNER Victor

STINNER Victor added the comment:

See also issue #9560 and the following email from Marc-Andre Lemburg.
http://mail.python.org/pipermail/python-checkins/2010-April/092099.html

Viktor, before making such changes to platform.py, please coordinate
with me, as I am the maintainer of that module.

The subprocess change is not OK, since platform.py has to stay
compatible with Python 2.3 which doesn't have subprocess. Please either
revert the change or make it fallback to os.popen().

--

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



[issue16125] open accepts arbitrary mode strings as long as they contain U

2012-10-04 Thread R. David Murray

R. David Murray added the comment:

Unfortunately, this is a backward compatibility concern (currently 
working-even-if-buggy code could stop working), so I'm -1 on fixing it.  Option 
[2] would be an enhancement/API change, and is thus also ruled out.  

A third alternative might be to add a warning.

--
nosy: +r.david.murray

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



[issue16098] Bisect optimization in heapq.nsmallest is never used

2012-10-04 Thread Ramchandra Apte

Ramchandra Apte added the comment:

 This is my first patch, so if I've done something wrong please let me know.
The Python Development Guide helps you with all this and more: 
http://docs.python.org/devguide/

--
nosy: +ramchandra.apte

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



[issue15158] Add support for multi-character delimiters in csv

2012-10-04 Thread Ramchandra Apte

Ramchandra Apte added the comment:

 I do not see the need to cater to something as foolish and rare as using a 
 multichar delimiter that is also within fields.
I need to generate tables for Google Code wikis.

--

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



[issue16123] IDLE - deprecate running without a subprocess

2012-10-04 Thread Ramchandra Apte

Ramchandra Apte added the comment:

Make it pop up a dialog with the message too in the patch, please.

--
nosy: +ramchandra.apte

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



  1   2   3   >