Re: [Tutor] print command

2005-03-20 Thread Lutz Horn
Hi, > To clarify: > > print 1 > print 2 > print 3 > > I want output to be > > 123 >>> l = [1, 2 3] >>> i = int("".join(map(str, l))) >>> print i, type(i) 123 If you don't care about the blanks, you can use >>> print 1, 2, 3 1 2 3 Lutz -- pub 1024D/6EBDA359 1999-09-20 Lutz Horn <[EMAIL

[Tutor] print command

2005-03-20 Thread Shitiz Bansal
Now this is so basic, i am feeling sheepish asking about it. I am outputting to the terminal, how do i use a print command without making it jump no newline after execution, which is the default behaviour in python. To clarify: print 1 print 2 print 3 I want output to be 123 whereas by default

Re: [Tutor] Re: [Pythoncard-users] global menubar

2005-03-20 Thread brad . allen
Thanks for the thoughts. I noticed that you didn't post directly to the PythonCard users list, so you might not be reading the discussion that followed. It sounds like MDI applications are deprecated under Windows, so I'm going to go with a single tabbed window with some small menuless child windo

Re: [Tutor] Prepend to a list? (fwd)

2005-03-20 Thread Danny Yoo
> I ended up changing my approach so that it won't require appending to > the list, but it's good to know anyway because I'm sure it will come up > in the future. I'm sort of surprised there isn't a prepend() method for > lists, but I'm sure there's a reason. Hi Jay, The interface of a data stru

Re: [Tutor] primes - sieve of odds

2005-03-20 Thread Gregor Lingl
Hi Sean! Thanks for your measurements. In the meantime I did another amendment, leaving out the even numbers from the sieve. It goes like this: def sieve(maximum): nums = range(3, maximum+1, 2) for p in nums: if p: if p*p > maximum: break start = (p*p-2)//2

Re: [Tutor] Changing Keyboard output

2005-03-20 Thread Alan Gauld
> I am looking for a way to change keyboard output within > Tkinter widget - for example, say I press "p" and I want > it to come out as "t". > > Could anyone possibly point me in the right direction? Take a look at the Event Driven programming topic in my tutor, it covers reading keyboard inpu

Re: [Tutor] Filtering a String

2005-03-20 Thread Sean Perry
Matt Williams wrote: Dear List, I'm trying to filter a file, to get rid of some characters I don't want in it. I've got the "Python Cookbook", which handily seems to do what I want, but: a) doesn't quite and b) I don't understand it I'm trying to use the string.maketrans() and string.translate().

Re: [Tutor] Filtering a String

2005-03-20 Thread Archie Maskill
On Sun, 20 Mar 2005 22:05:23 +, Matt Williams <[EMAIL PROTECTED]> wrote: > I've tried: > > #!/usr/bin/python > import string > test="1,2,3,bob,%,)" > allchar=string.maketrans('','') > #This aiming to delete the % and ): > x=''.translate(test,allchar,"%,)") > > but get: > TypeError: translate

Re: [Tutor] Filtering a String

2005-03-20 Thread Jacob S.
I'm trying to filter a file, to get rid of some characters I don't want in it. The easiest thing to do is use the string method replace. For example: char = "1" a = open("Myfile.txt","r") b = a.read() a.close() b = b.replace(char,"") a = open("Myfile.txt","w") ## Notice "w" so we can replace th

Re: [Tutor] Why is this not an error?

2005-03-20 Thread Kent Johnson
Hameed U. Khan wrote: This else is the part of the for loop. And the statements in this else will be executed if your for loop will complete all of its iterations. if you want this else with 'if' statement then remove the for loop. Or if you want the for loop to be part of the if then indent the

[Tutor] Filtering a String

2005-03-20 Thread Matt Williams
Dear List, I'm trying to filter a file, to get rid of some characters I don't want in it. I've got the "Python Cookbook", which handily seems to do what I want, but: a) doesn't quite and b) I don't understand it I'm trying to use the string.maketrans() and string.translate(). From what I've re

Re: [Tutor] primes (generator)

2005-03-20 Thread Sean Perry
Gregor Lingl wrote: The following variation of your sieve, using extended slice assignment seems to be sgnificantly faster. Try it out, if you like. Here are the numbers: Primes 1 - 1,000,000 timing: extendedSliceSieve: 0.708388 seconds listPrimes: 0.998758 seconds karlSi

Re: [Tutor] Changing Keyboard output

2005-03-20 Thread Michael Lange
On Sun, 20 Mar 2005 19:38:40 - "Igor Riabtchuk" <[EMAIL PROTECTED]> wrote: > Hi, > > I am totally new to Python and still learning. > > I am looking for a way to change keyboard output within Tkinter widget - for > example, say I press "p" and I want it to come out as "t". > > Could anyone

[Tutor] Changing Keyboard output

2005-03-20 Thread Igor Riabtchuk
Hi,   I am totally new to Python and still learning.   I am looking for a way to change keyboard output within Tkinter widget - for example, say I press "p" and I want it to come out as "t".   Could anyone possibly point me in the right direction?   Igor

Re: [Tutor] Re: [Pythoncard-users] global menubar

2005-03-20 Thread Liam Clarke
On Sun, 20 Mar 2005 12:05:11 -0600, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Thanks for the thoughts. I noticed that you didn't post directly to the > PythonCard users list, Sorry, that was my bad, I cc'ed to the tutor list instead of the Pythoncard list. -- 'There is only one basic hum

Re: [Tutor] primes (generator)

2005-03-20 Thread Gregor Lingl
Karl Pflästerer schrieb: On 19 Mrz 2005, [EMAIL PROTECTED] wrote: [Code] Maybe sombody likes... I did it ... : def sieve (max): max = max + 1 border = round(max**0.5) nums = range(0, max) nums[0] = nums[1] = None for p in nums: if p: if p >= border: break

Re: [Tutor] stopping greedy matches

2005-03-20 Thread Joerg Woelke
On Fri, Mar 18, 2005 at 12:27:35PM -0500, Christopher Weimann wrote: > So this [^\s]+ means match one or more of any char that > isn't whitespace. Could be just \S+ Greetings, J"o! -- Reply hazy, ask again later. ___ Tutor maillist - Tutor@python

Re: [Tutor] program for creation of unique objects

2005-03-20 Thread Alan Gauld
> I want a user to define an item and then > define multiple characteristics about that item, > save a dictionary of items, > and then reload the items back into the GUI upon restart. I'm still not absolutely sure what you mean. Do you mean the GUI itself is going to grow new panels etc as

Re: [Tutor] Re: [Pythoncard-users] global menubar

2005-03-20 Thread Alan Gauld
> > To clarify, what I'm trying to accomplish here is an overarching application > > window which contains other windows. At least, that's what it would look > > like under Windows. You mean this would be an MDI Application? There is usually a special class or attribute to support MDI in theGUI to

Re: [Tutor] Why is this not an error?

2005-03-20 Thread Sean Perry
Hameed U. Khan wrote: This else is the part of the for loop. And the statements in this else will be executed if your for loop will complete all of its iterations. if you want this else with 'if' statement then remove the for loop. for instance: looking_for = 11 for i in range(0,10): if i ==

Re: [Tutor] Why is this not an error?

2005-03-20 Thread Hameed U. Khan
On Sunday 20 Mar 2005 1846, Steve N wrote: > This code runs, but it seems to me it should generate > a syntax error. Can someone explain what's going on? Why do you think there is a syntax error? > x = [1,2,3,4] > z = 4 > if z in x: > print 'found:', z if clause has been ended here. > for i

[Tutor] Why is this not an error?

2005-03-20 Thread Steve N
This code runs, but it seems to me it should generate a syntax error. Can someone explain what's going on? x = [1,2,3,4] z = 4 if z in x: print 'found:', z for i in x: print 'in the loop with', i else: print 'not found:', z >>> found: 4 in the loop with 1 in the loop with 2 in the l

Re: [Tutor] program for creation of unique objects

2005-03-20 Thread Kent Johnson
Brainerd HeadFat wrote: Hi, I'm having trouble trying to figure out how to create multiple objects that contain duplicate entries that can be uniquely identified within a Tkinter GUI. I want a user to define an item and then define multiple characteristics about that item, save a dictionary o