Hi,
This code generates the message "UnboundLocalError: local variable 'doubles'
referenced before assignment" (line: if d[0] == d[1] and doubles == 2:)
http://pastebin.com/mYBaCfj1
I think I have a fair picture of what it means but I would be very happy if
someone could explain the d
Thanks Evert for pointing out the difference and the discussion on global
variables, it helped.
/Robert
-Ursprungligt meddelande-
Från: Evert Rol [mailto:evert@gmail.com]
Skickat: den 30 maj 2010 18:34
Till: Robert Johansson
Kopia: tutor@python.org
Ämne: Re: [Tutor] namespaces
Dear all,
I'm trying to check the size of a component in a random graph with this code
(by a component I mean a maximal connected sub graph):
http://pastebin.com/SzC77HdU
I'm not 100 % sure that the code is working as it should but my question is
if there is a better way to design the w
Dear all, I have a problem with Tkinter and swedish letters such as ä (or
'\xe4'). Heres a small code example that counts the number of occurrences
of the letter a is in a string given by the user:
from Tkinter import *
root=Tk()
def callback():
a=textLine.get()
print a.cou
> Hi,
> I'm writing a text based menu and want to validate the user input. I'm
> giving the options as integers, and I want to make sure the user enters a
> proper value.
> Here's what I've got so far: http://pastebin.com/m1fdd5863
> I'm most interested in this segment:
> while True:
>
> What if a valid user input has to be an integer between 10 and 20? I mean,
> it could be that you are doing something that only makes sense for that
> input. Would it be pythonic to add a test like:
>
> If prompt in range(10,21):
Better to write
if 10 <= prompt <= 20:
> ...
> else:
> ... ra
Hi!
I want to process corresponding elements of two lists, sequentially. Call
the
lists list1 and list2, and assume they have equal lengths. I can do
something
like
for index in range(len(list1)):
process(list1[index], list2[index])
But I find it somehow rather ugly, because we generate yet
Hi, I would like to use the GNU linear programming kit, preferably with
Python and under Windows. After some googling I found python-glpk and
ctypes-glpk. The later seems to be an alternative but I get a feeling that
the former is the one most people recommend (also, I'm not sure that it will
work
I think you mean a multiset not a necklace. A necklace is invariant under
rotations and reflections aabb=abba=bbaa=baab and abab=baba. Seems that some
people name them bags instead of multiset. Maybe this can help you finding
more examples? I see that you got a few already.
/Robert
Från: tutor
Hi all, suppose I need to import a module inside a class and that I need to
use it in to different methods. Is this is the way to do it?
class test():
import time
def method1(self):
print 'method 1: ', time.clock()
def method2(self):
print 'method 2: ', time.clo
I have some functions written in Matlab which I want to translate into
Python so that my friends (how don't have Matlab) can enjoy them. My program
does some work on a bunch of textfiles which I have put in the same
directory as the Python-scriptfile with the function definitions. Things run
pretty
Hi, I'm puzzled by the character encodings which I get when I use Python
with IDLE. The string '\xf6' represents a letter in the Swedish alphabet
when coded with utf8. On our computer with MacOSX this gets coded as
'\xc3\xb6' which is a string of length 2. I have configured IDLE to encode
utf8 but
Hi, I have problems using characters from the Swedish language. I tried the
following in IDLE under MacOS X leopard (running Python 2.5.1) :
S=ö
Displaying error message: unsupported characters in input.
Running Python from a terminal I cant even type the character, all that
happe
On 8/17/08, Robert Johansson <[EMAIL PROTECTED]> wrote:
> Hi, I have problems using characters from the Swedish language. I tried
the
> following in IDLE under MacOS X leopard (running Python 2.5.1) :
> S='ö'
> Displaying error message: "unsupported charac
Dear all, I'm trying to get my Python stuff to work on my new computer but I
have problems getting the Psyco module installed. First I tried Python 2.6
(which worked fine) but discovered that Psyco wasn't prepared for it. I
uninstalled Python 2.6 and when for 2.5.2 instead, but the problem with
ins
Hi all,
This is my attempt to generate all pairs of relatively prime pairs of
nonnegative integers (n, m) such that n + m <= N, using the Stern-Brocot tree.
def rp_bounded_sum(n, i = 0, p = (0, 1), q = (1, 1), S = set([(0, 1), (1, 1)])):
# Returns a set S with all relatively prime pairs (a,
Hi,
I know that there is a lot to read about different IDEs on the net but I have
tried a couple and I'm still not pleased. My demands are not that high, when
I'm under Windows I'm happy with IDLE (an interactive shell and debug) but the
problem is with Mac (Python >= 2.7 and OS 10.7). IDLE had
Prins
mailto:wpr...@gmail.com>> wrote:
On 29 September 2011 10:42, Robert Johansson
mailto:robert.johans...@math.umu.se>> wrote:
Hi,
I know that there is a lot to read about different IDEs on the net but I have
tried a couple and I'm still not pleased. My demands are not that high,
18 matches
Mail list logo