Re: Everything you did not want to know about Unicode in Python 3

2014-05-17 Thread Mark Lawrence

On 17/05/2014 05:19, Marko Rauhamaa wrote:


The sole copyright holder can
simply state: "this work is in the Public Domain," or: "all rights
relinquished," or some such. Ultimately, everything is decided by the
courts, of course.



For examples see all the Python PEPs.

--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


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


Re: Everything you did not want to know about Unicode in Python 3

2014-05-17 Thread Robert Kern

On 2014-05-17 02:07, Steven D'Aprano wrote:

On Fri, 16 May 2014 14:46:23 +, Grant Edwards wrote:


At least in the US, there doesn't seem to be such a thing as "placing a
work into the public domain".  The copyright holder can transfer
ownershipt to soembody else, but there is no "public domain" to which
ownership can be trasferred.


That's factually incorrect. In the US, sufficiently old works, or works
of a certain age that were not explicitly registered for copyright, are
in the public domain. Under a wide range of circumstances, works created
by the federal government go immediately into the public domain.


There is such a thing as the public domain in the US, and there are works in it, 
but there isn't really such a thing as "placing a work" there voluntarily, as 
Grant says. A work either is or isn't in the public domain. The author has no 
choice in the matter.


--
Robert Kern

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

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


Re: Everything you did not want to know about Unicode in Python 3

2014-05-17 Thread Chris Angelico
On Sat, May 17, 2014 at 6:57 PM, Robert Kern  wrote:
> There is such a thing as the public domain in the US, and there are works in
> it, but there isn't really such a thing as "placing a work" there
> voluntarily, as Grant says. A work either is or isn't in the public domain.
> The author has no choice in the matter.

Then what's copyright status on PEPs?

The nearest thing to "assigning to public domain" that works across
legislatures is probably CC0:

http://creativecommons.org/about/cc0

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


Re: Everything you did not want to know about Unicode in Python 3

2014-05-17 Thread Robert Kern

On 2014-05-17 05:19, Marko Rauhamaa wrote:

Steven D'Aprano :


On Fri, 16 May 2014 14:46:23 +, Grant Edwards wrote:


At least in the US, there doesn't seem to be such a thing as "placing
a work into the public domain". The copyright holder can transfer
ownershipt to soembody else, but there is no "public domain" to which
ownership can be trasferred.


That's factually incorrect. In the US, sufficiently old works, or works
of a certain age that were not explicitly registered for copyright, are
in the public domain. Under a wide range of circumstances, works created
by the federal government go immediately into the public domain.


Steven, you're not disputing Grant. I am. The sole copyright holder can
simply state: "this work is in the Public Domain," or: "all rights
relinquished," or some such. Ultimately, everything is decided by the
courts, of course.


One can state many things, but that doesn't mean they have legal effect. The US 
Code has provisions for how works become copyrighted automatically, how they 
leave copyright automatically at the end of specific time periods, how some 
works automatically enter the public domain on their creation (i.e. works of the 
US federal government), but has nothing at all for how a private creator can 
voluntarily place their work into the public domain when it would otherwise not 
be. It used to, but does not any more.


For a private individual to say about a work they just created that "this work 
is in the Public Domain" is, under US law, merely an erroneous statement of 
fact, not a speech act that effects a change in the legal status of the work. 
For another example of this distinction, saying "I am married" when I have not 
applied for, received, and solemnified a valid marriage license is just an 
erroneous statement of fact and does not make me legally married.


Relinquishing your rights can have some effect, but not all rights can be 
relinquished, and this is not the same as putting your work into the public 
domain. Among other things, your heirs can sometimes reclaim those rights in 
some circumstances if you are not careful (and if they are valuable enough to 
bother reclaiming).


If you wish to do something like this, I highly recommend (though IANAL and 
TINLA) using the CC0 Waiver from Creative Commons. It has thorough legalese for 
relinquishing all the rights that one can relinquish for the maximum terms that 
one can do so in as many jurisdictions as possible and acts as a license to 
use/distribute/etc. without restriction even if some rights cannot be 
relinquished. Even if US law were to change to provide for dedicating works to 
the public domain, I would probably still use the CC0 anyways to account for the 
high variability in how different jurisdictions around the world treat their own 
public domains.


  http://creativecommons.org/about/cc0
  http://wiki.creativecommons.org/CC0_FAQ

Note how they distinguish the CC0 Waiver from their Public Domain Mark: the 
Public Domain Mark is just a label for things that are known to be free of 
copyright worldwide but does not make a work so. The CC0 *does* have an 
operative effect that is substantially similar to the work being in the public 
domain.


--
Robert Kern

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

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


Bug in Decimal??

2014-05-17 Thread Stefan Krah
> I'll follow up directly with the author of mpdecimal, as this is
> somewhat serious on a language that's so widely used as python.

> But please test it and confirm, am I seeing ghost digits?

This has already been settled on libmpdec-devel, but for the list:

As Mark Dickinson has already explained, you need to increase the intermediate
precision. For example:

>>> from decimal import *
>>> getcontext().prec=4000
>>> one=Decimal(1)
>>> number=Decimal('1e-1007')
>>> partial=(one+number)/(one-number)
>>> getcontext().prec=2016
>>> partial.ln()
Decimal('2.
00
00
00
00
00
00
00
00
00
00
00
00
00
00
007E-1007')


Otherwise 'partial' has an error that is too large when you pass it to
the ln() function.  Since decimal mostly follows IEEE 754 with arbitrary
precision extensions, it cannot behave differently.


Stefan Krah



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


Re: Everything you did not want to know about Unicode in Python 3

2014-05-17 Thread Ben Finney
Chris Angelico  writes:

> On Sat, May 17, 2014 at 6:57 PM, Robert Kern  wrote:
> > There is such a thing as the public domain in the US, and there are works in
> > it, but there isn't really such a thing as "placing a work" there
> > voluntarily, as Grant says. A work either is or isn't in the public domain.
> > The author has no choice in the matter.
>
> Then what's copyright status on PEPs?

My guess: They are in the default copyright status, with all rights
reserved (i.e. everything that copyright law restricts, is forbidden to
the recipient).

But, if any of those copyright holders were ever to assert their
copyright had been infringed by some recipient, the “this work is in the
public domain” or equivalent would be taken as a clear indication of the
*intent* of the copyright holder.

Ultimately, what matters is the determination of whatever judge you find
yourself facing. To that end, clarifying in the copyright statement and
license terms exactly what is permitted can be immensely helpful in
foreshortening and, ideally, avoiding a future copyright suit.

Copyright is a ridiculous burden on everyone — to the extent that even
those copyright holders who don't *want* those rights which the law
reserves to the copyright holder, and want to divest themselves of the
role of copyright holder, find it frustratingly difficult to do so
effectively across jurisdictions.

-- 
 \  “Computer perspective on Moore's Law: Human effort becomes |
  `\   twice as expensive roughly every two years.” —anonymous |
_o__)  |
Ben Finney

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


Re: Loading modules from files through C++

2014-05-17 Thread Stefan Behnel
Roland Plüss, 17.05.2014 02:27:
> I'm using Python in an embedded situation. In particular I have to load
> python scripts through a memory interface so regular python module
> loading can not be used. I got working so far a module loader object
> I've added using C++ to sys.meta_path . Now I'm totally stuck at the
> finally loading step.
> 
> I've got this a C++ loader method "load_module(fullname)" which does
> load the requested module script files into a null-terminated string. I
> know that "load_module" has to return the module PyObject*. But I can't
> get the python source in the c-string into a module PyObject*.
> [...]
> Can anybody help how in gods name one is supposed to create a module
> from an in-memory c-string when called from within load_module (or
> anywhere)?

Looks like you want to implement a SourceLoader:

https://docs.python.org/3.4/library/importlib.html#importlib.abc.SourceLoader

I recommend implementing this in Python code instead of C code, though.
Much easier. Cython can help with the integration between both.

Stefan


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


Re: Everything you did not want to know about Unicode in Python 3

2014-05-17 Thread Steven D'Aprano
On Sat, 17 May 2014 09:57:06 +0100, Robert Kern wrote:

> On 2014-05-17 02:07, Steven D'Aprano wrote:
>> On Fri, 16 May 2014 14:46:23 +, Grant Edwards wrote:
>>
>>> At least in the US, there doesn't seem to be such a thing as "placing
>>> a work into the public domain".  The copyright holder can transfer
>>> ownershipt to soembody else, but there is no "public domain" to which
>>> ownership can be trasferred.
>>
>> That's factually incorrect. In the US, sufficiently old works, or works
>> of a certain age that were not explicitly registered for copyright, are
>> in the public domain. Under a wide range of circumstances, works
>> created by the federal government go immediately into the public
>> domain.
> 
> There is such a thing as the public domain in the US, and there are
> works in it, but there isn't really such a thing as "placing a work"
> there voluntarily, as Grant says. A work either is or isn't in the
> public domain. The author has no choice in the matter.

That's incorrect.

http://cr.yp.to/publicdomain.html

Here's the money quote, from the 9th Circuit Court:

It is well settled that rights gained under the Copyright Act 
may be abandoned. But abandonment of a right must be manifested
by some overt act indicating an intention to abandon that right.


There's also this:

http://creativecommons.org/publicdomain/zero/1.0/

which counts as an overt act.


By the way, there's more info on US copyright terms here:

http://copyright.cornell.edu/resources/publicdomain.cfm

although it doesn't specifically mention voluntarily abandonment of 
copyright.



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP 8 : Maximum line Length :

2014-05-17 Thread Albert van der Horst
In article ,
Chris Angelico   wrote:
>On Fri, May 16, 2014 at 12:17 AM,   wrote:
>> One another trick is to drop spaces around keywords
>>
> 9and 12345or 99if 'a'in'a' else or 77
>> 12345
>>
>> and pray, the tools from those who are wasting their time in
>> writing code analyzers or syntax colorizers or doc strings
>> collectors or ... are finally working. Depending of the tools
>> the interpretation may vary, but definitely all are producing
>> erroneous results.
>
>Yes. Another very effective way to get your code below 80 characters
>is to shorten all names to a single letter. Since you don't need to
>restrict yourself to monocase Roman letters (as I had to in my
>earliest programming days, in BASIC), it's actually quite practical to
>uniquely name everything in a single character; you could save
>enormous amounts of horizontal space. Then, aggressively "import as"
>to do the same with remote symbols (you might need two characters for
>those), and you'll be able to write everything in just a few tight
>symbols!

That may be tong-in-cheek but mathematicians do exactly that. We
use roman, greek and hebrew alphabets in normal italics and boldface
and then some special characters for element-of, logical-or, integral signs,
triangles and what not. Underbarred and upper twiggled, as a suffix a prefix
or a superfix. All in the name of avoiding names longer than one character.

When we run out then there are creative ways to combine known characters
into Jacobi symbols and choose functions.

There are even conventions that allow to leave out characters, like
"juxtaposition means multiplication" and the Einstein summation convention.

You have to invest but terseness pays off.

Now translate E=mc^2 into Java.

>
>ChrisA
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

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


Re: Loading modules from files through C++

2014-05-17 Thread Roland Plüss
That doesn't work in 2.x, doesn't it?

On 05/17/2014 01:58 PM, Stefan Behnel wrote:
> Roland Plüss, 17.05.2014 02:27:
>> I'm using Python in an embedded situation. In particular I have to load
>> python scripts through a memory interface so regular python module
>> loading can not be used. I got working so far a module loader object
>> I've added using C++ to sys.meta_path . Now I'm totally stuck at the
>> finally loading step.
>>
>> I've got this a C++ loader method "load_module(fullname)" which does
>> load the requested module script files into a null-terminated string. I
>> know that "load_module" has to return the module PyObject*. But I can't
>> get the python source in the c-string into a module PyObject*.
>> [...]
>> Can anybody help how in gods name one is supposed to create a module
>> from an in-memory c-string when called from within load_module (or
>> anywhere)?
> Looks like you want to implement a SourceLoader:
>
> https://docs.python.org/3.4/library/importlib.html#importlib.abc.SourceLoader
>
> I recommend implementing this in Python code instead of C code, though.
> Much easier. Cython can help with the integration between both.
>
> Stefan
>
>


-- 
Yours sincerely
Plüss Roland

Leader and Head Programmer
- Game: Epsylon ( http://www.indiedb.com/games/epsylon )
- Game Engine: Drag[en]gine ( http://www.indiedb.com/engines/dragengine
, http://dragengine.rptd.ch/wiki )
- Normal Map Generator: DENormGen ( http://epsylon.rptd.ch/denormgen.php )
- As well as various Blender export scripts und game tools



signature.asc
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with changes in traceback stack from Python 2.7 to Python 3.x

2014-05-17 Thread Albert van der Horst
In article ,
Andrew Konstantaras   wrote:
>-=-=-=-=-=-
>
>I guess I am missing something big as I am looking for a shorthand way
>of doing the following:
>
>   dctA = dict(x=x, y=y, ... n=n)
>
>This is, as I understand it a very natural way of using a dictionary.
>It seems that this syntax is unnecessarily redundant and hence my goal
>of writing something more compact.  Perhaps the way I am doing it is a
>little unorthodox, but the ultimate use of a dictionary is, as I
>understand it, completely in line with how dictionaries were designed to
>be used.  In my other code, I often use these dictionaries to pass
>arguments to functions and return results.  It allows me great
>flexibility without breaking existing code.  I pack a dictionary before
>passing and unpack when retrieving.

Okay very well. I suggest you use the m4 preprocessor. This will allow
you to get a maximum of compactness without compromising the Python
language. Implementations of it are available on MS-Windows too.

>
>I will give the locals approach a try, it seems a little more clumsy
>than simply passing the variables to the function.
>
>Thanks again for your input.
>
>---Andrew
>





Groetjes Albert
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

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


Re: PEP 8 : Maximum line Length :

2014-05-17 Thread Chris Angelico
On Sat, May 17, 2014 at 10:52 PM, Albert van der Horst
 wrote:
> That may be tong-in-cheek but mathematicians do exactly that. We
> use roman, greek and hebrew alphabets in normal italics and boldface
> and then some special characters for element-of, logical-or, integral signs,
> triangles and what not. Underbarred and upper twiggled, as a suffix a prefix
> or a superfix. All in the name of avoiding names longer than one character.
>
> When we run out then there are creative ways to combine known characters
> into Jacobi symbols and choose functions.
>
> There are even conventions that allow to leave out characters, like
> "juxtaposition means multiplication" and the Einstein summation convention.

This, I think, is the main reason for the one-character variable name
convention. Why else are there subscripts? Instead of using "V0"
(two-character name), you use "V₀" (one-character name with a
subscript tag on it) to avoid collision with multiplication.

> Now translate E=mc^2 into Java.

Dunno, but in Python it would be:

assert E==m*c*c

And would probably fail, because that's all floating point :)

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


Re: Loading modules from files through C++

2014-05-17 Thread Stefan Behnel
Roland Plüss, 17.05.2014 15:00:
> On 05/17/2014 01:58 PM, Stefan Behnel wrote:
>> Roland Plüss, 17.05.2014 02:27:
>>> I'm using Python in an embedded situation. In particular I have to load
>>> python scripts through a memory interface so regular python module
>>> loading can not be used. I got working so far a module loader object
>>> I've added using C++ to sys.meta_path . Now I'm totally stuck at the
>>> finally loading step.
>>>
>>> I've got this a C++ loader method "load_module(fullname)" which does
>>> load the requested module script files into a null-terminated string. I
>>> know that "load_module" has to return the module PyObject*. But I can't
>>> get the python source in the c-string into a module PyObject*.
>>> [...]
>>> Can anybody help how in gods name one is supposed to create a module
>>> from an in-memory c-string when called from within load_module (or
>>> anywhere)?
>> Looks like you want to implement a SourceLoader:
>>
>> https://docs.python.org/3.4/library/importlib.html#importlib.abc.SourceLoader
>>
>> I recommend implementing this in Python code instead of C code, though.
>> Much easier. Cython can help with the integration between both.
>
> That doesn't work in 2.x, doesn't it?

Is there a reason you have to use Py2?

Anyway, PEP 302 predates Py3 by a couple of years:

http://legacy.python.org/dev/peps/pep-0302/

Stefan


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


Re: PEP 8 : Maximum line Length :

2014-05-17 Thread Tim Chase
On 2014-05-17 12:52, Albert van der Horst wrote:
> Now translate E=mc^2 into Java.

I suspect it would be something like

public class Einstein  {
  private double mass=0, energy=0;
  public class Relativity implements IEquation {
Relativity(double mass) {
  set_mass(mass);
}
public double getEnergy() {return energy;}
public double setEnergy(double newEnergy) {
  energy = newEnergy;
  mass = newEnergy / (units.SPEED_OF_LIGHT * units.SPEED_OF_LIGHT);
}
public double get_mass() {return mass;}
public double setMass(double newMass) {
  mass = newMass;
  energy = newMass * (units.SPEED_OF_LIGHT * units.SPEED_OF_LIGHT);
}
  }
  
  public static void main(String[] args) {
Relativity relativity = new Relativity(
  Integer.parseInt(args[1])
  );
System.out.println(relativity.getEnergy())
  }
}


(untested, as it has been a long time since I've touched any Java code)

-tkc





signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Loading modules from files through C++

2014-05-17 Thread Roland Plüss
I'm willing to go to Py3 but only if the solution to the problem is
simpler than getting it fixed in Py2. So some questions first:

- does this importlib stuff you showed there apply to C++ land (I need
to fully drive it from C++ not Python code)?
- is the C++ land of Py3 similar to Py2 or totally different?

On 05/17/2014 03:26 PM, Stefan Behnel wrote:
> Roland Plüss, 17.05.2014 15:00:
>> On 05/17/2014 01:58 PM, Stefan Behnel wrote:
>>> Roland Plüss, 17.05.2014 02:27:
 I'm using Python in an embedded situation. In particular I have to load
 python scripts through a memory interface so regular python module
 loading can not be used. I got working so far a module loader object
 I've added using C++ to sys.meta_path . Now I'm totally stuck at the
 finally loading step.

 I've got this a C++ loader method "load_module(fullname)" which does
 load the requested module script files into a null-terminated string. I
 know that "load_module" has to return the module PyObject*. But I can't
 get the python source in the c-string into a module PyObject*.
 [...]
 Can anybody help how in gods name one is supposed to create a module
 from an in-memory c-string when called from within load_module (or
 anywhere)?
>>> Looks like you want to implement a SourceLoader:
>>>
>>> https://docs.python.org/3.4/library/importlib.html#importlib.abc.SourceLoader
>>>
>>> I recommend implementing this in Python code instead of C code, though.
>>> Much easier. Cython can help with the integration between both.
>> That doesn't work in 2.x, doesn't it?
> Is there a reason you have to use Py2?
>
> Anyway, PEP 302 predates Py3 by a couple of years:
>
> http://legacy.python.org/dev/peps/pep-0302/
>
> Stefan
>
>


-- 
Yours sincerely
Plüss Roland

Leader and Head Programmer
- Game: Epsylon ( http://www.indiedb.com/games/epsylon )
- Game Engine: Drag[en]gine ( http://www.indiedb.com/engines/dragengine
, http://dragengine.rptd.ch/wiki )
- Normal Map Generator: DENormGen ( http://epsylon.rptd.ch/denormgen.php )
- As well as various Blender export scripts und game tools



signature.asc
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP 8 : Maximum line Length :

2014-05-17 Thread Roy Smith
In article ,
 Tim Chase  wrote:

> On 2014-05-17 12:52, Albert van der Horst wrote:
> > Now translate E=mc^2 into Java.
> 
> I suspect it would be something like
> 
> public class Einstein  {
>   private double mass=0, energy=0;
>   public class Relativity implements IEquation {
> Relativity(double mass) {
>   set_mass(mass);
> }
> public double getEnergy() {return energy;}
> public double setEnergy(double newEnergy) {
>   energy = newEnergy;
>   mass = newEnergy / (units.SPEED_OF_LIGHT * units.SPEED_OF_LIGHT);
> }
> public double get_mass() {return mass;}
> public double setMass(double newMass) {
>   mass = newMass;
>   energy = newMass * (units.SPEED_OF_LIGHT * units.SPEED_OF_LIGHT);
> }
>   }
>   
>   public static void main(String[] args) {
> Relativity relativity = new Relativity(
>   Integer.parseInt(args[1])
>   );
> System.out.println(relativity.getEnergy())
>   }
> }
> 
> 
> (untested, as it has been a long time since I've touched any Java code)
> 
> -tkc

Not good enough.  Einstein should really be a singleton, so you need 
something like an AbstractScientistFactory, which implements Singleton.  
And you really should be importing 
SPEED_OF_LIGHT_IN_VACUUM_METERS_PER_SECOND from 
org.universe.physics.constants.  And you need to declare that 
Einstein.getEnergy() raises NumericValueOutOfBoundsError if mass is 
negative (and FlatEarthError if the code is run in certain states south 
of the Mason-Dixie line).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP 8 : Maximum line Length :

2014-05-17 Thread Roy Smith
In article ,
 Chris Angelico  wrote:

> On Sat, May 17, 2014 at 10:52 PM, Albert van der Horst
>  wrote:
> > That may be tong-in-cheek but mathematicians do exactly that. We
> > use roman, greek and hebrew alphabets in normal italics and boldface
> > and then some special characters for element-of, logical-or, integral signs,
> > triangles and what not. Underbarred and upper twiggled, as a suffix a prefix
> > or a superfix. All in the name of avoiding names longer than one character.
> >
> > When we run out then there are creative ways to combine known characters
> > into Jacobi symbols and choose functions.
> >
> > There are even conventions that allow to leave out characters, like
> > "juxtaposition means multiplication" and the Einstein summation convention.
> 
> This, I think, is the main reason for the one-character variable name
> convention. Why else are there subscripts? Instead of using "V0"
> (two-character name), you use "V?" (one-character name with a
> subscript tag on it) to avoid collision with multiplication.
> 
> > Now translate E=mc^2 into Java.
> 
> Dunno, but in Python it would be:
> 
> assert E==m*c*c
> 
> And would probably fail, because that's all floating point :)
> 
> ChrisA

Nah.  Python has relativistic duck typing:

>>> c = 186000
>>> m = 100
>>> E = 34596L
>>> assert E==m*c*c
>>>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Loading modules from files through C++

2014-05-17 Thread Stefan Behnel
Hi,

please avoid top-posting.


Roland Plüss, 17.05.2014 15:49:
> On 05/17/2014 03:26 PM, Stefan Behnel wrote:
>> Roland Plüss, 17.05.2014 15:00:
>>> On 05/17/2014 01:58 PM, Stefan Behnel wrote:
 Roland Plüss, 17.05.2014 02:27:
> I'm using Python in an embedded situation. In particular I have to load
> python scripts through a memory interface so regular python module
> loading can not be used. I got working so far a module loader object
> I've added using C++ to sys.meta_path . Now I'm totally stuck at the
> finally loading step.
>
> I've got this a C++ loader method "load_module(fullname)" which does
> load the requested module script files into a null-terminated string. I
> know that "load_module" has to return the module PyObject*. But I can't
> get the python source in the c-string into a module PyObject*.
> [...]
> Can anybody help how in gods name one is supposed to create a module
> from an in-memory c-string when called from within load_module (or
> anywhere)?
 Looks like you want to implement a SourceLoader:

 https://docs.python.org/3.4/library/importlib.html#importlib.abc.SourceLoader

 I recommend implementing this in Python code instead of C code, though.
 Much easier. Cython can help with the integration between both.
>>> That doesn't work in 2.x, doesn't it?
>> Is there a reason you have to use Py2?
>>
>> Anyway, PEP 302 predates Py3 by a couple of years:
>>
>> http://legacy.python.org/dev/peps/pep-0302/
>
> I'm willing to go to Py3 but only if the solution to the problem is
> simpler than getting it fixed in Py2. So some questions first:
> 
> - does this importlib stuff you showed there apply to C++ land (I need
> to fully drive it from C++ not Python code)?

As I said, implementing this in Python code is much simpler than doing it
in C/C++ code. Basically, stop where you got the C string and do the rest
in Python. All your C code has to do is to take a module lookup request
from your custom Python module Finder and return a byte string with the
code. Then let your Python code wrap that in a Loader and return it to the
import machinery.


> - is the C++ land of Py3 similar to Py2 or totally different?

Much the same, just slight differences. As I said, Cython can help with the
integration and would mostly cover the differences for you.

Stefan


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


Re: PEP 8 : Maximum line Length :

2014-05-17 Thread Mark Lawrence

On 17/05/2014 13:52, Albert van der Horst wrote:


Now translate E=mc^2 into Java.



I can't do that as I simply don't understand it.  What has the 
Marylebone Cricket Club got to do with E?


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


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


Re: PEP 8 : Maximum line Length :

2014-05-17 Thread Roy Smith
In article ,
 Mark Lawrence  wrote:

> On 17/05/2014 13:52, Albert van der Horst wrote:
> >
> > Now translate E=mc^2 into Java.
> >
> 
> I can't do that as I simply don't understand it.  What has the 
> Marylebone Cricket Club got to do with E?

A wicket looks like an E on its side.  Does that help?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-17 Thread Steven D'Aprano
On Sat, 17 May 2014 10:29:00 +0100, Robert Kern wrote:

> One can state many things, but that doesn't mean they have legal effect.
> The US Code has provisions for how works become copyrighted
> automatically, how they leave copyright automatically at the end of
> specific time periods, how some works automatically enter the public
> domain on their creation (i.e. works of the US federal government), but
> has nothing at all for how a private creator can voluntarily place their
> work into the public domain when it would otherwise not be. It used to,
> but does not any more.

The case for abandonment was stated as "well settled" in 1998 (Micro-Star 
v. Formgen Inc). Unless there has been a major legal change in the years 
since then, I don't think it is true that authors cannot abandon 
copyright.

 
> For a private individual to say about a work they just created that
> "this work is in the Public Domain" is, under US law, merely an
> erroneous statement of fact, not a speech act that effects a change in
> the legal status of the work. For another example of this distinction,
> saying "I am married" when I have not applied for, received, and
> solemnified a valid marriage license is just an erroneous statement of
> fact and does not make me legally married.

There may be something to what you say, although I think we're now 
arguing fine semantic details. See:

https://en.wikipedia.org/wiki/Wikipedia:Granting_work_into_the_public_domain

To play Devil's Advocate in favour of your assertion, it may be that 
abandoning copyright does not literally put the work in the public 
domain, but merely makes it "quack like the public domain". That is to 
say, the author still, in some abstract but legally meaningless sense, 
has copyright in the work *but* has given unlimited usage rights. (I 
don't actually think that is the case, at least not in the US.)

It's this tiny bit of residual uncertainty that leads some authorities to 
say that it is "hard" to release a work into the public domain, 
particularly in a world-wide context, and that merely stating "this is in 
the public domain" is not sufficient to remove all legal doubt over the 
status, and that a more overt and explicit release *may* be required. 
Hence the CC0 licence which you refer to. The human readable summary says 
in part:

 The person who associated a work with this deed has dedicated
 the work to the public domain by waiving all of his or her
 rights to the work worldwide under copyright law, including
 all related and neighboring rights, to the extent allowed by
 law.

 You can copy, modify, distribute and perform the work, even
 for commercial purposes, all without asking permission.

http://creativecommons.org/publicdomain/zero/1.0/

while the actual legal licence comes in at almost 800 words. This is 
basically the same as "I release this to the public domain" only longer.

(The CC0 licence is longer than you might expect, because it is assumed 
that it may have to apply in countries where you *really cannot* 
relinquish copyright. But we're specifically talking about the US, where 
the 9th Circuit says you can.)


> Relinquishing your rights can have some effect, but not all rights can
> be relinquished, 

Outside of the US, so-called "moral rights" or "reputation rights" cannot 
generally be relinquished, except perhaps in work-for-hire and perhaps 
not even then. (E.g. if you're a ghost writer.) The situation in the US 
is a bit murky -- there are no official moral rights per se, and 
copyright only controls usage rights such as copying, distribution and so 
forth. But this doesn't mean that you can (for example) claim authorship 
of a public domain work unless you actually wrote it.

In any case, we're discussing copyright, not other rights.


> and this is not the same as putting your work into the
> public domain. 

One might "not be the same" while still being "effectively the same". For 
example, the U.S. Copyright Office states that "one may not grant their 
work into the public domain. However, a copyright owner may release all 
of their rights to their work by stating the work may be freely 
reproduced, distributed, etc." as if it were in in the public domain.

But note that the Copyright Office does not make the final decision 
whether you can relinquish copyright or not. That's up to the courts.


> Among other things, your heirs can sometimes reclaim
> those rights in some circumstances if you are not careful (and if they
> are valuable enough to bother reclaiming).

That's a good point. A simplistic "I release this to the public domain" 
statement *may* (I emphasise the uncertainty) leave some doubt that it is 
*sufficiently overt* to prevent your heirs from disagreeing and coming 
after your users for infringement. Then the courts have to get involved, 
and it's all ugliness and only the lawyers win.

Hence the advice to be as explicit and overt as possible.


> If you wish to do something like thi

Re: PEP 8 : Maximum line Length :

2014-05-17 Thread Mark Lawrence

On 17/05/2014 15:06, Roy Smith wrote:

In article ,
  Mark Lawrence  wrote:


On 17/05/2014 13:52, Albert van der Horst wrote:


Now translate E=mc^2 into Java.



I can't do that as I simply don't understand it.  What has the
Marylebone Cricket Club got to do with E?


A wicket looks like an E on its side.  Does that help?



Ah, now I get it, thanks for that :)

--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


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


Re: Values and objects

2014-05-17 Thread Albert van der Horst
In article <536decca$0$29980$c3e8da3$54964...@news.astraweb.com>,

>Personally, I don't imagine that there ever could be a language where
>variables were first class values *exactly* the same as ints, strings,
>floats etc. Otherwise, how could you tell the difference between a
>function which operated on the variable itself, and one which operated on
>the value contained by the value? The best you can do is for variables to
>be "second class" -- you can do these things to them, but you need
>special syntax or declarations to tell the compiler you're operating on
>the variable rather than the variable's value. E.g. Pascal and Algol have
>syntax for instructing the compiler when to pass a variable as a value,
>and when to pass the value. C gives you nothing.

You're talking about Algol, but there is a great distinction between
Algol60 and Algol68. Algol68 through the ref keyword goes a long
way towards making variables first class citizens.
E.g. although `` int i'' in Algol68 means practically the same as in
C, it is defined as being an abbreviation of
'ref' 'int' i = 'loc' 'int';

This means so much that i is a reference to an otherwise unnamed int
that is allocated locally. Furthermore you can't break the tie between
i and that int (because you use =, you could have used := )
Because I refers to that location you can change it by
 i:=1;
Note that the left side *must* be a reference. You can't change an
int, you can only change the content of a memory place you can refer
to.

Now you can define
'ref' 'int' pi;
pi := i;

van Wijngaarden and crue pretty much nailed it, IMO.



>--
>Steven D'Aprano
>http://import-that.dreamwidth.org/

Groetjes Albert
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

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


Re: Loading modules from files through C++

2014-05-17 Thread Roland Plüss

On 05/17/2014 04:01 PM, Stefan Behnel wrote:
> Hi,
>
> please avoid top-posting.
>
>
> Roland Plüss, 17.05.2014 15:49:
>> On 05/17/2014 03:26 PM, Stefan Behnel wrote:
>>> Roland Plüss, 17.05.2014 15:00:
 On 05/17/2014 01:58 PM, Stefan Behnel wrote:
> Roland Plüss, 17.05.2014 02:27:
>> I'm using Python in an embedded situation. In particular I have to load
>> python scripts through a memory interface so regular python module
>> loading can not be used. I got working so far a module loader object
>> I've added using C++ to sys.meta_path . Now I'm totally stuck at the
>> finally loading step.
>>
>> I've got this a C++ loader method "load_module(fullname)" which does
>> load the requested module script files into a null-terminated string. I
>> know that "load_module" has to return the module PyObject*. But I can't
>> get the python source in the c-string into a module PyObject*.
>> [...]
>> Can anybody help how in gods name one is supposed to create a module
>> from an in-memory c-string when called from within load_module (or
>> anywhere)?
> Looks like you want to implement a SourceLoader:
>
> https://docs.python.org/3.4/library/importlib.html#importlib.abc.SourceLoader
>
> I recommend implementing this in Python code instead of C code, though.
> Much easier. Cython can help with the integration between both.
 That doesn't work in 2.x, doesn't it?
>>> Is there a reason you have to use Py2?
>>>
>>> Anyway, PEP 302 predates Py3 by a couple of years:
>>>
>>> http://legacy.python.org/dev/peps/pep-0302/
>> I'm willing to go to Py3 but only if the solution to the problem is
>> simpler than getting it fixed in Py2. So some questions first:
>>
>> - does this importlib stuff you showed there apply to C++ land (I need
>> to fully drive it from C++ not Python code)?
> As I said, implementing this in Python code is much simpler than doing it
> in C/C++ code. Basically, stop where you got the C string and do the rest
> in Python. All your C code has to do is to take a module lookup request
> from your custom Python module Finder and return a byte string with the
> code. Then let your Python code wrap that in a Loader and return it to the
> import machinery.
I don't get how this is supposed to work. I'm running it as fully
embedded Python. There is no main script. The builtin modules are added
as C++ bound classes and a user made main script is loaded but not run
directly (I'm hooking into a create object). For this purpose I load the
script module using C++ code using PyImport_ImportModule(moduleName). At
this time the module loading code has to kick in already (I've added
this one by C++ too before). The problem is now that in this call I end
up in my C++ loader version where there is no Python script involved. I
came to the conclusion that I can solve this only by having the C++ end
properly load the module. I could add Python code with
PyRun_SimpleString but then I'm down to the same problem as before: how
to evaluate code so it is attached to a module or type-class? As I
understand it the problem is the same as before just pushed around a bit.
>> - is the C++ land of Py3 similar to Py2 or totally different?
> Much the same, just slight differences. As I said, Cython can help with the
> integration and would mostly cover the differences for you.
Sounds good. I'll give it a try
>
> Stefan
>
>


-- 
Yours sincerely
Plüss Roland

Leader and Head Programmer
- Game: Epsylon ( http://www.indiedb.com/games/epsylon )
- Game Engine: Drag[en]gine ( http://www.indiedb.com/engines/dragengine
, http://dragengine.rptd.ch/wiki )
- Normal Map Generator: DENormGen ( http://epsylon.rptd.ch/denormgen.php )
- As well as various Blender export scripts und game tools



signature.asc
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Loading modules from files through C++

2014-05-17 Thread Stefan Behnel
Roland Plüss, 17.05.2014 17:28:
> On 05/17/2014 04:01 PM, Stefan Behnel wrote:
>> Roland Plüss, 17.05.2014 15:49:
>>> On 05/17/2014 03:26 PM, Stefan Behnel wrote:
 Roland Plüss, 17.05.2014 15:00:
> On 05/17/2014 01:58 PM, Stefan Behnel wrote:
>> Roland Plüss, 17.05.2014 02:27:
>>> I'm using Python in an embedded situation. In particular I have to load
>>> python scripts through a memory interface so regular python module
>>> loading can not be used. I got working so far a module loader object
>>> I've added using C++ to sys.meta_path . Now I'm totally stuck at the
>>> finally loading step.
>>>
>>> I've got this a C++ loader method "load_module(fullname)" which does
>>> load the requested module script files into a null-terminated string. I
>>> know that "load_module" has to return the module PyObject*. But I can't
>>> get the python source in the c-string into a module PyObject*.
>>> [...]
>>> Can anybody help how in gods name one is supposed to create a module
>>> from an in-memory c-string when called from within load_module (or
>>> anywhere)?
>> Looks like you want to implement a SourceLoader:
>>
>> https://docs.python.org/3.4/library/importlib.html#importlib.abc.SourceLoader
>>
>> I recommend implementing this in Python code instead of C code, though.
>> Much easier. Cython can help with the integration between both.
> That doesn't work in 2.x, doesn't it?
 Is there a reason you have to use Py2?

 Anyway, PEP 302 predates Py3 by a couple of years:

 http://legacy.python.org/dev/peps/pep-0302/
>>> I'm willing to go to Py3 but only if the solution to the problem is
>>> simpler than getting it fixed in Py2. So some questions first:
>>>
>>> - does this importlib stuff you showed there apply to C++ land (I need
>>> to fully drive it from C++ not Python code)?
>> As I said, implementing this in Python code is much simpler than doing it
>> in C/C++ code. Basically, stop where you got the C string and do the rest
>> in Python. All your C code has to do is to take a module lookup request
>> from your custom Python module Finder and return a byte string with the
>> code. Then let your Python code wrap that in a Loader and return it to the
>> import machinery.
>
> I don't get how this is supposed to work. I'm running it as fully
> embedded Python. There is no main script. The builtin modules are added
> as C++ bound classes and a user made main script is loaded but not run
> directly (I'm hooking into a create object). For this purpose I load the
> script module using C++ code using PyImport_ImportModule(moduleName). At
> this time the module loading code has to kick in already (I've added
> this one by C++ too before). The problem is now that in this call I end
> up in my C++ loader version where there is no Python script involved. I
> came to the conclusion that I can solve this only by having the C++ end
> properly load the module. I could add Python code with
> PyRun_SimpleString but then I'm down to the same problem as before: how
> to evaluate code so it is attached to a module or type-class? As I
> understand it the problem is the same as before just pushed around a bit.

No, just run some Python code (using PyRun_SimpleString() if you have to)
and let it do whatever you like. Such as, defining a Finder class and
injecting it into the import hook. Just provide it with the entry point of
your C++ loader as a (CFunction) object when you execute it, and then let
it call that function at need whenever the Finder gets executed.

Alternatively, compile your Python integration code with Cython and link it
into your main program as yet another binary extension module.

Stefan


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


Re: Loading modules from files through C++

2014-05-17 Thread Roland Plüss

On 05/17/2014 05:49 PM, Stefan Behnel wrote:
> Roland Plüss, 17.05.2014 17:28:
>> On 05/17/2014 04:01 PM, Stefan Behnel wrote:
>>> Roland Plüss, 17.05.2014 15:49:
 On 05/17/2014 03:26 PM, Stefan Behnel wrote:
> Roland Plüss, 17.05.2014 15:00:
>> On 05/17/2014 01:58 PM, Stefan Behnel wrote:
>>> Roland Plüss, 17.05.2014 02:27:
 I'm using Python in an embedded situation. In particular I have to load
 python scripts through a memory interface so regular python module
 loading can not be used. I got working so far a module loader object
 I've added using C++ to sys.meta_path . Now I'm totally stuck at the
 finally loading step.

 I've got this a C++ loader method "load_module(fullname)" which does
 load the requested module script files into a null-terminated string. I
 know that "load_module" has to return the module PyObject*. But I can't
 get the python source in the c-string into a module PyObject*.
 [...]
 Can anybody help how in gods name one is supposed to create a module
 from an in-memory c-string when called from within load_module (or
 anywhere)?
>>> Looks like you want to implement a SourceLoader:
>>>
>>> https://docs.python.org/3.4/library/importlib.html#importlib.abc.SourceLoader
>>>
>>> I recommend implementing this in Python code instead of C code, though.
>>> Much easier. Cython can help with the integration between both.
>> That doesn't work in 2.x, doesn't it?
> Is there a reason you have to use Py2?
>
> Anyway, PEP 302 predates Py3 by a couple of years:
>
> http://legacy.python.org/dev/peps/pep-0302/
 I'm willing to go to Py3 but only if the solution to the problem is
 simpler than getting it fixed in Py2. So some questions first:

 - does this importlib stuff you showed there apply to C++ land (I need
 to fully drive it from C++ not Python code)?
>>> As I said, implementing this in Python code is much simpler than doing it
>>> in C/C++ code. Basically, stop where you got the C string and do the rest
>>> in Python. All your C code has to do is to take a module lookup request
>>> from your custom Python module Finder and return a byte string with the
>>> code. Then let your Python code wrap that in a Loader and return it to the
>>> import machinery.
>> I don't get how this is supposed to work. I'm running it as fully
>> embedded Python. There is no main script. The builtin modules are added
>> as C++ bound classes and a user made main script is loaded but not run
>> directly (I'm hooking into a create object). For this purpose I load the
>> script module using C++ code using PyImport_ImportModule(moduleName). At
>> this time the module loading code has to kick in already (I've added
>> this one by C++ too before). The problem is now that in this call I end
>> up in my C++ loader version where there is no Python script involved. I
>> came to the conclusion that I can solve this only by having the C++ end
>> properly load the module. I could add Python code with
>> PyRun_SimpleString but then I'm down to the same problem as before: how
>> to evaluate code so it is attached to a module or type-class? As I
>> understand it the problem is the same as before just pushed around a bit.
> No, just run some Python code (using PyRun_SimpleString() if you have to)
> and let it do whatever you like. Such as, defining a Finder class and
> injecting it into the import hook. Just provide it with the entry point of
> your C++ loader as a (CFunction) object when you execute it, and then let
> it call that function at need whenever the Finder gets executed.
>
> Alternatively, compile your Python integration code with Cython and link it
> into your main program as yet another binary extension module.
>
> Stefan
>
>
I'm not using Cython so that's out of question. Concerning the injection
how would this work? From the PEP I assume it would have to look like this:

# CODE #
import sys
class VFSModuleLoader:
   def find_module(fullname, path=None):
  return self if VFS.exists( vfsPathFromFullname(fullname) ) else None
   def load_module(fullname):
  sourceCode = VFS.read( vfsPathFromFullname(fullname))
  ???
# CODE #

How does ??? work? If I use "eval" I end up with the code inside
VFSModuleLoader.load_modules as context but it should go into the global
context as an own module.

-- 
Yours sincerely
Plüss Roland

Leader and Head Programmer
- Game: Epsylon ( http://www.indiedb.com/games/epsylon )
- Game Engine: Drag[en]gine ( http://www.indiedb.com/engines/dragengine
, http://dragengine.rptd.ch/wiki )
- Normal Map Generator: DENormGen ( http://epsylon.rptd.ch/denormgen.php )
- As well as various Blender export scripts und game tools



signature.asc
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Problem building 3.5 on Windows

2014-05-17 Thread Mark Lawrence
First time in months I've tried building, first time I've ever had a 
problem that I can't solve for myself.  I'm using Visual C++ 2010 Express.


1>-- Build started: Project: make_versioninfo, Configuration: Debug 
Win32 --

1>  make_versioninfo.c
1>..\PC\make_versioninfo.c(1): fatal error C1083: Cannot open include 
file: 'stdio.h': No such file or directory
2>-- Build started: Project: kill_python, Configuration: Debug Win32 
--

2>  kill_python.c
2>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\windows.h(151): 
fatal error C1083: Cannot open include file: 'excpt.h': No such file or 
directory
3>-- Build started: Project: make_buildinfo, Configuration: Release 
Win32 --

3>  make_buildinfo.c
3>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\windows.h(151): 
fatal error C1083: Cannot open include file: 'excpt.h': No such file or 
directory


etc.

What stupid thing have I forgotten, apart from switching to *nix? :)

--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


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


Re: Problem building 3.5 on Windows

2014-05-17 Thread Chris Angelico
On Sun, May 18, 2014 at 2:59 AM, Mark Lawrence  wrote:
> 1>..\PC\make_versioninfo.c(1): fatal error C1083: Cannot open include file:
> 'stdio.h': No such file or directory
>
> What stupid thing have I forgotten, apart from switching to *nix? :)

Well, apart from that... I'd guess you have a pathing problem. Since
stdio.h is a standard compiler-provided header, I'd advise locating it
on disk, then checking if that path is in the INCLUDE env var. Not
sure if the Python build process overrides that, though, but it's a
start.

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


Re: Loading modules from files through C++

2014-05-17 Thread Stefan Behnel
Roland Plüss, 17.05.2014 18:28:
> On 05/17/2014 05:49 PM, Stefan Behnel wrote:
>> Roland Plüss, 17.05.2014 17:28:
>>> On 05/17/2014 04:01 PM, Stefan Behnel wrote:
 Roland Plüss, 17.05.2014 15:49:
> On 05/17/2014 03:26 PM, Stefan Behnel wrote:
>> Roland Plüss, 17.05.2014 15:00:
>>> On 05/17/2014 01:58 PM, Stefan Behnel wrote:
 Roland Plüss, 17.05.2014 02:27:
> I'm using Python in an embedded situation. In particular I have to 
> load
> python scripts through a memory interface so regular python module
> loading can not be used. I got working so far a module loader object
> I've added using C++ to sys.meta_path . Now I'm totally stuck at the
> finally loading step.
>
> I've got this a C++ loader method "load_module(fullname)" which does
> load the requested module script files into a null-terminated string. 
> I
> know that "load_module" has to return the module PyObject*. But I 
> can't
> get the python source in the c-string into a module PyObject*.
> [...]
> Can anybody help how in gods name one is supposed to create a module
> from an in-memory c-string when called from within load_module (or
> anywhere)?
 Looks like you want to implement a SourceLoader:

 https://docs.python.org/3.4/library/importlib.html#importlib.abc.SourceLoader

 I recommend implementing this in Python code instead of C code, though.
 Much easier. Cython can help with the integration between both.
>>> That doesn't work in 2.x, doesn't it?
>> Is there a reason you have to use Py2?
>>
>> Anyway, PEP 302 predates Py3 by a couple of years:
>>
>> http://legacy.python.org/dev/peps/pep-0302/
> I'm willing to go to Py3 but only if the solution to the problem is
> simpler than getting it fixed in Py2. So some questions first:
>
> - does this importlib stuff you showed there apply to C++ land (I need
> to fully drive it from C++ not Python code)?
 As I said, implementing this in Python code is much simpler than doing it
 in C/C++ code. Basically, stop where you got the C string and do the rest
 in Python. All your C code has to do is to take a module lookup request
 from your custom Python module Finder and return a byte string with the
 code. Then let your Python code wrap that in a Loader and return it to the
 import machinery.
>>> I don't get how this is supposed to work. I'm running it as fully
>>> embedded Python. There is no main script. The builtin modules are added
>>> as C++ bound classes and a user made main script is loaded but not run
>>> directly (I'm hooking into a create object). For this purpose I load the
>>> script module using C++ code using PyImport_ImportModule(moduleName). At
>>> this time the module loading code has to kick in already (I've added
>>> this one by C++ too before). The problem is now that in this call I end
>>> up in my C++ loader version where there is no Python script involved. I
>>> came to the conclusion that I can solve this only by having the C++ end
>>> properly load the module. I could add Python code with
>>> PyRun_SimpleString but then I'm down to the same problem as before: how
>>> to evaluate code so it is attached to a module or type-class? As I
>>> understand it the problem is the same as before just pushed around a bit.
>> No, just run some Python code (using PyRun_SimpleString() if you have to)
>> and let it do whatever you like. Such as, defining a Finder class and
>> injecting it into the import hook. Just provide it with the entry point of
>> your C++ loader as a (CFunction) object when you execute it, and then let
>> it call that function at need whenever the Finder gets executed.
>>
>> Alternatively, compile your Python integration code with Cython and link it
>> into your main program as yet another binary extension module.
>
> I'm not using Cython so that's out of question. Concerning the injection
> how would this work? From the PEP I assume it would have to look like this:
> 
> # CODE #
> import sys
> class VFSModuleLoader:
>def find_module(fullname, path=None):
>   return self if VFS.exists( vfsPathFromFullname(fullname) ) else None
>def load_module(fullname):
>   sourceCode = VFS.read( vfsPathFromFullname(fullname))
>   ???
> # CODE #
> 
> How does ??? work? If I use "eval" I end up with the code inside
> VFSModuleLoader.load_modules as context but it should go into the global
> context as an own module.

Yeah, well, the import machinery is rather badly exposed in Py2. This got
much cleaner in Py3, especially 3.3/3.4.

Here's a hacky way to do it in Py2:

import imp
module = imp.new_module(module_name)
module.__importer__ = self
exec source_code in module.__dict__
return module

Found here:

http://hg.python.org/cpython/file/568041fd8090/Lib/imputil.py#l284

You may hav

Re: PEP 8 : Maximum line Length :

2014-05-17 Thread Rustom Mody
On Saturday, May 17, 2014 7:36:19 PM UTC+5:30, Roy Smith wrote:
> 
>  Mark Lawrence  wrote:
> > > Now translate E=mc^2 into Java.
> > >
> > 
> > I can't do that as I simply don't understand it.  What has the 
> > Marylebone Cricket Club got to do with E?
> 
> A wicket looks like an E on its side.  Does that help?

Heh! Imaginative!

Now spend your life meditating on all the glyphs that inhabit unicode.
And mon cher u-no-hoo will award you with an epiphany.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem building 3.5 on Windows

2014-05-17 Thread Mark Lawrence

On 17/05/2014 18:05, Chris Angelico wrote:

On Sun, May 18, 2014 at 2:59 AM, Mark Lawrence  wrote:

1>..\PC\make_versioninfo.c(1): fatal error C1083: Cannot open include file:
'stdio.h': No such file or directory

What stupid thing have I forgotten, apart from switching to *nix? :)


Well, apart from that... I'd guess you have a pathing problem. Since
stdio.h is a standard compiler-provided header, I'd advise locating it
on disk, then checking if that path is in the INCLUDE env var. Not
sure if the Python build process overrides that, though, but it's a
start.

ChrisA



Solved as you got me looking in a different direction.  It certainly 
helps if you have an up to date version of the SDK :)


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


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


Re: Problem building 3.5 on Windows

2014-05-17 Thread Chris Angelico
On Sun, May 18, 2014 at 5:06 AM, Mark Lawrence  wrote:
> Solved as you got me looking in a different direction.  It certainly helps
> if you have an up to date version of the SDK :)

Hah. I don't know which versions of Visual Studio Express go with
which versions of Python, but I know there is a strict correspondence
(in terms of official builds and support, at least).

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


Re: Problem building 3.5 on Windows

2014-05-17 Thread Mark Lawrence

On 17/05/2014 20:08, Chris Angelico wrote:

On Sun, May 18, 2014 at 5:06 AM, Mark Lawrence  wrote:

Solved as you got me looking in a different direction.  It certainly helps
if you have an up to date version of the SDK :)


Hah. I don't know which versions of Visual Studio Express go with
which versions of Python, but I know there is a strict correspondence
(in terms of official builds and support, at least).

ChrisA



I have Visual Studio Express 2010 but the SDK was 7.0 instead of 7.1. 
I'm now waiting for the Visual Studio Express 2010 SP1 which fixes the 
linker problem.  And I've just got "restart now to finsih installing" 
after maybe one hour:)


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


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


Re: Everything you did not want to know about Unicode in Python 3

2014-05-17 Thread Robert Kern

On 2014-05-17 15:15, Steven D'Aprano wrote:

On Sat, 17 May 2014 10:29:00 +0100, Robert Kern wrote:


One can state many things, but that doesn't mean they have legal effect.
The US Code has provisions for how works become copyrighted
automatically, how they leave copyright automatically at the end of
specific time periods, how some works automatically enter the public
domain on their creation (i.e. works of the US federal government), but
has nothing at all for how a private creator can voluntarily place their
work into the public domain when it would otherwise not be. It used to,
but does not any more.


The case for abandonment was stated as "well settled" in 1998 (Micro-Star
v. Formgen Inc). Unless there has been a major legal change in the years
since then, I don't think it is true that authors cannot abandon
copyright.


Good old Micro-Star v. Formgen Inc. A perennial favorite. No, that case did not 
settle this question. There is a statement in the opinion that would suggest 
this, but (and this seems to be a reoccurring theme) it's inclusion in the 
opinion did not create precedent to that effect. The statement that you refer to 
is, as far as my NAL eyes can tell, what the lawyers call "dictum": a statement 
made by a judicial opinion but is unnecessary to decide the case and therefore 
not precedential. FormGen explicitly registered the copyright to the works in 
question, and the case was decided on whether or not the 
Micro-Star-redistributed works counted as derivative works (yes). Now, if the 
case were about an author that affirmatively dedicated his work to the public 
domain and then sued someone who redistributed it, then such a statement would 
have a precedential effect (because then the judge would decide in favor of the 
defendant on the basis of that statement). The quote that you refer to 
references a previous case, which follows similar lines, and also predates the 
"automatic copyright" regime post-Berne Convention, so it's not even clear to me 
that it should have been precedential to Micro-Star.


Even if this case did so decide (which, I will grant it more or less did later 
by codifying such a rule in their jury instructions for such cases), it would 
only have effect in the 9th Circuit of the US and not even in the rest of the 
US, much less worldwide. Why bother when the CC0 gives you the desired effect 
with more assurance to your audience?



For a private individual to say about a work they just created that
"this work is in the Public Domain" is, under US law, merely an
erroneous statement of fact, not a speech act that effects a change in
the legal status of the work. For another example of this distinction,
saying "I am married" when I have not applied for, received, and
solemnified a valid marriage license is just an erroneous statement of
fact and does not make me legally married.


There may be something to what you say, although I think we're now
arguing fine semantic details.


Sure, it's the law. Fine semantic details are important. However, the difference 
between speech acts and statements of fact is a pretty gross semantic 
distinction and not just splitting semantic hairs. The act of making some 
statements (e.g. declaring that a work you own the copyright to is available 
under a given license) actually makes a change in the legal status of something. 
Most statements don't. Which ones do and don't are defined by statute and (in 
common law countries like the US) court decisions. Deciding which is which is 
often hairy, but that's an epistemological problem, not a semantic one. :-)



See:

https://en.wikipedia.org/wiki/Wikipedia:Granting_work_into_the_public_domain

To play Devil's Advocate in favour of your assertion, it may be that
abandoning copyright does not literally put the work in the public
domain, but merely makes it "quack like the public domain". That is to
say, the author still, in some abstract but legally meaningless sense,
has copyright in the work *but* has given unlimited usage rights. (I
don't actually think that is the case, at least not in the US.)

It's this tiny bit of residual uncertainty that leads some authorities to
say that it is "hard" to release a work into the public domain,
particularly in a world-wide context, and that merely stating "this is in
the public domain" is not sufficient to remove all legal doubt over the
status, and that a more overt and explicit release *may* be required.
Hence the CC0 licence which you refer to. The human readable summary says
in part:

  The person who associated a work with this deed has dedicated
  the work to the public domain by waiving all of his or her
  rights to the work worldwide under copyright law, including
  all related and neighboring rights, to the extent allowed by
  law.

  You can copy, modify, distribute and perform the work, even
  for commercial purposes, all without asking permission.

http://creativecommons.org/publicdomain/zero/1.0/

while 

Re: Everything you did not want to know about Unicode in Python 3

2014-05-17 Thread Robert Kern

On 2014-05-17 13:07, Steven D'Aprano wrote:

On Sat, 17 May 2014 09:57:06 +0100, Robert Kern wrote:


On 2014-05-17 02:07, Steven D'Aprano wrote:

On Fri, 16 May 2014 14:46:23 +, Grant Edwards wrote:


At least in the US, there doesn't seem to be such a thing as "placing
a work into the public domain".  The copyright holder can transfer
ownershipt to soembody else, but there is no "public domain" to which
ownership can be trasferred.


That's factually incorrect. In the US, sufficiently old works, or works
of a certain age that were not explicitly registered for copyright, are
in the public domain. Under a wide range of circumstances, works
created by the federal government go immediately into the public
domain.


There is such a thing as the public domain in the US, and there are
works in it, but there isn't really such a thing as "placing a work"
there voluntarily, as Grant says. A work either is or isn't in the
public domain. The author has no choice in the matter.


That's incorrect.

http://cr.yp.to/publicdomain.html


Thanks for the link. While it has not really changed my opinion (as discussed at 
length in my other reply), I did not know that the 9th Circuit had formalized 
the "overt act" test in their civil procedure rules, so there is at least one 
jurisdiction in the US that does currently work like this. None of the others 
do, to my knowledge, and this is the product of judicial common law, not 
statutory law, so it's still pretty shaky.


--
Robert Kern

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

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


using a new computer and bringing needed libraries to it

2014-05-17 Thread CM
If I want to switch my work from one computer to a new one, and I have lots of 
various libraries installed on the original computer, what's the best way to 
switch that all to the new computer?  I'm hoping there is some simple way like 
just copying the Python/Lib/site-packages folder, but I'm also guessing this 
isn't sufficient. I was hoping I wouldn't have to just one-by-one install all 
of those libraries again on the newer computer.

I probably want to develop on BOTH these computers for the time being, too.  
One is at home and one is at a "remote site"/secret lair.  And then I'll be 
doing it again when I buy a newer computer at some point.

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


Can't figure out 'instance has no attribute' error

2014-05-17 Thread varun7rs
Hello Friends,

I am working on this code but I kind of get the same error over and over again. 
Could any of you help me fix this part of the error?

File RW1:
class PHY_NETWORK:
def __init__(self, nodes, edges):
self.nodes = nodes
self.edges = edges  

def addNode(self, node):
self.nodes.append( node )

def addEdge(self, edge):
self.edges.append( edge )

File RW3:
def createnetwork(graph):


doc = parse( args.paramFile )
noderef = []
num = 0
nodelist = doc.getElementsByTagName("node")
for node in nodelist:
noderef.append(node.getAttribute("id"))
proc = random.randint(3500, 5000)
stor = random.randint(7200, 8200)
switch = random.randint(7000, 1)
num = num + 1
totaldemands = random.randint(1, 5)
graph.addNode(PHY_NODES( node.getAttribute("id"), int(num), 
float(xCoordinates.firstChild.data), float(yCoordinates.firstChild.data), 
float(proc), float(stor), float(switch), int(totaldemands)))


linkid = 0
linklist = doc.getElementsByTagName("link")
for link in linklist :
linkid = linkid + 1
Source = link.getElementsByTagName("source") [0]
Destination = link.getElementsByTagName("target") [0]
Capacity = link.getElementsByTagName("capacity") [0]
SourceID = noderef.index(Source.firstChild.data) + 1
DestinationID = noderef.index(Destination.firstChild.data) + 1
graph.addEdge( PHY_LINKS( linkid, Source.firstChild.data, 
Destination.firstChild.data, DestinationID, SourceID, 
float(Capacity.firstChild.data) ))


global args
args = parser.parse_args()

samplenetwork = PHY_NETWORK([], [])
for i in range(1, 100):
createnetwork(samplenetwork)
exportXmlFile(samplenetwork, args.output, 'a' ) 

   
if __name__ == "__main__":
  main(sys.argv[1:])


srva@hades:~$ python RW3.py --output topology.xml --xml germany50.xml
Traceback (most recent call last):
  File "RW3.py", line 157, in 
main(sys.argv[1:])
  File "RW3.py", line 152, in main
createnetwork(samplenetwork)
  File "RW3.py", line 31, in createnetwork
graph.addNode(PHY_NODES( node.getAttribute("id"), int(num), 
float(xCoordinates.firstChild.data), float(yCoordinates.firstChild.data), 
float(proc), float(stor), float(switch), int(totaldemands)))
AttributeError: PHY_NETWORK instance has no attribute 'addNode'


The error that it give back is as above. I have the classes defined in RW1 file 
and I am importing the classes onto RW3 file and yet, It doesn't seem to work. 
I really am in need of your valuable suggestions. Thank You
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can't figure out 'instance has no attribute' error

2014-05-17 Thread Ned Batchelder

On 5/17/14 7:56 PM, varun...@gmail.com wrote:

Hello Friends,

I am working on this code but I kind of get the same error over and over again. 
Could any of you help me fix this part of the error?

File RW1:
class PHY_NETWORK:
def __init__(self, nodes, edges):
self.nodes = nodes
self.edges = edges

def addNode(self, node):
self.nodes.append( node )

def addEdge(self, edge):
self.edges.append( edge )


...



srva@hades:~$ python RW3.py --output topology.xml --xml germany50.xml
Traceback (most recent call last):
   File "RW3.py", line 157, in 
 main(sys.argv[1:])
   File "RW3.py", line 152, in main
 createnetwork(samplenetwork)
   File "RW3.py", line 31, in createnetwork
 graph.addNode(PHY_NODES( node.getAttribute("id"), int(num), 
float(xCoordinates.firstChild.data), float(yCoordinates.firstChild.data), float(proc), 
float(stor), float(switch), int(totaldemands)))
AttributeError: PHY_NETWORK instance has no attribute 'addNode'


The error that it give back is as above. I have the classes defined in RW1 file 
and I am importing the classes onto RW3 file and yet, It doesn't seem to work. 
I really am in need of your valuable suggestions. Thank You



You've set your editor to display tabs as 4 spaces, but then you've 
sometimes used tabs in your file, and sometimes 4 spaces.  Look at how 
your code is indented in your post: the addNode and addEdge definitions 
are indented with tab characters instead of spaces, so Python thinks 
they are eight spaces in.  This makes them defined inside of __init__, 
rather than as part of your class.


Set your editor to insert spaces when you use the Tab key, and set it to 
use 4-space indents.  Then find all the tab characters in your file and 
replace them with the proper number of spaces.


--
Ned Batchelder, http://nedbatchelder.com

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


Re: using a new computer and bringing needed libraries to it

2014-05-17 Thread Ned Batchelder

On 5/17/14 7:53 PM, CM wrote:

If I want to switch my work from one computer to a new one, and I have lots of 
various libraries installed on the original computer, what's the best way to 
switch that all to the new computer?  I'm hoping there is some simple way like 
just copying the Python/Lib/site-packages folder, but I'm also guessing this 
isn't sufficient. I was hoping I wouldn't have to just one-by-one install all 
of those libraries again on the newer computer.

I probably want to develop on BOTH these computers for the time being, too.  One is at 
home and one is at a "remote site"/secret lair.  And then I'll be doing it 
again when I buy a newer computer at some point.

Thanks.



Make a list of the packages you need.  Put it in a file called 
requirements.txt.  Then install them with:


$ pip install -r requirements.txt

Keep that file up-to-date as you add new requirements.

--
Ned Batchelder, http://nedbatchelder.com

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


Re: Can't figure out 'instance has no attribute' error

2014-05-17 Thread Rhodri James

On Sun, 18 May 2014 00:56:42 +0100,  wrote:


Hello Friends,

I am working on this code but I kind of get the same error over and over  
again. Could any of you help me fix this part of the error?


Shuffling your post around to make an explanation easier, the traceback is:


srva@hades:~$ python RW3.py --output topology.xml --xml germany50.xml
Traceback (most recent call last):
  File "RW3.py", line 157, in 
main(sys.argv[1:])
  File "RW3.py", line 152, in main
createnetwork(samplenetwork)
  File "RW3.py", line 31, in createnetwork
graph.addNode(PHY_NODES( node.getAttribute("id"), int(num),  
float(xCoordinates.firstChild.data),  
float(yCoordinates.firstChild.data), float(proc), float(stor),  
float(switch), int(totaldemands)))

AttributeError: PHY_NETWORK instance has no attribute 'addNode'


So Python thinks that PHY_NETWORK has no "addNode", but you do.  Do you  
perchance have the tab width in your editor set to 4?  I ask, because I  
imagine that you see this:



File RW1:
class PHY_NETWORK:
def __init__(self, nodes, edges):
self.nodes = nodes
self.edges = edges
def addNode(self, node):
self.nodes.append( node )

[snippety snip]

I however saw your post like this:


File RW1:
class PHY_NETWORK:
def __init__(self, nodes, edges):
self.nodes = nodes
self.edges = edges
def addNode(self, node):
self.nodes.append( node )

[snippety snip]

I've replaced the tabs with spaces to make it clearer.  Basically, you've  
got a mix of tabs and spaces, which is always a bad idea, and as a result  
Python thinks that addNode is an attribute of PHY_NETWORK.__init__, not of  
PHY_NETWORK.  You need to go through and replace all your tab characters  
with four spaces, and stop using tabs.


--
Rhodri James *-* Wildebeest Herder to the Masses
--
https://mail.python.org/mailman/listinfo/python-list


Re: Can't figure out 'instance has no attribute' error

2014-05-17 Thread Gary Herron

On 05/17/2014 04:56 PM, varun...@gmail.com wrote:

Hello Friends,

I am working on this code but I kind of get the same error over and over again. 
Could any of you help me fix this part of the error?


It's an indentation error:  In the following the three function defs for 
__init__, addNode and addEdge should all be at the same indentation 
level.  Instead, you have the later two defined *inside* the __init__.


Gary Herron




File RW1:
class PHY_NETWORK:
 def __init__(self, nodes, edges):
 self.nodes = nodes
 self.edges = edges
 
	def addNode(self, node):

self.nodes.append( node )

def addEdge(self, edge):
self.edges.append( edge )

File RW3:
def createnetwork(graph):


doc = parse( args.paramFile )
noderef = []
num = 0
nodelist = doc.getElementsByTagName("node")
for node in nodelist:
noderef.append(node.getAttribute("id"))
proc = random.randint(3500, 5000)
stor = random.randint(7200, 8200)
switch = random.randint(7000, 1)
num = num + 1
totaldemands = random.randint(1, 5)
graph.addNode(PHY_NODES( node.getAttribute("id"), int(num), 
float(xCoordinates.firstChild.data), float(yCoordinates.firstChild.data), float(proc), 
float(stor), float(switch), int(totaldemands)))


linkid = 0
linklist = doc.getElementsByTagName("link")
for link in linklist :
linkid = linkid + 1
Source = link.getElementsByTagName("source") [0]
Destination = link.getElementsByTagName("target") [0]
Capacity = link.getElementsByTagName("capacity") [0]
SourceID = noderef.index(Source.firstChild.data) + 1
DestinationID = noderef.index(Destination.firstChild.data) + 1
graph.addEdge( PHY_LINKS( linkid, Source.firstChild.data, 
Destination.firstChild.data, DestinationID, SourceID, 
float(Capacity.firstChild.data) ))


global args
args = parser.parse_args()

samplenetwork = PHY_NETWORK([], [])
for i in range(1, 100):
createnetwork(samplenetwork)
exportXmlFile(samplenetwork, args.output, 'a' ) 


if __name__ == "__main__":

   main(sys.argv[1:])


srva@hades:~$ python RW3.py --output topology.xml --xml germany50.xml
Traceback (most recent call last):
   File "RW3.py", line 157, in 
 main(sys.argv[1:])
   File "RW3.py", line 152, in main
 createnetwork(samplenetwork)
   File "RW3.py", line 31, in createnetwork
 graph.addNode(PHY_NODES( node.getAttribute("id"), int(num), 
float(xCoordinates.firstChild.data), float(yCoordinates.firstChild.data), float(proc), 
float(stor), float(switch), int(totaldemands)))
AttributeError: PHY_NETWORK instance has no attribute 'addNode'


The error that it give back is as above. I have the classes defined in RW1 file 
and I am importing the classes onto RW3 file and yet, It doesn't seem to work. 
I really am in need of your valuable suggestions. Thank You


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


Re: using a new computer and bringing needed libraries to it

2014-05-17 Thread Terry Reedy

On 5/17/2014 7:53 PM, CM wrote:

If I want to switch my work from one computer to a new one, and I
have lots of various libraries installed on the original computer,
what's the best way to switch that all to the new computer?  I'm
hoping there is some simple way like just copying the
Python/Lib/site-packages folder, but I'm also guessing this isn't
sufficient.


Have your tried it? Since Python only cares about the contents of 
site-packages, copying should be fine, at least as far as python is 
concerned. I have copied pythonx.y/Lib/site-packages to 
pythonx.(y+1)/Lib/site-packages more than once.


In each site-packages, I also have python.pth containing, in my case, 
"F:/Python". packages and modules in F:/Python are imported the same as 
if they were in each site-packages. This avoids copying and lets me try 
the same file on multiple versions.


Copying does not copy registry entries or anything outside of 
site-packages. I do not know whether pip, for instance, does either.


--
Terry Jan Reedy

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


Re: using a new computer and bringing needed libraries to it

2014-05-17 Thread Chris Angelico
On Sun, May 18, 2014 at 10:17 AM, Ned Batchelder  wrote:
> Make a list of the packages you need.  Put it in a file called
> requirements.txt.  Then install them with:
>
> $ pip install -r requirements.txt
>
> Keep that file up-to-date as you add new requirements.

+1. And the "keep up-to-date" bit can be done very well with source
control; that way, you don't need to wonder whether you added one over
here or deleted one over there - the commit history will tell you.

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


Pip requirements: Machine-readable configuration versus human-audience documentation (was: using a new computer and bringing needed libraries to it)

2014-05-17 Thread Ben Finney
Ned Batchelder  writes:

> Make a list of the packages you need.  Put it in a file called
> requirements.txt.  Then install them with:
>
> $ pip install -r requirements.txt
>
> Keep that file up-to-date as you add new requirements.

Since these requirements are specifically for Python, more specifically
for Pip, and even more specifically are supposed to be in a
machine-readable foramt and not just an arbitrary free-form text
document, can we recommend instead some more specific filename?

‘requirements.txt’ is already used in many projects to document *for a
human reader* the project-wide requirements, not jsut for Python, and we
should not arrogate a general name like that to a specific tool like
Pip.

I'd recommend (and have already begun to use) the name
‘pip_requirements’ or the like. I know that there is heaps of
Pip-specific documentation out there already recommending the more
general name, but I'd like that to change.

-- 
 \ “I believe our future depends powerfully on how well we |
  `\ understand this cosmos, in which we float like a mote of dust |
_o__) in the morning sky.” —Carl Sagan, _Cosmos_, 1980 |
Ben Finney

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


Python and Math

2014-05-17 Thread Bill Cunningham
Does Python have good mathematical capabilities? I am interested in 
learning a second language for mathematical purposes. I am considering 
looking at python, perl, fortran, Adas out. It looked too complicated to 
learn. Perl looked easy and I haven't really looked into python.

Bill


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


Re: Python and Math

2014-05-17 Thread Rustom Mody
On Sunday, May 18, 2014 8:43:11 AM UTC+5:30, Bill Cunningham wrote:
> Does Python have good mathematical capabilities? I am interested in 
> 
> learning a second language for mathematical purposes. I am considering 
> 
> looking at python, perl, fortran, Adas out. It looked too complicated to 
> 
> learn. Perl looked easy and I haven't really looked into python.
> 

What does the word 'mathematical' connote for you?
On the whole the term is so wide that its hard to answer without some
more context.

For example there's numpy,scipy for numerical and scientific* computing, 
there's sage, ipython etc.


Today many people who want a general purpose programming language with
a mathematical flair, choose Haskell

For statistics R is quite unbeatable (I am told), which is not python
or any of the others you mention.

Then there are specialized theorem proving systems.

Another question you should answer is "Whats the first programming
language you know?"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: using a new computer and bringing needed libraries to it

2014-05-17 Thread Rustom Mody
On Sunday, May 18, 2014 5:47:05 AM UTC+5:30, Ned Batchelder wrote:
> On 5/17/14 7:53 PM, CM wrote:
> 

> > If I want to switch my work from one computer to a new one, and I
> > have lots of various libraries installed on the original computer,
> > what's the best way to switch that all to the new computer?  I'm
> > hoping there is some simple way like just copying the
> > Python/Lib/site-packages folder, but I'm also guessing this isn't
> > sufficient. I was hoping I wouldn't have to just one-by-one
> > install all of those libraries again on the newer computer.

> > I probably want to develop on BOTH these computers for the time
> > being, too.  One is at home and one is at a "remote site"/secret
> > lair.  And then I'll be doing it again when I buy a newer computer
> > at some point.

> 
> Make a list of the packages you need.  Put it in a file called 
> requirements.txt.  Then install them with:
> 
> 
>  $ pip install -r requirements.txt
> 
> 
> Keep that file up-to-date as you add new requirements.


What about things installed at a lower level than pip, eg apt-get?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and Math

2014-05-17 Thread Chris Angelico
On Sun, May 18, 2014 at 1:13 PM, Bill Cunningham  wrote:
> Does Python have good mathematical capabilities? I am interested in
> learning a second language for mathematical purposes. I am considering
> looking at python, perl, fortran, Adas out. It looked too complicated to
> learn. Perl looked easy and I haven't really looked into python.

Absolutely it does! In the built-in types, your integer has arbitrary
precision, and there is an arbitrary-precision Decimal type in the
standard library. There is also, naturally, a standard set of trig
functions and so on. With additional libraries, you can get numeric
and scientific functionality (lots of which is written in Fortran, as
I understand it), giving incredibly high performance for a high level
language; look into SciPy and NumPy. Strongly recommend Python for
numeric work.

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


Re: Problem building 3.5 on Windows

2014-05-17 Thread Joseph L. Casale
Mark,
Excuse the format of this post, stuck on the road only with an iPhone but in 
the event it helps, 
http://blog.vrplumber.com/b/2014/02/12/step-2-get-amd64-compatible-vs-2010/ may 
be useful.

Jlc
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and Math

2014-05-17 Thread Gary Herron

On 05/17/2014 08:13 PM, Bill Cunningham wrote:

 Does Python have good mathematical capabilities? I am interested in
learning a second language for mathematical purposes. I am considering
looking at python, perl, fortran, Adas out. It looked too complicated to
learn. Perl looked easy and I haven't really looked into python.

Bill


Depends on what you mean by mathematics.  The language itself has a 
reasonable set of numeric types and operations on those types, but what 
really makes Python shine is the libraries built on Python and their 
capabilities.Beside the several already mentioned, I'll add

Sage: www.sagemath.org/index.html
which presents a consistent Python interface to nearly 100 OpenSource 
mathematical packages containing symbolic manipulation of all sorts of 
algebra, calculus, linear algebra, plotting, rings and groups, and much 
*much* more.


Gary Herron
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python and Math

2014-05-17 Thread Steven D'Aprano
On Sat, 17 May 2014 23:13:11 -0400, Bill Cunningham wrote:

> Does Python have good mathematical capabilities? I am interested in
> learning a second language for mathematical purposes. I am considering
> looking at python, perl, fortran, Adas out. It looked too complicated to
> learn. Perl looked easy and I haven't really looked into python.

Yes, Python is excellent for mathematics. Python is rapidly taking over 
as the language of choice for scientific computing:

http://www.talyarkoni.org/blog/2013/11/18/the-homogenization-of-scientific-computing-or-why-python-is-steadily-eating-other-languages-lunch/


You say you want to learn a *second* language, but you don't say what 
your first language is. Nor do you say what sort of mathematics you wish 
to do, or at what level. Depending on what you want to do, you might be 
best off with Mathematica, if you can afford it. Otherwise, there's an 
Open Source and free alternative, Sage, which uses Python.

You may find that the IPython interactive interface to Python is useful. 
It presents an interface which should be familiar to anyone with 
experience with Mathematica. 

For symbolic maths, I like Sympy, where you can do things like this:


py> from sympy import *
py> x, y = symbols('x y')
py> diff(cos(3*x+1), x)
-3*sin(3*x + 1)
py> integrate(-3*sin(3*x+1), x)
cos(3*x + 1)


There is also Numpy and Scipy, for heavy-duty numerical mathematics.

I recommend that you start with Python 3.4, as it is the latest version 
of Python, and also because I'm the author of the statistics standard 
library. It's not a full-blown professional statistics language like R, 
Matlab or SAS, but if you need basic scientific calculator level 
statistics it is useful. Feedback on the library is always welcome.

As far as other languages go, I think that Fortran is still an excellent
language if you need to write high-powered, low-level numeric functions,
but if you just want to *use* pre-existing libraries, you are better off
with a high-level language like Python which offers interfaces to Fortran
libraries. Numpy and Scipy are very good for that.

As far as Perl goes, I find that it suffers from the same weakness as R:

http://www.talyarkoni.org/blog/2012/06/08/r-the-master-troll-of-statistical-languages/

that is, the learning curve is far to steep for my liking. I find Perl
too inconsistent, with far too many special cases and tricks, and not
enough of a consistent design. It's not as bad as PHP, but it gives me
the impression of a language where the only design principle is "Oh, 
that looks cool. Hand me the welding iron, and I'll weld it on 
somewhere. Anywhere will do."


-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and Math

2014-05-17 Thread Bill Cunningham

"Rustom Mody"  wrote in message 
news:09bbda59-9c37-44b0-acfc-0571d4fe8...@googlegroups.com...

> What does the word 'mathematical' connote for you?
> On the whole the term is so wide that its hard to answer without some
> more context.
>
> For example there's numpy,scipy for numerical and scientific* computing, 
> there's sage, ipython etc.
>
>
> Today many people who want a general purpose programming language with
> a mathematical flair, choose Haskell
>
> For statistics R is quite unbeatable (I am told), which is not python
> or any of the others you mention.
>
> Then there are specialized theorem proving systems.
>
> Another question you should answer is "Whats the first programming
> language you know?"

Well linear algebra and gaussian elemination. Expanding and factoring 
equations of all degrees and identities. Not so much statistics. Some 
geometry. Euclidean and spatial.

Bill


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


Re: Python and Math

2014-05-17 Thread Bill Cunningham

"Steven D'Aprano"  wrote in message 
news:53783c5f$0$29977$c3e8da3

> You say you want to learn a *second* language, but you don't say what
> your first language is. Nor do you say what sort of mathematics you wish
> to do, or at what level. Depending on what you want to do, you might be
> best off with Mathematica, if you can afford it. Otherwise, there's an
> Open Source and free alternative, Sage, which uses Python.

I have spent a lot of time with C. But it's hard for me to learn and 
there are various factors there. That sage looked good. But as a language 
for *nixs and their respective APIs sockets, sys calls and such there's C. 
Fortran might still be a choice. Perl looks really easy. But I haven't 
gotten into any of these because I'm still halding out for one that appeals 
to me.

Bill


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


Why should __prepare__ be explicitly decorated as a @classmethod?

2014-05-17 Thread Shriramana Sharma
Hello. I did search for this but couldn't find the info anywhere else, so I'm 
asking here. Please point out if I've missed some other source of the same info:

https://docs.python.org/3/reference/datamodel.html#basic-customization 
documents that __new__ is special-cased so that while it is actually a static 
method, it need not be decorated as such. I have a similar question. IIUC 
__prepare__ is always a class method to be used in metaclasses, so why isn't it 
also special-cased so that it need not be decorated as a such?

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