Trying to understand 'import' a bit better

2012-03-04 Thread Frank Millman
Hi all

I have been using 'import' for ages without particularly thinking about it - 
it just works.

Now I am having to think about it a bit harder, and I realise it is a bit 
more complicated than I had realised - not *that* complicated, but there are 
some subtleties.

I don't know the correct terminology, but I want to distinguish between the 
following two scenarios -

1. A python 'program', that is self contained, has some kind of startup, 
invokes certain functionality, and then closes.

2. A python 'library', that exposes functionality to other python programs, 
but relies on the other program to invoke its functionality.

The first scenario has the following characteristics -
  - it can consist of a single script or a number of modules
  - if the latter, the modules can all be in the same directory, or in one 
or more sub-directories
  - if they are in sub-directories, the sub-directory must contain 
__init__.py, and is referred to as a sub-package
  - the startup script will normally be in the top directory, and will be 
executed directly by the user

When python executes a script, it automatically places the directory 
containing the script into 'sys.path'. Therefore the script can import a 
top-level module using 'import ', and a sub-package module using 
'import .'.

The second scenario has similar characteristics, except it will not have a 
startup script. In order for a python program to make use of the library, it 
has to import it. In order for python to find it, the directory containing 
it has to be in sys.path. In order for python to recognise the directory as 
a valid container, it has to contain __init__.py, and is referred to as a 
package.

To access a module of the package, the python program must use 'import 
.' (or 'from  import '), and to access a 
sub-package module it must use 'import ...

So far so uncontroversial (I hope).

The subtlety arises when the package wants to access its own modules. 
Instead of using 'import ' it must use 'import .'. 
This is because the directory containing the package is in sys.path, but the 
package itself is not. It is possible to insert the package directory name 
into sys.path as well, but as was pointed out recently, this is dangerous, 
because you can end up with the same module imported twice under different 
names, with potentially disastrous consequences.

Therefore, as I see it, if you are developing a project using scenario 1 
above, and then want to change it to scenario 2, you have to go through the 
entire project and change all import references by prepending the package 
name.

Have I got this right?

Frank Millman



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


Jython callable. How?

2012-03-04 Thread Sirotin Roman
Hi.
How exactly jython decides is object callable or not? I defined
__call__ method but interpreter says it's still not callable.
BTW, my code works in cpython
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jython callable. How?

2012-03-04 Thread Arnaud Delobelle
On Mar 4, 2012 9:04 AM, "Sirotin Roman"  wrote:
>
> Hi.
> How exactly jython decides is object callable or not? I defined
> __call__ method but interpreter says it's still not callable.
> BTW, my code works in cpython

It will help if you show us the code.

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


Re: Jython callable. How?

2012-03-04 Thread Steven D'Aprano
On Sun, 04 Mar 2012 16:03:56 +0700, Sirotin Roman wrote:

> Hi.
> How exactly jython decides is object callable or not? I defined __call__
> method but interpreter says it's still not callable. BTW, my code works
> in cpython

Works for me.

steve@runes:~$ jython
*sys-package-mgr*: processing modified jar, '/usr/share/java/servlet-
api-2.5.jar'
Jython 2.5.1+ (Release_2_5_1, Aug 4 2010, 07:18:19)
[OpenJDK Client VM (Sun Microsystems Inc.)] on java1.6.0_18
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> class Test:
... def __call__(self):
... return 42
...
>>>
>>> x = Test()
>>> x()
42


Perhaps if you show us what you actually do, and what happens, we might 
be able to tell you what is happening. Please COPY AND PASTE the full 
traceback.



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


How to convert simple B/W graphic to the dot matrix for the LED display/sign

2012-03-04 Thread Petr Jakes
I would like to convert simple B/W graphic to the 432x64 pixel matrix.
It is intended to display this graphic on the one color LED matrix
sign/display (432 LEDs width, 64 LEDs height).
I am experimenting with the PIL, but I did not find solution there.

It will be really helpful If somebody here can show me the direction
to go?

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


Re: How to convert simple B/W graphic to the dot matrix for the LED display/sign

2012-03-04 Thread Steven D'Aprano
On Sun, 04 Mar 2012 02:28:16 -0800, Petr Jakes wrote:

> I would like to convert simple B/W graphic to the 432x64 pixel matrix.
> It is intended to display this graphic on the one color LED matrix
> sign/display (432 LEDs width, 64 LEDs height). I am experimenting with
> the PIL, but I did not find solution there.
> 
> It will be really helpful If somebody here can show me the direction to
> go?

What file format is the graphic in? How big is it?

What file format do you want it to be?


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


Re: A possible change to decimal.Decimal?

2012-03-04 Thread A. Lloyd Flanagan
On Friday, March 2, 2012 6:49:39 PM UTC-5, Ethan Furman wrote:
> Jeff Beardsley wrote:
> > HISTORY:  
...
> 
> What you should be doing is:
> 
>import decimal
>from decimal import Decimal
> 
>reload(decimal)
>Decimal = decimal.Decimal   # (rebind 'Decimal' to the reloaded code)
> 
> ~Ethan~

Agree that's how the import should be done. On the other hand, removing 
gratuitous use of isinstance() is generally a Good Thing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to convert simple B/W graphic to the dot matrix for the LED display/sign

2012-03-04 Thread Petr Jakes

> What file format is the graphic in? How big is it?
>
> What file format do you want it to be?
>

Now, I am able to create the png file with the resolution 432x64 using
PIL (using draw.text method for example).

I would like to get the 432x64 True/False (Black/White) lookup table
from this file, so I can switch LEDs ON/OFF accordingly.

--
Petr

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


Re: Porting Python to an embedded system

2012-03-04 Thread Stefan Behnel
Justin Drake, 04.03.2012 11:58:
> I am working with an ARM Cortex M3 on which I need to port Python
> (without operating system). What would be my best approach? I just
> need the core Python and basic I/O.

The "without operating system" bit should prove problematic. Can't you just
install Linux on it?

Stefan

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


Re: Porting Python to an embedded system

2012-03-04 Thread Devin Jeanpierre
On Sun, Mar 4, 2012 at 5:58 AM, Justin Drake  wrote:
> I am working with an ARM Cortex M3 on which I need to port Python
> (without operating system). What would be my best approach? I just
> need the core Python and basic I/O.

How much time are you willing to budget to this? Porting something to
bare metal is not a small task. It's probably only worth it if you're
doing it for academic purposes. I expect for anything real-world it'd
be faster to do whatever it is you want to do using something that
already runs on the bare metal. (e.g. http://armpit.sourceforge.net/
for Scheme).

There used to be Flux OSKit ( http://www.cs.utah.edu/flux/oskit/ ) for
porting languages to bare metal, but it doesn't support ARM and it's
been dead a while. If you're really set on this, I'd try to see if
there's something similar out there, somewhere. 'cause writing an OS
from scratch would suck.

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


Re: Porting Python to an embedded system

2012-03-04 Thread TheSeeker
On Sunday, March 4, 2012 4:58:50 AM UTC-6, Justin Drake wrote:
> I am working with an ARM Cortex M3 on which I need to port Python
> (without operating system). What would be my best approach? I just
> need the core Python and basic I/O.

The python-on-a-chip project (p14p) (http://code.google.com/p/python-on-a-chip/)
might be something worth looking into.

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


Re: How to convert simple B/W graphic to the dot matrix for the LED display/sign

2012-03-04 Thread Max Erickson
Petr Jakes  wrote:

> 
>> What file format is the graphic in? How big is it?
>>
>> What file format do you want it to be?
>>
> 
> Now, I am able to create the png file with the resolution 432x64
> using PIL (using draw.text method for example).
> 
> I would like to get the 432x64 True/False (Black/White) lookup
> table from this file, so I can switch LEDs ON/OFF accordingly.
> 
> --
> Petr
> 

The convert and load methods are one way to do it:

>>> import Image
>>> im=Image.new('L', (100,100))
>>> im=im.convert('1')
>>> px=im.load()
>>> px[0,0]
0

That's the numeral one in the argument to convert. The load method 
returns a pixel access object.


Max

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


Re: Jython callable. How?

2012-03-04 Thread Sirotin Roman
> Perhaps if you show us what you actually do, and what happens, we might
> be able to tell you what is happening. Please COPY AND PASTE the full
> traceback.

Here is my code:
# Trying to make callable staticmethod

class sm(staticmethod):

   def __call__(self, *args, **kwargs):
   """ I know here is one more potential problem, because object
passed instead of real class """
   return self.__get__(None, object)(*args, **kwargs)

issubclass(sm, Callable)

class Foo(object):

   @sm
   def bar():
   print("ololo")

   print("inside", bar, callable(bar), bar())

if __name__=="__main__":
   print("class outise", Foo.bar, callable(Foo.bar), Foo.bar())
   f = Foo()
   print("instance outside", f.bar, callable(f.bar), f.bar())


cpython output:
ololo
('inside', <__main__.sm object at 0xb72b404c>, True, None)
ololo
('class outise', , True, None)
ololo
('instance outside', , True, None)

jython output:
Traceback (most recent call last):
 File "sm.py", line 17, in 
   class Foo(object):
 File "sm.py", line 23, in Foo
   print("inside", bar, callable(bar), bar())
TypeError: 'staticmethod' object is not callable
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The original command python line

2012-03-04 Thread Grant Edwards
On 2012-03-04, Chris Rebert  wrote:
> On Sat, Mar 3, 2012 at 9:38 PM, Damjan Georgievski  wrote:
>> How can I get the *really* original command line that started my python
>> interpreter?

> On Linux, you can read from:
> /proc//cmdline
> to get the null-delimited "command line".

And if what you want is your own command line, you can replace  with self:

/proc/self/cmdline

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


AttributeError: 'module' object has no attribute 'logger'

2012-03-04 Thread youssef . mahdia
hi all, when installing sage, there is a problem with emacs.py
so, this screen appeared after rynning ./sage
--
| Sage Version 4.4.2, Release Date: 2010-05-19   |
| Type notebook() for the GUI, and license() for information.|
--
Traceback (most recent call last):
  File "/home/zid/sage/local/bin/sage-ipython", line 18, in 
import IPython
  File "/usr/lib/python2.7/dist-packages/IPython/__init__.py", line
58, in 
__import__(name,glob,loc,[])
  File "/usr/lib/python2.7/dist-packages/IPython/ipstruct.py", line
17, in 
from IPython.genutils import list2dict2
  File "/usr/lib/python2.7/dist-packages/IPython/genutils.py", line
114, in 
import IPython.rlineimpl as readline
  File "/usr/lib/python2.7/dist-packages/IPython/rlineimpl.py", line
18, in 
from pyreadline import *
  File "/usr/local/lib/python2.7/dist-packages/pyreadline-2.0_dev1-
py2.7.egg/pyreadline/__init__.py", line 11, in 
from . import unicode_helper, logger, clipboard, lineeditor,
modes, console
  File "/usr/local/lib/python2.7/dist-packages/pyreadline-2.0_dev1-
py2.7.egg/pyreadline/modes/__init__.py", line 3, in 
from . import emacs, notemacs, vi
  File "/usr/local/lib/python2.7/dist-packages/pyreadline-2.0_dev1-
py2.7.egg/pyreadline/modes/emacs.py", line 11, in 
import pyreadline.logger as logger
AttributeError: 'module' object has no attribute 'logger'



any one can help me pleas

regards
Zid






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


Re: A possible change to decimal.Decimal?

2012-03-04 Thread Ethan Furman

A. Lloyd Flanagan wrote:

On Friday, March 2, 2012 6:49:39 PM UTC-5, Ethan Furman wrote:

Jeff Beardsley wrote:
HISTORY:  

...

What you should be doing is:

   import decimal
   from decimal import Decimal

   reload(decimal)
   Decimal = decimal.Decimal   # (rebind 'Decimal' to the reloaded code)

~Ethan~


Agree that's how the import should be done. On the other hand, removing 
gratuitous use of isinstance() is generally a Good Thing.


Gratuitous use?  How is it gratuitous for an class to check that one of 
its arguments is its own type?


class Frizzy(object):
def __add__(self, other):
if not isinstance(other, Frizzy):
return NotImplemented
do_stuff_with(self, other)

This is exactly what isinstance() is for, and this is how it is being 
used in Decimal.__init__().


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


Re: A possible change to decimal.Decimal?

2012-03-04 Thread Ethan Furman

Jeff Beardsley wrote:
The problem with that though:  I am not calling reload(), except to 
recreate the error as implemented by the web frameworks.


I am also unlikely to get a patch accepted into several different 
projects, where this is ONE project, and it's a simple change


Simple -- maybe.

Appropriate -- no.

It is unfortunate that those frameworks have that bug, but it is not up 
to Decimal to fix it for them.


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


RE: Python - CGI-BIN - Apache Timeout Problem

2012-03-04 Thread Sean Cavanaugh (scavanau)
Thanks Chris,

I isolated it using logging

import logging 
logging.basicConfig(filename="test3.log", level=logging.INFO)
then logging.info('sniffer got to point A')  

and going through my code until I isolated the problem to a function with scapy 
called sniff.  For some reason this function operates very weirdly on FreeBSD9. 
 I have already submitted an email to the scapy mailing list.  Going to try to 
replicate this on Fedora but I doubt I will see this problem.  Even from the 
command line the sniff() function is not working correctly on FreeBSD 9.

-S  

-Original Message-
From: ch...@rebertia.com [mailto:ch...@rebertia.com] On Behalf Of Chris Rebert
Sent: Friday, March 02, 2012 3:23 PM
To: Sean Cavanaugh (scavanau)
Cc: python-list@python.org
Subject: Re: Python - CGI-BIN - Apache Timeout Problem

On Fri, Mar 2, 2012 at 12:09 PM, Sean Cavanaugh (scavanau)
 wrote:

> THE PROBLEM:
>
> When I execute the scripts from the command line (#python main.py) it
> generates it fine (albeit slowly), it prints all the html code out including
> the script.  The ‘core’ part of the script dumbed down to the lowest level
> is->
>
>     proc = subprocess.Popen(['/usr/local/bin/python', 'tests.py'],
> stdout=subprocess.PIPE)
>     output = proc.stdout.read()

Note the red warning box about possible deadlock with .stdout.read()
and friends:
http://docs.python.org/library/subprocess.html#popen-objects

>     print output
>     proc.stdout.close()

As the docs advise, try using .communicate()
[http://docs.python.org/library/subprocess.html#subprocess.Popen.communicate
] instead:
proc = subprocess.Popen(…)
out, err = proc.communicate()
print out

> When I open main.py and execute the script it just hangs… it seems to
> execute the script (I see pcap fires on the interface that I am testing on
> the firewall) but its not executing correctly… or loading the entire
> webpage…the webpage keeps chugging along and eventually gives me an error
> timeout.

The hanging makes me suspect that the aforementioned deadlock is occurring.

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


python25.dll

2012-03-04 Thread Scott V
 I don't know if anyone has sent this in before.
> I loaded the current version of Python on my computer to learn the
> programming and, I believe, it helps my Blender to work. Anyway,
> occassionally, I get an error on the screen, before I have started running
> programs, that states "python25.dll" will not load or does not exist.
> I have removed Python from my system to stop this error.
> Anything else I can do? This is XP system.
> Scott
*I loaded version 3.2, so not sure why the python25 was in there.

___
Amazon:
Check out my over 800 items for sale on Amazon at:

http://www.amazon.com/shops/bookman236  

"I believe that everything happens for a reason.
 People change so that you can learn to let go,
 things go wrong so that you appreciate them
 when they're right, you believe lies so you 
eventually learn to trust no one but yourself, 
and sometimes good things fall apart so better
 things can fall together." -Marilyn Monroe-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Adopting ‘lockfile’

2012-03-04 Thread Chris Withers

On 03/03/2012 21:43, Ben Finney wrote:

I don't see a need to horse around with Git either :-) It's currently in
Subversion, right? Can you not export the VCS history from Google Code's
Subversion repository to a ‘fastimport’ stream? Maybe someone with
experience on that site can help us.


What's wrong with a "git svn clone svn-url-here" ?

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
   - http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


Is this the right location to launch IDLE?

2012-03-04 Thread John Salerno
I'm trying to get Notepad++ to launch IDLE and run the currently open file in 
IDLE, but all my attempts have failed so far. I'm wondering, am I even using 
the IDLE path correctly? I'm using this:

"C:\Python32\Lib\idlelib\idle.pyw" "$(FULL_CURRENT_PATH)"

(That last part puts in the full path to the open file.)

Is this not the proper way to launch IDLE with an argument? It actually does 
open up IDLE, but the file doesn't seem to have been loaded, because when I try 
to use variables or functions from the file, IDLE acts as if it doesn't know 
what I'm referring to.

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


Parse cisco's "show ip route" output in Python 2.7

2012-03-04 Thread Antgoodlife
Hi All,

Long time reader, first time poster.  I'm trying to parse the output
of the SHOW IP ROUTE command from a cisco router (It's a 3800 Series
IOS 12.4 although almost all should have same output format) and put
it into a CSV format to import into a database or spreadsheet.
While we of course have Static / Connected routes, we also have lots
of dynamic routing coming in via OSPF, BGP, RIP, etc...

The output of the command is easy enough for me to get into text files
via parimiko (on that, does this module or equivalent work on Python 3
yet?) .. it's just tough to present the data into a csv or tabbed
format.

To me, although I've done similar things in the past, it's a fairly
brutal output format to parse up.  I was about to post some sample
input, but I am even having a hard time sanitizing the IP's for use on
this forum (Any utility for that?) as it's filled with IP addresses
that I cannot share.  I'd love some python module if anyone has an
idea where I can get it?

Perl does seem to have something similar :
http://cpansearch.perl.org/src/MARKPF/Cisco-ShowIPRoute-Parser-1.02/Parser.pm
however, I'd like to keep it in python...

Mainly, did someone already do this so I don't have to reinvent this
wheel (which probably won't roll straight)?

Thanks in advance, and hopefully I've given enough information.. I've
been trying to parse it for about 9 hours... but the script get's
worse and worse as I keep finding flaws in my logic.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parse cisco's "show ip route" output in Python 2.7

2012-03-04 Thread Dan Stromberg
I've done little with Ciscos,  but what if you use individual things like
 "show ip ospf", "show ip rip database", etc. instead of "show ip route".
Does that makes things a little more consistent?

Often big problems are simpler if we can divide them into smaller, more
manageable subproblems.

On Sun, Mar 4, 2012 at 4:20 PM, Antgoodlife  wrote:

> Hi All,
>
> Long time reader, first time poster.  I'm trying to parse the output
> of the SHOW IP ROUTE command from a cisco router (It's a 3800 Series
> IOS 12.4 although almost all should have same output format) and put
> it into a CSV format to import into a database or spreadsheet.
> While we of course have Static / Connected routes, we also have lots
> of dynamic routing coming in via OSPF, BGP, RIP, etc...
>
> The output of the command is easy enough for me to get into text files
> via parimiko (on that, does this module or equivalent work on Python 3
> yet?) .. it's just tough to present the data into a csv or tabbed
> format.
>
> To me, although I've done similar things in the past, it's a fairly
> brutal output format to parse up.  I was about to post some sample
> input, but I am even having a hard time sanitizing the IP's for use on
> this forum (Any utility for that?) as it's filled with IP addresses
> that I cannot share.  I'd love some python module if anyone has an
> idea where I can get it?
>
> Perl does seem to have something similar :
>
> http://cpansearch.perl.org/src/MARKPF/Cisco-ShowIPRoute-Parser-1.02/Parser.pm
> however, I'd like to keep it in python...
>
> Mainly, did someone already do this so I don't have to reinvent this
> wheel (which probably won't roll straight)?
>
> Thanks in advance, and hopefully I've given enough information.. I've
> been trying to parse it for about 9 hours... but the script get's
> worse and worse as I keep finding flaws in my logic.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"?

2012-03-04 Thread Rick Johnson
On Mar 2, 11:06 pm, John Salerno  wrote:
> I'm tempted just to go back to wxPython. Two sets of widgets in Tkinter is a 
> little annoying.

Your complaint is justified. The Tkinter API is a disgrace. IDLE's
source is just as bad. Luckily i have not made the jump to py3000 full-
time yet, but when i do, i think the first item on my to-do list will
be to hack this hideous tk+ttk+blah+blah into something more
friendly.

Heck, maybe i'll even release it!

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


[FIXED] Re: Can't get tilde character with IDLE 3.2.2 on French Mac Lion

2012-03-04 Thread Ned Deily
A followup to a thread in 2011-12.

In article ,
 Ned Deily  wrote:
> In article ,
>  Franck Ditter  wrote:
> > In article ,
> >  Ned Deily  wrote:
> > > In article ,
> > >  Franck Ditter  wrote:
> > > > All is in the subject. I'm starting to use Python with Idle 3.2.2
> > > > on MacOS-X Lion (French). I can't get "Option-N space" to provide 
> > > > the ~ char.
> > > > I tried to go into the Keys preferences but I can't find "Option-N 
> > > > space"
> > > > to modify its meaning. Its actual behavior is to merge lines of a 
> > > > paragraph.
> > > You are likely running into a current problem in the OS X Cocoa version 
> > > of Tcl/Tk 8.5 as included with Lion and as shipped by ActiveState.  
> > > Previously, if you tried to type composite characters, like Option N, 
> > > the Cocoa Tcl/Tk would crash.  Pending a real fix, a patch was made to 
> > > Tcl/Tk 8.5 to discard composite characters rather than crash.  You 
> > > should be able to get a tilde by using the post-composite keyboard 
> > > sequence:  try typing "space" followed by "Shift-Option-N".
> > > 
> > > http://sourceforge.net/tracker/index.php?func=detail&aid=2907388&group_id=
> > > 12
> > > 997&atid=112997
> > Nope, "space" followed by "Shift-Option-N" gives a greek iota...
> > I tried other combinations, unsuccessfully.
> > IDLE 3 (French) seems to be unusable as we use many ~ in web applications 
> > :-(
> > Should we hope a fix soon, or leave IDLE ?
> 
> Yes, I see now that that won't work with the French input method.  
> Unfortunately, there is nothing that IDLE or Python can do to workaround 
> the issue as the problem is in Cocoa Tcl/Tk and I don't know that any 
> fix is being worked on.

Good news!  A fix for Cocoa Tcl/Tk 8.5 for improved handling of Mac OS X 
input methods was recently applied and has now been released in the 
latest ActiveState Tcl release (8.5.11.1) available here:

http://www.activestate.com/activetcl/downloads

It appears to fix the tilde problem and other similar problems with 
composite characters, like Option-U + vowel to form "umlauted" vowels in 
the U.S. input method.  Many thanks to Adrian Robert, Kevin Walzer, and 
the ActiveState team for addressing this nasty problem.

If you install ActiveState Tcl 8.5.x, it will automatically be used by 
the python.org 2.7.x, 3.2.x, and 3.3.x 64-bit/32-bit Pythons for OS X 
10.6 and 10.7.  It will *not* be used by the Apple-supplied system 
Pythons or by 32-bit-only python.org Pythons.   More details here:

http://www.python.org/download/mac/tcltk/

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

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


Re: Buffering in Wing and IDLE 3

2012-03-04 Thread Ned Deily
In article ,
 Kevin Walzer  wrote:
> On 2/1/12 3:01 PM, Terry Reedy wrote:
> > On 2/1/2012 10:17 AM, Franck Ditter wrote:
> >
> >> I would prefer to use IDLE but as we are in France, the Python team
> >> does not seem to be aware that the ~ and others are not available
> >> on MacOS-X here (probably the same in Europe)...
> >
> > We are quite aware of the problem but cannot directly do anything about
> > it as the problem is with tcl/tk and Apple. A couple of days ago, Kevin
> > Walzer wrote on an IDLE-sig post "I'm currently reviewing an updated
> > patch to address the problem. When I commit the patch, it will go into
> > both Tk's trunk and in the Cocoa 8.5 backport, and eventually be
> > available through ActiveState's distribution."
> >
> And it's been committed:
> 
> http://core.tcl.tk/tk/info/9844fe10b9

... and released in ActiveState 8.5.11.1

http://www.activestate.com/activetcl/downloads

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

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


Re: How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"?

2012-03-04 Thread Kevin Walzer

On 3/3/12 12:06 AM, John Salerno wrote:

I suppose the 'advantage' of this is that it will replace tk widgets
with equivalent ttk widgets, if they exist and have the same name. I
believe one has to program them differently, however, so the replacement
cannot be transparent and one mush know anyway what gets replaced and
what not.


Grr, sounds like a pain if I want to use the new widgets. Does this cause 
conflict with someone who isn't running 8.5, or will they still see the older 
widgets as normal?

I'm tempted just to go back to wxPython. Two sets of widgets in Tkinter is a 
little annoying.


The new widgets are not a drop-in replacement for the traditional Tk 
widgets. They can be used with 8.4 if the "tile" Tk extension is 
installed. This is how the ttk widgets were first deployed; they didn't 
enter Tk's core until 8.5.

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"?

2012-03-04 Thread Westley Martínez
On Sun, Mar 04, 2012 at 05:39:27PM -0800, Rick Johnson wrote:
> On Mar 2, 11:06 pm, John Salerno  wrote:
> > I'm tempted just to go back to wxPython. Two sets of widgets in Tkinter is 
> > a little annoying.
> 
> Your complaint is justified. The Tkinter API is a disgrace. IDLE's
> source is just as bad. Luckily i have not made the jump to py3000 full-
> time yet, but when i do, i think the first item on my to-do list will
> be to hack this hideous tk+ttk+blah+blah into something more
> friendly.
> 
> Heck, maybe i'll even release it!

Make sure not to write it from scratch!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Porting Python to an embedded system

2012-03-04 Thread 88888 Dihedral
On Sunday, March 4, 2012 6:58:50 PM UTC+8, Justin Drake wrote:
> I am working with an ARM Cortex M3 on which I need to port Python
> (without operating system). What would be my best approach? I just
> need the core Python and basic I/O.

Sounds like the JVM law suites  in ANDROINDS did stimulate a lot jobs
to use other VM-BYTECODE based programming languages. 

I suggest  that one can use tiny linux or MU-linux which is even smaller than 
Linux and then install a slimmer customized  python not the same as the fatter 
one used in PC. 


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


Re: Porting Python to an embedded system

2012-03-04 Thread Dan Stromberg
You might check out pymite.  http://wiki.python.org/moin/PyMite  Oh, but
I'm now realizing that's part of the python on a chip project, so in a way
it's already been mentioned.

Anyway, PyMite, I gather, is a tiny python for microcontrollers.

On Sun, Mar 4, 2012 at 2:58 AM, Justin Drake  wrote:

> I am working with an ARM Cortex M3 on which I need to port Python
> (without operating system). What would be my best approach? I just
> need the core Python and basic I/O.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this the right location to launch IDLE?

2012-03-04 Thread Chris Rebert
On Sun, Mar 4, 2012 at 3:07 PM, John Salerno  wrote:
> I'm trying to get Notepad++ to launch IDLE and run the currently open file in 
> IDLE, but all my attempts have failed so far. I'm wondering, am I even using 
> the IDLE path correctly? I'm using this:
>
> "C:\Python32\Lib\idlelib\idle.pyw" "$(FULL_CURRENT_PATH)"
>
> (That last part puts in the full path to the open file.)
>
> Is this not the proper way to launch IDLE with an argument?

Correct. According to IDLE's USAGE message, you want the "-r" option,
which would make your desired command:
"C:\Python32\Lib\idlelib\idle.pyw" -r "$(FULL_CURRENT_PATH)"

> It actually does open up IDLE, but the file doesn't seem to have been loaded, 
> because when I try to use variables or functions from the file, IDLE acts as 
> if it doesn't know what I'm referring to.

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


Re: Is this the right location to launch IDLE?

2012-03-04 Thread John Salerno
Unfortunately neither method worked. Adding "-r" to the path created this error 
when I tried it:

>>> 
*** Error in script or command!

Traceback (most recent call last):
  File "C:\Users\John\Documents\Python Scripts\chess_pieces.py", line 1
class ChessPiece:
  ^
SyntaxError: invalid character in identifier
>>> 

Although there really is no error in the file, and running it directly from 
within IDLE doesn't cause this problem.

Adding the "pythonw.exe" part to the beginning also gave this error, but when I 
remove the "-r", then it just opens IDLE as normal, but without having loaded 
the Notepad++ file.

I just know there has to be a way to do this, but perhaps it's more of an NP++ 
problem. I posted on their forums but no one responded. I thought I might see 
if the problem lies with calling IDLE, but apparently it's a Windows/NP++ 
thing...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this the right location to launch IDLE?

2012-03-04 Thread Chris Rebert
On Sun, Mar 4, 2012 at 7:51 PM, John Salerno  wrote:
> Unfortunately neither method worked. Adding "-r" to the path created this 
> error when I tried it:
>

> *** Error in script or command!
>
> Traceback (most recent call last):
>  File "C:\Users\John\Documents\Python Scripts\chess_pieces.py", line 1
>    ï»¿class ChessPiece:

That would be a Notepad++ problem. That "" gibberish is what you
get when a Unicode BOM (Byte Order Mark) character is encoded as UTF-8
but decoded as ISO-8859-1 or CP-1252. A BOM is not recommended for
UTF-8 text; there should be some setting in Notepad++ to suppress it.

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


Re: Is this the right location to launch IDLE?

2012-03-04 Thread John Salerno
> That would be a Notepad++ problem. That "" gibberish is what you
> get when a Unicode BOM (Byte Order Mark) character is encoded as UTF-8
> but decoded as ISO-8859-1 or CP-1252. A BOM is not recommended for
> UTF-8 text; there should be some setting in Notepad++ to suppress it.

You are my new hero! :) It works perfectly now!

I set the default for files to be UTF-8 without BOM, and I also checked the 
option that said "Apply to opened ANSI files." Is that okay?

Thank you!!!

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


Re: How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"?

2012-03-04 Thread John Salerno
On Sunday, March 4, 2012 7:39:27 PM UTC-6, Rick Johnson wrote:
> On Mar 2, 11:06 pm, John Salerno  wrote:
> > I'm tempted just to go back to wxPython. Two sets of widgets in Tkinter is 
> > a little annoying.
> 
> Your complaint is justified. The Tkinter API is a disgrace. IDLE's
> source is just as bad. Luckily i have not made the jump to py3000 full-
> time yet, but when i do, i think the first item on my to-do list will
> be to hack this hideous tk+ttk+blah+blah into something more
> friendly.
> 
> Heck, maybe i'll even release it!

Well, after reading about the themed widgets and using them a bit, they 
definitely seem a lot cleaner than the old ones. Just comparing the attributes 
of the new and old widgets is a big difference. Much more streamlined.
-- 
http://mail.python.org/mailman/listinfo/python-list


Tkinter: Why aren't my widgets expanding when I resize the window?

2012-03-04 Thread John Salerno
I can't seem to wrap my head around all the necessary arguments for making a 
widget expand when a window is resized. I've been following along with a 
tutorial and I feel like I'm doing everything it said, but I must be missing 
something. Here's what I have. What I expect is that when I resize the main 
window, I should be able to see the AppFrame's border stretch out, but it 
remains in the original position.

Is there something wrong with the sticky argument, maybe? The tutorial I'm 
reading says they can be strings, but it also uses what appears to be a tuple 
of constants like this: sticky=(N, S, E, W) -- but that didn't work either.


import tkinter as tk
import tkinter.ttk as ttk


class AppFrame(ttk.Frame):

def __init__(self, parent, **kwargs):
super().__init__(parent, **kwargs)
self.grid(row=0, column=0, sticky='nsew')
self.columnconfigure(0, weight=1)
self.rowconfigure(0, weight=1)

self.create_widgets()

def create_widgets(self):
entry = ttk.Entry(self)
entry.grid(row=0, column=1, sticky='nsew')
#entry.columnconfigure(0, weight=1)
#entry.rowconfigure(0, weight=1)
label = ttk.Label(self, text='Name:')
label.grid(row=0, column=0, sticky='nsew')


root = tk.Tk()
root.title('Test Application')
frame = AppFrame(root, borderwidth=15, relief='sunken')
root.mainloop()
-- 
http://mail.python.org/mailman/listinfo/python-list


[RELEASED] Python 3.3.0 alpha 1

2012-03-04 Thread Georg Brandl

On behalf of the Python development team, I'm happy to announce the
first alpha release of Python 3.3.0.

This is a preview release, and its use is not recommended in
production settings.

Python 3.3 includes a range of improvements of the 3.x series, as well as easier
porting between 2.x and 3.x.  Major new features in the 3.3 release series are:

* PEP 380, Syntax for Delegating to a Subgenerator ("yield from")
* PEP 393, Flexible String Representation (doing away with the
  distinction between "wide" and "narrow" Unicode builds)
* PEP 409, Suppressing Exception Context
* PEP 3151, Reworking the OS and IO exception hierarchy
* The new "packaging" module, building upon the "distribute" and
  "distutils2" projects and deprecating "distutils"
* The new "lzma" module with LZMA/XZ support
* PEP 3155, Qualified name for classes and functions
* PEP 414, explicit Unicode literals to help with porting
* The new "faulthandler" module that helps diagnosing crashes
* Wrappers for many more POSIX functions in the "os" and "signal"
  modules, as well as other useful functions such as "sendfile()"

For a more extensive list of changes in 3.3.0, see

http://docs.python.org/3.3/whatsnew/3.3.html

To download Python 3.3.0 visit:

http://www.python.org/download/releases/3.3.0/

Please consider trying Python 3.3.0a1 with your code and reporting any
bugs you may notice to:

http://bugs.python.org/


Enjoy!

--
Georg Brandl, Release Manager
georg at python.org
(on behalf of the entire python-dev team and 3.3's contributors)
--
http://mail.python.org/mailman/listinfo/python-list