PyCscope 1.1 Available on PyPI, project on GitHub

2012-10-03 Thread Peter Portante
Hello,

Just release PyCscope 1.1 on PyPI
(http://pypi.python.org/pypi/pycscope/1.1). The project is hosted on
GitHub at https://github.com/portante/pycscope.

Hope folks who like cscope find this useful for python code.

Comments, suggestions welcome.

-peter



PyCscope


:Copyright: Copyright 2012 Peter Portante.  See LICENSE for details.
:Author: Peter Portante
:Release: 1.1
:Date: 2012/10/01

Purpose
---

A python script to generate a cscope index from a Python source
tree.  `pycscope` uses Python's own parser and (C)oncrete (S)yntax
(T)ree to generate the index, so it is a bit more accurate than
plain cscope.


Usage
-

::

pycscope.py [-D] [-R] [-S] [-V] [-t cnt] [-f reffile] [-i
srclistfile] [files ...]
-D  Dump the (C)oncrete (S)yntax (T)ree generated by
the parser for each file
-R  Recurse directories for files
-S  Interpret simple strings as symbols
-V  Print version and exit
-t  Use 'cnt' threads (defaults to 1)
-f reffile  Use 'reffile' as cross-ref file name instead of 'cscope.out'
-i srclistfile  Use the contents of 'srclistfile' as the list of
source files to scan


License
---

Copyright 2012 Peter Portante

This program is free software; you can redistribute it and/or
modify it under the terms of version 2 of the GNU General
Public License as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA  02110-1301, USA


Install
---

PyCscope uses Python's distutils package for installation.
Use the following command to install this package::

% python setup.py install


Features


PyCscope has the following features:

- Supports both Python 2.7 and Python 3
- Command line interface
- Output can be used by the `CscopeFinder` plugin for jEdit
- Marks for all files ending in `.py`
- Marks for all `class` definitions
- Marks for all defined functions
- Marks for function calls (algorithm is not perfect)
- Marks for end-of-function (no search uses this mark yet)
- Marks for imported modules (use the search for #include)
- Marks for symbol assignment

A *mark* is an indicator to the cscope utility that something
of interest follows.


History
---

pycscope 0.3a and later are written and copyright Peter Portante.
pycscope 0.1 - 0.3 were originally written and copyright Dean Hall.


Status
--

It works well enough to generate an index file that can be used
by the `CscopeFinder` plugin for jEdit.  Other editors are not tested.


Release Notes
-

This is PyCscope release 1.1

==  = ==

DateRelease   TracChanges
==  = ==

2012/10/01  1.1   N/A Fix Python3 support; enhance unit tests
to run using
  nose, generating coverage by default; fix broken
  unit tests that were not properly run before the
  switch to nose; add contrib area containing the
  pyxcscope integration for (X)Emacs.
--  - --

2012/09/20  1.0   N/A Call it 1.0; update to use setuptools;
drop .py from
  installed script name; transition authorship from
  Dean Hall to Peter Portante.
--  - --

2012/09/19  0.3e-pajp N/A Fix issues #7 and #8: we now properly
handle symbols
  closest to the assignment itself (rather than the
  first one), and replace the crazy comma counting
  method with a more stable pattern
recognition method
  that explicitly records which tuples
should receive
  the assignment mark; fixed handling of
import state-
  ments of the form, from . import moda
--  - --

2012/09/18  0.3d-pajp N/A Implement debugging help from Issue #9:
dumpCst now
  works on subtrees of tuples, not just lists.
--  - --

2012/09/17  0.3c-pajp N/A First pass fix of Issue #6 removing
errant assertion
  

Re: local variable 'a' referenced b

2012-10-03 Thread Dave Angel
On 10/03/2012 01:54 AM, Demian Brecht wrote:
 On 12-10-02 07:26 PM, Dave Angel wrote:

 if you're stuck with Python2.x, you can use a mutable object for a, and
 mutate it, rather than replace it.  For example,


 def foo():
   a = [3]
   def bar():
   b=2
   a.append(b)   #this mutates a, but doesn't assign it
   print (a)
   a[0] += b  #likewise, for a number within the list
   print (a)
   bar()

 That should work in either 2.x or 3.2


 Alternatively, you can restructure your code by simply adding a
 parameter to bar(). Nice thing about this is that if you ever move
 bar() out into another module, then you don't have to worry about
 documenting the side effects on 'a' so users (including yourself)
 aren't confused later:

  def foo():
 ... a = 1
 ... def bar(n):
 ... b = 2
 ... return n + b
 ... a = bar(a)
 ... print a
 ...
  foo()
 3



One problem with short examples is they mask the reason for the code to
be structured that way.  I assumed that the OP was really talking about
a closure, and that sharing that variable was deliberate.  I seldom
write nested functions otherwise.

-- 

DaveA

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


Re: local variable 'a' referenced b

2012-10-03 Thread Demian Brecht

 One problem with short examples is they mask the reason for the code to
 be structured that way.


Couldn't agree more (I don't think I've ever written a nested function
outside a closure). I made the assumption that the OP wasn't asking about
closures based on his code samples. In hindsight, should have likely asked
for clarification first.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: design question:game skill system

2012-10-03 Thread Jean-Michel Pichavant


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


Re: unit testing class hierarchies

2012-10-03 Thread Oscar Benjamin
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. I find it
difficult to work out how to do such simple things with unittest
because of its Java-like insistence on organising all tests into
classes. I can't immediately remember what solution I came up with but
yours is definitely better.


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


Re: Experimental Python-based shell

2012-10-03 Thread Jorgen Grahn
On Tue, 2012-10-02, Jonathan Hayward wrote:
 I've made an experimental Python-based Unix/Linux shell at:

 http://JonathansCorner.com/cjsh/

 An experimental Unix/Linux command line shell, implemented in Python
 3, that takes advantage of some more recent concepts in terms of
 usability and searching above pinpointing files in heirarchies.

 I invite you to try it.

Hard to do without a manual page, or any documentation at all except
for a tiny hello world-style example ...

/Jorgen

-- 
  // Jorgen Grahn grahn@  Oo  o.   . .
\X/ snipabacken.se   O  o   .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Experimental Python-based shell

2012-10-03 Thread Amirouche Boubekki
Héllo,

2012/10/3 Jonathan Hayward christos.jonathan.hayw...@gmail.com

 I've made an experimental Python-based Unix/Linux shell at:

 http://JonathansCorner.com/cjsh/

 An experimental Unix/Linux command line shell, implemented in Python 3,
 that takes advantage of some more recent concepts in terms of usability and
 searching above pinpointing files in heirarchies.


This sound like a great idea!  What are the other benefits of it except the
file lookup thing ? Does it do fuzzy match yet ?

Is there any repository on bitbucket or github ?

Thanks,

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


Combinations of lists

2012-10-03 Thread Steen Lysgaard

Hi,

I am looking for a clever way to compute all combinations of two lists. 
Look at this example:


h = ['A','A','B','B']
m = ['a','b']

the resulting combinations should be of the same length as h and each 
element in m can be used twice. The sought after result using h and m 
from above is:


[['aA', 'aA', 'bB', 'bB'],
 ['aA', 'aB', 'bA', 'bB'],
 ['aB', 'aB', 'bA', 'bA']]

(the order of the results does not matter i.e. ['aA', 'aA', 'bB', 'bB'] 
and ['aA', 'bB', 'aA', 'bB'] are considered the same)


This is achieved by the code below, this however needs to go through all 
possible combinations (faculty of len(h)) and rule out duplicates as 
they occur and this is too much if for example len(h) is 16.


Can anyone guide me to a better solution?

Thanks,
Steen

h = ['A','A','B','B']
m = ['a','b']

c = []
for i in h:
c.append([])
for j in m:
c[-1].append(j+i)
c[-1].append(j+i)

combs = []

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

if comb not in combs:
combs.append(comb)

print combs

print len(combs)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Combinations of lists

2012-10-03 Thread Alain Ketterlin
Steen Lysgaard boxeakast...@gmail.com writes:

 I am looking for a clever way to compute all combinations of two
 lists. Look at this example:

 h = ['A','A','B','B']
 m = ['a','b']

 the resulting combinations should be of the same length as h and each
 element in m can be used twice. The sought after result using h and m
 from above is:

 [['aA', 'aA', 'bB', 'bB'],
  ['aA', 'aB', 'bA', 'bB'],
  ['aB', 'aB', 'bA', 'bA']]

I can't make sense of your explanation, which doesn't seem to match your
example (the result is not of the same size as h).

Here is a way to compute { xh | x in m }, where xh is a list where x is
prepended to each element of h.

result = [ [ x+l for l in h ] for x in m ]

If there is no duplicate in the original lists, then there will be no
duplicate in the result. Is that what you are looking for?

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


Re: Experimental Python-based shell

2012-10-03 Thread Jonathan Hayward
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
3
4
5
6
7
8
9

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.

On Wed, Oct 3, 2012 at 8:52 AM, Amirouche Boubekki 
amirouche.boube...@gmail.com wrote:

 Héllo,

 2012/10/3 Jonathan Hayward christos.jonathan.hayw...@gmail.com

 I've made an experimental Python-based Unix/Linux shell at:

 http://JonathansCorner.com/cjsh/

 An experimental Unix/Linux command line shell, implemented in Python 3,
 that takes advantage of some more recent concepts in terms of usability and
 searching above pinpointing files in heirarchies.


 This sound like a great idea!  What are the other benefits of it except
 the file lookup thing ? Does it do fuzzy match yet ?

 Is there any repository on bitbucket or github ?

 Thanks,

 Amirouche




-- 
[image: Christos Jonathan Hayward] http://jonathanscorner.com/
Christos Jonathan Hayward, an Orthodox Christian author.

*Amazon http://amazon.com/author/cjshayward* • Author
Biohttp://jonathanscorner.com/author/
 • *Email christos.jonathan.hayw...@gmail.com* •
Facebookhttp://www.facebook.com/christos.jonathan.hayward
 • Google Plus http://jonathanscorner.com/plus •
*Kindlehttp://stornge.com/amazon
* • LinkedIn http://www.linkedin.com/in/jonathanhayward •
*Professionalhttp://jonathanhayward.com/
* • Twitter http://twitter.com/JonathansCorner •
*Webhttp://jonathanscorner.com/
* • What's New? http://jonathanscorner.com/
I invite you to visit my theology, literature, and other creative works
site. *See one page of my website! http://random.jonathanscorner.com/*
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Combinations of lists

2012-10-03 Thread Steven D'Aprano
On Wed, 03 Oct 2012 16:26:43 +0200, Steen Lysgaard wrote:

 Hi,
 
 I am looking for a clever way to compute all combinations of two lists.
 Look at this example:
 
 h = ['A','A','B','B']
 m = ['a','b']
 
 the resulting combinations should be of the same length as h and each
 element in m can be used twice. 

Why twice? What if you had these?

h = ['A', 'A', 'B', 'B', 'C', 'D', 'E', 'E']
m = ['a', 'b', 'c']

Would you still use each element in m twice? Or some other number?



 The sought after result using h and m from above is:
 
 [['aA', 'aA', 'bB', 'bB'],
   ['aA', 'aB', 'bA', 'bB'],
   ['aB', 'aB', 'bA', 'bA']]
 
 (the order of the results does not matter i.e. ['aA', 'aA', 'bB', 'bB']
 and ['aA', 'bB', 'aA', 'bB'] are considered the same)
 
 This is achieved by the code below, this however needs to go through all
 possible combinations (faculty of len(h)) and rule out duplicates as
 they occur and this is too much if for example len(h) is 16.

I don't understand this requirement. In the example above, you don't rule 
out duplicates. Both 'aA' and 'bB' are duplicated. What duplicates are 
you ruling out?



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


Help me abstract this (and stop me from using eval)

2012-10-03 Thread Daniel Klein
Hi!

I've got import scripts for a bunch of csv files into an sqlite database. I 
have one csv file per language. I don't write directly to the sqlite db; this 
is a django app and I'm creating items in my django models. 

My script (scripts, unfortunately) work just fine, but it feels beyond stupid 
to have one script per language--importgerman, importfrench etc. The problem is 
that I don't know how to abstract which language I'm currently writing to. 
Here's the central loop:

http://pastebin.com/NBT6feNB

This is for the Polish version of the script, of course, the one that gets fed 
pl.csv. For those unfamiliar with django, I need to first retrieve the message 
instance for issue name / long text / short text / category name. Hence the 
ugly tempmes stuff. 

So ideally I would tell the script which language I'm currently importing and 
based on that it would write to the appropriate text fields. But I don't know 
how to abstract this:

tempmes.polish = row[1]

Well, I do. Like this:

eval(tempmes. + language +  = row[1])

But... eval is evil, no? There's got to be a better way? 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Combinations of lists

2012-10-03 Thread Manuel Pégourié-Gonnard
Steven D'Aprano scripsit :

 On Wed, 03 Oct 2012 16:26:43 +0200, Steen Lysgaard wrote:

 This is achieved by the code below, this however needs to go through all
 possible combinations (faculty of len(h)) and rule out duplicates as
 they occur and this is too much if for example len(h) is 16.

 I don't understand this requirement. In the example above, you don't rule 
 out duplicates. Both 'aA' and 'bB' are duplicated. What duplicates are 
 you ruling out?

I think the requirement is that r[i] != r[j] as soon as i != j, if r is
the resulting list of lists. (As opposed to having r[i][j] != r[i][k] for all i
and j != k.)

-- 
Manuel Pégourié-Gonnard - http://people.math.jussieu.fr/~mpg/


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


Re: Experimental Python-based shell

2012-10-03 Thread Amirouche Boubekki
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
 3
 4
 5
 6
 7
 8
 9

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


Re: Help me abstract this (and stop me from using eval)

2012-10-03 Thread Kwpolska
On Wed, Oct 3, 2012 at 6:23 PM, Daniel Klein bri...@gmail.com wrote:
 tempmes.polish = row[1]

 Well, I do. Like this:

 eval(tempmes. + language +  = row[1])

 But... eval is evil, no? There's got to be a better way?
 --
 http://mail.python.org/mailman/listinfo/python-list

Easy.

tempmes = myissue.name
language = 'polish'
setattr(tempmes, language, row[1])
tempmes.save()

-- 
Kwpolska http://kwpolska.tk
stop html mail  | always bottom-post
www.asciiribbon.org | www.netmeister.org/news/learn2quote.html
GPG KEY: 5EAAEA16
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Are ABCs an anti-pattern?

2012-10-03 Thread Demian Brecht


 ABCs were added (fairly recently) in 3.0 for the reasons given in
 http://python.org/dev/peps/**pep-3119/http://python.org/dev/peps/pep-3119/
 It was expected that it would take awhile for them to see good, pythonic
 uses. We obviously did okay without them up to 2.7.


I read the PEP before posting just to make sure that I wasn't missing
anything. The gut feeling that I got after reading PEP 3119 was that it was
written by an academic relatively recently out of school (or in school
even), or coming from a strictly typed language who saw this as a hole in
the language.

Don't get me wrong. In theory (and coming from a C/C++ background), I fully
appreciate the need for such language features. However, in practice, it
seems to somewhat be contrary to the Zen of Python.

One thing that irks me a bit about abc's is that those coming from other
(strictly typed) language backgrounds (or school for that matter) will
think hey, my prof/books told me that I should use an abstract base class
to define the contract for [x]. Next step, Google abstract base classes
and Python, they're presented with abcs, rather than how to look and think
about the problem differently using Pythonic idioms. This kind of thing
(imho) is a catalyst for many over-engineered Python packages and
misunderstanding of the core language.

In short, it seems like somewhat of an academic crutch to me.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help me abstract this (and stop me from using eval)

2012-10-03 Thread Steven D'Aprano
On Wed, 03 Oct 2012 09:23:03 -0700, Daniel Klein wrote:

 So ideally I would tell the script which language I'm currently
 importing and based on that it would write to the appropriate text
 fields. But I don't know how to abstract this:
 
 tempmes.polish = row[1]
 
 Well, I do. Like this:
 
 eval(tempmes. + language +  = row[1])

setattr(tempmes, language, row[1])



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


Re: Help me abstract this (and stop me from using eval)

2012-10-03 Thread Daniel Klein
Thank you Steven! That was PRECISELY what I was looking for.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help me abstract this (and stop me from using eval)

2012-10-03 Thread Daniel Klein
On Wednesday, October 3, 2012 5:40:12 PM UTC+1, Daniel Klein wrote:
 Thank you Steven! That was PRECISELY what I was looking for.

(And kwpolska!)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Experimental Python-based shell

2012-10-03 Thread Jonathan Hayward
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.

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
 3
 4
 5
 6
 7
 8
 9

 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




-- 
[image: Christos Jonathan Hayward] http://jonathanscorner.com/
Christos Jonathan Hayward, an Orthodox Christian author.

*Amazon http://amazon.com/author/cjshayward* • Author
Biohttp://jonathanscorner.com/author/
 • *Email christos.jonathan.hayw...@gmail.com* •
Facebookhttp://www.facebook.com/christos.jonathan.hayward
 • Google Plus http://jonathanscorner.com/plus •
*Kindlehttp://stornge.com/amazon
* • LinkedIn http://www.linkedin.com/in/jonathanhayward •
*Professionalhttp://jonathanhayward.com/
* • Twitter http://twitter.com/JonathansCorner •
*Webhttp://jonathanscorner.com/
* • What's New? http://jonathanscorner.com/
I invite you to visit my theology, literature, and other creative works
site. *See one page of my website! http://random.jonathanscorner.com/*
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2012-10-03 Thread Hans Mulder
On 1/10/12 00:14:29, Roy Smith wrote:
 In article mailman.1677.1349019431.27098.python-l...@python.org,
  Chris Angelico ros...@gmail.com wrote:
 
 you can't, for instance, retain a socket connection object across 
 that sort of reload.
 
 Yeah, that's a problem.  There's nothing fundamental about a TCP 
 connection endpoint which precludes it being serialized and passed 
 around.  The amount of state involved is pretty small.  Unless I've 
 forgotten something, 2 IP addresses, 2 port numbers, a few bits worth of 
 TCP protocol state, and, for open connections, 2 sequence numbers.  
 Maybe a couple of timers, but I don't think they're strictly necessary.  
 The problem is, most of that state is private to the kernel.

You're looking at the wrong abstraction level.  A socket connection
object is a thin wrapper around a file descriptor.  Most posix platforms
allow you to pass file descriptors to other processes running on the
same box.  Thus, most posix platforms *do* allow you to pass socket
connection objects around, though you won't win prizes for portability.

 On the other hand, you could do what screen does, and spawn a process 
 per connection to hold the connection open :-)

That won't work for the sort of application we're discussing, because
it creates too many processes.  A pool of processes, each handling
many connections, might work though.

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


Need Data Architect/Technical Business Analyst For 6months at San Rafael, CA

2012-10-03 Thread ram dev
Good Day,

urgent Requirement : San Rafael, CA 6 months 

As a member of the Market Intelligence team, the Data Architect/Technical 
Business Analyst will be tasked
with assessing current state business process and corresponding data flows, 
understanding Marketing business
objectives, and identifying gaps in process, systems, and data that prevent 
execution against those objectives. This
will require understanding the broader internal data integration landscape to 
adequately determine synergies/
overlap and call out integration areas pertinent to Marketing that are 
insufficiently addressed by current systems
and in-flight projects.

Principal Duties and Responsibilities:
• Develop clear understanding of company’s integrated Marketing objectives/KPIs
• Leverage IT and Marketing resources to understand related process/data flows
• Develop and execute ETL procedures to integrate required sources (where 
currently feasible)
• Perform data/system/project gap analysis, documenting issues within the 
context of Marketing objectives
• Work closely with/inform business owners and project teams to ensure that 
documented gaps are addressed

Requirements:
• 5+ years SQL experience (SQL Server, Oracle) experience
• 5+ years ETL (SSIS, DTS, Informatica) experience
• High proficiency in data/systems analysis and integration
• Understanding of data models, data quality
• Proven ability to work within a highly-matrixed, global organization
• Excellent documentation and organizational skills
• Excellent communication skills, both written and verbal, and interpersonal 
skills

Desired Knowledge/Skills:
• Siebel CRM data model experience strongly preferred
• Business systems analysis./process engineering experience strongly preferred
• SFDC data model experience a plus
• Understanding of Clients Customer, Product, Contract, and Entitlement 
data/structures a plus





Thanks,

Ram Dev
Recruiter
Tech-Net Inc.
Tel: 916-458-4390 Ext 102
Email: r...@tech-netinc.com 
-- 
http://mail.python.org/mailman/listinfo/python-list


Emulating C++ namespaces with ChainMap and metaclass trickery

2012-10-03 Thread Steven D'Aprano
C++ namespaces are useful for encapsulating related objects within a 
single file, subdividing the global namespace without using classes. 
Python has modules, but they come in separate files.

Using Python 3.3's ChainMap type, and some metaclass trickery, I abuse 
the class keyword to (almost) emulate C++ namespaces:

http://code.activestate.com/recipes/578279/




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


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

2012-10-03 Thread Wolfgang Keller
 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.

However, Ruby has reproduced quite a few of those well-known problems of
other languages that Python deliberately avoids (such as e.g. deficit of
orthogonality) and that make reading and understanding code difficult,
besides introducing sources for potential bugs.

Sincerely,

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


Re: Combinations of lists

2012-10-03 Thread Joshua Landau
On 3 October 2012 15:26, Steen Lysgaard boxeakast...@gmail.com wrote:

 Hi,

 I am looking for a clever way to compute all combinations of two lists.
 Look at this example:

 h = ['A','A','B','B']
 m = ['a','b']

 the resulting combinations should be of the same length as h and each
 element in m can be used twice. The sought after result using h and m from
 above is:

 [['aA', 'aA', 'bB', 'bB'],
  ['aA', 'aB', 'bA', 'bB'],
  ['aB', 'aB', 'bA', 'bA']]

 (the order of the results does not matter i.e. ['aA', 'aA', 'bB', 'bB']
 and ['aA', 'bB', 'aA', 'bB'] are considered the same)

 This is achieved by the code below, this however needs to go through all
 possible combinations (faculty of len(h)) and rule out duplicates as they
 occur and this is too much if for example len(h) is 16.

 Can anyone guide me to a better solution?


What lengths can the two lists be?

Is len(h) === 2*len(m), or it it just this time?

Depending on your answer this could be easy or hard ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Combinations of lists

2012-10-03 Thread Oscar Benjamin
On 3 October 2012 15:26, Steen Lysgaard boxeakast...@gmail.com wrote:
 Hi,

 I am looking for a clever way to compute all combinations of two lists. Look
 at this example:

 h = ['A','A','B','B']
 m = ['a','b']

 the resulting combinations should be of the same length as h and each
 element in m can be used twice. The sought after result using h and m from
 above is:

 [['aA', 'aA', 'bB', 'bB'],
  ['aA', 'aB', 'bA', 'bB'],
  ['aB', 'aB', 'bA', 'bA']]

 (the order of the results does not matter i.e. ['aA', 'aA', 'bB', 'bB'] and
 ['aA', 'bB', 'aA', 'bB'] are considered the same)

 This is achieved by the code below, this however needs to go through all
 possible combinations (faculty of len(h)) and rule out duplicates as they
 occur and this is too much if for example len(h) is 16.

I'm assuming that len(m) is always 2. Then if len(m) is 16 each
element of h can be used 8 times. If this is not as you intended you
will need to clarify how this problem generalises to other cases.

The elements that go with the 'b's are implicitly determined once you
have chosen the elements that go with the 'a's. The problem then is
solved if you choose the elements that go with the 'a's. If we need to
choose say k elements to go with the 'a's the basic problem becomes:
enumerate over all multisets of size k that are subsets of the
multiset h.

'''
def submultisets(multiset, subsetsize, stack=None):
# Enter recursion
if stack is None:
multiset = dict((c, multiset.count(c)) for c in set(multiset))
stack = []

c = next(iter(multiset))

# End recursion
if len(multiset) == 1:
missing = subsetsize - len(stack)
if multiset[c] = missing:
yield stack + missing  * [c]
return

# Continue recursion
count = multiset.pop(c)
for n in range(count + 1):
stack.extend(n * c)
for result in submultisets(multiset, subsetsize, stack):
yield result
del stack[-n:]
multiset[c] = count

def uniquecombinations(h, m):
for ha in submultisets(h, len(h)//2):
hb = list(h)
for c in ha:
hb.remove(c)
yield [m[0] + a for a in ha] + [m[1] + b for b in hb]

h = ['A', 'A', 'B', 'B']
m = ['a', 'b']

for x in uniquecombinations(h, m):
print(x)
'''

Output:
['aB', 'aB', 'bA', 'bA']
['aA', 'aB', 'bA', 'bB']
['aA', 'aA', 'bB', 'bB']


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


Re: Combinations of lists

2012-10-03 Thread Joshua Landau
On 3 October 2012 20:20, Oscar Benjamin oscar.j.benja...@gmail.com wrote:

 On 3 October 2012 15:26, Steen Lysgaard boxeakast...@gmail.com wrote:
  Hi,
 
  I am looking for a clever way to compute all combinations of two lists.
 Look
  at this example:
 
  h = ['A','A','B','B']
  m = ['a','b']
 
  the resulting combinations should be of the same length as h and each
  element in m can be used twice. The sought after result using h and m
 from
  above is:
 
  [['aA', 'aA', 'bB', 'bB'],
   ['aA', 'aB', 'bA', 'bB'],
   ['aB', 'aB', 'bA', 'bA']]
 
  (the order of the results does not matter i.e. ['aA', 'aA', 'bB', 'bB']
 and
  ['aA', 'bB', 'aA', 'bB'] are considered the same)
 
  This is achieved by the code below, this however needs to go through all
  possible combinations (faculty of len(h)) and rule out duplicates as they
  occur and this is too much if for example len(h) is 16.

 I'm assuming that len(m) is always 2. Then if len(m) is 16 each
 element of h can be used 8 times. If this is not as you intended you
 will need to clarify how this problem generalises to other cases.


His code only works when len(m) is half of len(h), so this may not be the
right assumption.


 The elements that go with the 'b's are implicitly determined once you
 have chosen the elements that go with the 'a's. The problem then is
 solved if you choose the elements that go with the 'a's. If we need to
 choose say k elements to go with the 'a's the basic problem becomes:
 enumerate over all multisets of size k that are subsets of the
 multiset h.

 '''
 def submultisets(multiset, subsetsize, stack=None):
 # Enter recursion
 if stack is None:
 multiset = dict((c, multiset.count(c)) for c in set(multiset))
 stack = []

 c = next(iter(multiset))

 # End recursion
 if len(multiset) == 1:
 missing = subsetsize - len(stack)
 if multiset[c] = missing:
 yield stack + missing  * [c]
 return

 # Continue recursion
 count = multiset.pop(c)
 for n in range(count + 1):
 stack.extend(n * c)
 for result in submultisets(multiset, subsetsize, stack):
 yield result
 del stack[-n:]
 multiset[c] = count

 def uniquecombinations(h, m):
 for ha in submultisets(h, len(h)//2):
 hb = list(h)
 for c in ha:
 hb.remove(c)
 yield [m[0] + a for a in ha] + [m[1] + b for b in hb]

 h = ['A', 'A', 'B', 'B']
 m = ['a', 'b']

 for x in uniquecombinations(h, m):
 print(x)
 '''

 Output:
 ['aB', 'aB', 'bA', 'bA']
 ['aA', 'aB', 'bA', 'bB']
 ['aA', 'aA', 'bB', 'bB']

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


Re: Combinations of lists

2012-10-03 Thread Steen Lysgaard
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.

/Steen

2012/10/3 Joshua Landau joshua.landau...@gmail.com:
 On 3 October 2012 20:20, Oscar Benjamin oscar.j.benja...@gmail.com wrote:

 On 3 October 2012 15:26, Steen Lysgaard boxeakast...@gmail.com wrote:
  Hi,
 
  I am looking for a clever way to compute all combinations of two lists.
  Look
  at this example:
 
  h = ['A','A','B','B']
  m = ['a','b']
 
  the resulting combinations should be of the same length as h and each
  element in m can be used twice. The sought after result using h and m
  from
  above is:
 
  [['aA', 'aA', 'bB', 'bB'],
   ['aA', 'aB', 'bA', 'bB'],
   ['aB', 'aB', 'bA', 'bA']]
 
  (the order of the results does not matter i.e. ['aA', 'aA', 'bB', 'bB']
  and
  ['aA', 'bB', 'aA', 'bB'] are considered the same)
 
  This is achieved by the code below, this however needs to go through all
  possible combinations (faculty of len(h)) and rule out duplicates as
  they
  occur and this is too much if for example len(h) is 16.

 I'm assuming that len(m) is always 2. Then if len(m) is 16 each
 element of h can be used 8 times. If this is not as you intended you
 will need to clarify how this problem generalises to other cases.


 His code only works when len(m) is half of len(h), so this may not be the
 right assumption.


 The elements that go with the 'b's are implicitly determined once you
 have chosen the elements that go with the 'a's. The problem then is
 solved if you choose the elements that go with the 'a's. If we need to
 choose say k elements to go with the 'a's the basic problem becomes:
 enumerate over all multisets of size k that are subsets of the
 multiset h.

 '''
 def submultisets(multiset, subsetsize, stack=None):
 # Enter recursion
 if stack is None:
 multiset = dict((c, multiset.count(c)) for c in set(multiset))
 stack = []

 c = next(iter(multiset))

 # End recursion
 if len(multiset) == 1:
 missing = subsetsize - len(stack)
 if multiset[c] = missing:
 yield stack + missing  * [c]
 return

 # Continue recursion
 count = multiset.pop(c)
 for n in range(count + 1):
 stack.extend(n * c)
 for result in submultisets(multiset, subsetsize, stack):
 yield result
 del stack[-n:]
 multiset[c] = count

 def uniquecombinations(h, m):
 for ha in submultisets(h, len(h)//2):
 hb = list(h)
 for c in ha:
 hb.remove(c)
 yield [m[0] + a for a in ha] + [m[1] + b for b in hb]

 h = ['A', 'A', 'B', 'B']
 m = ['a', 'b']

 for x in uniquecombinations(h, m):
 print(x)
 '''

 Output:
 ['aB', 'aB', 'bA', 'bA']
 ['aA', 'aB', 'bA', 'bB']
 ['aA', 'aA', 'bB', 'bB']
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Combinations of lists

2012-10-03 Thread Oscar Benjamin
Oscar wrote:
 def uniquecombinations(h, m):
 for ha in submultisets(h, len(h)//2):
 hb = list(h)
 for c in ha:
 hb.remove(c)
 yield [m[0] + a for a in ha] + [m[1] + b for b in hb]

 h = ['A', 'A', 'B', 'B']
 m = ['a', 'b']

 for x in uniquecombinations(h, m):
 print(x)
 '''

 Output:
 ['aB', 'aB', 'bA', 'bA']
 ['aA', 'aB', 'bA', 'bB']
 ['aA', 'aA', 'bB', 'bB']

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.

 /Steen

Then you can make the uniquecombinations function recursive. First
find the elements that go with 'a' then from the remaining elements
find those that go with 'b', then 'c' and so on.

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


Re: Combinations of lists

2012-10-03 Thread 88888 Dihedral
Oscar Benjamin於 2012年10月4日星期四UTC+8上午4時29分51秒寫道:
 Oscar wrote:
 
  def uniquecombinations(h, m):
 
  for ha in submultisets(h, len(h)//2):
 
  hb = list(h)
 
  for c in ha:
 
  hb.remove(c)
 
  yield [m[0] + a for a in ha] + [m[1] + b for b in hb]
 
 
 
  h = ['A', 'A', 'B', 'B']
 
  m = ['a', 'b']
 
 
 
  for x in uniquecombinations(h, m):
 
  print(x)
 
  '''
 
 
 
  Output:
 
  ['aB', 'aB', 'bA', 'bA']
 
  ['aA', 'aB', 'bA', 'bB']
 
  ['aA', 'aA', 'bB', 'bB']
 
 
 
 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.
 
 
 
  /Steen
 
 
 
 Then you can make the uniquecombinations function recursive. First
 
 find the elements that go with 'a' then from the remaining elements
 
 find those that go with 'b', then 'c' and so on.
 
 
 
 Oscar

Lets simplify the problem as follows:

A set of m symbols [0, 1,2,3...m-1] and each symbol can occur
a pecified number of times [(0, k(0)), (1, k(1)), (m-1, k(m-1)].rom a list 
to form a list of (i, k(i)) where  k(i) are  all positive integers.

For example [ (0,3), (1,2), (2, 1), (3, 2)], this is easy to generate 
valid numbers in base m numbers of sum(k(i)) digits.



in the final string.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Emulating C++ namespaces with ChainMap and metaclass trickery

2012-10-03 Thread Mark Adam
On Wed, Oct 3, 2012 at 1:26 PM, Steven D'Aprano 
steve+comp.lang.pyt...@pearwood.info wrote:

 C++ namespaces are useful for encapsulating related objects within a
 single file, subdividing the global namespace without using classes.
 Python has modules, but they come in separate files.

 Using Python 3.3's ChainMap type, and some metaclass trickery, I abuse
 the class keyword to (almost) emulate C++ namespaces:


Very interesting.  I like the idea of continuing the namespace meme.

My idea of using the builtins (in the prior list thread of namespaces and
modules), is that if we overhaul the builtins, a unified data model could
emerge to incorporate whatever ideas one may have for namespaces (i.e.
enclosures with a name).

My idea was to introduce the compound data type (using a : colon to
separate two sides), whereby one associates a (*hashable*) name  with an
object (meals:{breakfast,lunch,dinner}) .  This has the extra
advantage of killing two warts in Python with one stone:  {} now is the
empty set literal like people are taught, and a set of compounds makes a
dictionary (dict now has set operations available), something which, in
theory, should simply CPython implementation AND the python environment/API.

expose name put the dictionary (or whatever type is decided for the rhs)
into the builtin/global namespace.

I have further thoughts, but that's all I have at the moment

markj
gothenburg, nebraska
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2012-10-03 Thread Piotr Dobrogost
Why is pylauncher in Python 3.3 being installed in Windows folder and
not in Program Files folder? Installing into Windows folder was maybe
acceptable 10 years ago but not now...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: design question:game skill system

2012-10-03 Thread Littlefield, Tyler
I just wanted to say thanks to all the people that provided input, both 
aonand off list. It gave me a good direction to head in. Thanks again.

On 10/2/2012 2:34 PM, Ian Kelly wrote:

On Tue, Oct 2, 2012 at 2:00 PM, Littlefield, Tyler ty...@tysdomain.com wrote:

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.

What are the cost calculations based on?  If there are specific
formulas then you would need to store them somehow, possibly just as a
function to be called or string to be evaled, but if the security of
the perk database is of concern then you could engineer a more
sandboxed representation.  For dependencies, you can keep them in a
container.  An extended health perk might look something like:

cost_formula = 5 * level ** 2
dependencies = {HEALTH: 50, PLAYER_LEVEL: 15}
benefits = {HEALTH: 7 * level}

where HEALTH and PLAYER_LEVEL are just some arbitrary known constants.
  Your core perks library would then be responsible for looking this
information up, running the formulas, and performing whatever
calculations on it are needed.


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?

When you say uids, you mean UUIDs, right?  I'm not sure what advantage
there is in using abstracted unique identifiers for these.  Assuming
you have full control over what perks are added, you can ensure there
will be no name clashes, so why not just use the name or a name-based
tag to uniquely identify each perk?  Regardless of how you identify
them, though, your code is at some point going to have to go to the
database to look them up, so I would suggest you just go ahead and
write that code, and then you can add some caching later if it turns
out to be needed.


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?

Sounds reasonable.  I wouldn't use a separate flag attribute, though.
When max HP becomes dirty, clear the cached value, and use the absence
of a cached value to inform your code that it needs to recalculate.



--
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.

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


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

2012-10-03 Thread Benjamin Jessup
I have a group of objects identified by unique (x,y) pairs and I want to 
find out an object's neighbors in a matrix of size 2400 x 2400.

   #
   #obj#   #   #
   #
   #   #   #obj#  3 x 3 Example
   #
   #   #   #   #
   #
There is either a neighbor, or a null value. I always know the (x,y) 
pair to check the neighbors of, so is doing,

 obj = grid[x][y] #lists, doesn't scale with num of objects
or,
 obj = grid.get((x,y),None) #dictionary, scales with num of objects
the fastest? I can't seem to find a conclusion by testing each alone, 
then in the full environment. Is it that, depending on the number of 
objects, each has an advantage?


I know the fastest way to retrieve them would be to have them store 
pointers to their neighbors, then use those for retrieval. When large 
numbers of objects are changing their (x,y) pairs, rebuilding the 
pointers is too slow.

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


Re: Combinations of lists

2012-10-03 Thread Joshua Landau
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 http://www.catb.org/jargon/html/T/top-post.html)

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


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

2012-10-03 Thread Joshua Landau
On 3 October 2012 23:30, Benjamin Jessup b...@abzinc.com wrote:

 I have a group of objects identified by unique (x,y) pairs and I want to
 find out an object's neighbors in a matrix of size 2400 x 2400.
#
#obj#   #   #
#
#   #   #obj#  3 x 3 Example
#
#   #   #   #
#
 There is either a neighbor, or a null value. I always know the (x,y) pair
 to check the neighbors of, so is doing,
  obj = grid[x][y] #lists, doesn't scale with num of objects
 or,
  obj = grid.get((x,y),None) #dictionary, scales with num of objects
 the fastest? I can't seem to find a conclusion by testing each alone, then
 in the full environment. Is it that, depending on the number of objects,
 each has an advantage?

 I know the fastest way to retrieve them would be to have them store
 pointers to their neighbors, then use those for retrieval. When large
 numbers of objects are changing their (x,y) pairs, rebuilding the pointers
 is too slow


You really are asking the wrong question.

If most of the data is None, then a sparse matrix is best. Otherwise, lists
make the most sense.
*However, *what you really want is... a matrix. Look for a sparse matrix
type (
http://stackoverflow.com/questions/1053928/python-numpy-very-large-matrices)
if you need sparse, and otherwise Numpy's matrix should do fine.

The thing is this:
I can't seem to find a conclusion by testing each alone, then in the full
environment. Is it that, depending on the number of objects, each has an
advantage?

If you can't tell, don't bother. Dictionaries will have a memory advantage
with sparse matrices, lists in the other cases. That's the important part,
as look-up is fast for both*. If you need faster than these builtins, use
Numpy or SciPy.

If you really need optimization help, profile and ask the *right* question
to this list.

* To actually answer the question:
They both have O(1) look-up time, although dictionaries have a theoretical *
worst* case of O(N). Being simpler, it's faster to index a list. However,
you're doing that twice, so it's probably around even.
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2012-10-03 Thread Steven D'Aprano
On Wed, 03 Oct 2012 18:30:24 -0400, Benjamin Jessup wrote:

 I have a group of objects identified by unique (x,y) pairs and I want to
 find out an object's neighbors in a matrix of size 2400 x 2400.
[...]
 There is either a neighbor, or a null value. I always know the (x,y)
 pair to check the neighbors of, so is doing,
   obj = grid[x][y] #lists, doesn't scale with num of objects
 or,
   obj = grid.get((x,y),None) #dictionary, scales with num of objects
 the fastest? I can't seem to find a conclusion by testing each alone,
 then in the full environment. Is it that, depending on the number of
 objects, each has an advantage?

Almost certainly not. Since you don't show how you test each, I have no 
idea why you can't find a conclusion.

Let's start off with the question you don't ask: which uses less memory? 
The answer is, the dict solution by far. Here is a test:

# 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


Now let's test the speed:

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

# build some test code
from timeit import Timer
setup = from __main__ import adict, alist, test_coords
t1 = Timer(for p in test_coords: obj = adict.get(p), setup)
t2 = Timer(for p in test_coords: obj = alist[p[0]][p[1]], setup)

# run the test code
print(min(t1.repeat(number=1, repeat=7)))
print(min(t2.repeat(number=1, repeat=7)))


Again, on my system using Python 2.7, I get:
3.13823986053
2.97539305687

which shows that the two are very close, but the list solution is about 
6% faster. So in this situation, a list of lists uses about 100 times 
more memory than a dict, but look-ups are about 6% faster.

I would be very surprised if the timing results depended on the number of 
objects in the matrices.

In case you are not familiar with timeit, let me explain what I have done:

* I pre-select 1000 random coordinates.
* I write some test code inside a Timer object that look up each of 
  those coordinates, plus some setup code.
* timeit runs the setup code once.
* Then it runs my test code 1 times as a single trial, timing
  it as accurately as possible.
* It does seven trials, and I report the best of the seven.

The time printed is measured in seconds. In this case, I get 3 seconds 
per trial, or 3e-7 seconds = 0.3 microseconds per lookup.


 I know the fastest way to retrieve them would be to have them store
 pointers to their neighbors, then use those for retrieval.

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.



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


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

2012-10-03 Thread Steven D'Aprano
On Wed, 03 Oct 2012 14:13:10 -0700, Piotr Dobrogost wrote:

 Why is pylauncher in Python 3.3 being installed in Windows folder and
 not in Program Files folder? Installing into Windows folder was maybe
 acceptable 10 years ago but not now...

Read the PEP:

http://www.python.org/dev/peps/pep-0397/



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


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

2012-10-03 Thread Steven D'Aprano
On Thu, 04 Oct 2012 01:58:16 +, Steven D'Aprano wrote:

 adict: 24712
 alist: 23127324
[...]
 So in this situation, a list of lists uses about 100 times
 more memory than a dict, but look-ups are about 6% faster.

Correction: about 1000 times more memory. Sorry for the typo.



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


+ in regular expression

2012-10-03 Thread contro opinion
 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?
-- 
http://mail.python.org/mailman/listinfo/python-list


final question: logging to stdout and updating files

2012-10-03 Thread Littlefield, Tyler

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.

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


Re: + in regular expression

2012-10-03 Thread Ian Kelly
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})+
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2012-10-03 Thread Ian Kelly
On Wed, Oct 3, 2012 at 8:04 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Wed, 03 Oct 2012 14:13:10 -0700, Piotr Dobrogost wrote:

 Why is pylauncher in Python 3.3 being installed in Windows folder and
 not in Program Files folder? Installing into Windows folder was maybe
 acceptable 10 years ago but not now...

 Read the PEP:

 http://www.python.org/dev/peps/pep-0397/

The PEP explains why it's in the Windows folder as opposed to the
System32 folder, but not why either of those locations should be
preferable to Program Files.
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2012-10-03 Thread Chris Rebert
On Wed, Oct 3, 2012 at 8:21 PM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Wed, Oct 3, 2012 at 8:04 PM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
 On Wed, 03 Oct 2012 14:13:10 -0700, Piotr Dobrogost wrote:

 Why is pylauncher in Python 3.3 being installed in Windows folder and
 not in Program Files folder? Installing into Windows folder was maybe
 acceptable 10 years ago but not now...

 Read the PEP:

 http://www.python.org/dev/peps/pep-0397/

 The PEP explains why it's in the Windows folder as opposed to the
 System32 folder, but not why either of those locations should be
 preferable to Program Files.

Presumably because Program Files isn't part of the $PATH.
http://superuser.com/questions/124239/what-is-the-default-path-environment-variable-setting-on-fresh-install-of-window
Contrast (from the PEP): However, the Windows directory is always on the path.

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

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


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

2012-10-03 Thread Chris Rebert
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.

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


[issue15963] Improve ./configure's support for 32/64-bit debug|release|profiled builds w/ vendor (non-gcc) compilers on proprietary UNIX systems (Solaris/HP-UX/AIX et al).

2012-10-03 Thread GOGER Valentin Eugen

GOGER Valentin Eugen added the comment:

Hello
On AIX 64bit (see http://bugs.python.org/issue6600) you should add in CFLAGS  
-U__STR__ to bypass xlc(_r) define/inlining issue.

--
nosy: +gix

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



[issue15963] Improve ./configure's support for 32/64-bit debug|release|profiled builds w/ vendor (non-gcc) compilers on proprietary UNIX systems (Solaris/HP-UX/AIX et al).

2012-10-03 Thread GOGER Valentin Eugen

Changes by GOGER Valentin Eugen gixgo...@yahoo.com:


--
versions: +Python 2.6, Python 2.7

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



[issue16115] test that executable arg to Popen() takes precedence over args[0] arg

2012-10-03 Thread Chris Jerdonek

New submission from Chris Jerdonek:

The executable argument to Popen() takes precedence over args[0] when the 
executable argument is provided.  The test suite should include a test of this 
that runs on all systems.  The test suite does not currently include such a 
test.  This test is a precursor to more specific, platform-specific tests that 
will be added for issue 16114.

--
assignee: chris.jerdonek
components: Library (Lib)
keywords: easy
messages: 171856
nosy: asvetlov, chris.jerdonek
priority: normal
severity: normal
stage: test needed
status: open
title: test that executable arg to Popen() takes precedence over args[0] arg
versions: Python 3.3, Python 3.4

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



[issue16114] incorrect path in subprocess.Popen() FileNotFoundError message

2012-10-03 Thread Chris Jerdonek

Chris Jerdonek added the comment:

Adding issue 16115 as a dependency so that the more general case can be settled 
and committed before dealing with the current issue's more specific (and 
platform-specific) case.

--
dependencies: +test that executable arg to Popen() takes precedence over 
args[0] arg

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



[issue12947] doctest directive examples in library/doctest.html lack the flags

2012-10-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 662fb4bd5f84 by Nick Coghlan in branch '2.7':
Issue #12947: Add a note to doctest until the example rendering is fixed
http://hg.python.org/cpython/rev/662fb4bd5f84

--
nosy: +python-dev

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



[issue12947] doctest directive examples in library/doctest.html lack the flags

2012-10-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 679b3e3aadae by Nick Coghlan in branch '3.3':
Issue #12947: Add a note to doctest until the example rendering is fixed
http://hg.python.org/cpython/rev/679b3e3aadae

--

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



[issue12947] doctest directive examples in library/doctest.html lack the flags

2012-10-03 Thread Nick Coghlan

Nick Coghlan added the comment:

Since the status quo is thoroughly confusing for readers, I added an explicit 
note before the affected examples. That note should be removed once the 
rendering problem is fixed. (The note is there on trunk as well, I just forgot 
to include the issue number in the merge commit)

--
nosy: +ncoghlan

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



[issue16105] Pass read only FD to signal.set_wakeup_fd

2012-10-03 Thread STINNER Victor

STINNER Victor added the comment:

A signal handler can be called anymore, anywhere. How do you handle such
exception in an application? handle: do something better than exit the
apllication.

--

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



[issue12947] doctest directive examples in library/doctest.html lack the flags

2012-10-03 Thread Chris Jerdonek

Chris Jerdonek added the comment:

I thought of an easy work-around we can use after looking at the changeset 
Terry referenced above:

 [2] https://bitbucket.org/birkenfeld/sphinx/changeset/d91bf8e465ef

At the expense of pretty color highlighting, we can enable Pygments' TextLexer 
for the affected examples (aka null lexer).  For example--

.. code-block:: text

raise CustomError('message') #doctest: +IGNORE_EXCEPTION_DETAIL
   Traceback (most recent call last):
   CustomError: message

I confirmed locally that this works.  I realized this might work because the 
Sphinx changeset referenced above has this logic:

# trim doctest options if wanted
if isinstance(lexer, PythonConsoleLexer) and self.trim_doctest_flags:

--

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



[issue13290] get vars for object with __slots__

2012-10-03 Thread Michele Orrù

Michele Orrù added the comment:

Patch + unittests + documentation attached.

$ ./python -m test -R 3:2 test_builtin
[1/1] test_builtin
beginning 5 repetitions
12345
.
1 test OK.
[158296 refs]

--
keywords: +patch
nosy: +maker
Added file: http://bugs.python.org/file27395/issue13290.patch

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



[issue16114] incorrect path in subprocess.Popen() FileNotFoundError message

2012-10-03 Thread Chris Jerdonek

Chris Jerdonek added the comment:

Attaching proposed tests.

--
keywords: +patch
stage: test needed - needs patch
Added file: http://bugs.python.org/file27396/issue-16114-1-tests-default.patch

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



[issue16105] Pass read only FD to signal.set_wakeup_fd

2012-10-03 Thread STINNER Victor

STINNER Victor added the comment:

 A signal handler can be called anymore, anywhere.

Oopos: anywhere/anytime.

--

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



[issue12947] doctest directive examples in library/doctest.html lack the flags

2012-10-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 18d927fb8671 by Nick Coghlan in branch '2.7':
Issue #12947: Better workaround for the problem with doctest directives being 
stripped from code examples that are intended to illustrate those directives
http://hg.python.org/cpython/rev/18d927fb8671

--

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



[issue13290] get vars for object with __slots__

2012-10-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I added some comments in Rietveld.

ReST documentation should be updated too.

vars() returns modifiable dict. The patch should be much harder if we want to 
preserve this behavior. Otherwise, the difference must be explicitly documented.

--
nosy: +storchaka
versions: +Python 3.4 -Python 3.3

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



[issue12947] doctest directive examples in library/doctest.html lack the flags

2012-10-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d93a59a0a984 by Nick Coghlan in branch '3.3':
Issue #12947: Better workaround for the problem with doctest directives being 
stripped from code examples that are intended to illustrate those directives
http://hg.python.org/cpython/rev/d93a59a0a984

New changeset 26200f535296 by Nick Coghlan in branch 'default':
Merge #12947 workaround from 3.3
http://hg.python.org/cpython/rev/26200f535296

--

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



[issue12947] doctest directive examples in library/doctest.html lack the flags

2012-10-03 Thread Nick Coghlan

Nick Coghlan added the comment:

Adopted Chris's workaround for now. I kept a reworded version of the preceding 
note (with the link to this bug), so readers know that the lack of syntax 
highlighting is intended-but-not-desired.

--

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



[issue13290] get vars for object with __slots__

2012-10-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There's another thing. __slots__ value is converted to a tuple and saved as 
ht_slots field in PyHeapTypeObject. You can use fast PyTuple_GET_ITEM() for 
item access.

--

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



[issue12947] doctest directive examples in library/doctest.html lack the flags

2012-10-03 Thread Chris Jerdonek

Chris Jerdonek added the comment:

Thanks, Nick.  It looks like there are a few more though?  I'm counting four 
more in default (search for doctest:): three IGNORE_EXCEPTION_DETAIL and one 
ELLIPSIS.

--

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



[issue16105] Pass read only FD to signal.set_wakeup_fd

2012-10-03 Thread Charles-François Natali

Charles-François Natali added the comment:

 A signal handler can be called anymore, anywhere. How do you handle such
 exception in an application? handle: do something better than exit the
 apllication.

Well, chances are you won't, but failing with an explicit error
message is better than silently failing to deliver signals (which may
result in a deadlock, for example).

--

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



[issue12370] Use of super overwrites use of __class__ in class namespace

2012-10-03 Thread Nick Coghlan

Nick Coghlan added the comment:

Carsten: emulating __class__ is necessary to implement proxy types (and similar 
utilities like mock objects) correctly. The difference between x.__class__ is 
that proxies can remap it to the type of the referent, while type(x) will 
always report the real class of x (which may be a proxy like weakref.proxy, 
or a mock object, as it is in the case Michael is interested in).

Mark: correct, the problem is that the compiler is treating *all* references to 
__class__ inside a class body as references to the cell variable, when it 
should really only be doing that for references inside methods - references 
directly at the class body level should still be to the entry in the class 
locals namespace that later become attributes of the class object. Hence my 
idea of introducing a separate closure namespace encapsulating the class 
namespace to separate the two more cleanly than the current hacky override.

--

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



[issue12947] doctest directive examples in library/doctest.html lack the flags

2012-10-03 Thread Nick Coghlan

Nick Coghlan added the comment:

I only changed the ones that were specifically in the section explaining 
doctest directives. There are probably others, but it didn't seem necessary to 
change them and lose the syntax highlighting at this point.

--

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



[issue16116] Can not install C extension modules to inside a venv on Python 3.3.0 for Win32

2012-10-03 Thread Masami HIRATA

New submission from Masami HIRATA:

I'm trying to install C extension modules inside a venv.
It works outside a venv and inside a virtualenv-1.8.2 but breaks inside the 
venv.

OS: Windows 7 Starter Edition SP1 (32-bit)
Python: 3.3.0 (python-3.3.0.msi)
Compiler: Microsoft Visual C++ 2010 Express SP1

--
components: Library (Lib)
files: Python33_with_venv.txt
messages: 171875
nosy: msmhrt
priority: normal
severity: normal
status: open
title: Can not install C extension modules to inside a venv on Python 3.3.0 for 
Win32
type: behavior
versions: Python 3.3
Added file: http://bugs.python.org/file27397/Python33_with_venv.txt

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



[issue16116] Can not install C extension modules to inside a venv on Python 3.3.0 for Win32

2012-10-03 Thread Masami HIRATA

Changes by Masami HIRATA msm...@gmail.com:


Added file: http://bugs.python.org/file27398/Python33_with_virtualenv.txt

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



[issue16116] Can not install C extension modules to inside a venv on Python 3.3.0 for Win32

2012-10-03 Thread Masami HIRATA

Changes by Masami HIRATA msm...@gmail.com:


Added file: http://bugs.python.org/file27399/Python33_without_venv.txt

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



[issue16117] python2.7.3 struct misaligned when returned

2012-10-03 Thread Roland Lezuo

New submission from Roland Lezuo:

class Int(ctypes.Structure):
   _fields_ = [ (_i, ctypes.c_uint64),
   (undef, ctypes.c_bool)]

class Int {
public:
Int();
Int(uint64_t i);

uint64_t _i;
bool undef;
};

extern C Int foo(const Int a , const Int b , const Int c)
{
ret = ...
return Int(ret);
}

(gdb) p ret
$3 = 16
(gdb) fin
Run till exit from #0  BVSignExtend (a=..., b=..., c=...) at foo.hpp:130
0x7784eea4 in ffi_call_unix64 () from 
/usr/lib/python2.7/lib-dynload/_ctypes.so
Value returned is $4 = {_i = 18577824, undef = 16}

My guess: The value 18577824 was not expected to be on the stack.

The following actions solve the problem:

1) add another int the class Int (after bool) and adopt _fields_ accordingly.
2) in foo C++ function:
   Int reti = Int(ret);
   return reti;

Because of the above solutions I strongly suspect a bug in ctypes.

--
components: ctypes
messages: 171876
nosy: iroli
priority: normal
severity: normal
status: open
title: python2.7.3 struct misaligned when returned
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16117
___
___
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-03 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

I admit that I kind of like Java's approach to this.  First off, they define an 
interface, ReadWriteLock:
http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/locks/ReadWriteLock.html
There, they also discuss the different choices an implementation of the 
interface can make, regarding a) policy, b) reentrancy, c) upgrading or 
downgrading.
A concrete implemention is then presented in the form of the 
ReentrantReadWriteLock, with documented behaviour for the above.
The rest of threading is also, as previously pointed out, more or less a 
rip-off from Java.

Since there is no single correct choice for the above, and since the 
implementation restrictions are different between inter-process and 
inter-thread locks, it would make sense to adopt a similar model, where a 
RWLock() function is a factory function, taking an argument specify a desired 
class of locks.

The policies that have been seen in this thread are:
a) greedy policy (no policy)
b) writer preference
c) 'Fair' (or in-order) preference.
All have their benefits and disadvantages.

We have also seen recursive and nonrecursive.

The restrictions appear more serious in the inter-process case since I don't 
know if it is possible to maintain a shared dynamic array of thread ids across 
processes.

--

___
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



[issue13290] get vars for object with __slots__

2012-10-03 Thread Richard Oudkerk

Richard Oudkerk added the comment:

The patch does not seem to walk the mro to look for slots in base classes.  
Also, an instance with a __dict__ attribute may also have attributes stored in 
slots.

BTW, copyreg._slotnames(cls) properly calculates the slot names for cls and 
tries to cache them as cls.__slotnames__.  Pickle does the equivalent of

try:
slotnames = cls.__slotnames__
except AttributeError:
slotnames = copyreg._slotnames(cls)

--
nosy: +sbt

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



[issue16118] Implement SHA-3

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

New submission from Jesús Cea Avión:

We have a #sha3 winner!! Keccak - https://en.wikipedia.org/wiki/Keccak

--
components: Extension Modules
messages: 171879
nosy: jcea
priority: normal
severity: normal
stage: needs patch
status: open
title: Implement SHA-3
type: enhancement
versions: Python 3.4

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



[issue15786] IDLE code completion window does not scoll/select with mouse

2012-10-03 Thread suddha sourav

suddha sourav added the comment:

Thank you for the hint, Roger! On my side, I have changed the
HIDE_SEQUENCES tuple to (Key-Escape,) and it is giving me the behaviour
I desired. However, I am not sure if this is a fix of the real issue.

I tried IDLE on OpenSUSE 12.2 last night and faced the problem in its other
manifestation, which you describe.

Thank you again tor the quick feedback!

--

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



[issue16117] python2.7.3 struct misaligned when returned

2012-10-03 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
nosy: +mark.dickinson, meador.inge

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



[issue16118] Implement SHA-3

2012-10-03 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
superseder:  - Add SHA-3 (Keccak) support

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



[issue16118] Implement SHA-3

2012-10-03 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
resolution:  - duplicate
status: open - closed

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



[issue16114] incorrect path in subprocess.Popen() FileNotFoundError message

2012-10-03 Thread Arfrever Frehtes Taifersar Arahesis

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


--
nosy: +Arfrever

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



[issue16115] test that executable arg to Popen() takes precedence over args[0] arg

2012-10-03 Thread Arfrever Frehtes Taifersar Arahesis

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


--
nosy: +Arfrever

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



[issue15535] Fix pickling efficiency of named tuples in 2.7.3

2012-10-03 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/issue15535
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15617] FAIL: test_create_connection (test.test_socket.NetworkConnectionNoServer)

2012-10-03 Thread koobs

koobs added the comment:

Incase it helps at all, I'm seeing the test failure preparing for adding 
python33 to the FreeBSD ports tree. 

On FreeBSD 9.0-RELEASE-p3 (amd64), with /etc/hosts configured as follows:

::1 localhost.domain localhost
127.0.0.1   localhost.domain localhost

The following is returned:

 socket.getaddrinfo('localhost', 80, 0, socket.SOCK_STREAM, 0, 
 socket.AI_ADDRCONFIG)
[(2, 1, 6, '', ('127.0.0.1', 80)), (28, 1, 6, '', ('::1', 80, 0, 0))]


--
nosy: +koobs

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15617
___
___
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-03 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/issue16113
___
___
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-03 Thread Jesús Cea Avión

Jesús Cea Avión added the comment:

We have MD5, SHA1, sha256, sha512 implemented, to use when openssl is not 
available. Can we do the same with sha-3?. I would suggest to adopt the 
reference implementation without extensive optimizations, since we will have 
them when openssl has them.

So we might implement SHA-3 now and integrate OpenSSL implementation later, 
when available. This is interesting, for instance, because many users of Python 
3.4 will have a non up to date OpenSSL system library.

--

___
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-03 Thread Richard Oudkerk

Richard Oudkerk added the comment:

 Multiprocessing:  Because there is no way I know to share a list of 
 owning thread ids, this version is more limited

Why do you need a *shared* list?  I think it should be fine to use a 
per-process list of owning thread ids.   So the current thread owns the lock if 
and only if it is in the current process's list of owners.

(On Unix you should probably clear the list when you fork by using 
multiprocessing.util.register_after_fork() in the initializer.)

--

___
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



[issue15786] IDLE code completion window does not scroll/select with mouse

2012-10-03 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
title: IDLE code completion window does not scoll/select with mouse - IDLE 
code completion window does not scroll/select with mouse

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



[issue16119] Python 2.7 IDLE not working in WinVista

2012-10-03 Thread Spiros K.

New submission from Spiros K.:

Hello.

I intalled EPD Free 7.3-2 WIN x86 a few hours ago and idle script doesn't work. 
When i try to run IDLE from cmd (c:\Python27\Lib\idlelibidle.py) i take the 
following output:

Traceback (most recent call last):
  File C:\Python27\Lib\idlelib\idle.py, line 10, in module
import idlelib.PyShell
  File C:\Python27\Lib\idlelib\PyShell.py, line 9, in module
import socket
  File C:\Python27\Lib\socket.py, line 47, in module
import _socket
ImportError: DLL load failed: ─ίΊ ▐ΪάΊ ϊΫΊάΪⁿ Ίά ίΊΪΎΏώ≤Ϊί▀ ύ ΆάϋΎ±ώ≤Ή▌Ίύ ΉΎΊ▄ϊά
.

My operating system is WinVista HomePremium SP2. Is there any way to solve this 
problem?

--
components: IDLE
messages: 171884
nosy: sk7
priority: normal
severity: normal
status: open
title: Python 2.7 IDLE not working in WinVista
type: behavior
versions: Python 2.7

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



[issue11245] Implementation of IMAP IDLE in imaplib?

2012-10-03 Thread Gereon Kremer

Gereon Kremer added the comment:

We have implemented this functionality according to RFC 2177.
We actually implemented a synchronous idle function that blocks until a timeout 
occurs or the server sent some event.

This is not the most flexible way, however it will provide a basic 
functionality that enables user to use imap idle based notifications.
Besides, every other solution would require threads or regular polling.

See attached patch file.

--
keywords: +patch
nosy: +nafur
Added file: http://bugs.python.org/file27400/imapidle.patch

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



[issue15989] Possible integer overflow of PyLong_AsLong() results

2012-10-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Added patches for 2.7 and 3.2.

--
Added file: http://bugs.python.org/file27401/long_aslong_overflow-3.2.patch
Added file: http://bugs.python.org/file27402/long_aslong_overflow-2.7.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15989
___diff -r 0f4d4f4db724 Include/longobject.h
--- a/Include/longobject.h  Wed Oct 03 03:16:42 2012 +0200
+++ b/Include/longobject.h  Wed Oct 03 10:12:33 2012 +0300
@@ -26,6 +26,9 @@
 PyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *);
 PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *);
 PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *);
+#ifndef Py_LIMITED_API
+PyAPI_FUNC(int) _PyLong_AsInt(PyObject *);
+#endif
 PyAPI_FUNC(PyObject *) PyLong_GetInfo(void);
 
 /* It may be useful in the future. I've added it in the PyInt - PyLong
diff -r 0f4d4f4db724 Modules/_ctypes/stgdict.c
--- a/Modules/_ctypes/stgdict.c Wed Oct 03 03:16:42 2012 +0200
+++ b/Modules/_ctypes/stgdict.c Wed Oct 03 10:12:33 2012 +0300
@@ -335,7 +335,7 @@
 
 isPacked = PyObject_GetAttrString(type, _pack_);
 if (isPacked) {
-pack = PyLong_AsLong(isPacked);
+pack = _PyLong_AsInt(isPacked);
 if (pack  0 || PyErr_Occurred()) {
 Py_XDECREF(isPacked);
 PyErr_SetString(PyExc_ValueError,
diff -r 0f4d4f4db724 Modules/_io/_iomodule.c
--- a/Modules/_io/_iomodule.c   Wed Oct 03 03:16:42 2012 +0200
+++ b/Modules/_io/_iomodule.c   Wed Oct 03 10:12:33 2012 +0300
@@ -303,7 +303,8 @@
 int text = 0, binary = 0, universal = 0;
 
 char rawmode[5], *m;
-int line_buffering, isatty;
+int line_buffering;
+long isatty;
 
 PyObject *raw, *modeobj = NULL, *buffer = NULL, *wrapper = NULL;
 
@@ -441,12 +442,12 @@
 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
 {
 struct stat st;
-long fileno;
+int fileno;
 PyObject *res = PyObject_CallMethod(raw, fileno, NULL);
 if (res == NULL)
 goto error;
 
-fileno = PyLong_AsLong(res);
+fileno = _PyLong_AsInt(res);
 Py_DECREF(res);
 if (fileno == -1  PyErr_Occurred())
 goto error;
diff -r 0f4d4f4db724 Modules/_io/fileio.c
--- a/Modules/_io/fileio.c  Wed Oct 03 03:16:42 2012 +0200
+++ b/Modules/_io/fileio.c  Wed Oct 03 10:12:33 2012 +0300
@@ -240,7 +240,7 @@
 return -1;
 }
 
-fd = PyLong_AsLong(nameobj);
+fd = _PyLong_AsInt(nameobj);
 if (fd  0) {
 if (!PyErr_Occurred()) {
 PyErr_SetString(PyExc_ValueError,
diff -r 0f4d4f4db724 Modules/_sqlite/connection.c
--- a/Modules/_sqlite/connection.c  Wed Oct 03 03:16:42 2012 +0200
+++ b/Modules/_sqlite/connection.c  Wed Oct 03 10:12:33 2012 +0300
@@ -861,7 +861,7 @@
 rc = SQLITE_DENY;
 } else {
 if (PyLong_Check(ret)) {
-rc = (int)PyLong_AsLong(ret);
+rc = _PyLong_AsInt(ret);
 } else {
 rc = SQLITE_DENY;
 }
@@ -1289,7 +1289,7 @@
 goto finally;
 }
 
-result = PyLong_AsLong(retval);
+result = _PyLong_AsInt(retval);
 if (PyErr_Occurred()) {
 result = 0;
 }
diff -r 0f4d4f4db724 Modules/grpmodule.c
--- a/Modules/grpmodule.c   Wed Oct 03 03:16:42 2012 +0200
+++ b/Modules/grpmodule.c   Wed Oct 03 10:12:33 2012 +0300
@@ -85,7 +85,7 @@
 grp_getgrgid(PyObject *self, PyObject *pyo_id)
 {
 PyObject *py_int_id;
-unsigned int gid;
+long gid;
 struct group *p;
 
 py_int_id = PyNumber_Long(pyo_id);
@@ -93,8 +93,15 @@
 return NULL;
 gid = PyLong_AS_LONG(py_int_id);
 Py_DECREF(py_int_id);
+if (gid == -1  PyErr_Occurred())
+return NULL;
+if ((long)(gid_t)gid != gid) {
+PyErr_SetString(PyExc_OverflowError,
+Python int too large to convert to gid_t);
+return NULL;
+}
 
-if ((p = getgrgid(gid)) == NULL) {
+if ((p = getgrgid((gid_t)gid)) == NULL) {
 PyErr_Format(PyExc_KeyError, getgrgid(): gid not found: %d, gid);
 return NULL;
 }
diff -r 0f4d4f4db724 Modules/parsermodule.c
--- a/Modules/parsermodule.cWed Oct 03 03:16:42 2012 +0200
+++ b/Modules/parsermodule.cWed Oct 03 10:12:33 2012 +0300
@@ -747,7 +747,7 @@
 /* elem must always be a sequence, however simple */
 PyObject* elem = PySequence_GetItem(tuple, i);
 int ok = elem != NULL;
-long  type = 0;
+int type = 0;
 char *strn = 0;
 
 if (ok)
@@ -758,8 +758,14 @@
 ok = 0;
 else {
 ok = PyLong_Check(temp);
-if (ok)
-type = PyLong_AS_LONG(temp);
+if (ok) {
+type = _PyLong_AsInt(temp);
+if (type == -1  PyErr_Occurred()) {
+

[issue16119] Python 2.7 IDLE not working in WinVista

2012-10-03 Thread Roger Serwy

Roger Serwy added the comment:

Does the official Python 2.7.3 installation from python.org/download/ work for 
you?

--
nosy: +serwy

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



[issue16105] Pass read only FD to signal.set_wakeup_fd

2012-10-03 Thread Felipe Cruz

Felipe Cruz added the comment:

 Why limit to EBADF? You could also have EPIPE, EINVAL and many other errors.
 The only error you may not want to report is EAGAIN.

Charles,
You're right! If all errno cases get covered in the patch,  will It looks 
reasonable?

--

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



[issue11245] Implementation of IMAP IDLE in imaplib?

2012-10-03 Thread R. David Murray

R. David Murray added the comment:

To fully answer the original question that opened this issue: contributions 
will be welcomed.  While I don't currently have time to work on imaplib myself, 
I have an interest and will review and if appropriate commit patches.

I like Shay's proposal, but absent a patch along those lines having blocking 
IMAP support will definitely be an improvement.  An application needing to 
monitor more than one imap connection could do its own threading.

Thanks for proposing the patch.  Could you please submit a contributor 
agreement?  I probably won't have time to fully consider the proposed patch for 
a bit, but I've put it on my todo list.  

test_imaplib does have a testing framework now, do you think you could write 
tests for the new feature?

--
components: +email
nosy: +barry
versions: +Python 3.4 -Python 3.3

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



[issue16119] Python 2.7 IDLE not working in WinVista

2012-10-03 Thread Spiros K.

Spiros K. added the comment:

i removed the EPD version and installed the official Python 2.7.3, but still 
IDLE doesn't work (neither the start menu sortcut, nor the idle.py from cmd 
which still gives the same dll error).

The only difference is that the python (command line) works this time.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16119
___
___
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-03 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Excellent point, I hadn't thought of that!
Yes, it is is sufficient to test if _I_ am in the list.  I'll make the 
necessary changes. That will make the thread/process implementation virtually 
identical.

--

___
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



[issue15104] Unclear language in __main__ description

2012-10-03 Thread Mike Hoy

Changes by Mike Hoy mho...@gmail.com:


--
nosy: +mikehoy

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



[issue16119] Python 2.7 _socket DLL import error on Windows Vista

2012-10-03 Thread Roger Serwy

Roger Serwy added the comment:

This is not a problem with IDLE, but with an error with loading the _socket 
DLL. I changed the title to reflect the problem.

--
components: +Library (Lib) -IDLE
title: Python 2.7 IDLE not working in WinVista - Python 2.7 _socket DLL import 
error on Windows Vista

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



[issue13290] get vars for object with __slots__

2012-10-03 Thread Michele Orrù

Michele Orrù added the comment:

 The patch does not seem to walk the mro to look for slots in base 
 classes.  Also, an instance with a __dict__ attribute may also have 
attributes stored in slots.
Well, what I am doing is more or less the equivalent of 

return object.__slots__ if hasattr(object, '__slots') else object.__dict__

and this is coherent with the updated documentation. The one you proposed is an 
alternative behavior; am I supposed to follow that one?


 BTW, copyreg._slotnames(cls) properly calculates the slot names for cls and 
 tries to cache them as cls.__slotnames__.  Pickle does the equivalent of

 try:
 slotnames = cls.__slotnames__
 except AttributeError:
 slotnames = copyreg._slotnames(cls)
thanks! I'll take into account. 

-- 
ù

--

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



[issue16120] Use |yield from| in stdlib

2012-10-03 Thread Berker Peksag

New submission from Berker Peksag:

Related changesets:

- http://hg.python.org/cpython/rev/33a221662f39
- http://hg.python.org/cpython/rev/fb90e2ff95b7

--
components: Library (Lib)
files: yield-from_v1.diff
keywords: patch
messages: 171894
nosy: berker.peksag
priority: normal
severity: normal
status: open
title: Use |yield from| in stdlib
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file27403/yield-from_v1.diff

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



[issue16120] Use |yield from| in stdlib

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

Jesús Cea Avión added the comment:

3.3 is in bugfix mode only now. So, targeting 3.4.

I am neutral to this change. Showing use of new language idioms is nice, but 
merging patches to 3.3 and 3.4 would be more difficult.

--
nosy: +jcea
versions:  -Python 3.3

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



[issue16120] Use |yield from| in stdlib

2012-10-03 Thread R. David Murray

R. David Murray added the comment:

Thanks for the patch.

I think that seeing as we've already done a bunch, there's little reason not to 
do more.

--
nosy: +r.david.murray

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



[issue13290] get vars for object with __slots__

2012-10-03 Thread Richard Oudkerk

Richard Oudkerk added the comment:

 Well, what I am doing is more or less the equivalent of 
 
 return object.__slots__ if hasattr(object, '__slots') else object.__dict__
 
 and this is coherent with the updated documentation. The one you 
 proposed is an alternative behavior; am I supposed to follow that one?

Ignoring some slots but not others would be confusing.  I would be inclined to 
just leave vars() alone.  Maybe a Python implementation could be put in 
inspect.py instead.

A possible implementation (which can't be used to modify the object) might be:

import copyreg

def fullvars(obj):
cls = type(obj)
try:
slotnames = cls.__dict__['__slotnames__']
except (KeyError, AttributeError):
slotnames = copyreg._slotnames(cls)
try:
d = vars(obj).copy()
except TypeError:
d = {}
for name in slotnames:
try:
d[name] = getattr(obj, name)
except AttributeError:
pass
return d

class A:
__slots__ = 'x', 'y'

class B(A):
__slots__ = 'u', 'v'

class C(B):
pass

a = A()
a.x = 1
print(fullvars(a))  # {'x': 1}

b = B()
b.x = 2; b.u = 3
print(fullvars(b))  # {'u': 3, 'x': 2}

c = C()
c.y = 4; c.r = 5
print(fullvars(c))  # {'y': 4, 'r': 5}



BTW, I before should have written

try:
slotnames = cls.__dict__['__slotnames__']
except (KeyError, AttributeError):
slotnames = copyreg._slotnames(cls)

--

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



  1   2   >