Cross-Platform ReadKey

2005-11-21 Thread Dustan
I found this site that has the code for readkey for Windows, Unix, and in an updated version, Mac: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/134892 . The Mac object returns a character whether or not a key was pressed. I modified the Windows object to do the same when I downloaded i

Modifying Unix ReadKey Code

2005-11-25 Thread Dustan
I found this site that has code for readkey for Windows, Unix, and in an updated version, Mac: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/134892 . The Mac object returns a character whether or not a key was pressed. I modified the Windows object to do the same when I downloaded it, b

Cross-Platform Readkey (one more try...)

2005-11-27 Thread Dustan
I've posted this before, but not gotten an answer: I found this site that has code that does readkey for Windows, Unix, and in an updated version, Mac: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/134892 The Mac readkey class returns a character whether or not a key was pressed. I modi

Scientific Notation

2005-12-03 Thread Dustan
How can I get a number into scientific notation? I have a preference for the format '1 E 50' (as an example), but if it's well known, it works. -- http://mail.python.org/mailman/listinfo/python-list

Re: Scientific Notation

2005-12-03 Thread Dustan
No, I mean given a big number, such as 1000, convert it into scientific notation. -- http://mail.python.org/mailman/listinfo/python-list

Re: Scientific Notation

2005-12-04 Thread Dustan
Thanks for your help, Alex, Roy and Jorge. I'm new to Python, and programming in general, which might explain my lack of knowledge, Fredrick. -- http://mail.python.org/mailman/listinfo/python-list

Fixed Width Font in Tkinter

2005-12-06 Thread Dustan
How do I make a fixed font width in Tkinter? Here's my code (there's more, of course, but this is the focus of the question): import tkFont Font=tkFont.Font(root=master, family="Courier", size=14) I'm sure it's possible, because it's done in IDLE. -- http://mail.python.org/mailman/listinfo/pyth

Re: Fixed Width Font in Tkinter

2005-12-06 Thread Dustan
Never mind, I got it to work. -- http://mail.python.org/mailman/listinfo/python-list

Clearing the Tkinter Window

2005-12-15 Thread Dustan
I'm a newbie here, especially with Tkinter. I'm writing a program that has 3 phases, if you will, in which I would have to clear the window and insert new widgets. Is this possible, and if so, how? I'm writing my application class based on Frame, if that helps at all. -- http://mail.python.org/

Re: Clearing the Tkinter Window

2005-12-16 Thread Dustan
I don't want to destroy the root, I just want to remove the widgets (the exact opposite of what Martin was saying). I started working on James' idea, but it'll be a while before I have it fully implemented to test. -- http://mail.python.org/mailman/listinfo/python-list

Tkinter Scrollbar not working

2006-01-02 Thread Dustan
I'm trying to get a scrollbar bound with a Frame, and I keep on getting a scrollbar, but it doesn't actually scroll. Some help, please? -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter Scrollbar not working

2006-01-02 Thread Dustan
BTW, experience tells me it is necessary for me to explicitly state that I'm a newbie (otherwise I get rude people saying I should already know such-and-such). -- http://mail.python.org/mailman/listinfo/python-list

Re: OOP: method overriding works in mysterious ways?

2006-01-02 Thread Dustan
Parent.critique() is calling self.critique(), which has been overriden by Child.critique() instead of Parent.critique. It makes perfect sense to me. -- http://mail.python.org/mailman/listinfo/python-list

Re: OOP: method overriding works in mysterious ways?

2006-01-02 Thread Dustan
Oh, I see what you mean. From my experience, the methods are passed down, not referred to from the parent. That is, Parent does have its own critique method, not a reference to Grand_parent.critique(). So when Child calls self.advise, it is calling its inherrited copy. Then, since the inherited Chi

Re: OOP: method overriding works in mysterious ways?

2006-01-02 Thread Dustan
> it calls it's own overriden critique method (overriden meaning the one that did the overriding) -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter Scrollbar not working

2006-01-03 Thread Dustan
Martin Franklin wrote: > Dustan wrote: > > I'm trying to get a scrollbar bound with a Frame, and I keep on getting > > a scrollbar, but it doesn't actually scroll. Some help, please? > > > > It can be tricky getting an empty frame to scroll, can you post yo

Re: Tkinter Scrollbar not working

2006-01-03 Thread Dustan
Label Widget, sorry -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter Scrollbar not working

2006-01-03 Thread Dustan
Yes, I know PMW has scrolled Text, but the module has to be installed seperately; this is something I'm releasing to a number of people. I'll try doing it with a canvas. -- http://mail.python.org/mailman/listinfo/python-list

Help Dialogue

2006-01-06 Thread Dustan
How do I make a help dialogue, like the one seen in IDLE when you go to Help-IDLE Help? -- http://mail.python.org/mailman/listinfo/python-list

Limitting the Contents of an Entry Widget in Tkinter

2006-01-14 Thread Dustan
How do I limit what the user can enter in an Entry Widget? I know I can set it to display '*' to hide a password, but what I want to do is limit the contents to numeric characters. What is the easiest way of doing this? -- http://mail.python.org/mailman/listinfo/python-list

Re: random shuffles

2006-07-21 Thread Dustan
Boris Borcic wrote: > does > > x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) > > pick a random shuffle of x with uniform distribution ? > > Intuitively, assuming list.sort() does a minimal number of comparisons to > achieve the sort, I'd say the answer is yes. But I don't feel quite > confo

Grail not downloading

2006-07-23 Thread Dustan
Does anybody know anything about Grail? I've been unable to get at it, and I've tried on both Windows and Macintosh machines. http://grail.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Grail not downloading

2006-07-25 Thread Dustan
SuperHik wrote: > Dustan wrote: > > Does anybody know anything about Grail? I've been unable to get at > > it, and I've tried on both Windows and Macintosh machines. > > > > http://grail.sourceforge.net/ > > > > http://prdownloads.sourceforge.n

Re: Grail not downloading

2006-07-25 Thread Dustan
Martin v. Löwis wrote: > Dustan wrote: > > Does anybody know anything about Grail? I've been unable to get at > > it, and I've tried on both Windows and Macintosh machines. > > > > http://grail.sourceforge.net/ > > The files just don't exist

Re: Small problem with print and comma

2006-07-30 Thread Dustan
Dennis Lee Bieber wrote: > > for i in range(0,len(param)): > > print a[i], > > for it in param: > print it, That's one way. However, if you need the position (this is for future reference; you don't need the position number here): for i in range(len(param)+1): prin

Re: Nested if and expected an indent block

2006-08-13 Thread Dustan
> Thanks for the replies: > > I'm sorry, the colon is there in the original, I accidentally blew it > off when I added the comment. The only information I get from IDLE is a > dialog box that says: > > Syntax Error > There's an error in your program: > expected an indented block > > Keith To see t

Long Tkinter Menu

2006-10-04 Thread Dustan
I don't know if this is because of Tkinter (ie Tk) itself or the Windows default way of handling things, but when I create a very long menu (my test is shown below), the way it displays is rather sucky; the menu stretches from the top of the moniter's window to the bottom (no matter the size of the

Re: Long Tkinter Menu

2006-10-05 Thread Dustan
Eric Brunel wrote: > On Thu, 05 Oct 2006 02:33:54 +0200, Dustan <[EMAIL PROTECTED]> wrote: > > > I don't know if this is because of Tkinter (ie Tk) itself or the > > Windows default way of handling things, but when I create a very long > > menu (my test is s

Re: Strange sorting error message

2006-10-05 Thread Dustan
Steve Holden wrote: > Dustan wrote: > > I'm hiding some of the details here, because I don't want to say what > > I'm actually doing. > > [...] > > I have the answer to your problem but I don't actually want to tell you > what it is. That's

Re: Strange sorting error message

2006-10-05 Thread Dustan
Neil Cerutti wrote: > On 2006-10-05, Dustan <[EMAIL PROTECTED]> wrote: > > > > Steve Holden wrote: > >> Dustan wrote: > >> > I'm hiding some of the details here, because I don't want to > >> > say what I'm actually doing.

Reverse string-formatting (maybe?)

2006-10-14 Thread Dustan
Is there any builtin function or module with a function similar to my made-up, not-written deformat function as follows? I can't imagine it would be too easy to write, but possible... >>> template = 'I am %s, and he %s last %s.' >>> values = ('coding', "coded', 'week') >>> formatted = template % v

Re: Reverse string-formatting (maybe?)

2006-10-15 Thread Dustan
Peter Otten wrote: > Dustan wrote: > > > Is there any builtin function or module with a function similar to my > > made-up, not-written deformat function as follows? I can't imagine it > > would be too easy to write, but possible... > > > >&

Re: Reverse string-formatting (maybe?)

2006-10-15 Thread Dustan
Tim Chase wrote: > > My template outside of the '%s' characters contains only commas and > > spaces, and within, neither commas nor spaces. Given that information, > > is there any reason it might not work properly? > > Given this new (key) information along with the assumption that > you're doing

Re: Reverse string-formatting (maybe?)

2006-10-15 Thread Dustan
Dustan wrote: > Tim Chase wrote: > > > My template outside of the '%s' characters contains only commas and > > > spaces, and within, neither commas nor spaces. Given that information, > > > is there any reason it might not work properly? > > >

Re: Reverse string-formatting (maybe?)

2006-10-15 Thread Dustan
Dustan wrote: > Dustan wrote: > > Tim Chase wrote: > > > > My template outside of the '%s' characters contains only commas and > > > > spaces, and within, neither commas nor spaces. Given that information, > > > > is there any reason it m

Re: Reverse string-formatting (maybe?)

2006-10-15 Thread Dustan
> Only you know what anomalies will be found in your data-sets. If > you know/assert that > > -the only stuff in the formatting string is one set of characters > > -that stuff in the replacement-values can never include any of > your format-string characters > > -that you're not using funky chara

Inheriting property functions

2006-10-20 Thread Dustan
Looking at this interactive session: >>> class A(object): def __init__(self, a): self.a = a def get_a(self): return self.__a def set_a(self, new_a): self.__a = new_a a = property(get_a, set_a) >>> class B(A): b = property(get_a, set_a) Tr

Re: Inheriting property functions

2006-10-20 Thread Dustan
Dustan wrote: > Looking at this interactive session: > > >>> class A(object): > def __init__(self, a): > self.a = a > def get_a(self): return self.__a > def set_a(self, new_a): self.__a = new_a > a = property(get_a, set_a

Re: Inheriting property functions

2006-10-20 Thread Dustan
Robert Kern wrote: > Dustan wrote: > > Looking at this interactive session: > > > >>>> class A(object): > > def __init__(self, a): > > self.a = a > > def get_a(self): return self.__a > > def set_a(self, new_

Customize the effect of enumerate()?

2006-10-20 Thread Dustan
Can I make enumerate(myObject) act differently? class A(object): def __getitem__(self, item): if item > 0: return self.sequence[item-1] elif item < 0: return self.sequence[item] elif item == 0:

Re: Customize the effect of enumerate()?

2006-10-21 Thread Dustan
Paul Rubin wrote: > "Dustan" <[EMAIL PROTECTED]> writes: > > Can I make enumerate(myObject) act differently? > > No. > > > Why the funny behavior, you ask? For my class A, it doesn't make sense > > to number everything the standard programming

Re: Customize the effect of enumerate()?

2006-10-23 Thread Dustan
Simon Forman wrote: > Dustan wrote: > > Can I make enumerate(myObject) act differently? > > > > class A(object): > > def __getitem__(self, item): > > if item > 0: > > return self.sequence[item-1] > >

Re: Customize the effect of enumerate()?

2006-10-23 Thread Dustan
Fredrik Lundh wrote: > "Dustan" wrote: > > > Except that my program is supposed to be treated as a module with tools > > to do certain things. I certainly can't control whether a 3rd party > > programmer uses "import myModule" or "from myM

disabledforeground or similar for Entry (in Tkinter)

2006-11-04 Thread Dustan
Back in this post, I attempted to make a label look like a button: http://groups.google.com/group/comp.lang.python/browse_thread/thread/a83195d3970a6851/2053cbaec1bc1f19?auth=DQAAAHkMDAWnhNnzpuKlwOKZUwAGUTtT2Ay-EAB7rCY6SnwfnDzZ98M37bZDW2Is0LrBVrr8XEgPfcuOkiUE-CrSsKbBSX-67voDUXfbATBd0eYNMClezby4

Re: disabledforeground or similar for Entry (in Tkinter)

2006-11-04 Thread Dustan
Dustan wrote: > Back in this post, I attempted to make a label look like a button: > http://groups.google.com/group/comp.lang.python/browse_thread/thread/a83195d3970a6851/2053cbaec1bc1f19?auth=DQAAAHkMDAWnhNnzpuKlwOKZUwAGUTtT2Ay-EAB7rCY6SnwfnDzZ98M37bZDW2Is0LrBVrr8XEgPfcuOkiUE-CrS

reduce to be removed?

2006-11-11 Thread Dustan
According to the following page on Wikipedia: http://en.wikipedia.org/wiki/Python_%28programming_language%29#Future_development reduce is going to be removed in python 3.0. It talks of an accumulation loop; I have no idea what that's supposed to mean. So, === >>> x =\ [

Re: reduce to be removed?

2006-11-11 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > > What's an accumulation loop, and how would I convert this code so it's > > compatible with the future 3.0 > > the release of Python 3.0 is far away, and nobody knows how it's going > to look. trying to be futur

Re: reduce to be removed?

2006-11-11 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > > It's always nice to know there are such good-natured people ready to > > help on this group. > > any special reason why you keep pretending that some random wikipedia > editor knows more about a future Python release

Re: reduce to be removed?

2006-11-11 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > > Because I'm embedding this expression in a list comprehension > > because? > > Because I thought I would be able to get an answer without revealing the exact details of what I am doing. I didn't realize that wasn&

Re: reduce to be removed?

2006-11-11 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > >> > Because I'm embedding this expression in a list comprehension > >> > >> because? > > > > Because I thought I would be able to get an answer without revealing > > the exact details of what

Re: reduce to be removed?

2006-11-11 Thread Dustan
Robert Kern wrote: > Dustan wrote: > > Fredrik Lundh wrote: > > >> if you care about writing robust code, why not just use a for-loop, > >> and the list extend method? > > > > Because I'm embedding this expression in a list comprehension (as I &

Re: reduce to be removed?

2006-11-11 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > >>>> foo =\ > > [[[1,2,3],[4,5,6],[7,8,9]], > > [[3,2,1],[6,5,4],[9,8,7]]] > > > > Here, foo appears to be a 3-dimensional list - except it's supposed to > > be 2-dimensional. The inner-list-of-list

Re: reduce to be removed?

2006-11-12 Thread Dustan
Alright, I can see I'm a bit outvoted here. I tried your suggestions and it worked fine. I'll also try to consider in the future that part of the problem might be lack of information conveyed on my part. -- http://mail.python.org/mailman/listinfo/python-list

Re: reduce to be removed?

2006-11-14 Thread Dustan
George Sakkis wrote: > Dustan wrote: > > > Alright, I can see I'm a bit outvoted here. I tried your suggestions > > and it worked fine. > > > > I'll also try to consider in the future that part of the problem might > > be lack of information convey

Downloading and Displaying an Image from the Internet in Tkinter

2006-05-31 Thread Dustan
The title pretty much says it all. What is the easiest way in Tkinter to display an image from the internet given the URL? -- http://mail.python.org/mailman/listinfo/python-list

Again, Downloading and Displaying an Image from the Internet in Tkinter

2006-06-05 Thread Dustan
Nobody answered last time. I guess they wanted me to give it a shot. Well, here is how I download the image (it's a class method): def download_image(self): web_download=self.opener.open(self.url) save=open("image.jpg","w") save.writelines(web_download.readlines())

Re: Again, Downloading and Displaying an Image from the Internet in Tkinter

2006-06-05 Thread Dustan
I wrote: > Nobody answered last time. I guess they wanted me to give it a shot. > Well, here is how I download the image (it's a class method): > > def download_image(self): > web_download=self.opener.open(self.url) > save=open("image.jpg","w") > save.writelines(web_down

Re: Again, Downloading and Displaying an Image from the Internet in Tkinter

2006-06-06 Thread Dustan
Justin Ezequiel wrote: > cannot help you with Tkinter but... > > save=open("image.jpg","wb") > save.write(web_download.read()) > save.close() > > perhaps this would let you open the file in Paint Ok, that worked (was it plain w or the writelines/readlines that messed it up?

Re: Again, Downloading and Displaying an Image from the Internet in Tkinter

2006-06-07 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > > Ok, that worked (was it plain w or the writelines/readlines that messed > > it up?). > > the plain "w"; very few image files are text files. > > > But Tkinter still can't find the image. I'm get

Re: Importing again and again

2006-06-08 Thread Dustan
abcd wrote: > If I have code which imports a module over and over again...say each > time a function is called, does that cause Python to actually re-import > it...or will it skip it once the module has been imported?? > > for example: > > def foo(): > import bar > bar.printStuff() > > foo

Making a Label that looks the same as a button.

2006-06-13 Thread Dustan
I have a Button object that gets replaced by a Label when clicked. Button(buttonsframe,text=' ',command=c,font=buttonsFont) Note that the text is a single space. buttonsFont uses 'Courier New' as a family. When clicked, the Button is destroyed and replaced with a Label object: Label(buttonsframe,

Re: Making a Label that looks the same as a button.

2006-06-13 Thread Dustan
Cameron Laird wrote: > In article <[EMAIL PROTECTED]>, > Grayson, John <[EMAIL PROTECTED]> wrote: > > > > > > > >Buttons can look like labels without the need to create another object - > >just remove the > >Command binding, set state to DISABLED and disabledforeground='same > >color as NORMAL'...

Re: Tkinter.Button(... command) lambda and argument problem

2006-09-15 Thread Dustan
Jay wrote: > Thanks for the tip, but that breaks things later for what I'm doing. > > [EMAIL PROTECTED] wrote: > > In that case you don't need a lambda: > > > > import Tkinter as tk > > > > class Test: > > def __init__(self, parent): > > buttons = [tk.Button(parent, text=str(x+1), > >

Re: Tkinter.Button(... command) lambda and argument problem

2006-09-16 Thread Dustan
James Stroud wrote: > Dustan wrote: > > Jay wrote: > > > >>Thanks for the tip, but that breaks things later for what I'm doing. > >> > >>[EMAIL PROTECTED] wrote: > >> > >>>In that case you don't need a lambda: > >

Re: eval(repr(object)) hardly ever works

2006-09-17 Thread Dustan
Matthew Wilson wrote: > I understand that idea of an object's __repr__ method is to return a > string representation that can then be eval()'d back to life, but it > seems to me that it doesn't always work. > > For example it doesn't work for instances of the object class: > > In [478]: eval(repr(

webbrowser module's Firefox support

2006-09-23 Thread Dustan
At http://docs.python.org/whatsnew/modules.html on the webbrowser module, it says "A number of additional browsers were added to the supported list such as Firefox, Opera, Konqueror, and elinks." I just installed python 2.5, looking forward to being able to control firefox without having to make i

Re: webbrowser module's Firefox support

2006-09-23 Thread Dustan
MonkeeSage wrote: > Dustan wrote: > > I did do a search here, but came up empty-handed. Can anyone tell me > > how to get the webbrowser module to recognize firefox's existence, > > given this information? > > Looks like it is checking %PATH% for fir

Re: webbrowser module's Firefox support

2006-09-23 Thread Dustan
MonkeeSage wrote: > Dustan wrote: > > >>> cont=webbrowser._browsers['firefox'][1] > > Why not use the api? cont=webbrowser.get('firefox') That didn't work either. > > ValueError: close_fds is not supported on Windows platforms >

Re: webbrowser module's Firefox support

2006-09-23 Thread Dustan
MonkeeSage wrote: > Dustan wrote: > > That didn't work either. > > Well, I'm out of ideas. It's also odd that it was being read as > webbrowser.BackgroundBrowser...whatever that is! It should have been > webbrowser.Mozilla. Thanks anyway; you have helpe

Re: webbrowser module's Firefox support

2006-09-24 Thread Dustan
> > This is a bug, and has now been fixed in SVN. As a workaround, you can > edit the webbrowser.py file and remove the close_fds and preexec_fn arguments > to Popen. > > Georg Finally! It's working. Thank you so much! -- http://mail.python.org/mailman/listinfo/python-list

Re: does anybody earn a living programming in python?

2006-09-25 Thread Dustan
walterbyrd wrote: > > > > Well I do. So do the other dozen or so developers at my company. We're > > looking > > to hire a few more, in fact. > > > > I'm surprised. It seems I never see listings for python developers. > > I didn't mean any disrespect. I think python is a great language. It > just

Strange sorting error message

2006-10-03 Thread Dustan
I'm hiding some of the details here, because I don't want to say what I'm actually doing. I have a special-purpose class with a __cmp__ method all set up and ready to go for sorting. Then I have a special class that is based on the builtin type list (though I didn't actually inherit list; I probab

Re: Strange sorting error message

2006-10-03 Thread Dustan
Diez B. Roggisch wrote: > Dustan schrieb: > > I'm hiding some of the details here, because I don't want to say what > > I'm actually doing. > > > I have a special-purpose class with a __cmp__ method all set up and > > ready to go for sorting. Then I

Re: a -very- case sensitive search

2006-11-25 Thread Dustan
Ola K wrote: > Hi, > I am pretty new to Python and I want to make a script that will search > for the following options: > 1) words made of uppercase characters -only- (like "YES") > 2) words made of lowercase character -only- (like "yes") > 3) and words with only the first letter capitalized (lik

Re: a -very- case sensitive search

2006-11-25 Thread Dustan
Dustan wrote: > Ola K wrote: > > Hi, > > I am pretty new to Python and I want to make a script that will search > > for the following options: > > 1) words made of uppercase characters -only- (like "YES") > > 2) words made of lowercase character -only-

Re: a -very- case sensitive search

2006-11-25 Thread Dustan
Steven D'Aprano wrote: > On Sat, 25 Nov 2006 13:39:55 -0800, Ola K wrote: > > > Hi, > > I am pretty new to Python and I want to make a script that will search > > for the following options: > > 1) words made of uppercase characters -only- (like "YES") > > 2) words made of lowercase character -only

Re: How to detect what type a variable is?

2006-11-29 Thread Dustan
Eduardo "EdCrypt" O. Padoan wrote: > > > > One might prefer to check for string-ness, as strings can > > duck-type somewhat like lists: > > > > my_list = ['my', 'brain', 'hurts'] > > my_string = 'Are you the brain specialist?' > > > > for test in [my_list, my_string]: > > try: > > fo

Re: The del statement

2006-12-05 Thread Dustan
Marco Aschwanden wrote: > > do you find the x[i] syntax for calling the getitem/setitem methods a > > bit awkward too? what about HTTP's use of "GET" and "POST" for most > > about everything ? ;-) > > No. I like the x[i] syntax. I use it in every second row of my code and > getting an item like:

Re: reloading modules

2006-12-06 Thread Dustan
[EMAIL PROTECTED] wrote: > I'm using python.exe to execute my modules. I have a music.py module > which contains my classes and a main.py module which uses these > classes. In python.exe, I call "import main" to execute my program. The > problem is that I have to close python and reopen it everytim

Re: reloading modules

2006-12-06 Thread Dustan
Dustan wrote: > [EMAIL PROTECTED] wrote: > > I'm using python.exe to execute my modules. I have a music.py module > > which contains my classes and a main.py module which uses these > > classes. In python.exe, I call "import main" to execute my program. The

Re: Emulate @classmethod using decorator and descriptor

2006-12-12 Thread Dustan
WaterWalk wrote: > Hello, I was recently learning python decorator and descriptor and > emulated a @classmethod decorator: > class EmuClassMethod(object): > def __init__(self, f=None): > self.f = f > def __get__(self, obj, klass=None): > if klass is None: >klass

Re: slices - handy summary

2006-12-13 Thread Dustan
meridian wrote: > If, like me, you're always forgetting which way around your list/seq > slices need to go then worry no more. Just put my handy "slice > lookupper" (TM) ) on a (large!) PostIt beside your screen and, Hey > Presto! no more tediously typing a 1-9 seq into your interpreter and > then

Re: newb: Creating Exception

2006-12-13 Thread Dustan
johnny wrote: > Thank you Dennis, > So when line 2, gets executed, its exception goes to do_some1_error. > And when line 3, gets executed, its exception goes to do_some2_error > and so on. > > line 1: try > line 2:do_some1 > line 3:do_some2 > line 4:do_some3 > line 5: except do_some1_

Re: newb: Creating Exception

2006-12-13 Thread Dustan
Dustan wrote: > johnny wrote: > > Documentation is not written for newbs, it's written by guys with 6yrs > > of experience FOR guys with 6yrs of experience. > > You might want to get a book on python, rather than depend on the > documentation, which is, as you say,

Re: newb: Creating Exception

2006-12-13 Thread Dustan
Dennis Lee Bieber wrote: > On 13 Dec 2006 03:52:49 -0800, "Dustan" <[EMAIL PROTECTED]> > declaimed the following in gmane.comp.python.general: > > > > > I didn't complete my thought. If you run into a situation like this, > > then you might want to

Re: Changing variable to integer

2006-12-17 Thread Dustan
vertigo wrote: > Hello > > I receive such error: > File "p4.py", line 24, in PrintWordCountFloat > print "%s %f" % (word,words[word]) > TypeError: list indices must be integers > > i call PrintWordCountFloat with hash table, keys are words(string) and > values float. > This part of the code:

Re: regular expression

2006-12-24 Thread Dustan
Kleine Aap wrote: > Asper Faner wrote: > > > I seem to always have hard time understaing how this regular expression > > works, especially how on earth do people bring it up as part of > > computer programming language. Natural language processing seems not > > enough to explain by the way. Why no

Re: regular expression

2006-12-25 Thread Dustan
[EMAIL PROTECTED] wrote: > Rad [Visual C# MVP] wrote: > > On Sun, 24 Dec 2006 16:36:31 +0100, Stef Mientki wrote: > > > > > Dustan wrote: > > >> Kleine Aap wrote: > > >>> Asper Faner wrote: > > >>> > > >>>> I

Re: Why does Python never add itself to the Windows path?

2006-12-25 Thread Dustan
WaterWalk wrote: > Ben Sizer wrote: > > I've installed several different versions of Python across several > > different versions of MS Windows, and not a single time was the Python > > directory or the Scripts subdirectory added to the PATH environment > > variable. Every time, I've had to go thr

Re: strange for loop construct

2007-01-07 Thread Dustan
Mark Elston wrote: > * Gabriel Genellina wrote (on 1/5/2007 12:49 PM): > > At Friday 5/1/2007 17:39, [EMAIL PROTECTED] wrote: > > > >> wordfreq = [wordlist.count(p) for p in wordlist] > >> > >> I would expect > >> > >> for p in wordlist: > >> wordfreq.append(wordlist.count(p)) > >> > >> > >> I

Numeric Entry in Tkinter

2006-01-22 Thread Dustan
Earlier I asked about limitting what a user can enter in an Entry. I got a few greatly appreciated replies, but I was hoping it would be possible to take a more direct approach, that is, is there a method I can override, when creating a class that inherits the Entry methods, that is called whenever

Get System Date?

2006-02-05 Thread Dustan
Is it possible to get the system date on a Windows XP machine? Most Convenient would to retrieve , MM, and DD as seperate variables. When I say system date, I'm thinking of the small clock in the lower-right hand corner, which has date as well as time, but if there's another clock that Python

Re: Get System Date?

2006-02-05 Thread Dustan
Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Pop Quiz

2007-06-02 Thread Dustan
On Jun 1, 9:33 pm, [EMAIL PROTECTED] wrote: > 1. Do you like Python? yes > 2. Do you think Python is good? yes > 3. Do you think Python is real good? yes > 4. What is your favorite version of Python? The most recent one. > 5. Because of Python, do you think it will be easier to take over th

Re: function in a function accessing vars

2007-06-06 Thread Dustan
On Jun 6, 6:40 am, "Jorgen Bodde" <[EMAIL PROTECTED]> wrote: > Hi Diez, > > Thanks, I thought it worked similar to C++ where a higher compound > could access a lower section. It can 'access a lower section'; what it can't do is *change* that 'lower section'; in your example case with an int, this

Re: Determinant of Large Matrix

2007-06-06 Thread Dustan
On Jun 6, 6:47 am, Tommy Nordgren <[EMAIL PROTECTED]> wrote: > On 6 jun 2007, at 13.10, James Stroud wrote: > > > > > Hello All, > > > I'm using numpy to calculate determinants of matrices that look like > > this (13x13): > > > [[ 0. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.] > > [ 1.

Re: get a list from a string

2007-06-07 Thread Dustan
On Jun 7, 6:06 am, simon kagwe <[EMAIL PROTECTED]> wrote: > > exec("distances = [[1,1,1,1],[2,2,2,2]]") To be clear, exec is *not* a function; it's a statement. That means it can't be used in lambda functions, for example. > Wow! So simple! but dodgy, as it'll execute any python code. > Thanks

Re: running a random function

2007-06-07 Thread Dustan
On Jun 7, 10:56 am, David Bear <[EMAIL PROTECTED]> wrote: > I would like to write some code that would randomly select a function from a > list of functions and call it. I was looking in the globals names space and > randomly selecting items that were of type function.. Careful!!! You don't want t

Re: running a random function

2007-06-07 Thread Dustan
On Jun 7, 1:30 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-06-07, Stebanoid <[EMAIL PROTECTED]> wrote: > > > if you have a list of functions you can try this: > > > import random > > import math > > m[int(math.floor(len(m)*random.random()))]() # seems like Lisp > > Or rather m[random.ran

Re: How to create a tuple quickly with list comprehension?

2007-06-13 Thread Dustan
On Jun 13, 5:37 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, Diez B. Roggisch wrote: > > > No need to create the intermediate list, a generator expression works just > > fine: > > > a = tuple(i for i in range(10)) > > But `range()` creates the intermediate list

  1   2   3   >