Re: Help. HOW TO guide for PyQt installation

2013-03-21 Thread jmfauth
On 20 mar, 11:38, Phil Thompson  wrote:
> On Wed, 20 Mar 2013 03:29:35 -0700 (PDT), jmfauth 
> wrote:
>
>
>
>
>
>
>
>
>
> > On 20 mar, 10:30, Phil Thompson  wrote:
> >> On Wed, 20 Mar 2013 02:09:06 -0700 (PDT), jmfauth 
> >> wrote:
>
> >> > On 20 mar, 01:12, "D. Xenakis"  wrote:
> >> >> Hi there,
> >> >> Im searching for an installation guide for PyQt toolkit.
> >> >> To be honest im very confused about what steps should i follow for a
> >> >> complete and clean installation. Should i better choose to install
> the
> >> >> 32bit or the 64bit windows version? Or maybe both? Any chance one of
> >> them
> >> >> is more/less bug-crashy than the other? I know both are availiable
> on
> >> the
> >> >> website but just asking.. If i installed this package on windows 8,
> >> >> should i have any problems? From what i read PyQt supports only xp
> and
> >> >> win7.
> >> >> I was thinking about installing the newer version of PyQt along with
> >> the
> >> >> QT5. I have zero expirience on PyQt so either way, everything is
> going
> >> to
> >> >> be new to me, so i dont care that much about the learning curve
> >> diference
> >> >> between new and old PyQt - Qt version. I did not find any installer
> so
> >> i
> >> >> guess i should customly do everything. Any guide for this plz?
>
> >> >> Id also like to ask.. Commercial licence of PyQt can only be bought
> on
> >> >> riverbank's website? I think i noticed somewhere an other reseller
> >> >> "cheaper one" or maybe i didnt know what the hell i was reading :).
> >> Maybe
> >> >> something about Qt and not PyQt.
>
> >> >> Please help this noob,
> >> >> Regards
>
> >> > 
>
> >> > Short answer without explanation. It does not work.
>
> >> > jmf
>
> >> Well it works for me. Care to elaborate?
>
> >> Phil
>
> > No problem.
>
> > Yesterday, I downloaded "PyQt4-4.10-gpl-Py3.3-Qt5.0.1-x32-2.exe"
> > and installed it on my Windows 7 Pro box after having removed
> > a previous version.
>
> > No problem with the installation.
>
> > I quickly tested it with one of my interactive Python interpreters
> > and got an error "from PyQt4 import QtGui, QtCore" saying, that the
> > DLL cannot be found.
>
> > Something similar to what Detlev Offenbach reported on
> > the PyQt mailing list. Although, I'm not using Qsci.
>
> > Strangely, I had not problem (if I recall correctly) with a
> > very basic application (QMainWindow + QLineEdit).
>
> > I had no problem with the demo (I only lauched it).
>
> > I did not spend to much time in investigating further.
>
> > It's the first time I see such an error; usually, no problem.
>
> The only time that I've seen a problem like that is when running from a
> shell that was started before running the PyQt installer (ie. one with an
> out of date PATH).
>
> Phil

--

The PATH could be the cause. I stupidly forgot to check it
before removing PyQt...

I repeated the experiment (app == eta26.py). With and
without "PyQt" in the system PATH. (Btw, why is it
necessary?)

D:\jm\jmpy\eta\eta26>c:\python32\python eta26.py
PyQt: 4.8.6, Qt: 4.7.4 Python 3.2.3

No problem.



D:\jm\jmpy\eta\eta26>c:\python33\python eta26.py
Traceback (most recent call last):
  File "eta26.py", line 32, in 
from PyQt4 import QtGui, QtCore
ImportError: DLL load failed: Le module spécifié est introuvable.
(Translation: The specified module can no be found.)



D:\jm\jmpy\eta\eta26>c:\python33\python eta26.py
PyQt: 4.10, Qt: 4.8.4 Python 3.3.0

No problem.



No idea. It is mysterious for me. eta26 is only
importing QtGui and QtCore. It however uses a sophisticated
widget like QPlainTextEdit.

jmf

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


Oracle

2013-03-21 Thread amani . abdulhadi
Oracle 
In Classical Antiquity, an oracle was a person or agency considered to be a 
source of wise counsel or prophetic predictions or precognition of the future, 
inspired by the gods. As such it is a form of divination. 
The word oracle comes from the Latin verb ōrāre "to speak" and properly refers 
to the priest or priestess uttering the prediction. In extended use, oraclemay 
also refer to the site of the oracle, and to the oracular utterances 
themselves, called khrēsmoi (χρησμοί) in Greek. 
Oracles were thought to be portals through which the gods spoke directly to 
people. In this sense they were different from seers (manteis, μάντεις) who 
interpreted signs sent by the gods through bird signs, animal entrails, and 
other various methods.[1] 
The most important oracles of Greek antiquity were Pythia, priestess to Apollo 
at Delphi, and the oracle of Dione and Zeus at Dodona in Epirus. Other temples 
of Apollo were located at Didyma on the coast of Asia Minor, at Corinth and 
Bassae in the Peloponnese, and at the islands of Delos andAegina in the Aegean 
Sea. Only the Delphic Oracle was a male; all others were female.[2] The 
Sibylline Oracles are a collection of oracular utterances written in Greek 
hexameters ascribed to the Sibyls, prophetesses who uttered divine revelations 
in a frenzied state. 
please visit web site http://vb.mediu.edu.my/showthread.php?t=20631
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "monty" < "python"

2013-03-21 Thread Terry Reedy

On 3/20/2013 10:03 AM, franzferdinand wrote:

Ok, thanks everybody!


Threads are like the Sorcerer's Apprentice. You can start 'em, but you 
cannot stop 'em ;-)


--
Terry Jan Reedy

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


free and nonlocal variables

2013-03-21 Thread bartolome . sintes
In Python 3, "free variable" and "nonlocal variable" are synonym terms? Or is 
there a difference, like "a free variable is a variable that is not a local 
variable, then nonlocal variables and global variables are both free variables"?

Thanking you in advance,
Bartolomé Sintes
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help. HOW TO guide for PyQt installation

2013-03-21 Thread jmfauth
On 20 mar, 11:29, jmfauth  wrote:
> On 20 mar, 10:30, Phil Thompson  wrote:

-
>
>
> Strangely, I had not problem (if I recall correctly) with a
> very basic application (QMainWindow + QLineEdit).


ADDENDUM, CORRECTION

It fails too. I forgot to rename PySide --> PyQt4 !

I tried to collect other experiences via Google. No luck.

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


Re: free and nonlocal variables

2013-03-21 Thread 88888 Dihedral
bartolom...@gmail.com於 2013年3月21日星期四UTC+8下午4時52分17秒寫道:
> In Python 3, "free variable" and "nonlocal variable" are synonym terms? Or is 
> there a difference, like "a free variable is a variable that is not a local 
> variable, then nonlocal variables and global variables are both free 
> variables"?
> 
> 
> 
> Thanking you in advance,
> 
> Bartolomé Sintes

In python the interpreter has to check 4 levels of dictionaries
in the run time to perform an action. The for levels are:
1. object instance level 
2. class level
3. local function level
4. global level.

Objects created at level 1,2,3 can be returned to some other 
object in the run time.

Thus a GC is available to save the  trouble of tracking 
everything for the programmer in a complex system.

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


Re: Vowels [was Re: "monty" < "python"]

2013-03-21 Thread David H Wild
In article , Larry Hudson
 wrote:
> The word "apron" was originally "napron", and over the years the phrase
> "a napron" mutated to "an apron".  So that became the accepted word.

Similarly, the snake was a nadder - congruent with the natterjack toad.

-- 
David Wild using RISC OS on broadband
www.davidhwild.me.uk
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Vowels [was Re: "monty" < "python"]

2013-03-21 Thread Chris Angelico
On Thu, Mar 21, 2013 at 8:36 PM, David H Wild  wrote:
> In article , Larry Hudson
>  wrote:
>> The word "apron" was originally "napron", and over the years the phrase
>> "a napron" mutated to "an apron".  So that became the accepted word.
>
> Similarly, the snake was a nadder - congruent with the natterjack toad.

Hey look, snakes, we're back on topic!

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


Re: free and nonlocal variables

2013-03-21 Thread Steven D'Aprano
On Thu, 21 Mar 2013 01:52:17 -0700, bartolome.sintes wrote:

> In Python 3, "free variable" and "nonlocal variable" are synonym terms?
> Or is there a difference, like "a free variable is a variable that is
> not a local variable, then nonlocal variables and global variables are
> both free variables"?


"Free variable" is a formal term from computer science. As far as I know, 
Python uses it in exactly the same way.

A free variable is a variable in an expression or function that is not 
local (which includes function parameters) to that expression. So both 
global and non-local variables are free variables.


def spam(x):
def inner():
y = x**2 - 1
return x + y + z
return inner()


In inner(), both x and z are free variables, but y is not, since it is 
local to the inner() function.



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


encoding for colon-separated hex?

2013-03-21 Thread Mathias Kőrber
is there a built-in encoding (for encode/decode methods) that
as colon-separated hex (01:02:03:04...)?

'hex' seems to encode as '01020304' and while one can postprocess that
to insert the colons, if a single operation exists, I'd rather use that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: free and nonlocal variables

2013-03-21 Thread Terry Reedy

On 3/21/2013 4:52 AM, bartolome.sin...@gmail.com wrote:

In Python 3, "free variable" and "nonlocal variable" are synonym terms?


Yes, but that is idiosyncratic to Python.


Or is there a difference, like "a free variable is a variable that is
not a local variable, then nonlocal variables and global variables are

> both free variables"?

I believe that is the usual definition, such as you would find on Wikipedia.

--
Terry Jan Reedy

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


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

2013-03-21 Thread Steven D'Aprano
On Thu, 21 Mar 2013 08:35:26 -0400, Colin J. Williams wrote:

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

No. It is equally true for all versions of Python.


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


Re: "monty" < "python"

2013-03-21 Thread Roy Smith
In article ,
 Terry Reedy  wrote:

> On 3/20/2013 10:03 AM, franzferdinand wrote:
> > Ok, thanks everybody!
> 
> Threads are like the Sorcerer's Apprentice. You can start 'em, but you 
> cannot stop 'em ;-)

Of course you can stop threads.  Just call _exit().  No more threads!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "monty" < "python"

2013-03-21 Thread Chris Angelico
On Thu, Mar 21, 2013 at 11:45 PM, Roy Smith  wrote:
> In article ,
>  Terry Reedy  wrote:
>
>> On 3/20/2013 10:03 AM, franzferdinand wrote:
>> > Ok, thanks everybody!
>>
>> Threads are like the Sorcerer's Apprentice. You can start 'em, but you
>> cannot stop 'em ;-)
>
> Of course you can stop threads.  Just call _exit().  No more threads!

I don't think Mickey Mouse knew about that call, otherwise he'd have
used it. Either that, or he had a completely saturated system and
couldn't type anything at the console, so it took the wizard's SSH
session to deal with the problem using "kill -9".

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


Re: "monty" < "python"

2013-03-21 Thread Wayne Werner

On Thu, 21 Mar 2013, Roy Smith wrote:


In article ,
Terry Reedy  wrote:


On 3/20/2013 10:03 AM, franzferdinand wrote:

Ok, thanks everybody!


Threads are like the Sorcerer's Apprentice. You can start 'em, but you
cannot stop 'em ;-)


Of course you can stop threads.  Just call _exit().  No more threads!


Thank you for making me laugh this morning - I found that extremely 
amusing.


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


Re: "monty" < "python"

2013-03-21 Thread Dave Angel

On 03/21/2013 08:55 AM, Chris Angelico wrote:

On Thu, Mar 21, 2013 at 11:45 PM, Roy Smith  wrote:

In article ,
  Terry Reedy  wrote:


On 3/20/2013 10:03 AM, franzferdinand wrote:

Ok, thanks everybody!


Threads are like the Sorcerer's Apprentice. You can start 'em, but you
cannot stop 'em ;-)


Of course you can stop threads.  Just call _exit().  No more threads!


I don't think Mickey Mouse knew about that call, otherwise he'd have
used it. Either that, or he had a completely saturated system and
couldn't type anything at the console, so it took the wizard's SSH
session to deal with the problem using "kill -9".



Denial-of-service, the traditional way.

--
DaveA

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


Re: Vowels [was Re: "monty" < "python"]

2013-03-21 Thread istjanichtzufassen
Am Donnerstag, 21. März 2013 10:36:20 UTC+1 schrieb David H Wild:
> In article , Larry Hudson
> 
>  wrote:
> 
> > The word "apron" was originally "napron", and over the years the phrase
> 
> > "a napron" mutated to "an apron".  So that became the accepted word.
> 
> 
> 
> Similarly, the snake was a nadder - congruent with the natterjack toad.
> 

And conversely, the "nickname" once was "an ekename", meaning an additional 
name.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Vowels [was Re: "monty" < "python"]

2013-03-21 Thread Chris Angelico
On Fri, Mar 22, 2013 at 12:26 AM,   wrote:
> Am Donnerstag, 21. März 2013 10:36:20 UTC+1 schrieb David H Wild:
>> In article , Larry Hudson
>>
>>  wrote:
>>
>> > The word "apron" was originally "napron", and over the years the phrase
>>
>> > "a napron" mutated to "an apron".  So that became the accepted word.
>>
>> Similarly, the snake was a nadder - congruent with the natterjack toad.
>>
>
> And conversely, the "nickname" once was "an ekename", meaning an additional 
> name.

Until Eccles came along. Most people call him by his nickname, which is "Nick".

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


tkinter: invisible PanedWindow "sashes" on OS X

2013-03-21 Thread Arnaud Delobelle
Hi Python List,

I'm trying to use PanedWindow on OS X (10.8.3).  I've started with the
effbot docs example (http://effbot.org/tkinterbook/panedwindow.htm),
namely:

--
from Tkinter import *

m = PanedWindow(orient=VERTICAL)
m.pack(fill=BOTH, expand=1)

top = Label(m, text="top pane")
m.add(top)

bottom = Label(m, text="bottom pane")
m.add(bottom)

mainloop()
--

I can see two panes alright, but no handle to resize them (or 'sash'
as they seem to be called in tkinter).  Is there something else that I
should be doing?

TIA,

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


Re: SOAPpy.Types.faultType: Cannot use object of type stdClass as array

2013-03-21 Thread Chris Angelico
On Thu, Mar 21, 2013 at 6:06 AM, Tamer Higazi  wrote:
> SOAPpy.Types.faultType:  type stdClass as array>

stdClass looks like a PHP error. Check out the server's requirements;
perhaps you need to provide something as a list that you're providing
as a dict, or something. I'd look at that loginData, for instance.

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


Re: Vowels [was Re: "monty" < "python"]

2013-03-21 Thread Grant Edwards
On 2013-03-21, Steven D'Aprano  wrote:

> By the way, the "n" in "an" is not the only such "bridging" sound. In 
> Shakespearean times, it was usual to use "mine" in the same fashion:

In many (most?) modern, non-rhotic, dialects of English one inserts an
"intrusive" bridging "R" sound after a word that ends in certain vowel
sounds and is followed by a word starting with a vowel.

That description is a bit hard to "picture", but if you read the
examples in the link below, you'll recogize it immediately:

 http://en.wikipedia.org/wiki/Linking_and_intrusive_R#Linking_R

However, this only affects spoken English -- not written English.

Is the Python language rhotic or non-rhotic?

-- 
Grant Edwards   grant.b.edwardsYow! Hello, GORRY-O!!
  at   I'm a GENIUS from HARVARD!!
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tkinter: invisible PanedWindow "sashes" on OS X

2013-03-21 Thread Christian Gollwitzer

Am 21.03.13 15:37, schrieb Arnaud Delobelle:

Hi Python List,

I'm trying to use PanedWindow on OS X (10.8.3).  I've started with the
effbot docs example (http://effbot.org/tkinterbook/panedwindow.htm),
namely:

--
from Tkinter import *

m = PanedWindow(orient=VERTICAL)
m.pack(fill=BOTH, expand=1)

top = Label(m, text="top pane")
m.add(top)

bottom = Label(m, text="bottom pane")
m.add(bottom)

mainloop()
--

I can see two panes alright, but no handle to resize them (or 'sash'
as they seem to be called in tkinter).  Is there something else that I
should be doing?


This is, unfortunately, the platform standard on both OSX and Windows7. 
You can still resize the windows: Just grab the space between the two 
labels. There should be at least a cursor change.


With you example it doesn't work particularly well, because the labels 
are small and have no visible border. Try using e.g. a text widget 
instead (or maybe relief=SUNKEN)


Christian

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


Re: free and nonlocal variables

2013-03-21 Thread Nobody
On Thu, 21 Mar 2013 01:52:17 -0700, bartolome.sintes wrote:

> In Python 3, "free variable" and "nonlocal variable" are synonym terms?

"Free variable" is a computer science term. A variable is free if it is
not bound. E.g. x and y are free in "x+y", x is bound and y is free in
"lambda x: x+y", x and y are both bound in "lambda y: lambda x: x+y". IOW,
a variable is free in an expression if the expression doesn't include
whatever created the variable.

In Python 3, the "nonlocal" keyword indicates that a name refers to a
variable created in an outer function.

Names are deduced as referring to local, nonlocal (outer) or global
variables at compile time.

If a name is a function parameter, then it's a local variable.

If a function definition doesn't include an assignment to a name, or a
global or nonlocal statement for that name, the name refers to a nonlocal
variable (local variable in an enclosing function) if one exists,
otherwise to a global variable.

By default, the presence of an assignment causes the name to be treated as
a local variable. If the variable is read prior to assignment, an
UnboundLocalError is raised (even if a global or nonlocal variable exists
with that name; the decision is made when the function is compiled, not
when the assignment is executed).

However, a "global" statement causes the name to be treated as a global
variable, while a "nonlocal" statement causes it to be treated as a
reference to a local variable of the enclosing function. Again, it is the
presence of these statements during compilation, not execution of them at
run time, which causes the name to be deduced as a global or nonlocal
variable.

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


problem with function

2013-03-21 Thread leonardo selmi
hi all,

i wrote the following code:

def find(word, letter):
index = 0
while index < len(word):
if word[index] == letter:
return index
index = index + 1
return -1

if i run the program i get this error: name 'word' is not defined.  how can i 
solve it?

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


Re: problem with function

2013-03-21 Thread Chris Angelico
On Fri, Mar 22, 2013 at 5:31 AM, leonardo selmi  wrote:
> hi all,
>
> i wrote the following code:
>
> def find(word, letter):
> index = 0
> while index < len(word):
> if word[index] == letter:
> return index
> index = index + 1
> return -1
>
> if i run the program i get this error: name 'word' is not defined.  how can i 
> solve it?

You'll need to post the whole code of your program. That function
works fine for me. (Though it's somewhat unPythonic code, and in any
case already exists in the standard library.) Tip: Look at the full
traceback from the error. Chances are you'll find the cause of the
error on one of the lines near the end of the trace.

ChrisA
-- 
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: problem with function

2013-03-21 Thread Dave Angel

On 03/21/2013 02:31 PM, leonardo selmi wrote:

hi all,

i wrote the following code:

def find(word, letter):
 index = 0
 while index < len(word):
 if word[index] == letter:
 return index
 index = index + 1
 return -1

if i run the program i get this error: name 'word' is not defined.  how can i 
solve it?




If I run it, I get nothing at all, since there's no call to find()). 
And when I add lines that print the results of calling the function, I 
get reasonable results.


How about if you do the following:

1) tell us Python version and OS.
2) show us the whole code, copy/pasted into your message
3) show us the whole error message (traceback), copy/pasted into your 
message


And if you're running it from somewhere other than a terminal window, 
tell us how you're running it.  Or better, run it from a terminal, and 
show us the whole sequence, by copy/pasting from the terminal to the 
message.



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


Re: Binary for numpy 1.7.0 with Python 2.7.3

2013-03-21 Thread Dave Angel

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



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


Re: Binary for numpy 1.7.0 with Python 2.7.3

2013-03-21 Thread Kwpolska
On Thu, Mar 21, 2013 at 8: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
> --
> http://mail.python.org/mailman/listinfo/python-list

You don’t.  First off, nobody really likes nor uses SourceForge today.
 Python can be found on the website, http://www.python.org/getit/ and
numpy is in the PyPI: https://pypi.python.org/pypi/numpy .  Both links
have Windows binaries, which I assume you want.

--
Kwpolska  | GPG KEY: 5EAAEA16
stop html mail| always bottom-post
http://asciiribbon.org| http://caliburn.nl/topposting.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problem with function

2013-03-21 Thread Alex
leonardo selmi wrote:

> hi all,
> 
> i wrote the following code:
> 
> def find(word, letter):
> index = 0
> while index < len(word):
> if word[index] == letter:
> return index
> index = index + 1
> return -1
> 
> if i run the program i get this error: name 'word' is not defined.
> how can i solve it?
> 

What does your call to find look like? I called it with:

find("word", 'd')

and it returned 3, as expected.

If I call find with

find(word, 'd')

I get an error, as expected, since I have not assigned a string to the
name word.


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


Windows Deployment Of Python Modules

2013-03-21 Thread Adam Tauno Williams

Python itself is easy to deploy on Windows;  just toss the MSI in your
local update server and away it goes.

That's slick;  LSUS is awesome.
  

But that gives you Python with no pip, easy_install, etc...  And *that*
is not packaged appropriately.  Is there some trick to getting modules
installed on Windows workstations en masse [in an automated fashion]?
It seems like I must be missing something.

For example, I want Python installed, and the iniparse module.

-- 
Adam Tauno Williams  GPG D95ED383
Systems Administrator, Python Developer, LPI / NCLA

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


Re: free and nonlocal variables

2013-03-21 Thread Jussi Piitulainen
Nobody writes:
> On Thu, 21 Mar 2013 01:52:17 -0700, bartolome.sintes wrote:
> 
> > In Python 3, "free variable" and "nonlocal variable" are synonym
> > terms?
> 
> "Free variable" is a computer science term. A variable is free if it
> is not bound. E.g. x and y are free in "x+y", x is bound and y is
> free in "lambda x: x+y", x and y are both bound in "lambda y: lambda
> x: x+y". IOW, a variable is free in an expression if the expression
> doesn't include whatever created the variable.

And in (lambda x : x)(x) + x below, x occurs both free and bound. The
free occurrences are bound by the outer lambda.

   >>> (lambda x : (lambda x : x)(x) + x)(3)
   6
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tkinter: invisible PanedWindow "sashes" on OS X

2013-03-21 Thread Arnaud Delobelle
On 21 March 2013 18:42, Christian Gollwitzer  wrote:
> Am 21.03.13 15:37, schrieb Arnaud Delobelle:
>
>> Hi Python List,
>>
>> I'm trying to use PanedWindow on OS X (10.8.3).  I've started with the
>> effbot docs example (http://effbot.org/tkinterbook/panedwindow.htm),
>> namely:
>>
>> --
>> from Tkinter import *
>>
>> m = PanedWindow(orient=VERTICAL)
>> m.pack(fill=BOTH, expand=1)
>>
>> top = Label(m, text="top pane")
>> m.add(top)
>>
>> bottom = Label(m, text="bottom pane")
>> m.add(bottom)
>>
>> mainloop()
>> --
>>
>> I can see two panes alright, but no handle to resize them (or 'sash'
>> as they seem to be called in tkinter).  Is there something else that I
>> should be doing?
>
>
> This is, unfortunately, the platform standard on both OSX and Windows7. You
> can still resize the windows: Just grab the space between the two labels.
> There should be at least a cursor change.

I cannot effect a cursor change with the example above.

> With you example it doesn't work particularly well, because the labels are
> small and have no visible border. Try using e.g. a text widget instead (or
> maybe relief=SUNKEN)

If I use text widgets for the top and bottom panes, then I can get a
resize cursor and I am able to drag the 'sash' up and down.  That's
good enough for me to get started.  Thanks for the suggestion,

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


Re: Vowels [was Re: "monty" < "python"]

2013-03-21 Thread Peter Pearson
On Thu, 21 Mar 2013 21:09:52 +1100, Chris Angelico  wrote:
> On Thu, Mar 21, 2013 at 8:36 PM, David H Wild  wrote:
>> In article , Larry Hudson
>>  wrote:
>>> The word "apron" was originally "napron", and over the years the phrase
>>> "a napron" mutated to "an apron".  So that became the accepted word.
>>
>> Similarly, the snake was a nadder - congruent with the natterjack toad.
>
> Hey look, snakes, we're back on topic!

Ha!  Great shot, Chris A.

People who enjoy this sort of linguistic diversion would
very likely enjoy John McWhorter's classes from the Teaching
Company, which is where I first encountered many of the examples
given in this thread.

-- 
To email me, substitute nowhere->spamcop, invalid->net.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Vowels [was Re: "monty" < "python"]

2013-03-21 Thread Chris Angelico
On Fri, Mar 22, 2013 at 8:52 AM, Peter Pearson  wrote:
> On Thu, 21 Mar 2013 21:09:52 +1100, Chris Angelico  wrote:
>> On Thu, Mar 21, 2013 at 8:36 PM, David H Wild  wrote:
>>> In article , Larry Hudson
>>>  wrote:
 The word "apron" was originally "napron", and over the years the phrase
 "a napron" mutated to "an apron".  So that became the accepted word.
>>>
>>> Similarly, the snake was a nadder - congruent with the natterjack toad.
>>
>> Hey look, snakes, we're back on topic!
>
> Ha!  Great shot, Chris A.
>
> People who enjoy this sort of linguistic diversion would
> very likely enjoy John McWhorter's classes from the Teaching
> Company, which is where I first encountered many of the examples
> given in this thread.

I love a good grammar discussion. Programming requires precise use of
some language, so programmers tend to appreciate precise use of other
languages too. Plus, in one of my other lives, I'm a D&D Dungeon
Master with a reputation for puns and wordplay in my descriptions...
though I'm as often slapped as clapped for them.

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


Re: problem with function

2013-03-21 Thread Ian Kelly
On Mar 21, 2013 1:35 PM, "leonardo selmi"  wrote:
>
> hi all,
>
> i wrote the following code:
>
> def find(word, letter):
> index = 0
> while index < len(word):
> if word[index] == letter:
> return index
> index = index + 1
> return -1
>

More efficient:

def find(word, letter):
return word.find(letter)

Or even:

find = str.find

Cheers,
Ian
-- 
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: Windows Deployment Of Python Modules

2013-03-21 Thread Adam Tauno Williams
David Robinow  wrote:
>On Thu, Mar 21, 2013 at 4:14 PM, Adam Tauno Williams
> wrote:
>>
>> Python itself is easy to deploy on Windows;  just toss the MSI in
>your
>> local update server and away it goes.
>>
>> That's slick;  LSUS is awesome.
>>   
>>
>> But that gives you Python with no pip, easy_install, etc...  And
>*that*
>> is not packaged appropriately.  Is there some trick to getting
>modules
>> installed on Windows workstations en masse [in an automated fashion]?
>> It seems like I must be missing something.
>> For example, I want Python installed, and the iniparse module.
>python setup.py install
>Am I missing something?


Yes! 

 That does not get the package to the workstation.  It also is not conducive to 
automation (or success auditing).


-- 
Adam Tauno Williams
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows Deployment Of Python Modules

2013-03-21 Thread David Robinow
On Thu, Mar 21, 2013 at 6:23 PM, Adam Tauno Williams
 wrote:
> David Robinow  wrote:
>>On Thu, Mar 21, 2013 at 4:14 PM, Adam Tauno Williams
>> wrote:
>>>
>>> Python itself is easy to deploy on Windows;  just toss the MSI in
>>your
>>> local update server and away it goes.
>>>
>>> That's slick;  LSUS is awesome.
>>>   
>>>
>>> But that gives you Python with no pip, easy_install, etc...  And
>>*that*
>>> is not packaged appropriately.  Is there some trick to getting
>>modules
>>> installed on Windows workstations en masse [in an automated fashion]?
>>> It seems like I must be missing something.
>>> For example, I want Python installed, and the iniparse module.
>>python setup.py install
>>Am I missing something?
>
>
> Yes!
>
>  That does not get the package to the workstation.  It also is not conducive 
> to automation (or success auditing).
 OK, I have no idea what you're talking about. Clearly you want
something more than installing packages.
-- 
http://mail.python.org/mailman/listinfo/python-list


How can I wrap a binary file-like object with an IO stream?

2013-03-21 Thread Will McGugan
Hi,

I am looking in to improving Python 3.X support for PyFilesystem (https://
code.google.com/p/pyfilesystem/).

There is provisional Python 3 support in there, but a stumbling block is 
that I would like the open method to work like io.open in Py3 -- 
specifically returning text mode streams that handle the unicode encoding/
decoding. At the moment, the 'open' method of PyFilesystem objects just 
returns a Python 2 style file-like object.

What I could use is a way of taking a Python 2.X file-like object 
together with the mode, encoding and buffering etc. and return an 
appropriate IO stream that handles the encoding/decoding.

I'm sure I could implement the logic myself by looking at the mode/
encoding and return the appropriate IO interface, but I was hoping there 
was something in the stdlib to do this, or some pre-existing code I can 
lift?

Thanks in advance,

Will McGugan
-- 
http://www.willmcgugan.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Vowels [was Re: "monty" < "python"]

2013-03-21 Thread Terry Reedy

On 3/21/2013 1:31 PM, Grant Edwards wrote:


http://en.wikipedia.org/wiki/Linking_and_intrusive_R


Is the Python language rhotic or non-rhotic?


Python uses American rather that British English, which would make it 
rhotic.


I never imagined that there were people who would mix up 'tuner' and 
'tuna'. Live and learn.


--
Terry Jan Reedy

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


Re: problem with function

2013-03-21 Thread Terry Reedy

On 3/21/2013 2:31 PM, leonardo selmi wrote:


i wrote the following code:

def find(word, letter):
 index = 0
 while index < len(word):
 if word[index] == letter:
 return index
 index = index + 1
 return -1


Since this is a learning exercise, consider the following.

def find(word, letter):
for index, let in enumerate(word):
if let  == letter:
return index
return -1

for w, l, n in (('abc', 'a', 0), ('abc', 'c', 2), ('abc', 'd', -1)):
assert find(w, l)  == n
print("no news is good news")

I copied the code, wrote the test, ran it, and it passed. I then 
re-wrote until syntax errors were gone and the new version passed. For 
loops are specialized, easier-to-write version of while loops that scan 
the items of a collection (iterable). Learn them and use them well. 
Learn to write automated tests as soon as possible.


--
Terry Jan Reedy

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


Global NameError Fix?

2013-03-21 Thread maiden129
Hello,

I'm using the version 3.2.3 of Python and I am having an issue in my program 
and I don't know how to fix it:

counterLabel["text"] = str(counter)
NameError: global name 'counterLabel' is not defined

Here is my program:

from tkinter import *


class CounterButton(Button):

def __init__(self, window):

   
   super(CounterButton,self).__init__(window, text = "0", 
command=self.startCounter)


def startCounter(self):
counter = int(self["text"])
counter +=1
counterLabel["text"] = str(counter)

window = Tk()
window.title("counter")


counterButton1 = CounterButton(window)
counterButton2 = CounterButton(window)


counterButton1.pack()
counterButton1.pack()


window.mainloop()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Vowels [was Re: "monty" < "python"]

2013-03-21 Thread Roy Smith
In article ,
 Terry Reedy  wrote:

> On 3/21/2013 1:31 PM, Grant Edwards wrote:
> 
> 
> http://en.wikipedia.org/wiki/Linking_and_intrusive_R
> 
> > Is the Python language rhotic or non-rhotic?
> 
> Python uses American rather that British English, which would make it 
> rhotic.
> 
> I never imagined that there were people who would mix up 'tuner' and 
> 'tuna'. Live and learn.

Remember, "You can tune a file system, but you can't tune a fish."
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Global NameError Fix?

2013-03-21 Thread Dave Angel

On 03/21/2013 07:43 PM, maiden129 wrote:

Hello,

I'm using the version 3.2.3 of Python and I am having an issue in my program 
and I don't know how to fix it:

counterLabel["text"] = str(counter)
NameError: global name 'counterLabel' is not defined



Please include the entire traceback when reporting an exception.  In 
this case, we can figure it out, but frequently we can't.



Here is my program:

from tkinter import *


class CounterButton(Button):

 def __init__(self, window):


super(CounterButton,self).__init__(window, text = "0", 
command=self.startCounter)


 def startCounter(self):
 counter = int(self["text"])
 counter +=1
 counterLabel["text"] = str(counter)


Where did you think counterLabel was defined?  It needs to be a dict or 
equivalent, in order for you to use the ["text"] notation on it.  If 
it's supposed to be an attribute of the CounterButton, then you should 
create it in the __init__() method, as


self.counterLabel = {}

And if it's supposed to be inherited from Button (unlikely, with that 
name), presumably it's initialized there.


In either case, if it's supposed to be specific to this instance of 
CounterButton, you need the self. prefix:


self.counterLabel["text"] = ...

I don't use tkinter, and it's not installed in my Python, but I suspect 
that it is in the Button object, and it's called something else, like text.


Based on a quick internet search, I might try something like:

self.config(text= str(counter))


This is assuming you actually wanted to change the text on the button 
itself.  You may well want to change something else in your GUI.





window = Tk()
window.title("counter")


counterButton1 = CounterButton(window)
counterButton2 = CounterButton(window)


counterButton1.pack()
counterButton1.pack()


window.mainloop()




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


Re: Global NameError Fix?

2013-03-21 Thread David Robinow
On Thu, Mar 21, 2013 at 7:43 PM, maiden129  wrote:
> Hello,
>
> I'm using the version 3.2.3 of Python and I am having an issue in my program 
> and I don't know how to fix it:
>
> counterLabel["text"] = str(counter)
> NameError: global name 'counterLabel' is not defined
>
> Here is my program:
>
> from tkinter import *
> class CounterButton(Button):
> def __init__(self, window):
>super(CounterButton,self).__init__(window, text = "0", 
> command=self.startCounter)
>
> def startCounter(self):
> counter = int(self["text"])
> counter +=1
> counterLabel["text"] = str(counter)
This should be:
   self["text"] = str(counter)
>
> window = Tk()
> window.title("counter")
...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Binary for numpy 1.7.0 with Python 2.7.3

2013-03-21 Thread Miki Tebeka
> I'm trying to update to both 2.7.3 and Numpy 1.7.0.
Updating Python is from python.org

If you're on 64bit windows, see http://www.lfd.uci.edu/~gohlke/pythonlibs/
-- 
http://mail.python.org/mailman/listinfo/python-list