Re: Python-list Digest, Vol 163, Issue 14

2017-04-13 Thread Colin J. Williams

Thanks Eryk,

I have today successfully installed python 3.6.1.  Next I have to tackle 
installing the whl versions of Numpy and Matplotlib.


Colin W.


On 2017-04-11 11:25 AM, python-list-requ...@python.org wrote:

Send Python-list mailing list submissions to
python-list@python.org

To subscribe or unsubscribe via the World Wide Web, visit
https://mail.python.org/mailman/listinfo/python-list
or, via email, send a message with subject or body 'help' to
python-list-requ...@python.org

You can reach the person managing the list at
python-list-ow...@python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Python-list digest..."


Today's Topics:

1. Re: using HTTPHandler cause Django server side shows http 400
   and Invalid HTTP_HOST header message (iMath)
2. Re: using HTTPHandler cause Django server side shows http 400
   and Invalid HTTP_HOST header message (iMath)
3. Re: using HTTPHandler cause Django server side shows http 400
   and Invalid HTTP_HOST header message (iMath)
4. Re: Need help with getting Key, Value out of dicts in lists
   (John Ralph)
5. Re: Installing Python 3.6.1 on a Windows 10 (eryk sun)
6. [ANN] txkube 0.1.0 (Jean-Paul Calderone)
7. Re: Swiss Ephemeris (Peter Henry)
8. how to convert this container back to format build result?
   (Ho Yeung Lee)
9. RE: Swiss Ephemeris (Deborah Swanson)
   10. Fwd: Swiss Ephemeris (Peter Henry)
   11. RE: Swiss Ephemeris (Deborah Swanson)
   12. Re: read in a list in a file to list (Erik)
   13. Re: Python and the need for speed (Erik)
   14. Re: Python and the need for speed (Chris Angelico)
   15. Re: Pound sign problem (Steve D'Aprano)
   16. Re: Python and the need for speed (Christian Gollwitzer)
   17. Re: Swiss Ephemeris (Rustom Mody)
   18. Re: Python and the need for speed (Steven D'Aprano)
   19. Re: Python and the need for speed (Tim Golden)
   20. Re: Python and the need for speed (Chris Angelico)
   21. Re: Python and the need for speed (breamore...@gmail.com)
   22. Re: Python and the need for speed (Chris Angelico)
   23. Re: Python and the need for speed (Brecht Machiels)
   24. Re: Python and the need for speed (bartc)
   25. Re: strange behaviour when writing a large amount of data on
   stdout (tlnaray...@gmail.com)
   26. IOError: [Errno 12] Not enough space (LnT)
   27. Re: Python and the need for speed (Steve D'Aprano)
   28. Re: Temporary variables in list comprehensions (Piet van Oostrum)
   29. Re: Python and the need for speed (Steve D'Aprano)
   30. django user images (Xristos Xristoou)
   31. Need webFOCUS Business Intelligence Developer
   (j...@nichesoftsolutions.com)
   32. Need webFOCUS Business Intelligence Developer
   (j...@nichesoftsolutions.com)
   33. Re: Python and the need for speed (Steve D'Aprano)
   34. Re: Python and the need for speed (breamore...@gmail.com)
   35. ldap search and Tuple (Alejandro Decchi)
   36. Mcidas format (jorge.conr...@cptec.inpe.br)
   37. Re: Pound sign problem (Lew Pitcher)




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


Installing Python 3.6.1 on a Windows 10

2017-04-10 Thread Colin J. Williams
   Below is the tail of my Install Log.

   Is this a problem that I should be able to resolve?

   Advice sought.

   C

   Property(S): RedirectedDllSupport = 2
   Property(S): MsiRunningElevated = 1
   Property(S): Privileged = 1
   Property(S): USERNAME = AdminOnly
   Property(S): Installed = 00:00:00
   Property(S): DATABASE = C:\WINDOWS\Installer\3cb4905.msi
   Property(S): OriginalDatabase = C:\WINDOWS\Installer\3cb4905.msi
   Property(S): UILevel = 2
   Property(S): MsiUISourceResOnly = 1
   Property(S): Preselected = 1
   Property(S): ACTION = INSTALL
   Property(S): ROOTDRIVE = E:\
   Property(S): CostingComplete = 1
   Property(S): OutOfDiskSpace = 0
   Property(S): OutOfNoRbDiskSpace = 0
   Property(S): PrimaryVolumeSpaceAvailable = 0
   Property(S): PrimaryVolumeSpaceRequired = 0
   Property(S): PrimaryVolumeSpaceRemaining = 0
   Property(S): INSTALLLEVEL = 1
   MSI (s) (2C:60) [09:00:59:536]: Note: 1: 1724
   MSI (s) (2C:60) [09:00:59:536]: Note: 1: 2205 2:  3: Error
   MSI (s) (2C:60) [09:00:59:536]: Note: 1: 2228 2:  3: Error 4: SELECT
   `Message` FROM `Error` WHERE `Error` = 1724
   MSI (s) (2C:60) [09:00:59:536]: Note: 1: 2205 2:  3: Error
   MSI (s) (2C:60) [09:00:59:536]: Note: 1: 2228 2:  3: Error 4: SELECT
   `Message` FROM `Error` WHERE `Error` = 1709
   MSI (s) (2C:60) [09:00:59:536]: Product: Python 3.6.1 Core Interpreter
   (64-bit symbols) -- Removal completed successfully.

   MSI (s) (2C:60) [09:00:59:536]: Windows Installer removed the product.
   Product Name: Python 3.6.1 Core Interpreter (64-bit symbols). Product
   Version: 3.6.1150.0. Product Language: 1033. Manufacturer: Python Software
   Foundation. Removal success or error status: 0.

   MSI (s) (2C:60) [09:00:59:536]: Deferring clean up of packages/files, if
   any exist
   MSI (s) (2C:60) [09:00:59:536]: MainEngineThread is returning 0
   MSI (s) (2C:DC) [09:00:59:536]: RESTART MANAGER: Session closed.
   MSI (s) (2C:DC) [09:00:59:536]: No System Restore sequence number for this
   installation.
   === Logging stopped: 2017-04-10  9:00:59 ===
   MSI (s) (2C:DC) [09:00:59:551]: User policy value 'DisableRollback' is 0
   MSI (s) (2C:DC) [09:00:59:551]: Machine policy value 'DisableRollback' is
   0
   MSI (s) (2C:DC) [09:00:59:551]: Incrementing counter to disable shutdown.
   Counter after increment: 0
   MSI (s) (2C:DC) [09:00:59:551]: Note: 1: 1402 2:
   
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts
   3: 2
   MSI (s) (2C:DC) [09:00:59:551]: Note: 1: 2265 2:  3: -2147287035
   MSI (s) (2C:DC) [09:00:59:551]: Note: 1: 1402 2:
   
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts
   3: 2
   MSI (s) (2C:DC) [09:00:59:551]: Decrementing counter to disable shutdown.
   If counter >= 0, shutdown will be denied.  Counter after decrement: -1
   MSI (s) (2C:DC) [09:00:59:551]: Post-install cleanup: removing installer
   file 'C:\WINDOWS\Installer\3cb4905.msi'
   MSI (c) (C8:98) [09:00:59:551]: Decrementing counter to disable shutdown.
   If counter >= 0, shutdown will be denied.  Counter after decrement: -1
   MSI (c) (C8:98) [09:00:59:551]: MainEngineThread is returning 0
   === Verbose logging stopped: 2017-04-10  9:00:59 ===
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem installing 3.6.1 AMD64

2017-04-06 Thread Colin J. Williams
   Eryk,

   Many thanks.  I wasn't aware of the Path Editor,

   Colin W.

   On 2017-04-05 7:55 PM, eryk sun wrote:

 On Wed, Apr 5, 2017 at 6:46 PM, Colin J. Williams [1]<c...@ncf.ca> wrote:

Successful install reported, but:

  Microsoft Windows [Version 10.0.14393]
  (c) 2016 Microsoft Corporation. All rights reserved.

 You're using Windows 10.


  C:\Users\CJW>cd\python
  The system cannot find the path specified.

  C:\Users\CJW>cd\

 What is this supposed to be doing?


  C:\>path
  PATH=C:\Program Files\Python35\Scripts\;C:\Program
  Files\Python35\;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system
  
32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
  Files (x86)\ATI Technologi
  es\ATI.ACE\Core-Static;C:\Program Files
  
(x86)\AMD\ATI.ACE\Core-Static;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;
  C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL
  Server\130\Tools\Binn\;C:\Program Files\TortoiseHg\;
  C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files
  (x86)\Skype\Phone\;C:\Users\CJW\AppData\Local\Progra
  
ms\Python\Python35\Scripts\;C:\Users\CJW\AppData\Local\Programs\Python\Python35\;C:\Python35\Lib\site-packages\PyQt5;C:\
  
Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
  Files (x86)\
  ATI Technologies\ATI.ACE\Core-Static;C:\Program Files
  (x86)\Skype\Phone\;C:\Users\CJW\AppData\Local\Programs\Git\cmd;C:\
  Users\CJW\AppData\Local\Microsoft\WindowsApps;

  C:\>

Python35 has been deleted, but it remains in the PATH.

I would welcome advice.

 The environment variable editor in Windows 10 has made editing PATH
 about as easy as possible. Just manually remove (select and click on
 "Delete") whichever paths are no longer valid. Apparently one is
 per-machine in "C:\Program Files\Python35", which will likely be in
 the system PATH, and the other is per-user in
 "C:\Users\CJW\AppData\Local\Programs\Python\Python35", which will
 likely be in the user PATH.

References

   Visible links
   1. mailto:c...@ncf.ca
-- 
https://mail.python.org/mailman/listinfo/python-list


Problem installing 3.6.1 AMD64

2017-04-05 Thread Colin J. Williams
   Successful install reported, but:

 Microsoft Windows [Version 10.0.14393]
 (c) 2016 Microsoft Corporation. All rights reserved.

 C:\Users\CJW>cd\python
 The system cannot find the path specified.

 C:\Users\CJW>cd\

 C:\>path
 PATH=C:\Program Files\Python35\Scripts\;C:\Program
 Files\Python35\;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system
 
32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
 Files (x86)\ATI Technologi
 es\ATI.ACE\Core-Static;C:\Program Files
 
(x86)\AMD\ATI.ACE\Core-Static;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;
 C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL
 Server\130\Tools\Binn\;C:\Program Files\TortoiseHg\;
 C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files
 (x86)\Skype\Phone\;C:\Users\CJW\AppData\Local\Progra
 
ms\Python\Python35\Scripts\;C:\Users\CJW\AppData\Local\Programs\Python\Python35\;C:\Python35\Lib\site-packages\PyQt5;C:\
 
Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
 Files (x86)\
 ATI Technologies\ATI.ACE\Core-Static;C:\Program Files
 (x86)\Skype\Phone\;C:\Users\CJW\AppData\Local\Programs\Git\cmd;C:\
 Users\CJW\AppData\Local\Microsoft\WindowsApps;

 C:\>

   Python35 has been deleted, but it remains in the PATH.

   I would welcome advice.

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


Python 3.4.4 Install

2016-01-09 Thread Colin J. Williams
The reponse is not understood.

*** Python 3.4.4rc1 (v3.4.4rc1:04f3f725896c, Dec  6 2015, 17:06:10) [MSC v.1600 
64 bit (AMD64)] on win32. ***
>>>   File "C:\Users\Adm\AppData\Roaming\PyScripter\python_init.py", line 1
Öü:Vt‡Ö{ZðN)’ƒ2%hóýL"®ÁwÇ,”¿ƾJ
 ^
SyntaxError: invalid syntax
  File "C:\Users\Adm\AppData\Roaming\PyScripter\pyscripter_init.py", line 1
Öü:Vt‡Ö{ZðN)’t—œ2¢í.Tûôø«ÄØ´Õ7l‰ˆ(°¢äßÅ
 ^
SyntaxError: invalid syntax

Help!

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


Re: Windows Studio 2008 Download

2014-07-29 Thread Colin J. Williams
i.  I've seen notes, in various places to say that the Express version is
not acceptable for compiling Python packages.  Is it, in fact usable for
this purpose?

ii. The Service Pack 1 has the original studio as a prerequisite.  That is
no longer available from Microsoft.

Any advice would be welcomed.

Colin W.


On 28 July 2014 16:04, TP wing...@gmail.com wrote:

 Hmmm. Now that I think about it the full Microsoft Visual Studio 2008
 Service Pack 1 download I mentioned in my last email probably needs to have
 Visual Studio 2008 already installed (it's been a number of years since I
 had to install VS2008)? You could try it and see if it works.

 If not download the free Express version I mentioned instead. Trying to
 find the download link for the free VS2008 Express version is much harder
 so I guess that's why people keep asking for it :)

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


Windows Studio 2008 Download

2014-07-28 Thread Colin J. Williams
I gather that Python is compiled with Windows Studio 2008.

Unfortunately, the MS Download link points to a Studio 2010 advertising .ppx

Could someone point to an alternative please?

Colin W.

PS  I need it for Numpy-1.8.1, which does not seem to be available with a
binary version.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.4.1 64 bit Version

2014-07-18 Thread Colin J. Williams
Thanks to Chris and Zachary,

I shall retreat to Python 3.3

*pro tem*

*Colin W.*


On 18 July 2014 09:53, Zachary Ware zachary.ware+pyl...@gmail.com wrote:

 On Fri, Jul 18, 2014 at 8:29 AM,  cjwilliam...@gmail.com wrote:
  The version given on Python.org is Python 3.4.1 (v3.4.1:c0e311e010fc,
 May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32.
 
  This question is prompted by difficulties installing PyScripter.  What
 does on win32 mean in the above.  I was using PyScripter on an AMD64
 processor with Python 2.7.  Now, with an attempt to move to Python 3, I
 have grief.
 
  How does one install python-3.4.1.amd64-pdb?
 
  I would welcome any advice.

 The problem there isn't on win32, it's .4 :).  Unless I've just
 missed the announcement PyScripter has not been updated to support
 Python 3.4, and I haven't figured out a way to trick it into working.
 However, PyScripter works fine with Python 3.3, and there were no
 syntax changes between 3.3 and 3.4.  What I have found to work fairly
 well is to use PyScripter with 3.3, then test your program from a
 command prompt with 3.4.

 For the record, all versions of CPython on Windows (not counting
 anything relating to cygwin) are on win32 regardless of the
 bittedness of the processor or the interpreter.

 Hope this helps,
 --
 Zach

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


Re: Python for microcontrollers

2013-12-03 Thread Colin J. Williams

On 03/12/2013 7:58 AM, Mark Lawrence wrote:

I thought this might be of interest
Http://www.kickstarter.com/projects/214379695/micro-python-python-for-microcontrollers


Is this intended to be better than the Raspberry PI?  RPi handles Python 
2 or 3.


How would it differ?

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


Re: UnicodeDecodeError: 'ascii' codec can't decodee byte 0xff in position 0: ordinal not in range(128)

2013-11-18 Thread Colin J. Williams

On 17/11/2013 11:55 PM, Hoàng Tuấn Việt wrote:

Hi all,

I use Python telnetlib on Windows 7 32 bit. Here is my code:

def*telnet*(/self/, host, os, username, password):

 connection = telnetlib.Telnet(host)

 connection.read_until(/'login: '/)

connection.write(username + /'\r'/)

 connection.read_until(/'assword: '/)

 connection.write(password + /'\r'/)

 connection.read_until(/''/, timeout = TIMEOUT)

returnconnection

I can run the program in Eclipse and telnet successfully to a Windows host.

But when I export to .exe file:

fromdistutils.core importsetup

importpy2exe

setup(

 options = {

/py2exe/:{

/packages/: [/'wx.lib.pubsub'/],

/dll_excludes/: [/MSVCP90._dll_/, /HID.DLL/, /w9xpopen.exe/],

 }

 },

 console = [{/'script'/: /‘my_program.py'/}]

)

and run the programe, I encounter this error:

UnicodeDecodeError: 'ascii' codec can't decodee byte 0xff in position 0:
ordinal not in range(128)

at line:

connection.write(username + '\r')

I have debugged and searched the Internet hard but found no solution yet.

I think it is because of ‘\r’.

Do you have any idea?

Viet


What about:
   connection.write(username, ' r') ?

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


Re: Running Python programmes

2013-10-27 Thread Colin J. Williams

On 27/10/2013 10:32 AM, David wrote:

I am an absolute beginner and am working through the book Python Programming for the 
Absolute Beginner by Michael Dawson.  Everything is fine except if I run a scripted 
programme, or one I have downloaded, and then run another one, the second one will not 
run, I just get the  in the interactive window.  I have to exit Python and 
start again, when the second programme then runs fine.

Any suggestions much appreciated.

David



David,

Perhaps you could show a very small program, maybe 3 or 4 lines, that 
illustrates the problem.


Python 3?  Windows? Using Idle?

Colin W.


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


Re: indentation blocking in Python

2013-10-27 Thread Colin J. Williams

On 27/10/2013 11:31 AM, ajetrum...@gmail.com wrote:

a=1;
if a==1: print(1)
else: print(0)
wait = input(press key)

You indent only subordinate statements.

You don't need a semi-colon unless it separates two statements on the 
same line.


Your code:

a=1
if a==1:
print(1)
else:
print(0)
wait = input(press key)

I hope that this helps.

Colin W.

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


Re: Will Python 3.x ever become the actual standard?

2013-10-24 Thread Colin J. Williams

On 23/10/2013 9:13 AM, Tim Golden wrote:

On 23/10/2013 14:05, Colin J. Williams wrote:

On 23/10/2013 8:35 AM, Mark Lawrence wrote:

On 23/10/2013 12:57, duf...@gmail.com wrote:

Years have passed, and a LARGE number of Python programmers has not
even bothered learning version 3.x.


The changes aren't large enough to worry a Python programmer so
effectively there's nothing to learn, other than how to run 2to3.


...there is no sign of their being updated for v3.x.


Could have fooled me.  The number is growing all the time.  The biggest
problem is likely (IMHO) to be the sheer size of the code base and
limitations on manpower.


I get the impression as if 3.x, despite being better and more advanced
than 2.x from the technical point of view, is a bit of a letdown in
terms of adoption.


I agree with this technical aspect, other than the disastrous flexible
string representation, which has been repeatedly shot to pieces by, er,
one idiot :)  As for adaption we'll get there so please don't do a
Captain Mainwearing[1] and panic.  People should also be pursuaded by
watching this from Brett Cannon
http://www.youtube.com/watch?v=Ebyz66jPyJg

Just my 2 pence worth.

[1] From the extremely popular BBC TV series Dad's Army of the late
60s and 70s.


It would be good if more of the packages were available, for Python 3.3,
in binary for the Windows user.

I am currently wrestling with Pandas, lxml etc.


Can I assume you're aware of the industrious Christopher Gohlke?

http://www.lfd.uci.edu/~gohlke/pythonlibs/

TJG


Tim,

Many thanks.  I have installed lxml.  help(lxml) looks good.

I'll keep this link for future use.

It would be good if, after some verification process for each package, 
it could be included in  PyPi.


Colin W.

PS  A problem in building lxml from source is that the build expects 
?Cygwin? and I have Mingw32 installed.



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


Re: Will Python 3.x ever become the actual standard?

2013-10-23 Thread Colin J. Williams

On 23/10/2013 8:35 AM, Mark Lawrence wrote:

On 23/10/2013 12:57, duf...@gmail.com wrote:

Years have passed, and a LARGE number of Python programmers has not
even bothered learning version 3.x.


The changes aren't large enough to worry a Python programmer so
effectively there's nothing to learn, other than how to run 2to3.


...there is no sign of their being updated for v3.x.


Could have fooled me.  The number is growing all the time.  The biggest
problem is likely (IMHO) to be the sheer size of the code base and
limitations on manpower.


I get the impression as if 3.x, despite being better and more advanced
than 2.x from the technical point of view, is a bit of a letdown in
terms of adoption.


I agree with this technical aspect, other than the disastrous flexible
string representation, which has been repeatedly shot to pieces by, er,
one idiot :)  As for adaption we'll get there so please don't do a
Captain Mainwearing[1] and panic.  People should also be pursuaded by
watching this from Brett Cannon http://www.youtube.com/watch?v=Ebyz66jPyJg

Just my 2 pence worth.

[1] From the extremely popular BBC TV series Dad's Army of the late
60s and 70s.

It would be good if more of the packages were available, for Python 3.3, 
in binary for the Windows user.


I am currently wrestling with Pandas, lxml etc.

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


Re: Determine actually given command line arguments

2013-05-15 Thread Colin J. Williams

On 15/05/2013 2:34 AM, Henry Leyh wrote:

Hello,
I am writing a program that gets its parameters from a combination of
config file (using configparser) and command line arguments (using
argparse).  Now I would also like the program to be able to _write_ a
configparser config file that contains only the parameters actually
given on the commandline.  Is there a simple way to determine which
command line arguments were actually given on the commandline, i.e. does
argparse.ArgumentParser() know which of its namespace members were
actually hit during parse_args().

I have tried giving the arguments default values and then looking for
those having a non-default value but this is really awkward, especially
if it comes to non-string arguments.  Also, parsing sys.argv looks
clumsy because you have to keep track of short and long options with and
without argument etc. i.e. all things that I got argparse for in the
first place.

Thanks  Greetings,
Henry

Try sys.argv

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


Re: Fractal

2013-05-15 Thread Colin J. Williams

On 13/05/2013 11:41 AM, Sharon COUKA wrote:

Hello, I'm new to python and i have to make a Mandelbrot fractal image for 
school but I don't know how to zoom in my image.
Thank you for helping me.

Envoyé de mon iPad



Google is your friend.  Try Mandelbrot Python

Colin W.




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


Re: Unicode humor

2013-05-15 Thread Colin J. Williams

On 15/05/2013 1:21 PM, MRAB wrote:

On 15/05/2013 18:04, Jean-Michel Pichavant wrote:

- Original Message -

On 15/05/2013 14:19, Jean-Michel Pichavant wrote:

This reflects a lack of understanding of Unicode.



jmf



And this reflects a lack of a sense of humor.  :)


Isn't that a crime in the UK?

ChrisA


The problem with English humour (as against standard humor)
is that its not unicode compliant


British humour includes double entendre, which is not
French-compliant.


I didn't get that one. Which possibly confirm MRAB's statement.


It's called double entendre in English (using French words, from
à double entente), but that isn't correct French (double
sens).


Thanks for clarifying, I didn't know double entendre had actually a
meaning in english, it's obviously 2 french words but this is the
first time I see them used together.


Occasionally speakers of one language will borrow a word or phrase from
another language and use it in a way a native speaker wouldn't (or even
understand).


double-entendre - Chambers Fails, but see Wiktionary: 
http://en.wiktionary.org/wiki/double_entendre


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


Re: Style question -- plural of class name?

2013-05-08 Thread Colin J. Williams

On 08/05/2013 4:20 PM, Roy Smith wrote:

FooEntry is a class.  How would you describe a list of these in a
docstring?

A list of FooEntries  0

A list of FooEntrys   -1

A list of FooEntry's  +1

A list of FooEntry instances  No FooEntry is specified as a class.

The first one certainly sounds the best, but it seems wierd to change
the spelling of the class name to make it plural.



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


Re: multiple versions of python

2013-05-07 Thread Colin J. Williams

On 07/05/2013 6:26 PM, sokovic.anamar...@gmail.com wrote:

Hi,

what is the generally recommended structure when we have into play this type of 
problem:
multiple versions of python (both in the sense of main versions and sub 
versions, e.g.,
2.7 :
2.7.1
2.7.3
3:
  3.3
3.3.1
Different versions of gcc
different compilation strategies (-vanilla and non-vanilla)
different modules (numpy,scipy) together with the different versions of all the 
rest.

any help is appreciated

Ana


Do you really need more than 2.7.3  and 3.3.1.

Typically, these go to C:\Python27 and C:\Python33 with windows.

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


Re: Help with loading file into an array

2013-05-05 Thread Colin J. Williams

On 05/05/2013 3:43 AM, Fábio Santos wrote:

Using a nested array should waste a lot of memory. I think you should
use PIL to load and read the image.

 
  I want to read the data from that gif file taking the red data
(excluding the green and blue data) and store that in an array called
Image[][] which is a nested array length 1024 with a list in each item
of 1024 length (ie 1024 x 1024)
 


Fabio,

Have you considered numpy?

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


Re: [ANNC] pynguin-0.14 python turtle graphics application

2013-05-03 Thread Colin J. Williams

On 13/04/2013 8:10 PM, Miki Tebeka wrote:

Pynguin is a python-based turtle graphics application.

I wonder why Pynguin does not get more traction in the teaching sector. Looks 
ideal for teaching kids.


Mili,

I suggest that it's because Pynguin is not yet fully operational.

I don't know where to report problems.

The problems I had were installing for Python 3.3 and 2.7, using win32

In the latter case, it seem as though the code is tied with 3.3.

On the face of it, the package appear to have potential.

Colin W.


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


Re: [Edu-sig] [ANNC] pynguin-0.14 python turtle graphics application

2013-05-03 Thread Colin J. Williams

On 03/05/2013 12:01 PM, Jurgis Pralgauskis wrote:

Hi,

do you plan to make step/debug functionality
as it is made in RurPLE?

I generally like  RurPLE-NG
http://dev.lshift.net/paul/rurple/

I improoved it fore easier learning
http://grokbase.com/t/python/edu-sig/129r2hkchm/rurple-ng-is-nice#20121113xy5wryeowevmgumpyo6o3t6jka

but moving around just rows and columns is a bit boring --
Would it be hard to somehow merge code tracking with Pynguin?


I tried to run it using PySCripter, but I didn't get far enough to check 
it out


Colin W.

[snip]

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


Re: There must be a better way

2013-04-22 Thread Colin J. Williams

On 22/04/2013 10:42 AM, Neil Cerutti wrote:

On 2013-04-21, Colin J. Williams c...@ncf.ca wrote:

On 20/04/2013 9:07 PM, Terry Jan Reedy wrote:

On 4/20/2013 8:34 PM, Tim Chase wrote:

In 2.x, the csv.reader() class (and csv.DictReader() class) offered
a .next() method that is absent in 3.x


In Py 3, .next was renamed to .__next__ for *all* iterators. The
intention is that one iterate with for item in iterable or use builtin
functions iter() and next().



Thanks to Chris, Tim and Terry for their helpful comments.

I was seeking some code that would be acceptable to both Python 2.7 and 3.3.

In the end, I used:

inData= csv.reader(inFile)

def main():
  if ver == '2':
  headerLine= inData.next()
  else:
  headerLine= inData.__next__()
  ...
  for item in inData:
  assert len(dataStore) == len(item)
  j= findCardinal(item[10])
  ...

This is acceptable to both versions.

It is not usual to have a name with preceding and following
udserscores,imn user code.

Presumably, there is a rationale for the change from csv.reader.next
to csv.reader.__next__.

If next is not acceptable for the version 3 csv.reader, perhaps __next__
could be added to the version 2 csv.reader, so that the same code can be
used in the two versions.

This would avoid the kluge I used above.


Would using csv.DictReader instead a csv.reader be an option?

Since I'm only interested in one or two columns, the simpler approach is 
probably better.


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


Re: There must be a better way

2013-04-21 Thread Colin J. Williams

On 20/04/2013 9:07 PM, Terry Jan Reedy wrote:

On 4/20/2013 8:34 PM, Tim Chase wrote:

In 2.x, the csv.reader() class (and csv.DictReader() class) offered
a .next() method that is absent in 3.x


In Py 3, .next was renamed to .__next__ for *all* iterators. The
intention is that one iterate with for item in iterable or use builtin
functions iter() and next().



Thanks to Chris, Tim and Terry for their helpful comments.

I was seeking some code that would be acceptable to both Python 2.7 and 3.3.

In the end, I used:

inData= csv.reader(inFile)

def main():
if ver == '2':
headerLine= inData.next()
else:
headerLine= inData.__next__()
...
for item in inData:
assert len(dataStore) == len(item)
j= findCardinal(item[10])
...

This is acceptable to both versions.

It is not usual to have a name with preceding and following 
udserscores,imn user code.


Presumably, there is a rationale for the change from csv.reader.next
to csv.reader.__next__.

If next is not acceptable for the version 3 csv.reader, perhaps __next__ 
could be added to the version 2 csv.reader, so that the same code can be 
used in the two versions.


This would avoid the kluge I used above.

Colin W.

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


Re: There must be a better way

2013-04-21 Thread Colin J. Williams

On 21/04/2013 9:39 AM, Jussi Piitulainen wrote:

Colin J. Williams writes:
...

It is not usual to have a name with preceding and following
udserscores,imn user code.

Presumably, there is a rationale for the change from csv.reader.next
to csv.reader.__next__.

...

I think the user code is supposed to be next(csv.reader). For example,
current documentation contains the following.

# csvreader.__next__()
# Return the next row of the reader’s iterable object as a list,
# parsed according to the current dialect. Usually you should call
# this as next(reader).


Thanks,

This works with both 2.7 and 3.3

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


Re: There must be a better way

2013-04-21 Thread Colin J. Williams

On 21/04/2013 9:43 AM, Peter Otten wrote:

Colin J. Williams wrote:


I was seeking some code that would be acceptable to both Python 2.7 and
3.3.

In the end, I used:

inData= csv.reader(inFile)

def main():
  if ver == '2':
  headerLine= inData.next()
  else:
  headerLine= inData.__next__()
  ...


I think it was mentioned before, but to be explicit:

def main():
 headerLine = next(inData)
 ...

works in Python 2.6, 2.7, and 3.x.



Yes, the penny dropped eventually.  I've used your statement

The Chris suggestion was slightly different:

Use the built-in next() function
(http://docs.python.org/2/library/functions.html#next ) instead:
headerLine = next(iter(inData))

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


There must be a better way

2013-04-20 Thread Colin J. Williams
Below is part of a script which shows the changes made to permit the 
script to run on either Python 2.7 or Python 3.2.


I was surprised to see that the CSV next method is no longer available.

Suggestions welcome.

Colin W.


def main():
global inData, inFile
if ver == '2':
   headerLine= inData.next()
else:  # Python version 3.3
inFile.close()
inFile= open('Don Wall April 18 2013.csv', 'r', newline= '')
inData= csv.reader(inFile)
headerLine= inData.__next__()
--
http://mail.python.org/mailman/listinfo/python-list


Re: Interactive development in Python à la Smalltalk?

2013-04-08 Thread Colin J. Williams

On 08/04/2013 4:33 AM, Bienlein wrote:

Hello,

I'm absolutely new to Python, just looked at the language description for the 
first time. The first thought that came to my mind was whether you can program  
in Python in an interactive programming style, i.e. I can change code in the 
debugger which becomes immediately effective (no edit-compile loop) and I can 
also send messages to objects visible inside the debugger.

Then Python could become my replacemenet for my dearly missed Smalltalk, which 
to my great grief meanwhile really has become quite dead, I fear. In Smalltalk 
you can open up an inspector window (e.g. you don't have to get into debug 
mode), inspect objects in it and evaluate code in it, send messaages to 
objects. I guess this cannot be done in Python out of the box. But if changes 
made in the debugger became immediately effective, this would be interactive 
enough for my purposes.

Thanks, Bienlein


If you are using Windows, PyScripter is a good choice.

I understand that, with Linux, it can also be used with Wine.  I haven't 
tried that.


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


Re: Fwd: Re: distutils without a compiler

2013-04-05 Thread Colin J. Williams

  
  

On 04/04/2013 9:30 PM, Colin J.
  Williams wrote:


  
  
  
   Original Message 
  
  Subject: Re: distutils without a compiler
  
  Date: Tue, 02 Apr 2013 16:26:59 -0700
  
  From: Ned Deily n...@acm.org
  
  To: python-list@python.org
  
  Newsgroups: comp.lang.python
  
  References: 515aa9bf.4010...@chamonix.reportlab.co.uk
  
  
  In article 515aa9bf.4010...@chamonix.reportlab.co.uk,
  
   Robin Becker ro...@reportlab.com wrote:
  
  Is there a neat way to get distutils to
report compiler absence? Most windows

users don't have a compiler so building extensions usually
doesn't work.


However, python's builtin batteries would allow pre-built pyds
to be

downloaded

in lieu of an actual build.


Has anyone created a fallback download compiler or similar?

  
  
  I'm not totally sure I understand what you are asking but here's a
  
  guess.  Today, probably the most widely-used solution to provide
  
  packages with pre-built C extension modules is to use setuptools
  or its
  
  Distribute fork and build a bdist egg which can then be downloaded
  and
  
  installed with the easy_install command.
  
  
  Note the whole area of binary distributions for Python is one that
  is
  
  now under intense active development.  The standard library
  replacement
  
  for binary eggs will be wheels;  various tools to support building
  and
  
  installing them are being designed and implemented and are
  expected to
  
  be part of Python 3.4 with downloadable support for selected
  earlier
  
  releases.  It's all happening on the distutils-sig and in various
  PEPs.
  
  Nick Coughlan, the core developer leading the design effort, gives
  an
  
  overview of the current plans here:
  
  
http://python-notes.boredomandlaziness.org/en/latest/pep_ideas/core_packa
  
  ging_api.html
  
  

I understand that easy_install does not make provision
for BLAS and similar linear algebra optimizations.

A few weeks back, I reported that a test ran more slowly
on 3.2 than on 2.7.  This was attributed, by one respondent,
to the absence of these optimizations when using easy_install.

easy_install was used for both of my installations.

I have not yet sorted out how to use the setup.py so
that the optimizations are included.

Colin W.
  
  

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


Re: Change in Python 3.3 with the treatment of sys.argv

2013-03-23 Thread Colin J. Williams

On 22/03/2013 6:11 PM, Ethan Furman wrote:

On 03/22/2013 02:57 PM, Colin J. Williams wrote:

Below is an extract from some code to run on Python 2.7.3, 3.2.3 and
3.3.0 to compare speeds, both between versions and
machines:

if __name__ == '__main__':
 # Text string for initial test - Modify for your own machine or
 # delete it and and answer the input statement with your own machine
 # characteristics.
 sys.argv[1:]= ('Intel Pentium D CPU 3.0GHz 1.99 GB of RAM 221GB
Disk Free space', )
 main()


def main():
 if len(sys.argv)  1:
 idMachine= ' '.join(sys.argv[1:])
 ...
 oFile= open('FP' + now + '.log', 'w')
 oFile.writelines(idM + '\n' + sys.version + '\n')

For 2.7, the result is:
Intel_Pentium_D_CPU_3.0GHz_1.99_GB_of_RAM_221GB_Disk_Free_space
2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)]

for 3.2, the result is:
Intel_Pentium_D_CPU_3.0GHz_1.99_GB_of_RAM_221GB_Disk_Free_space
3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)]

For 3.3, the result is:
I_n_t_e_l___P_e_n_t_i_u_m___D___C_P_U___3_._0_G_H_z___1_._9_9___G_B___o_f___R_A_M___2_2_1_G_B___D_i_s_k___F_r_e_e___s_p_a_c_e


3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit
(Intel)]

The full test result, for random matrices of increasing order is
available
here(http://web.ncf.ca/cjw/FP%20Summary%20over%20273-323-330.txt)


First, this is what I get with 3.3:

Python 3.3.0 (default, Sep 29 2012, 17:14:58)
[GCC 4.7.2] on linux
Type help, copyright, credits or license for more information.
-- import sys
-- sys.argv
['']
-- sys.argv[1:] = ('this is a test!', )
-- sys.argv
['', 'this is a test!']
-- ' '.join(sys.argv[1:])
'this is a test!'


Second, your code doesn't show being joined by an underscore.

--
~Ethan~


No, the same program ran against each of the three versions.  I assume 
that 3.3 behaves differently.


Colin W.

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


Re: Change in Python 3.3 with the treatment of sys.argv

2013-03-23 Thread Colin J. Williams

On 22/03/2013 6:11 PM, Ethan Furman wrote:

On 03/22/2013 02:57 PM, Colin J. Williams wrote:

Below is an extract from some code to run on Python 2.7.3, 3.2.3 and
3.3.0 to compare speeds, both between versions and
machines:

if __name__ == '__main__':
 # Text string for initial test - Modify for your own machine or
 # delete it and and answer the input statement with your own machine
 # characteristics.
 sys.argv[1:]= ('Intel Pentium D CPU 3.0GHz 1.99 GB of RAM 221GB
Disk Free space', )
 main()


def main():
 if len(sys.argv)  1:
 idMachine= ' '.join(sys.argv[1:])
 ...
 oFile= open('FP' + now + '.log', 'w')
 oFile.writelines(idM + '\n' + sys.version + '\n')

For 2.7, the result is:
Intel_Pentium_D_CPU_3.0GHz_1.99_GB_of_RAM_221GB_Disk_Free_space
2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)]

for 3.2, the result is:
Intel_Pentium_D_CPU_3.0GHz_1.99_GB_of_RAM_221GB_Disk_Free_space
3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)]

For 3.3, the result is:
I_n_t_e_l___P_e_n_t_i_u_m___D___C_P_U___3_._0_G_H_z___1_._9_9___G_B___o_f___R_A_M___2_2_1_G_B___D_i_s_k___F_r_e_e___s_p_a_c_e


3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit
(Intel)]

The full test result, for random matrices of increasing order is
available
here(http://web.ncf.ca/cjw/FP%20Summary%20over%20273-323-330.txt)


First, this is what I get with 3.3:

Python 3.3.0 (default, Sep 29 2012, 17:14:58)
[GCC 4.7.2] on linux
Type help, copyright, credits or license for more information.
-- import sys
-- sys.argv
['']
-- sys.argv[1:] = ('this is a test!', )
-- sys.argv
['', 'this is a test!']
-- ' '.join(sys.argv[1:])
'this is a test!'


Second, your code doesn't show being joined by an underscore.

--
~Ethan~


APOLOGIES to those who responded.

It seems that a change was made in the program between the 3.3 run and 
the other runs.


Each produces the same heading now.

Yes, I should have posted the test code.  But, in these circumstances, 
there is no point in doing that.


Colin W.

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


Change in Python 3.3 with the treatment of sys.argv

2013-03-22 Thread Colin J. Williams
Below is an extract from some code to run on Python 2.7.3, 3.2.3 and 
3.3.0 to compare speeds, both between versions and machines:


if __name__ == '__main__':
# Text string for initial test - Modify for your own machine or
# delete it and and answer the input statement with your own machine
# characteristics.
sys.argv[1:]= ('Intel Pentium D CPU 3.0GHz 1.99 GB of RAM 221GB 
Disk Free space', )

main()


def main():
if len(sys.argv)  1:
idMachine= ' '.join(sys.argv[1:])
...
oFile= open('FP' + now + '.log', 'w')
oFile.writelines(idM + '\n' + sys.version + '\n')

For 2.7, the result is:
Intel_Pentium_D_CPU_3.0GHz_1.99_GB_of_RAM_221GB_Disk_Free_space
2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)]

for 3.2, the result is:
Intel_Pentium_D_CPU_3.0GHz_1.99_GB_of_RAM_221GB_Disk_Free_space
3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)]

For 3.3, the result is:
I_n_t_e_l___P_e_n_t_i_u_m___D___C_P_U___3_._0_G_H_z___1_._9_9___G_B___o_f___R_A_M___2_2_1_G_B___D_i_s_k___F_r_e_e___s_p_a_c_e
3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit 
(Intel)]


The full test result, for random matrices of increasing order is 
available here(http://web.ncf.ca/cjw/FP%20Summary%20over%20273-323-330.txt)


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


Re: x += ... is not the same than x = x + ... if x is mutable

2013-03-21 Thread Colin J. Williams

On 21/03/2013 12:27 AM, Nobody wrote:

On Wed, 20 Mar 2013 07:17:08 -0700, bartolome.sintes wrote:


I thought that x += ... was the same than x = x + ..., but today I have
realized it is not true when operating with mutable objects.


It may or may not be the same. x += y will invoke x.__iadd__(y) if x has
an __iadd__ method, otherwise x + y will be evaluated and the result
assigned to x.


Does this depend on whether Py27 or Py32 is used?

Colin W.

In the first case, x will always continue to refer to the same object
(i.e. id(x) won't change). In the second case, x will typically (but not
always) refer to a different object.



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


Binary for numpy 1.7.0 with Python 2.7.3

2013-03-21 Thread Colin J. Williams

How do I find the binaries on Source Forge?

I'm trying to update to both 2.7.3 and Numpy 1.7.0.

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


Re: Binary for numpy 1.7.0 with Python 2.7.3

2013-03-21 Thread Colin J. Williams

On 21/03/2013 4:00 PM, Dave Angel wrote:

On 03/21/2013 03:40 PM, Colin J. Williams wrote:

How do I find the binaries on Source Forge?

I'm trying to update to both 2.7.3 and Numpy 1.7.0.

Colin W


Best answer might depend on what OS you're running, and what
implementation of Python you're after.

Why would you look on SourceForge for Python;  get it from Python.org

http://www.python.org/getit/

or you may want the one from ActiveState, also linked from that page.

or you may just want to get it from your Linux distro, perhaps from the
Synaptic Package Manager.

For numpy, try:

 http://www.scipy.org/Download




I'm not trying to get the Python, that's clearly available from python.org.

The SciPy/Numpy page refers to sourceforge.

KWPolska referred me to PyPi., using that is a smooth job to retrieve 
Numpy..


Thanks to both.

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


Re: Apparent magic number problem

2013-03-09 Thread Colin J. Williams

On 09/03/2013 3:51 AM, Peter Otten wrote:

Colin J. Williams wrote:

The program runs correctly under each version, but it runs more slowly
under 3.2.



This is probably due to the fact that the .pyc file is created for the
Python 2.7 execution.



When Python 3.2 is run it fails to create a new .pyc file and if the 2.7
.pyc is offered directly a magic number problem is reported.


(1) .pyc files are only created if a module is imported
(2) The 2.7 .pyc file is put alongside the .py file whereas the 3.2 .pyc is
put into the __pycache__ subfolder. No clash can occur.

A simple example:

$ ls
mod.py
$ cat mod.py
print(hello world)

Run it; no pyc is created:

$ python2.7 mod.py
hello world
$ ls
mod.py

Import it using 2.7:

$ python2.7 -c 'import mod'
hello world
$ ls
mod.py  mod.pyc

Import it using 3.2:

$ python3.2 -c 'import mod'
hello world
$ ls
mod.py  mod.pyc  __pycache__
$ ls __pycache__/
mod.cpython-32.pyc

Run the compiled code:

$ python2.7 mod.pyc
hello world
$ python3.2 __pycache__/mod.cpython-32.pyc
hello world

But I'm with Steven, it's unlikely that the module compilation phase is
responsible for a noticeable slowdown.



Thanks to Steven and Peter for their responses.

My main problem appears to be with:

Profile with Python 2.7
   11   25.7362.340   25.7362.340 
{numpy.linalg.lapack_lite.dgesv}


Profile with Python 3.2
   11  152.111   13.828  152.111   13.828 {built-in method dgesv}

In other words, the Python 3.2 linear equation solve takes longer than 
with Python 2.7.   I'll pursue this with the numpy folk.


There also appears to be a problem with the generation of the .pyc. 
Please see the example below:


rem temp.bat
dir *.pyc
del *.pyc
C:\python32\python.exe profiler.py Intel P4 2.8GHz 2MB Ram 221 GB Free 
Disk cjw prof3.txt

dir *.pyc

This is executed with: tmp.bat  tmp.lst

profiler.py contains:
#---
# Name:profiler.py
# Purpose:
#
# Author:  cjw
#
# Created: 17/02/2013
# Copyright:   (c) cjw 2013
# Licence: your licence
#---

import  cProfile as p, pstats as s, sys

def main():
v= sys.version
statsFile= 'FPSStats' + v[0] + v[2] + '.txt'
p.run('import testFPSpeed; testFPSpeed.main()',
 statsFile)
t= s.Stats(statsFile)
t.strip_dirs().sort_stats('cumulative').print_stats(40)

pass

if __name__ == '__main__':
main()

tmp.lst contains:

C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspirem temp.bat

C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidir *.pyc
 Volume in drive C has no label.
 Volume Serial Number is D001-FAC4

 Directory of C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspi


C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidel *.pyc

C:\Documents and Settings\cjw.P4A\My 
Documents\devpy\raspiC:\python32\python.exe profiler.py Intel P4 2.8GHz 
2MB Ram 221 GB Free Disk cjw 1prof3.txt


C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidir *.pyc
 Volume in drive C has no label.
 Volume Serial Number is D001-FAC4

 Directory of C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspi


C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspirem temp.bat

C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidir *.pyc
 Volume in drive C has no label.
 Volume Serial Number is D001-FAC4

 Directory of C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspi


C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidel *.pyc

C:\Documents and Settings\cjw.P4A\My 
Documents\devpy\raspiC:\python32\python.exe profiler.py Intel P4 2.8GHz 
2MB Ram 221 GB Free Disk cjw 1prof3.txt


C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidir *.pyc
 Volume in drive C has no label.
 Volume Serial Number is D001-FAC4

 Directory of C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspi




tmp.lst contains:

C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspirem temp.bat

C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidir *.pyc
 Volume in drive C has no label.
 Volume Serial Number is D001-FAC4

 Directory of C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspi


C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidel *.pyc

C:\Documents and Settings\cjw.P4A\My 
Documents\devpy\raspiC:\python32\python.exe profiler.py Intel P4 2.8GHz 
2MB Ram 221 GB Free Disk cjw 1prof3.txt


C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidir *.pyc
 Volume in drive C has no label.
 Volume Serial Number is D001-FAC4

 Directory of C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspi

From this we see that no .pys was reported for testFPSpeed.py.

However, looking at the directory itself. the .pyc is in fact created.

Thus,  the .pyc is, if necessary, generated upon the import of a .py and 
so this does not explain the time difference between 2.7 and 3.2

Apparent magic number problem

2013-03-08 Thread Colin J. Williams

I have a program that I wish to run in both Python 2.7 and Python 3.2

The program runs correctly under each version, but it runs more slowly 
under 3.2.


This is probably due to the fact that the .pyc file is created for the 
Python 2.7 execution.


When Python 3.2 is run it fails to create a new .pyc file and if the 2.7 
.pyc is offered directly a magic number problem is reported.


Is there a bug here?  it seems to me that the Magic Number exception 
should lead to a new compile of the program.


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


Re: Is it correct this way to inherit from a list?

2013-03-03 Thread Colin J. Williams

On 02/03/2013 9:30 PM, gialloporpora wrote:

Risposta al messaggio di Rick Johnson :


What are you trying to achieve exactly?



I would like to implement a class (vector) to works with vectors, for
example using scalar multiplication:
a*v = [a*v1, a*vn]
and a dual class for dual vector (the only method that I'll change is
the __str__ method to print it as colun.
Sandro

Numpy facilitates this sort of thing more efficiently than using a List.

Colin W.

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


Re: yield expression

2013-02-26 Thread Colin J. Williams

On 24/02/2013 7:36 PM, Ziliang Chen wrote:

Hi folks,
When I am trying to understand yield expression in Python2.6, I did the following coding. I have difficulty understanding why 
val will be None ? What's happening under the hood? It seems to me very time the counter resumes to execute, it will assign 
count to val, so val should NOT be None all the time.

Thanks !

code snippet:

  def counter(start_at=0):
  count = start_at
  while True:
  val = (yield count)
  if val is not None:
  count = val
  else:
  print 'val is None'
  count += 1


Perhaps it's becaoue (teild count) is a statement.  Statements do not 
return a value.


Colin W.




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


Re: yield expression

2013-02-26 Thread Colin J. Williams

On 26/02/2013 12:07 PM, Vytas D. wrote:

Hi,

You are using yield incorrectly. yield works like return, but it can
return more than once from the same function. Functions that yield
produce a so called generator object. This generator object gives you
values every time you call it.

The generator works very interesting way. It starts like normal function
and goes until it finds yield and returns the value. The state of
generator is saved - it is like it is put to sleep until you call it
again. So the next time you call generator() it runs from the point it
returned last time and will return you another value.

Simple sample of making and using generator (prints forever, so just
kill with CTRL+C).

def counter(start_at=0):
 Returns integer each time called

 count = start_at
 while True:
 yield count
 count += 1

def main():
 generator = counter()

 while True:
 print(next(generator))


if __name__ == '__main__':
 main()


Hope helps.

Vytas D.



On Tue, Feb 26, 2013 at 4:34 PM, Colin J. Williams c...@ncf.ca
mailto:c...@ncf.ca wrote:

On 24/02/2013 7:36 PM, Ziliang Chen wrote:

Hi folks,
When I am trying to understand yield expression in Python2.6,
I did the following coding. I have difficulty understanding why
val will be None ? What's happening under the hood? It seems
to me very time the counter resumes to execute, it will assign
count to val, so val should NOT be None all the time.

Thanks !

code snippet:

   def counter(start_at=0):
   count = start_at
   while True:
   val = (yield count)
   if val is not None:
   count = val
   else:
   print 'val is None'
   count += 1


Perhaps it's becaoue (teild count) is a statement.  Statements do
not return a value.

Colin W.



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



Yes, it's very helpful.  Thanks also to the other two responders.

This brings us back to the OP question.  Why not  val = (yield count)?

Colin W.


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


Re: A newbie question

2013-02-12 Thread Colin J. Williams

On 12/02/2013 10:06 AM, Alberto Salvati wrote:

Hi, All.
I'm a (old) delphi developer.
I want to learn Python.
I've python 2.7 and django.
For learning purpose I want to use firebird.
But, package (egg) to use firebird needs easy_install for setup.
When i run:

python ez_setup.py install

python says me error:

Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-p
y2.7.egg
Searching for install
Reading http://pypi.python.org/simple/install/
Couldn't find index page for 'install' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for install
Best match: None
Traceback (most recent call last):
   File ez_setup.py, line 278, in module
 main(sys.argv[1:])
   File ez_setup.py, line 213, in main
 return main(list(argv)+[egg])   # we're done here
   File 
C:\Python27\Scripts\setuptools-0.6c11-py2.7.egg\setuptools\command\easy_
install.py, line 1712, in main
   File 
C:\Python27\Scripts\setuptools-0.6c11-py2.7.egg\setuptools\command\easy_
install.py, line 1700, in with_ei_usage
   File 
C:\Python27\Scripts\setuptools-0.6c11-py2.7.egg\setuptools\command\easy_
install.py, line 1716, in lambda
   File C:\Python27\lib\distutils\core.py, line 152, in setup
 dist.run_commands()
   File C:\Python27\lib\distutils\dist.py, line 953, in run_commands
 self.run_command(cmd)
   File C:\Python27\lib\distutils\dist.py, line 972, in run_command
 cmd_obj.run()
   File 
C:\Python27\Scripts\setuptools-0.6c11-py2.7.egg\setuptools\command\easy_
install.py, line 211, in run
   File 
C:\Python27\Scripts\setuptools-0.6c11-py2.7.egg\setuptools\command\easy_
install.py, line 434, in easy_install
   File 
C:\Python27\Scripts\setuptools-0.6c11-py2.7.egg\setuptools\package_index
.py, line 475, in fetch_distribution
AttributeError: 'NoneType' object has no attribute 'clone'


In download site I get info about installer works only on win32, but I'm uisng 
64 bit version, so I need to do setup manually.

Searching error, I see a lot of message baout errors AFTER easy_install was 
done.
Also, I see that some link used in python file does'nt exist or is broken.

TIA for any suggestion.

A.

Try Easy_install, but first, make sure that C:\Python27\Scripts is in 
your path.


Colin W.

PS Assuming you are using Windows, you might wish to try PyScripter.  I 
was developed using Delphi.


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


Re: Statistics...help with numpy/scipy install

2013-02-10 Thread Colin J. Williams

On 10/02/2013 12:35 PM, Rex Macey wrote:

I'm new to Python with a new windows 8 machine (64-bit OS).  Learning 
programming mainly for fun.  Naturally I downloaded Python 3.3 (who doesn't 
want the latest and greatest).  What I want involves functions related to the 
normal distribution. Based on my google research, it appears that SCIPY is a 
good way to go. That requires NUMPY.   I don't seem to find an install that 
works for my environment which leads to the questions on this post: Is there an 
install for my environment and if so, where do I get it? If not, is there 
another package I should use? Or do I need to bite the bullet and install an 
earlier version of Python.  Suggestions and comments appreciated. Thanks.



Rex,

A good start for supplementary packages is PyPi, see: 
http://en.wikipedia.org/wiki/Python_Package_Index


The packages in PyPi can be downloaded using easy-install, see: 
http://en.wikipedia.org/wiki/EasyInstall


Yes, the Enthught Numpy is a good starting point.

Good luck and have fun,

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


sub-classing datetime

2013-02-07 Thread Colin J. Williams

I'm just making the transition from 2 to 3 for one module.

With Python 2.7, I had the benefit of mx datetime, but this is not yet 
available for Python 3.2.


I find that the 3.2 datetime is not subclassable, for reasons that were 
known some years back.


It would help if there was a note in the docs listing the builtin 
classes which are not subclassable.


I am retreating to the use of a function.

Any other suggestions?

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


Re: Good Python IDE

2013-01-06 Thread Colin J. Williams

On 06/01/2013 7:48 AM, Tetsuya wrote:

On 01/06/2013 05:45 AM, Sourabh Mhaisekar wrote:

Hello All,
I am recently started couple of projects in Python, one in Python GTK

  and one in Python Qt. I want a good IDE (For Windows ) for Python which
  gives support for Python as well as PyGtk and PyQt.


Features I am looking for
* Support for Core Python Auto-completion.
* Support for PyGtk and PyQt
* Support for either Bazaar (preferred) or CVS

Thanks !

- Sourabh



I develop only under GNU/Linux (using Vim, with some plugins like
python-jedi and supertab for autocompletion, Gundo for undo management
in a *very* smart way, etc..), but in the recent past I tried various
IDEs. They're all ugly and/or cumbersome, but it seemed to me that the
less ugly maybe is PyCharm, you could try that.
I would suggest that you look at PyScripter for Windows or Linuz when 
Wine is available.


See: http://www.decalage.info/en/python/tutorial

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


Re: Pigeon Computer 0.1 Initial (BETA) release

2012-12-22 Thread Colin J. Williams

On 21/12/2012 7:07 PM, Amirouche Boubekki wrote:

Héllo,


2012/12/22 Simon Forman forman.si...@gmail.com
mailto:forman.si...@gmail.com

Pigeon Computer 0.1 Initial (BETA) release

Summary


The Pigeon Computer is a simple but sophisticated system for learning
and exploring the fundamentals of computers and programming.

It is written to support a course or class (as yet pending) to learn
programming from the bit to the compiler.

There is a DRAFT manual and a Pigeon User Interface that includes:

   * An assembler for the ATmega328P micro-controller.
   * A polymorphic meta-compiler.
   * Forth-like firmware in assembly.
   * Simple high-level language for assembly control structures.
   * A virtual computer that illustrates Functional Programming.

Source code is released under the GPL (v3) and is hosted on Github:
https://github.com/PhoenixBureau/PigeonComputer

The manual is online in HTML form here:
http://phoenixbureau.github.com/PigeonComputer/

Mailing list:
https://groups.google.com/d/forum/pigeoncomputer

It has been tested on Linux with Python 2.7, YMMV.

I'm releasing it now because it's basically done even though it needs
polish and I'm just too excited about it.  Happy End of the World Day!


This sound fun!

Could you elaborate a bit in simple words what it is and what's the
common way to interact with the system ? What do you mean by «
Forth-like firmware in assembly » ? Is there a GUI ? Does it feels like
being a hipster like in the '50s or before and breaking the 1 billion
dollar thing ?

Of course the little tutorial I stripped and read a bit gives some of
the responses.

Thanks

Amirouche


  - - -

Whew!  If you are still reading, thank you.  There is a lot more to be
done and I am hoping to form classes in early January 2013.  If you
are interested please email me at forman.si...@gmail.com
mailto:forman.si...@gmail.com

You can also participate on Github and join the mailing list.
   * https://github.com/PhoenixBureau/PigeonComputer
   * https://groups.google.com/d/forum/pigeoncomputer

Warm regards,
~Simon P. Forman
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


The Pigeon would appear to have objectives similar to those of the 
Raspberry Pi Project, which uses an ARM processor and has operational 
both Python 2.7 and Python 3.2.  The Raspberry Pi Foundation can be 
reached at: http://www.cl.cam.ac.uk/projects/raspberrypi/


Colin W.


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


Re: py2exe is on Sourceforge list of top growth projects

2012-12-18 Thread Colin J. Williams

On 18/12/2012 1:52 AM, Frank Millman wrote:

This is from Sourceforge's monthly update -

quote

Top Growth Projects

We're always on the lookout for projects that might be doing interesting
things, and a surge in downloads is one of many metrics that we look at
to identify them. Here's the projects that had the greatest growth in
the last month.

[...]

py2exe: A distutils extension to create standalone Windows programs from
python scripts.

/quote

It is 19th on a list of 19, but still, it is nice to see. I wonder if
there was any particular reason for that?

Frank Millman


Yes, but py2exe appears limited to Python 2.6.

PyInstaller is another option with similar functionality.

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


Re: Yet another Python textbook

2012-11-22 Thread Colin J. Williams

From Yet another Python textbook
On 21/11/2012 5:17 PM, Chris Angelico wrote:

On Thu, Nov 22, 2012 at 4:03 AM, Colin J. Williams c...@ncf.ca wrote:

On 20/11/2012 4:00 PM, Chris Angelico wrote:

To the OP: jmf has an unnatural hatred of Python 3.3 and PEP 393
strings. Take no notice; the rest of the world sees this as a huge
advantage. Python is now in a VERY small group of languages (I'm aware
of just one other) that have absolutely proper Unicode handling *and*
efficient string handling.

ChrisA


It's interesting to see that someone else finds the format function to be a
pain.  Perhaps the problem lies with the documentation.


Hang on, what? I'm not sure where the format function comes in. I was
referring to the underlying representation.

The OP wrote:
  The absurd flexible string representation has practically
borrowed the idea to propose once Python has a teaching tool.

I perhaps stretched this to refer specifically on one aspect, formatting 
in my comment.


That said, though, I'm just glad that %-formatting is staying. It's an
extremely expressive string formatting method, and exists in many
languages (thanks to C's heritage). Pike's version is insanely
powerful, Python's is more like C's, but all three are compact and
convenient.

str.format(), on the other hand, is flexible. It strikes me as rather
more complicated than a string formatting function needs to be, but
that may be a cost of its flexibility.

ChrisA


Yes is is complicated.

From my reading of the docs, it seems to me that the three following 
should be equivalent:


  (a) formattingStr.format(values)
with
  (b) format(values, formattingStr)
or
  (c) tupleOfValues.__format__(formattingStr

Example:
print('{:-^14f}{:^14d}'.format(-25.61, 95 ))
print(format((-25.61, 95), '{:-^14f}{:^14d}'))
(-25.61, 95 ).__format__('{:-^14f}{:^14d}')

The second fails, perhaps because values can only be a single value.
The third fails, the reason is unclear.

Steven D'Aprano earlier said that a better diagnostic tool is planned 
for Python 3.4.


Should we retreat to %-formatting for now?

Colin W.







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


Re: Yet another Python textbook

2012-11-22 Thread Colin J. Williams

On 22/11/2012 1:27 PM, Ian Kelly wrote:

On Thu, Nov 22, 2012 at 5:24 AM, Colin J. Williams c...@ncf.ca wrote:

 From my reading of the docs, it seems to me that the three following should
be equivalent:

   (a) formattingStr.format(values)
with
   (b) format(values, formattingStr)
or
   (c) tupleOfValues.__format__(formattingStr

Example:
print('{:-^14f}{:^14d}'.format(-25.61, 95 ))
print(format((-25.61, 95), '{:-^14f}{:^14d}'))
(-25.61, 95 ).__format__('{:-^14f}{:^14d}')

The second fails, perhaps because values can only be a single value.
The third fails, the reason is unclear.


The latter two (which are more or less equivalent) fail because they are
intended for invoking the formatting rules of a single value.  The
string argument to each of them is not a format string, but a format
specification, which in a format string is only the part that goes
inside the curly braces and after the optional colon.  For example, in
this format string:


Thanks, this is clear.  I wish the docs made this clearer.

You and I used __format__.  I understand that the use of double 
underscore functions is deprecated.  Is there some regular function 
which can achieve the same result?





'Hello world {0!s:_4s}'.format(42)

'Hello world __42'

The format specifier here is _4s:


format('42', '_4s')

'__42'

The valid format specifiers depend upon the type of the object being formatted:


format(42, '04x')

'002a'


format(datetime(2012, 11, 22, 11, 17, 0), 'The time is %Y %d %m %H:%M:%S')

'The time is 2012 22 11 11:17:00'

Custom types can implement custom format specifications by overriding
the __format__ method:


class Foo:

... def __init__(self, value):
... self.value = value
... def __format__(self, spec):
... if spec == 'a':
... return str(self.value)
... if spec == 'b':
... return ''.join(reversed(str(self.value)))
... raise ValueError(Unknown format code {!r}.format(spec))
...

format(Foo(42), 'a')

'42'

format(Foo(42), 'b')

'24'

The same format specifications can then also be passed to str.format:


'{0:a} reversed is {0:b}'.format(Foo(42))

'42 reversed is 24'

Unfortunately, there does not seem to be a good reference to the
format specifications available for built-in types beyond basic
strings and numbers.  I only knew about the datetime example because
it is used in an example in the str.format docs.  The
datetime.__format__ implementation (which seems to be just a thin
wrapper of datetime.strftime) does not seem to be documented anywhere
in the datetime module docs.



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


Re: Yet another Python textbook

2012-11-21 Thread Colin J. Williams

On 20/11/2012 4:00 PM, Chris Angelico wrote:

On Wed, Nov 21, 2012 at 1:57 AM,  wxjmfa...@gmail.com wrote:

Le mardi 20 novembre 2012 09:09:50 UTC+1, Chris Angelico a écrit :

On Tue, Nov 20, 2012 at 7:02 PM, Pavel Solin solin.pa...@gmail.com wrote:


Perhaps you are right. Is there any statistics of how many Python



programmers are using 2.7 vs. 3? Most of people I know use 2.7.




If you're teaching Python, the stats are probably about zero for zero.

Start them off on Py3 and help move the world forward.



ChrisA




Do not count with me.

The absurd flexible string representation has practically
borrowed the idea to propose once Python has a teaching tool.


To the OP: jmf has an unnatural hatred of Python 3.3 and PEP 393
strings. Take no notice; the rest of the world sees this as a huge
advantage. Python is now in a VERY small group of languages (I'm aware
of just one other) that have absolutely proper Unicode handling *and*
efficient string handling.

ChrisA

It's interesting to see that someone else finds the format function to 
be a pain.  Perhaps the problem lies with the documentation.


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


Error messages from format()

2012-11-13 Thread Colin J. Williams
Is there some way to get more informative error messages from the 
builtin format?


Most messages are such as:
Traceback (most recent call last):
  File interactive input, line 1, in module
ValueError: Invalid conversion specification

This example doesn't point to the first invalid case.

[Dbg] format((25, 31),'{0^9o} a(1:9x}')
Traceback (most recent call last):
  File interactive input, line 1, in module
ValueError: Invalid conversion specification

Basically, I'm trying to make use of the format function with Python 
3.2, but find little in the way of examples in the docs.


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


Re: Error messages from format()

2012-11-13 Thread Colin J. Williams

On 13/11/2012 1:38 PM, Steven D'Aprano wrote:

On Tue, 13 Nov 2012 10:08:59 -0500, Colin J. Williams wrote:


Is there some way to get more informative error messages from the
builtin format?


Yes -- post a feature request on the Python bug tracker, then wait until
Python 3.4 comes out in about 16 months.

:(


Many thanks :)

I am working on the assumption that the first argument of the format 
builtin function and be a sequence of values, which can be selected

with {1:}, {2:}, {0:} etc.

The docs don't make this clear.  I would appreciate advice.

Colin W.

[snip]

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


Re: Error messages from format()

2012-11-13 Thread Colin J. Williams

  
  

On 13/11/2012 4:18 PM, Dave Angel
  wrote:


  On 11/13/2012 03:24 PM, Colin J. Williams wrote:

  
SNIP

I am working on the assumption that the first argument of the format
builtin function and be a sequence of values, which can be selected
with {1:}, {2:}, {0:} etc.

The docs don't make this clear.  I would appreciate advice.


  
  
The built-in function format():

http://docs.python.org/3.3/library/functions.html?highlight=format%20builtin#format

The first parameter is a single object, NOT a sequence.  One object, one
format.  If you want more generality, use the str.format() method:

http://docs.python.org/3.3/library/stdtypes.html?highlight=format#str.format

where you can supply a list or a dictionary of multiple items to be
formatted into a single string.  That's the one where you supply the
curly braces.




The docs for the first case leave open the possibility of using a
sequence when they say:
"Convert a value to a formatted representation, as
  controlled by
  format_spec. The
  interpretation of format_spec
  will depend on the type
  of the value argument, however there is a standard formatting syntax that
  is used by most built-in types: Format
  Specification Mini-Language."

I hope that, as time goes by, consideration will be given to
permitting a sequence. It would appear to be a relatively simple
change. This would extend the generality of the format function.

Thanks for clarifying this. It confirmed my trial and error
results.

Colin W.





  

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


Re: Numpy module

2012-11-08 Thread Colin J. Williams

On 08/11/2012 8:09 AM, Anssi Saari wrote:

farrellpolym...@gmail.com writes:


[snip]

Does Numpy 1.6.2 not run with Python 3.2.3?


It does on the Raspberry Pi, which uses a variant of Debian.

Colin W.

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


Re: How to get progress in python script.

2012-09-29 Thread Colin J. Williams

On 28/09/2012 12:26 PM, Rolando Cañer Roblejo wrote:

Hi all,

Please, I need you suggest me a way to get statistics about a progress
of my python script. My python script could take a lot of time
processing a file, so I need a way that an external program check the
progress of the script. My first idea was that the python script write a
temp file showing the progress and the external program can check that
file, but I think might happen file read/write locking issues.

Thanks.

Would the Python profiler meet your need?

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


Re: which a is used?

2012-09-25 Thread Colin J. Williams

On 24/09/2012 10:14 PM, alex23 wrote:

On Sep 25, 11:13 am, Dwight Hutto dwightdhu...@gmail.com wrote:

bitch


I honestly could not care less what you think about me, but don't use
that term. This isn't a boys' club and we don't need your hurt ego
driving people away from here.


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


Re: Setting up a class

2012-09-06 Thread Colin J. Williams

On 06/09/2012 8:20 AM, MRAB wrote:

On 06/09/2012 13:00, shaun wrote:

Hi all,

So I'm trying to to OO a script which is currently in place on work.
It connects to the database and makes multiple strings and sends them
to a server.

But I'm having major problems since I am new to python I keep trying
to do it as I would do it in Java but classes seem to be very
different. I was wondering could someone answer a few questions?

1) Is there anything I should know about passing in variables from
another script to the class?

2) When I'm passing variables back to the script they seem to come
back blank as if I haven't done it correctly (I declare the empty
variable at the top of the class, I use the information I get from the
database to fill it and I send it back) Is there anything I'm not
doing right with this.

3)When I want to use a method from a class in another class method it
never seems to work for me, I have a feeling this is to do with self
but im not too sure??

Any help would be appreciated.
Thanks,
Shaun


You should have a look as a Python tutorial to help you get used to the
language. It shouldn't take you long, provided that you remember that
Python isn't Java and don't try to write Java in Python. :-)

Here's one you could look at:

Python for Java programmers
http://python4java.necaiseweb.org/Main/TableOfContents


The link given seems dated and incomplete - see operator overloading.

Sorry I can't assist the OP.

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


Re: Sudden doubling of nearly all messages

2012-07-21 Thread Colin J. Williams

On 21/07/2012 6:48 AM, Dave Angel wrote:

Has anybody else noticed the sudden double-posting of nearly all
messages in the python mailing list?



No.

Colin W.

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


Re: lambda in list comprehension acting funny

2012-07-11 Thread Colin J. Williams

On 11/07/2012 2:41 AM, Daniel Fetchinson wrote:

funcs = [ lambda x: x**i for i in range( 5 ) ]
print funcs[0]( 2 )
print funcs[1]( 2 )
print funcs[2]( 2 )

This gives me

16
16
16

When I was excepting

1
2
4

Does anyone know why?

Cheers,
Daniel



I don't understand why you would expect 1, 2, 4.

Perhaps parentheses will help the order of evaluation:

funcs = [(lambda x: x**i) for i in range( 5 )]

This gives:
1
16
81

Colin W.

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


Re: Which way is best to execute a Python script in Excel?

2012-07-06 Thread Colin J. Williams

On 06/07/2012 1:09 AM, Terry Reedy wrote:


On 7/5/2012 10:30 PM, Karim wrote:


An excellent link to derived all code example to python:
http://www.pitonyak.org/AndrewMacro.sxw.


Even though he only writes in OOBasic, you are right that he explains
the basic concepts needed for accessing the api from any language. He is
also honest. Writing non-api code is relatively easy; accessing the
OO/LO api is harder. I made a start. When I get further, I will look at
the examples that are close to some things I want to do. I will also
study your Python examples. Thanks for the help.

Terry



You might be interested in pyspread
(http://manns.github.com/pyspread/).

It is no longer maintained for Windows.

Colin W.

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


Re: Nexus Programming Language

2012-06-10 Thread Colin J. Williams

On 10/06/2012 1:45 AM, rusi wrote:

On Jun 10, 7:46 am, Adam Campbellabcampbell...@gmail.com  wrote:

The Nexus programming language version 0.5.0 has been released. It is
an object-oriented, dynamically-typed, reflective programming
language, drawing from Lua and Ruby.www.nexuslang.org


What does nexus have that python doesn't?
Yeah I know this kind of question leads to flames but a brief glance
at the about page does not tell me anything in this direction.


It has a more complex block structure, with lots of braces {}.

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


Re: Smallest/cheapest possible Python platform?

2012-05-27 Thread Colin J. Williams

On 26/05/2012 12:25 PM, Paul Rubin wrote:

Roy Smithr...@panix.com  writes:

The Rasberry Pi certainly looks attractive, but isn't quite available
today.  Can you run Python on an Arduino?


No.  YOu want a 32-bit platform with an OS and perhaps 1 meg of memory.
And by the time you port Python to it unless it's there already, you may
as well have just written your application in C.


Python is available and included with the Debian distribution for the 
RPi.  32 bit and smaller operations are provided.  Floating point is by 
software.  A FPU is available for the AIM processor, but not provided 
with the BRCM 2835 board.


Colin W.

[snip]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic comparison operators

2012-05-24 Thread Colin J. Williams

On 24/05/2012 10:14 AM, mlangenho...@gmail.com wrote:

I would like to pass something like this into a function
test(val1,val2,'=')

and it should come back with True or False.

Is there a way to dynamically compare 2 values like this or will I have to code 
each operator individually?


Would something like the following meet your need?

Yes, it would be nice if there were a b.__name__ constant.

Colin W.
'''
I would like to pass something like this into a function
test(val1,val2,'=')

and it should come back with True or False.

Is there a way to dynamically compare 2 values like this or will I have 
to code each operator individually?

'''
def test(text):
return eval(text)

a= 25
b= 50

print test('a == b')
print test('a != b')
print test('a = b')



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


Re: .py to .pyc

2012-05-19 Thread Colin J. Williams

On 18/05/2012 7:20 PM, Tony the Tiger wrote:

On Sun, 13 May 2012 23:36:02 +0200, Irmen de Jong wrote:


Why do you care anyway?


Wanna hide his code...?

  /Grrr
Curiosity.  Perhaps there are stack-based processors out there which 
could use the .pyc code more directly.


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


.py to .pyc

2012-05-13 Thread Colin J. Williams
Is there some way to ensure that a .pyc file is produced when executing 
a .py file?


It seems that for small files the .pyc file is not produced.

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


.py to .pyc

2012-05-13 Thread Colin J. Williams
Is there some way to ensure that a .pyc file is produced when executing 
a .py file?


It seems that for small files the .pyc file is not produced.

Colin W.
PLEASE IGNORE - I was in the wrong directory.

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


Re: numpy (matrix solver) - python vs. matlab

2012-05-01 Thread Colin J. Williams

On 01/05/2012 2:43 PM, someone wrote:
[snip]

a = [1 2 3]; b = [11 12 13]; c = [21 22 23].

Then notice that c = 2*b - a. So c is linearly dependent on a and b.
Geometrically this means the three vectors are in the same plane,
so the matrix doesn't have an inverse.




Does it not mean that there are three parallel planes?

Consider the example in two dimensional space.

Colin W.
[snip]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Some posts do not show up in Google Groups

2012-04-30 Thread Colin J. Williams

On 30/04/2012 2:20 AM, Frank Millman wrote:

Hi all

For a while now I have been using Google Groups to read this group, but on the 
odd occasion when I want to post a message, I use Outlook Express, as I know 
that some people reject all messages from Google Groups due to the high spam 
ratio (which seems to have improved recently, BTW).

 From time to time I see a thread where the original post is missing, but the 
follow-ups do appear. My own posts have shown up with no problem.

Now, in the last month, I have posted two messages using Outlook Express, and 
neither of them have shown up in Google Groups. I can see replies in OE, so 
they are being accepted. I send to the group gmane.comp.python.general.

Does anyone know a reason for this, or have a solution?

Frank Millman


I lose about two messages a day from the Usenet Group.  At the end of 
the day, the Group reports one or two messges as being available, but 
they are not.


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


Re: Python-URL! - weekly Python news and links (Mar 31)

2012-04-03 Thread Colin J. Williams

On 31/03/2012 11:38 AM, Cameron Laird wrote:

I pine for the fjords.

And it's time to bring Python-URL! to a close.  Python-URL!, which
Jean-Claude Wippler and I appear to have launched in 1998, has reached
the end of its utility.  We still have many loyal and enthusiastic
readers--one subscription request arrived within the last day, in
fact--and certainly much writing turns up every week that *deserves*
the spotlight Python-URL! has shone in the past.

However, the Python world has changed a great deal over the last
fourteen years.  There are many, MANY other ways for those with an
interest in Python to nourish themselves, and Python itself has grown
and normalized so much that it no longer fits particularly well in
the Python-URL! format.  Enjoy Mouse vs. PythonURL:
http://www.blog.pythonlibrary.org/, the Python areas of DZone,
Reddit, developerWorks, stackoverflow, and so on.

For your reference, I append below the most-recent-but-not-
particularly-
current version of Python-URL!'s coda of related readings.

That is all.



Everything Python-related you want is probably one or two clicks away
in
these pages:

 Python.org's Python Language Website is the traditional
 center of Pythonia
 http://www.python.org
 Notice especially the master FAQ
 http://www.python.org/doc/FAQ.html

 Just beginning with Python?  This page is a great place to start:
http://wiki.python.org/moin/BeginnersGuide/Programmers

 Planet Python:  you want to visit there:
http://planet.python.org
 But don't confuse it with Planet SciPy:
http://planet.scipy.org
 And don't confuse *that* with SciPyTip, a high-quality daily (!)
tip
 for the numerically-inclined:
http://twitter.com/SciPyTip

 Python Insider is the official blog of the Python core development
 team:
http://pyfound.blogspot.com/2011/03/python-dev-launches-python-insider
-blog.html

 The Python Software Foundation (PSF) has replaced the Python
 Consortium as an independent nexus of activity.  It has official
 responsibility for Python's development and maintenance.
 http://www.python.org/psf/
 Among the ways you can support PSF is with a donation.
 http://www.python.org/psf/donations/
 Keep up with the PSF at Python Software Foundation News:
http://pyfound.blogspot.com

 The Python Papers aims to publish the efforts of Python
enthusiasts:
http://pythonpapers.org/

 Doug Hellman's Module of the week is essential reading:
http://www.doughellmann.com/PyMOTW/

 comp.lang.python.announce announces new Python software.  Be
 sure to scan this newsgroup weekly.
 http://groups.google.com/group/comp.lang.python.announce/topics

 Python411 indexes podcasts ... to help people learn Python ...
 Updates appear more-than-weekly:
 http://www.awaretek.com/python/index.html

 The Python Package Index catalogues packages.
 http://www.python.org/pypi/

 Much of Python's real work takes place on Special-Interest Group
 mailing lists
 http://www.python.org/sigs/

 Python Success Stories--from air-traffic control to on-line
 match-making--can inspire you or decision-makers to whom you're
 subject with a vision of what the language makes practical.
 http://www.pythonology.com/success

 The Summary of Python Tracker Issues is an automatically generated
 report summarizing new bugs, closed ones, and patch submissions.
 http://search.gmane.org/?author=status%40bugs.python.orggroup=gmane.c
omp.python.develsort=date

 nullege is an interesting search Web application, with the
intelligence
 to distinguish between Python code and comments.  It provides what
 appear to be relevant results, and demands neither Java nor CSS be
 enabled:
http://www.nullege.com

 Although unmaintained since 2002, the Cetus collection of Python
 hyperlinks retains a few gems.
 http://www.cetus-links.org/oo_python.html

 The Cookbook is a collaborative effort to capture useful and
 interesting recipes:
http://code.activestate.com/recipes/langs/python/

 Many Python conferences around the world are in preparation.
 Watch this space for links to them.

 Among several Python-oriented RSS/RDF feeds available, see:
 http://www.python.org/channews.rdf
 For more, see:
 http://www.syndic8.com/feedlist.php?ShowMatch=pythonShowStatus=all
 The old Python To-Do List now lives principally in a
 SourceForge reincarnation.
 http://sourceforge.net/tracker/?atid=355470group_id=5470func=browse
http://www.python.org/dev/peps/pep-0042/

 del.icio.us presents an intriguing approach to reference
commentary.
 It already aggregates quite a bit of Python intelligence.
 http://del.icio.us/tag/python

 

Re: Fabric Engine v1.0 released under AGPL

2012-03-20 Thread Colin J. Williams

On 20/03/2012 12:51 PM, Fabric Paul wrote:

Hi everyone - just letting you know that we released v1.0 of Fabric
Engine today. We've open-sourced the core under AGPL, so I hope that
gives you an incentive to get started with high-performance for
Python :)

http://fabricengine.com/technology/benchmarks/ - to give you an idea
of the kind of performance possible. Most of these are with node, but
the core engine is the same - we just bound it to Python.

For those of you using Python on the desktop (particularly if you're
working with 3D), we've started a closed beta on a PyQt framework -
you can see more here: 
http://fabricengine.com/2012/03/pyqt-framework-for-fabric-engine/
- email b...@fabricengine.com if you'd like to take part in the
testing program.

Thanks for your time,

Paul



It seems that sing;e dimension arrays are used in KL.  How does this 
compare with Numpy?


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


Re: Why not use juxtaposition to indicate function application

2012-03-16 Thread Colin J. Williams

On 16/03/2012 8:45 AM, Ray Song wrote:

I confess i've indulged in Haskell and found
 f a
more readable than
 f(a)

And why aren't functions curried (partially applied function is another 
function which takes the rest arguments) by default?


Thanks in advance for any suggestions.

--
Ray

+1

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


Re: newb __init__ inheritance

2012-03-10 Thread Colin J. Williams

On 08/03/2012 10:25 AM, hyperboogie wrote:

Hello everyone.

This is my first post in this group.
I started learning python a week ago from the dive into python e-
book and thus far all was clear.
However today while reading chapter 5 about objects and object
orientation I ran into something that confused me.
it says here:
http://www.diveintopython.net/object_oriented_framework/defining_classes.html#fileinfo.class.example

__init__ methods are optional, but when you define one, you must
remember to explicitly call the ancestor's __init__ method (if it
defines one). This is more generally true: whenever a descendant wants
to extend the behavior of the ancestor, the descendant method must
explicitly call the ancestor method at the proper time, with the
proper arguments. 

However later on in the chapter:
http://www.diveintopython.net/object_oriented_framework/userdict.html

it says:
Methods are defined solely by their name, and there can be only one
method per class with a given name. So if a descendant class has an
__init__ method, it always overrides the ancestor __init__ method,
even if the descendant defines it with a different argument list. And
the same rule applies to any other method. 

My question is if __init__ in the descendant class overrides __init__
in the parent class how can I call the parent's __init__ from the
descendant class - I just overrode it didn't I?

Am I missing something more fundamental here?
Thanks


The mro function [Method Resolution Order]is not too well advertised in 
the docs.  This should illustrate its usage:


#!/usr/bin/env python

class A():
  def __init__(self):
z= 1

  def ringA(self):
print ('aaa')

  def ringB(self):
print('bbb')

class B(A):
  def __init__(self):
z= 2

  def ringB(self):
print('BBB')

a= A()
b= B()
b.ringB()
b.ringA()
b.__class__.mro()[1].ringB(b)

z= 1
def main():
pass

if __name__ == '__main__':
main()
I'm not sure that the class initialization is required.

Good luck,

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


Re: newb __init__ inheritance

2012-03-10 Thread Colin J. Williams

On 10/03/2012 12:58 PM, Colin J. Williams wrote:

On 08/03/2012 10:25 AM, hyperboogie wrote:

Hello everyone.


[snip]

main()
I'm not sure that the class initialization is required.

Good luck,

Colin W.

When I wrote earlier, I wondered about the need for initialization.

With Version 2, both __new__ and __init__ were required, not in the 
example below, using version 3.2:

#!/usr/bin/env python

class A():

  def ringA(self):
print ('aaa')

  def ringB(self):
print('bbb')

class B(A):
  def __init__(self:)
  def ringB(self):
print('BBB')

a= A()
b= B()
b.ringB()
b.ringA()
b.__class__.mro()[0].ringB(22)   #  22 is used for the ringB attribute
 #  Trial and error shows that any
 #  non-Null,including None for the
 #  argument gives the same result
z= 1
def main():
pass

if __name__ == '__main__':
main()

Colin W.


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


Re: Running Python Demo on the Web?

2011-09-06 Thread Colin J. Williams

On 05-Sep-11 18:00 PM, Python Fiddle Admin wrote:

Python has been ported to the web browser at pythonfiddle.com. Python
Fiddle can import snippets of code that you are reading on a web page
and run them in the browser. It supports a few popular libraries.

Another common usage is to post code on the site to allow other people
to play around with it. Also, it can be used to demonstrate a working
program.

A neat idea.

import brian
dir(brian)

Responds scipy not available

Colin W.

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


Re: [OT] Anyone here familiar with installing Open Watcom F77?

2011-09-05 Thread Colin J. Williams

On 05-Sep-11 12:22 PM, Dan Nagle wrote:

Hello,

On 2011-09-05 16:15:20 +, W. eWatson said:


On 9/5/2011 8:24 AM, Chris Angelico wrote:

On Tue, Sep 6, 2011 at 1:15 AM, W. eWatsonwolftra...@invalid.com
wrote:

See Subject.


snip


To what extent familiar? I have it installed on several computers,

but only because it comes with Open Wat C/C++.

With something off-topic like this,


snip


sierra_mtnview @ sbcglobal.net

Here's the story.

As far as I can tell F77 1.8 is not available. I've Googled quite a
bit for it. My source for 1.9 is
http://www.openwatcom.org/index.php/Download. It gives me:
open-watcom-f77-win32-1.9.exe.


On Usenet, comp.lang.fortran might be the best source of help for this.
There's a good chance one of the regulars there can answer you
within one or two posts. (I'll not cross-post, you can choose for
yourself.)

HTH



You might get in touch with someone at Waterloo University, which is 
located in Kitchener/Waterloo.


This could have come from the 60's or 70's.

Good luck.

Colin W.

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


Re: how to format long if conditions

2011-08-27 Thread Colin J. Williams

On 27-Aug-11 03:50 AM, Hans Mulder wrote:

On 27/08/11 09:08:20, Arnaud Delobelle wrote:

I'm wondering what advice you have about formatting if statements with
long conditions (I always format my code to80 colums)

Here's an example taken from something I'm writing at the moment and
how I've formatted it:


if (isinstance(left, PyCompare) and isinstance(right, PyCompare)
and left.complist[-1] is right.complist[0]):
py_and = PyCompare(left.complist + right.complist[1:])
else:
py_and = PyBooleanAnd(left, right)

What would you do?


I would break after the '(' and indent the condition once and
put the '):' bit on a separate line, aligned with the 'if':


if (
isinstance(left, PyCompare)
and isinstance(right, PyCompare)
and left.complist[-1] is right.complist[0]
):
py_and = PyCompare(left.complist + right.complist[1:])
else:
py_and = PyBooleanAnd(left, right)

It may look ugly, but it's very clear where the condition part ends
and the 'then' part begins.

-- HansM


What about:
  cond=  isinstance(left, PyCompare)
 and isinstance(right, PyCompare)
 and left.complist[-1] is right.complist[0]
  py_and= PyCompare(left.complist + right.complist[1:])if cond
  else: py_and = PyBooleanAnd(left, right)
Colin W.

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


Re: how to format long if conditions

2011-08-27 Thread Colin J. Williams

On 27-Aug-11 11:53 AM, Hans Mulder wrote:

On 27/08/11 17:16:51, Colin J. Williams wrote:


What about:
cond= isinstance(left, PyCompare)
and isinstance(right, PyCompare)
and left.complist[-1] is right.complist[0]
py_and= PyCompare(left.complist + right.complist[1:])if cond
else: py_and = PyBooleanAnd(left, right)
Colin W.


That's a syntax error. You need to add parenthesis.

How about:

cond = (
isinstance(left, PyCompare)
and isinstance(right, PyCompare)
and left.complist[-1] is right.complist[0]
}
py_and = (
PyCompare(left.complist + right.complist[1:])
if cond
else PyBooleanAnd(left, right)
)

-- HansM


I like your 11:53 message but suggest indenting the if cond as below to 
make it clearer that it, with the preceding line, is all one statement.


Colin W.

#!/usr/bin/env python
z= 1
class PyCompare:
complist = [True, False]
def __init__(self):
pass
left= PyCompare
right= PyCompare
def isinstance(a, b):
return True
def PyBooleanAnd(a, b):
return True
def PyCompare(a):
return False
z=2

def try1():

  '''Hans Mulder suggestion  03:50  '''
  if (
  isinstance(left, PyCompare)
  and isinstance(right, PyCompare)
  and left.complist[-1] is right.complist[0]
  ):
  py_and = PyCompare(left.complist + right.complist[1:])
  else:
  py_and = PyBooleanAnd(left, right)

def try2():
  '''cjw response - corrected  11:56  '''
  cond=  (isinstance(left, PyCompare)
 and isinstance(right, PyCompare)
 and left.complist[-1] is right.complist[0])
  py_and= (PyCompare(left.complist + right.complist[1:]) if cond
  else PyBooleanAnd(left, right))

def try3():
'''   Hans Mulder 11:53   '''
cond = (
isinstance(left, PyCompare)
and isinstance(right, PyCompare)
and left.complist[-1] is right.complist[0]
)  # not }
py_and = (
 PyCompare(left.complist + right.complist[1:])
 if   cond
 else PyBooleanAnd(left, right)
)
def main():
try1()
try2()
try3()
if __name__ == '__main__':
main()
pass
--
http://mail.python.org/mailman/listinfo/python-list


Re: Announcing a new podcast: Radio Free Python

2011-08-24 Thread Colin J. Williams

On 24-Aug-11 00:15 AM, Larry Hastings wrote:



Radio Free Python is a new monthly podcast focused on Python and its
community.

Episode 1 has just been released! It features a panel discussion with
the PythonLabs team:

  * Barry Warsaw,
  * Fred Drake,
  * Guido van Rossum,
  * Roger Masse,
  * and Tim Peters.


You can find it at http://www.radiofreepython.com/ as of this very minute.

Enjoy!


/larry/



+1

Colin W.

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


Re: python.org is down?

2011-07-24 Thread Colin J. Williams

On 24-Jul-11 03:43 AM, Laszlo Nagy wrote:

Can it be a problem on my side? I have tried from several different
computers. I cannot even ping it.


The same for me at Noon EST

Holland where are you?

Colin W.

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


Re: Function docstring as a local variable

2011-07-10 Thread Colin J. Williams

On 10-Jul-11 13:44 PM, rantingrick wrote:

On Jul 10, 12:41 pm, Tim Johnsont...@johnsons-web.com  wrote:

It possible for a function to print it's own docstring?


def f():
docstring
print docstring

any questions?


Try:

def f():
 ds= docstring
 print ds


Colin W.

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


Re: reg: playing with the list

2011-06-24 Thread Colin J. Williams

On 24-Jun-11 03:01 AM, kaustubh joshi wrote:

Hey all,
I am new here and new to python too. In general new to programming .
I was working on aproblem.
and need some help.
I have a list of numbers say [2,3,5,6,10,15]
which all divide number 30.
Now i have to reduce this list to the numbers which are prime in number.
i.e.
[2,3,5]
can somebody suggest?
K



You might try  writing the boolean function is_prime(n) for almost any n.

There was a recent discussion on this topic.

Colin W.

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


Re: Question about isodate

2011-05-28 Thread Colin J. Williams

On 26-May-11 07:48 AM, truongxuan quang wrote:

Hello list,

I am installing and testing istSOS wrote base on Python with its
extension like gdal, isodate, easy istall, setuptool, psycopg. I have
already installed all these stuff when I was using method POST the error
appear is _No module named mx.DateTime.ISO_ , could you please give me
your command and advice.

Many thanks

Quang

Does this help? 
http://www.google.com/url?sa=tsource=webcd=1ved=0CB0QFjAAurl=http%3A%2F%2Fwww.egenix.com%2Fproducts%2Fpython%2FmxBase%2FmxDateTime%2Frct=jq=mxdatetimeei=eengTYf5MM6EtgfdzeSoBwusg=AFQjCNEsnznUS1kZ_zAzbSxGlP2IF6BsTgsig2=3GgXQ9caWtvHTwzZoJOBuQcad=rja


Colin W.

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


Re: Beginner needs advice

2011-05-25 Thread Colin J. Williams

On 25-May-11 02:22 AM, Lew Schwartz wrote:

So, if I read between the lines correctly, you recommend Python 3? Does
the windows version install with a development environment?



It would be safer to stick with Python 2.7 initially and then consider 
the transition to 3.2 later.


No, there is not more than Idle.

PyScripter provides an excellent development environment.  See: 
http://en.wikipedia.org/wiki/PyScripter


Colin W.

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


Re: and becomes or and or becomes and

2011-05-23 Thread Colin J. Williams

On 22-May-11 15:23 PM, Stef Mientki wrote:

hello,

must of us will not use single bits these days,
but at first sight, this looks funny :


a=2
b=6
a and b

6

a  b

2

a or b

2

a | b

6

cheers,
Stef

5.2. Boolean Operations — and, or, not

These are the Boolean operations, ordered by ascending priority:
  Operation Result  Notes
x or y   if x is false, then y, else x  (1)
   x and y   if x is false, then x, else y  (2)
not xif x is false, then True, else False   (3)

The second line is puzzling at first look, but consistent.

It is analogous to the Conditional Expression.
See: 
http://docs.python.org/reference/expressions.html#conditional-expressions


Colin W.

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


Re: Function __defaults__

2011-04-25 Thread Colin J. Williams

On 24-Apr-11 13:07 PM, Ken Seehart wrote:

On 4/24/2011 2:58 AM, Steven D'Aprano wrote:

Consider this in Python 3.1:



def f(a=42):

... return a
...

f()

42

f.__defaults__ = (23,)
f()

23


Is this an accident of implementation, or can I trust that changing
function defaults in this fashion is guaranteed to work?


This is documented in python 3, so I would expect it to be stable (until
python 4, that is)
http://docs.python.org/py3k/whatsnew/3.0.html#operators-and-special-methods
http://docs.python.org/py3k/library/inspect.html#types-and-members

The f.__defaults__ attribute was previously known as f.func_defaults (in
python 2.x), which has been around, documented and stable for quite a
while.

So it's probably just as safe as any other monkey patching technique. :)

Best of luck,
Ken



Wouldn't it make more sense to return a dictionary instead of a tuple?

Colin W.

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


Re: Function __defaults__

2011-04-25 Thread Colin J. Williams

On 25-Apr-11 08:30 AM, Ken Seehart wrote:

On 4/25/2011 4:59 AM, Colin J. Williams wrote:

On 24-Apr-11 13:07 PM, Ken Seehart wrote:

On 4/24/2011 2:58 AM, Steven D'Aprano wrote:

Consider this in Python 3.1:



def f(a=42):

... return a
...

f()

42

f.__defaults__ = (23,)
f()

23


Is this an accident of implementation, or can I trust that changing
function defaults in this fashion is guaranteed to work?


This is documented in python 3, so I would expect it to be stable (until
python 4, that is)
http://docs.python.org/py3k/whatsnew/3.0.html#operators-and-special-methods

http://docs.python.org/py3k/library/inspect.html#types-and-members

The f.__defaults__ attribute was previously known as f.func_defaults (in
python 2.x), which has been around, documented and stable for quite a
while.

So it's probably just as safe as any other monkey patching technique. :)

Best of luck,
Ken



Wouldn't it make more sense to return a dictionary instead of a tuple?

Colin W.



I assume you mean making the value of f.__defaults__ a dictionary
instead of a tuple.

A dictionary would be slower to process since it would have to iterate
the dictionary keys and assign arguments by name.
Since argument defaults can only be applied to the rightmost contiguous
sequence of zero or more parameters (excluding *args,**kwargs), a tuple
is sufficient to cover all cases, so a dictionary would provide no
advantage.
Also, a dictionary would produce an unnecessary error case (if a key in
the dictionary is not the name of an argument).

Good question though.

Cheers,
Ken

I doubt that this functionality would be used in time critical work and 
so I suggest that efficiency is not a key consideration.


Loss of information is perhaps more important.  With the tuple being 
returned, the user is not informed that the value is associated with the 
name a


Colin W.

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


Re: Python IDE/text-editor

2011-04-16 Thread Colin J. Williams

On 15-Apr-11 23:20 PM, Alec Taylor wrote:

Good Afternoon,

I'm looking for an IDE which offers syntax-highlighting,
code-completion, tabs, an embedded interpreter and which is portable
(for running from USB on Windows).

Here's a mockup of the app I'm looking for: http://i52.tinypic.com/2uojswz.png

Which would you recommend?

Thanks in advance for any suggestions,

Alec Taylor


Here is an extract from the PyScripter Help:

PyScripter - a Python IDE



PyScripter originally started as a lightweight IDE designed to to serve 
the purpose of providing a strong scripting solution for Delphi 
applications, complementing the excellent Python for Delphi (P4D) 
components.  However, and with the encouragement of the P4D creator 
Morgan Martinez and a few early users, it has now evolved into a 
full-featured stand-alone Python IDE.  It is built in Delphi using P4D 
and the SynEdit component but is extensible using Python scripts. 
Currently, it is only available for Microsoft Windows operating systems 
and  features a modern user-interface. Being built in a compiled 
language is rather snappier than some of the other IDEs   and provides 
an extensive blend of features that make it a productive Python 
development environment.


Why yet another Python IDE?


There are many Python Integrated Development Environments around.  And 
quite a few good ones, for example PythonWin, Boa (a Delphi clone built 
for and with wxPython), SPE and Eric3, not to mention IDLE which is 
included in the standard Python distribution.  So it is reasonable to 
ask why bother to develop yet another Python IDE.  The short answer is 
for the fun of it!  The long answer relates to the ambition to create a 
Python IDE that is competitive with commercial Windows-based IDEs 
available for other languages.


It has the functionality that you seek.

Colin W.




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


Python IDE/text-editor

2011-04-16 Thread Colin J. Williams

On 15-Apr-11 23:20 PM, Alec Taylor wrote:
 Good Afternoon,

 I'm looking for an IDE which offers syntax-highlighting,
 code-completion, tabs, an embedded interpreter and which is portable
 (for running from USB on Windows).

 Here's a mockup of the app I'm looking for: http://i52.tinypic.com

 Which would you recommend?

 Thanks in advance for any suggestions,

 Alec Taylor

Here is an extract from the PyScripter Help:

PyScripter - a Python IDE



PyScripter originally started as a lightweight IDE designed to to serve 
the purpose of providing a strong scripting solution for Delphi 
applications, complementing the excellent Python for Delphi (P4D) 
components.  However, and with the encouragement of the P4D creator 
Morgan Martinez and a few early users, it has now evolved into a 
full-featured stand-alone Python IDE.  It is built in Delphi using P4D 
and the SynEdit component but is extensible using Python scripts. 
Currently, it is only available for Microsoft Windows operating systems 
and  features a modern user-interface. Being built in a compiled 
language is rather snappier than some of the other IDEs   and provides 
an extensive blend of features that make it a productive Python 
development environment.


Why yet another Python IDE?


There are many Python Integrated Development Environments around.  And 
quite a few good ones, for example PythonWin, Boa (a Delphi clone built 
for and with wxPython), SPE and Eric3, not to mention IDLE which is 
included in the standard Python distribution.  So it is reasonable to 
ask why bother to develop yet another Python IDE.  The short answer is 
for the fun of it!  The long answer relates to the ambition to create a 
Python IDE that is competitive with commercial Windows-based IDEs 
available for other languages.


It has the functionality that you seek.

Colin W.




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


Re: Feature suggestion -- return if true

2011-04-12 Thread Colin J. Williams

On 12-Apr-11 06:55 AM, scattered wrote:

On Apr 12, 2:21 am, James Millsprolo...@shortcircuit.net.au  wrote:

On Tue, Apr 12, 2011 at 4:08 PM, Nobodynob...@nowhere.com  wrote:

It should be abundantly clear that this only returns if the expression is
considered true, otherwise it continues on to the following statements.


Uggh come on guys. We've been over this.
You cannot make that assumption.

cheers
James

--
-- James Mills
--
-- Problems are solved by method


I'm puzzled as to why you seem to be parsing the OP's statements
different from everybody else. The only assumption that people other
than you seem to be making is that they are assuming that the OP meant
what he said. He *gave* a definition of what he meant by return? and
the definition he actually gave has the property that it terminates
the function only when the condition is true, whereas your suggested
translation *always* terminates the function call. I agree with
Nobody that the OP's intention was abundantly clear. Your return
expr or None suggestion was not an unreasonable try - but it doesn't
provide something which is equivalent to what the OP gave. On the
other hand, your persistence in defending your original statement as a
plausible translation of return? after the difference has been pointed
out by various posters *is* starting to become unreasonable.


In my view, the suggestion would add complexity to the language without 
sufficient benefit.


Colin W.



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


Re: Argument of the bool function

2011-04-10 Thread Colin J. Williams

On 10-Apr-11 12:21 PM, Mel wrote:

Chris Angelico wrote:


Who would use keyword arguments with a function that takes only one arg
anyway?


It's hard to imagine.  Maybe somebody trying to generalize function calls
(trying to interpret some other language using a python program?)

# e.g. input winds up having the effect of ..
function = bool
name = 'x'
value = 'the well at the end of the world'
## ...
actions.append ((function, {name:value}))
## ...
for function, args in actions:
 results.append (function (**args))

Not something I, for one, do every day.  But regularity in a language is
good when you can get it, especially for abstract things like that.

I can sort of guess that `dir` was perhaps coded in C for speed and doesn't
spend time looking for complicated argument lists.

Python is a pragmatic language, so all the rules come pre-broken.


Mel.

This thread has lasted 3 days so far.

I presume that it is agreed they the following is a satisfactory outcome:

*** Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit 
(Intel)] on win32. ***

 bool(x=0)
False
 bool(x=1)
True


Colin W.

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


Re: Python benefits over Cobra

2011-04-05 Thread Colin J. Williams

On 05-Apr-11 06:22 AM, Brendan Simon (eTRIX) wrote:

I just came across the Cobra language, which appears to be heavily
influenced by Python (and other languages). The pitch sounds great. It's
supposed to have:

   1. Quick, expressive coding
   2. Fast execution
   3. Static and dynamic binding
   4. Language level support for quality


http://cobra-language.com/docs/why/

http://cobra-language.com/docs/python/

I was wondering what advantages Python has over Cobra. I know it's
probably a difficult question to answer and depends on specific
requirements. All I can think of is:

* Maturity of language
  o Robust and tested.
  o availability of modules (standard and built-in).
  o large community support (commercial and non-commercial).
* No dependence of .NET/Mono
  o I don't know if this is an pro or con as I don't know .NET.


Presumably the maturity argument would be less significant over time.

I'm not sure about the .NET/Mono framework, whether that is good or bad.
Sounds good in some situations at least.

Any other arguments where Python has benefits over Cobra ??

Cheers, Brendan.


Two questions:
   1. Is Cobra Open Source?
   2. The blog ended on October, did he run out of steam?

I liked the '.', in place of '.self', but that's been rejected for Python.

Colin W.


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


Python Tutorial

2011-03-27 Thread Colin J. Williams

I have come across: http://www.java2s.com/Tutorial/Python/CatalogPython.htm

On a quick skim, the above seems to cover more ground
than the standard: http://docs.python.org/tutorial/

I spotted one bug in the former, but one of the Network
examples was helpful.

Colin W.

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


Re: in house pypi?

2011-03-25 Thread Colin J. Williams

On 24-Mar-11 03:13 AM, John Nagle wrote:

On 3/23/2011 8:19 PM, Miki Tebeka wrote:

Greetings,

My company want to distribute Python packages internally. We would
like something like an internal PyPi where people can upload and
easy_install from packages.

Is there such a ready made solution? I'd like something as simple as
possible, without my install headache.

Thanks, -- Miki


PyPi isn't a code repository, like CPAN or SourceForge.
It's mostly a collection of links.

Take a look at CPAN, Perl's package repository. That's
well organized and useful. Modules are stored in a common archive
after an approval process, and can be downloaded and installed
in a standard way.

easy_install generally isn't easy. It has some built-in
assumptions about where things are stored, assumptions which
often don't hold true.

John Nagle


I've not found problems with easy_install using Windows.

Colin W.

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


Re: Could I joined in this Happy family

2011-03-20 Thread Colin J. Williams
On 18-Mar-11 15:47 PM, Nick Stinemates wrote:
 Welcome aboard !
 
 On Mar 18, 2011 11:34 AM, duxiu xiang xiangduxi...@gmail.com 
 mailto:xiangduxi...@gmail.com wrote:
   Dear friends:
   I am in China.For some rearon,I cannot visit your Google Group.May
   I joint this mail list for help in learning Python?
  
   --
   笑看嫣红染半山,逐风万里白云间。
 
You might try: http://gmane.org/

Colin W.

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


Re: Python getting stuck

2011-02-27 Thread Colin J. Williams

On 26-Feb-11 18:55 PM, Shanush Premathasarathan wrote:

Hi All,

When I use cut, copy, paste, and any keyboard shortcuts, Python freezes and I 
am unable to use Python. Please Help as quick as possible!!!

Thanks a lot.

Kind Regards
Big Python fan!
Shanush


What operating system are you using?

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


Re: lxml

2011-02-25 Thread Colin J. Williams

On 24-Feb-11 19:39 PM, alex23 wrote:

On Feb 24, 6:20 pm, Stefan Behnelstefan...@behnel.de  wrote:

MRAB, 24.02.2011 01:25:

The latest stable release is here:



http://pypi.python.org/pypi/lxml/2.2.8


Not quite the latest stable release (that would be 2.3), but at least one
that's pre-built for Windows.


Christoph Gohlke has an 'unofficial' Window's binaries site that
includes lxml 2.3 for Python 2.6, 2.7, 3.1 and 3.1:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml

Very handy site.


Thanks,

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


Re: lxml

2011-02-24 Thread Colin J. Williams

On 24-Feb-11 03:20 AM, Stefan Behnel wrote:

MRAB, 24.02.2011 01:25:

On 24/02/2011 00:10, Colin J. Williams wrote:

Could someone please let me know whether lxml is available for Windows
XP?. If so, is it available for Python 2.7?


The latest stable release is here:

http://pypi.python.org/pypi/lxml/2.2.8


Not quite the latest stable release (that would be 2.3), but at least
one that's pre-built for Windows.

Stefan


Thanks to both respondents.  I had tried easy_install before.

It now looks clean and importable.

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


lxml

2011-02-23 Thread Colin J. Williams
Could someone please let me know whether lxml is available for Windows 
XP?.  If so, is it available for Python 2.7?


Thanks,

Colin W.

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


Re: EPD 7.0 released

2011-02-14 Thread Colin J. Williams

On 14-Feb-11 06:59 AM, sturlamolden wrote:

On 14 Feb, 01:50, Robert Kernrobert.k...@gmail.com  wrote:


I'd just like to jump in here to clear up this last statement as an Enthought
employee. While Enthought and its employees do contribute to the development of
numpy and scipy in various ways (and paying us money is a great way to let us do
more of it!), there is no direct relationship to the revenue we get from EPD
subscriptions and our contributions to numpy and scipy.


But you do host the website, and several key NumPy and SciPy
developers work for you. And NumPy and SciPy would not have reached
the current maturity without Enthought. I know that you have
commercial insterests in the current restructuring of NumPy (such as
making it available for .NET), but it does help the development of
NumPy as well.

Enthought EPD also helps NumPy/SciPy indirectly, by making Python a
viable alternative to Matlab:

* Just having one big installer instead of 100 is why I'm allowed to
use Python instead of Matlab. Others might have to use my programs, so
the runtime cannot take a man year to install.

* A myriad of installers is a big deterrent for any scientist
considering to use Python.

* Intel MKL instead of reference LAPACK (actually lapack_lite) make
EPD very fast for matrix computations.

* It has a 64-bit version (as opposed to only 32-bit in the official
SciPy installer; that might have changed now.)

* We don't have to know which libraries are important and/or spend
time search for them.

* It comes with C, C++ and Fortran compilers (GCC) preconfigured to
work with distutils, link correctly, etc.


Sturla


The purchase price for what, until now, has been open source and free 
seems high.


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


Re: Which is the best book to learn python

2011-01-24 Thread Colin J. Williams

On 24-Jan-11 12:38 PM, Jean-Michel Pichavant wrote:

santosh hs wrote:

Hi All,
i am beginner to python please tell me which is the best available
reference for beginner to start from novice


Hi,

You could have searched the archive, this question was raised many times.

http://wiki.python.org/moin/IntroductoryBooks

I read Learning Python when I started. Since it's the only one I read
I cannot tell you which one is the best (if there is).
Python is easy to learn, I'm not sure it's possible to write a bad book
about it.

JM


I liked Alex Martelli's Python in a nutshell, but it's a bit dated now.

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


Re: python 3 and Unicode line breaking

2011-01-14 Thread Colin J. Williams

On 14-Jan-11 14:47 PM, Antoine Pitrou wrote:


Hey,

On 14 Jan 2011 16:07:12 GMT
Steven D'Apranosteve+comp.lang.pyt...@pearwood.info  wrote:



I also see no reason to reply to a simple question with such
discourtesy, and cannot understand why someone would be so aggressive to
a stranger.


If you think my reply was aggressive and discourteous, you've got a lot
to learn about public forums.


Perhaps you've got to learn about politeness yourself! Just because
some people are jerks on internet forums (or in real life) doesn't mean
everyone should; this is quite a stupid and antisocial excuse actually.

You would never have reacted this way if the same question had been
phrased by a regular poster here (let alone on python-dev). Taking
cheap shots at newcomers is certainly not the best way to welcome
them.

Thank you

Antoine.



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


  1   2   3   4   5   >