Click Here
home features news forums classifieds faqs links search
6071 members 
Amiga Q&A /  Free for All /  Emulation /  Gaming / (Latest Posts)
Login

Nickname

Password

Lost Password?

Don't have an account yet?
Register now!

Support Amigaworld.net
Your support is needed and is appreciated as Amigaworld.net is primarily dependent upon the support of its users.
Donate

Menu
Main sections
» Home
» Features
» News
» Forums
» Classifieds
» Links
» Downloads
Extras
» OS4 Zone
» IRC Network
» AmigaWorld Radio
» Newsfeed
» Top Members
» Amiga Dealers
Information
» About Us
» FAQs
» Advertise
» Polls
» Terms of Service
» Search

IRC Channel
Server: irc.amigaworld.net
Ports: 1024,5555, 6665-6669
SSL port: 6697
Channel: #Amigaworld
Channel Policy and Guidelines

Who's Online
25 crawler(s) on-line.
 156 guest(s) on-line.
 0 member(s) on-line.



You are an anonymous user.
Register Now!
 DiscreetFX:  5 mins ago
 Hypex:  14 mins ago
 AndreasM:  14 mins ago
 kolla:  23 mins ago
 Gunnar:  35 mins ago
 saimo:  1 hr 23 mins ago
 amigakit:  1 hr 42 mins ago
 OldFart:  1 hr 42 mins ago
 _ThEcRoW:  2 hrs 2 mins ago
 NutsAboutAmiga:  2 hrs 29 mins ago

/  Forum Index
   /  Amiga OS4.x \ Workbench 4.x
      /  Python issues
Register To Post

PosterThread
ggw 
Python issues
Posted on 21-Jul-2007 22:06:57
#1 ]
Super Member
Joined: 24-May-2003
Posts: 1106
From: Austin, TX

@all

PYTHONPATH is usable, but not as advertized. In order to have Amiga Python2.5.1 find your own scripts you must add to the end of:

SetEnv PYTHONPATH PYTHON:Lib,PYTHON:Lib/lib-dynload

= = = = = = = = = Details = = = = = = = = = = = = = = = = = =
Here is my investigation.

First the normal...
8.Work1:> unSetEnv PYTHONPATH
8.Work1:> python
Python 2.5.1 (r251:54863, Jun 23 2007, 15:21:14)
[GCC 4.0.4 (AmigaOS build 20070219)] on ppc-amiga
Type "help", "copyright", "credits" or "license" for more information.
>>> import pydoc
>>>^/

Everywhere I read, the claim is that PYTHONPATH augments (not replace) the places that python searchs for modules.

The supposed default of PYTHON:Lib results in troubles.
8.Work1:> SetEnv PYTHONPATH PYTHON:Lib
8.Work1:> python
Python 2.5.1 (r251:54863, Jun 23 2007, 15:21:14)
[GCC 4.0.4 (AmigaOS build 20070219)] on ppc-amiga
Type "help", "copyright", "credits" or "license" for more information.
>>> import pydoc
Traceback (most recent call last):
File "", line 1, in
File "PYTHON:lib/pydoc.py", line 55, in
import sys, imp, os, re, types, inspect, __builtin__, pkgutil
File "PYTHON:lib/inspect.py", line 32, in
from operator import attrgetter
ImportError: No module named operator
>>>^\
8.Work1:>

operator is, as of this release, here:

8.Work1:> list python:lib/lib-dynload/operator#?
Directory "python:lib/lib-dynload" on Saturday 21-Jul-07
operator.so 95103 ----rwed 23-Jun-07 14:21:56
1 file - 92K bytes - 49 blocks used

This works better:
8.Work1:> SetEnv PYTHONPATH PYTHON:Lib,PYTHON:Lib/lib-dynload
8.Work1:> python
Python 2.5.1 (r251:54863, Jun 23 2007, 15:21:14)
[GCC 4.0.4 (AmigaOS build 20070219)] on ppc-amiga
Type "help", "copyright", "credits" or "license" for more information.
>>> import pydoc
>>>^\

So I conclude the docs are wrong about the default for PYTHONPATH. It would seem that it does replace, not augment, and it has both directories, instead of just the 1st one.

Armed with this information I can now inform python where I am keeping my python scripts:

SetEnv PYTHONPATH PYTHON:Lib,PYTHON:Lib/lib-dynload,Work1:py

George Wyche

_________________
..effects of civilization upon...nature, the growing gap between what education was supposed to accomplish and what it consisted of, the national debt and...high taxes, the problem of the excess cost of medical care -- Philip Wylie, 1951

 Status: Offline
Profile     Report this post  
yak 
Re: Python issues
Posted on 22-Jul-2007 1:21:31
#2 ]
Regular Member
Joined: 15-Mar-2006
Posts: 322
From: Bochum, Germany

@ggw

The "sys" module contains a "path" list. Normally it contains paths where Python searches for modules. You might want to check what's there after you start python.

To do this start it and type:

import sys
sys.path

 Status: Offline
Profile     Report this post  
ggw 
Re: Python issues
Posted on 22-Jul-2007 15:09:28
#3 ]
Super Member
Joined: 24-May-2003
Posts: 1106
From: Austin, TX

@yak

Sorry, but I'm missing your point in connection with PYTHONPATH.

ggw

_________________
..effects of civilization upon...nature, the growing gap between what education was supposed to accomplish and what it consisted of, the national debt and...high taxes, the problem of the excess cost of medical care -- Philip Wylie, 1951

 Status: Offline
Profile     Report this post  
broadblues 
Re: Python issues
Posted on 22-Jul-2007 18:37:36
#4 ]
Amiga Developer Team
Joined: 20-Jul-2004
Posts: 4446
From: Portsmouth England

@ggw
Quote:

Everywhere I read, the claim is that PYTHONPATH augments (not replace) the places that python searchs for modules.


Where is everywhere? The document "Amiga Python.pdf" does not state that PYTHONPATH augments, but says it a commas seperated list of search paths.

I know python is not perl but perl behaves exactly like this I'm not suprised by what you find.

BTW

If you do the sys.path thing metioned above you get the path:-

['', 'PYTHON:lib/', 'PYTHON:lib/lib-dynload/', 'PYTHON:lib/plat-amiga/']

Doing this would have saved a bit of research



_________________
BroadBlues On Blues BroadBlues On Amiga Walker Broad

 Status: Offline
Profile     Report this post  
mwoof 
Re: Python issues
Posted on 24-Jul-2007 21:40:12
#5 ]
Super Member
Joined: 12-Jan-2004
Posts: 1174
From: Larisa, Greece

@ggw

I have a complaint about Python! It doesn't seem to be platform independent!! I tried running some apps, e.g a couple of IDEs, written in Python and got platform-specific errors!

_________________
And may the AmigaGuide you!

AmigaOne G3-SE, OS4 Final (July 2007 update), Debian Sarge, 512 MB RAM, 20 + 80 GB hard disks, NEC 3540 DVD writer, LG DVD reader, Radeon 9250, SB Live, Intracom Netfaster router, PCI USB card (NEC - OHCI/EHCI)

 Status: Offline
Profile     Report this post  
Samurai_Crow 
Re: Python issues
Posted on 24-Jul-2007 22:23:32
#6 ]
Elite Member
Joined: 18-Jan-2003
Posts: 2320
From: Minnesota, USA

@mwoof

I don't know of any Python IDEs that use Amiga-supported GUIs at this time.

 Status: Offline
Profile     Report this post  
abalaban 
Re: Python issues
Posted on 25-Jul-2007 11:47:45
#7 ]
Super Member
Joined: 1-Oct-2004
Posts: 1114
From: France

@Samurai_Crow

I don't know any Python GUI supported by AmigaPython yet.

_________________
AOS 4.1 : I dream it, Hyperion did it !
Now dreaming AOS 4.2...
Thank you to all devs involved for this great job !

 Status: Offline
Profile     Report this post  
mwoof 
Re: Python issues
Posted on 25-Jul-2007 12:01:03
#8 ]
Super Member
Joined: 12-Jan-2004
Posts: 1174
From: Larisa, Greece

@abalaban, Samurai_Crow



Who can compile Java, at least for Cygnix? Or alternatively, if some X or Windose libraries can be ported to Python...

_________________
And may the AmigaGuide you!

AmigaOne G3-SE, OS4 Final (July 2007 update), Debian Sarge, 512 MB RAM, 20 + 80 GB hard disks, NEC 3540 DVD writer, LG DVD reader, Radeon 9250, SB Live, Intracom Netfaster router, PCI USB card (NEC - OHCI/EHCI)

 Status: Offline
Profile     Report this post  
Rogue 
Re: Python issues
Posted on 25-Jul-2007 12:50:06
#9 ]
OS4 Core Developer
Joined: 14-Jul-2003
Posts: 3999
From: Unknown

@ggw

Quote:
Everywhere I read, the claim is that PYTHONPATH augments (not replace) the places that python searchs for modules.


From my understanding, PYTHONPATH specifies the search path, replacing the whole of the search path not adding to it.

_________________
Seriously, if you want to contact me do not bother sending me a PM here. Write me a mail

 Status: Offline
Profile     Report this post  
Rogue 
Re: Python issues
Posted on 25-Jul-2007 12:54:48
#10 ]
OS4 Core Developer
Joined: 14-Jul-2003
Posts: 3999
From: Unknown

@mwoof

Quote:

mwoof wrote:
@ggw

I have a complaint about Python! It doesn't seem to be platform independent!! I tried running some apps, e.g a couple of IDEs, written in Python and got platform-specific errors!


Er...

Python is not platform-independent. You will see that there are a number of platform-dependent modules. For a lot of applications and for IDLE (the IDE) you will need the tkinter module, and that required TCL/Tk, which depends on X. There is a Windows port, but I don't think I'll touch that.

I plan to do a Reaction module at one point, but that has low priority.

_________________
Seriously, if you want to contact me do not bother sending me a PM here. Write me a mail

 Status: Offline
Profile     Report this post  
ggw 
Re: Python issues
Posted on 25-Jul-2007 15:11:08
#11 ]
Super Member
Joined: 24-May-2003
Posts: 1106
From: Austin, TX

@Rogue

Thank you so much for this native OS4 port of Python. It has not failed me yet. All of my command line scripts are usable.

I did figure out the PYTHONPATH for myself. If *I* can do that, anyone can. I had foolishly googled PYTHONPATH after my naive failure to cite the new dynamic libraries, and the 1st reference I read used the word "augment". The official python tutorial is clear that PYTHONPATH, if present, if *the* final authority for all modules. My faux pas.

Soon I will approach further use of python inside a program via this AmigaOne.

Did I understand that there is a thought out there for arranging programs with Python friendly internal commands just as there are ARexx such?

ggw

_________________
..effects of civilization upon...nature, the growing gap between what education was supposed to accomplish and what it consisted of, the national debt and...high taxes, the problem of the excess cost of medical care -- Philip Wylie, 1951

 Status: Offline
Profile     Report this post  
Rogue 
Re: Python issues
Posted on 25-Jul-2007 15:40:48
#12 ]
OS4 Core Developer
Joined: 14-Jul-2003
Posts: 3999
From: Unknown

@ggw

Quote:
Did I understand that there is a thought out there for arranging programs with Python friendly internal commands just as there are ARexx such?


The idea is, at a certain point in the development process, to develop a system that allows a two-way interfacing - from an application point of view and a scripting language point of view...

Think of it as some kind of mediator between a scripting language and an application.

The idea is to allow an application to set up a set of commands/interfaces/data objects for external scripts, and have external script interpreters such as python or ruby or TCL represent these as commands/data objects.

As an example, a paint program might have a PICTURE data object with a few methods (say READPIXEL and WRITEPIXEL). From a python script, you could do something like


---
import paintprogram

p = paintprogram.getPicture("name");
p.writePixel(100, 100, r,g,b);
r,g,b = p.readPixel(100, 100);
---

something like that. The same would work with e.g. RUBY or TCL or REXX.

The basic idea is to replace AREXX by something broader that does not force people into learning a specific language but allow them to pick their scripting language, or even develop their own.

_________________
Seriously, if you want to contact me do not bother sending me a PM here. Write me a mail

 Status: Offline
Profile     Report this post  
ggw 
Re: Python issues
Posted on 26-Jul-2007 17:43:16
#13 ]
Super Member
Joined: 24-May-2003
Posts: 1106
From: Austin, TX

I cannot get the date into ts. Why not?

ViNCEd Version 3.73 © 1990-2000 THOR-Software.
New Shell process 2
2.Work1:Wyche/george/2007> python
Python 2.5.1 (r251:54863, Jun 23 2007, 15:21:14)
[GCC 4.0.4 (AmigaOS build 20070219)] on ppc-amiga
Type "help", "copyright", "credits" or "license" for more information.
>>> from time import strptime
>>> ts=strptime('2007-07-26','%Y-%m-%d')
Traceback (most recent call last):
File "", line 1, in
File "SYS:System/Python/Lib/_strptime.py", line 272, in
_TimeRE_cache = TimeRE()
File "SYS:System/Python/Lib/_strptime.py", line 191, in __init__
self.locale_time = LocaleTime()
File "SYS:System/Python/Lib/_strptime.py", line 77, in __init__
self.__calc_timezone()
File "SYS:System/Python/Lib/_strptime.py", line 171, in __calc_timezone
no_saving = frozenset(["utc", "gmt", time.tzname[0].lower()])
AttributeError: 'module' object has no attribute 'tzname'
>>>


_________________
..effects of civilization upon...nature, the growing gap between what education was supposed to accomplish and what it consisted of, the national debt and...high taxes, the problem of the excess cost of medical care -- Philip Wylie, 1951

 Status: Offline
Profile     Report this post  
Snuffy 
Re: Python issues
Posted on 26-Jul-2007 18:00:47
#14 ]
Super Member
Joined: 25-Oct-2005
Posts: 1121
From: Michigan, USA

Hi @ggw

>>>> Import.os

Before you kill me with questions, I d/l'ed the 2.5 Docs from here:

http://docs.python.org/download.html

I think it should of been included in the JulyUpdate!

Last edited by Snuffy on 26-Jul-2007 at 06:01 PM.

_________________

 Status: Offline
Profile     Report this post  
yak 
Re: Python issues
Posted on 26-Jul-2007 19:26:13
#15 ]
Regular Member
Joined: 15-Mar-2006
Posts: 322
From: Bochum, Germany

@ggw

This does seem like a bug. It looks like there is no 'tzname' variable in 'time' module.

 Status: Offline
Profile     Report this post  
ggw 
Re: Python issues
Posted on 26-Jul-2007 19:53:58
#16 ]
Super Member
Joined: 24-May-2003
Posts: 1106
From: Austin, TX

@Snuffy

Yes sir. I have that.

In general my head is back at Python 2.3, so I have the new docs from python.org

Thanks,
ggw

_________________
..effects of civilization upon...nature, the growing gap between what education was supposed to accomplish and what it consisted of, the national debt and...high taxes, the problem of the excess cost of medical care -- Philip Wylie, 1951

 Status: Offline
Profile     Report this post  
ggw 
Re: Python issues
Posted on 6-Aug-2007 14:57:00
#17 ]
Super Member
Joined: 24-May-2003
Posts: 1106
From: Austin, TX

@yak

I can get today's date via

import time
print time.asctime(time.localtime(time.time()))

I can also subtract 6*3600 to get my true local time.

Are we at the mercy of Rogue to improve our situation so that the tzname stuff gets into Python2.5.1 ? If so, I'll email him with this bug.

I suppose I should find the test suite setup and test the whole thing...

One more curiosity. The above print results in a time that is 5 minutes behind the actual time. Strange.

ggw

_________________
..effects of civilization upon...nature, the growing gap between what education was supposed to accomplish and what it consisted of, the national debt and...high taxes, the problem of the excess cost of medical care -- Philip Wylie, 1951

 Status: Offline
Profile     Report this post  
ggw 
Re: Python issues
Posted on 14-Aug-2007 17:45:29
#18 ]
Super Member
Joined: 24-May-2003
Posts: 1106
From: Austin, TX

@Rogue

Amiga Python 2.5.1 passes 193 official tests
4 tests crash python into the Grim Reaper
49 tests Failed
69 tests were skipped
80 tests I deemed as inappropriate for AmigaOS4 like those needing unicode, thread, WINDOWS or SUN for instance.

There are some very important features among those 49 Failures.

I have 2 files, too large to paste here.
1) pytestlist.txt has 640 lines and is a list suitable for running of files that pass. A small bit of editing can enable which ever tests.
2) Pythontest.txt has 4078 lines with Crash output for the 4 tests which caused the crashes.

It is my understanding that your Amiga Python is proprietary. I'm not sure who owns it now or who will own it in the near(ish) future. I have no feeling for what is helpful for "us" to do to help Amiga Python be better.

I would be glad to send these files to whoever would like them, or post them somewhere convenient. Any suggestions, encouragement, or advice is welcome.

Sincerely,

_________________
..effects of civilization upon...nature, the growing gap between what education was supposed to accomplish and what it consisted of, the national debt and...high taxes, the problem of the excess cost of medical care -- Philip Wylie, 1951

 Status: Offline
Profile     Report this post  
ggw 
Re: Python issues
Posted on 21-Aug-2007 14:21:51
#19 ]
Super Member
Joined: 24-May-2003
Posts: 1106
From: Austin, TX

@yak

Quote:
This does seem like a bug. It looks like there is no 'tzname' variable in 'time' module.


Well, Sunday I gave up on Python 2.5.1 and have chosen to revert to the emulation mode for Python 2.0.

ggw

_________________
..effects of civilization upon...nature, the growing gap between what education was supposed to accomplish and what it consisted of, the national debt and...high taxes, the problem of the excess cost of medical care -- Philip Wylie, 1951

 Status: Offline
Profile     Report this post  

[ home ][ about us ][ privacy ] [ forums ][ classifieds ] [ links ][ news archive ] [ link to us ][ user account ]
Copyright (C) 2000 - 2019 Amigaworld.net.
Amigaworld.net was originally founded by David Doyle