Re: Photoimage on button appears pixelated when button is disabled

2009-05-18 Thread Dustan
On May 17, 7:11 am, Tim Golden m...@timgolden.me.uk wrote: Dustan wrote: On May 15, 2:59 pm, Dustan dustangro...@gmail.com wrote: In tkinter, when I place a photoimage on a button and disable the button, the image has background dots scattered through the image. Searching the web, I

Re: Photoimage on button appears pixelated when button is disabled

2009-05-17 Thread Dustan
On May 15, 2:59 pm, Dustan dustangro...@gmail.com wrote: In tkinter, when I place a photoimage on a button and disable the button, the image has background dots scattered through the image. Searching the web, I wasn't able to find any documentation on this behavior, nor how to turn it off. So

Photoimage on button appears pixelated when button is disabled

2009-05-15 Thread Dustan
I extract the base-64 encoding of a GIF, so I can put the image directly into the code instead of having to keep a separate file for the image? All responses appreciated, Dustan -- http://mail.python.org/mailman/listinfo/python-list

How do I escape slashes the string formatting operator? (or: why is it behaving this way?)

2009-05-06 Thread Dustan
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. 'HELP!%(xyz)/' % {'xyz':' PLEASE! '} Traceback (most recent call last): File stdin, line 1, in module ValueError: unsupported format character '/'

Re: How do I escape slashes the string formatting operator? (or: why is it behaving this way?)

2009-05-06 Thread Dustan
On May 6, 6:51 pm, marek.ro...@wp.pl wrote: Dustan napisa³(a): Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. 'HELP!%(xyz)/' % {'xyz':' PLEASE! '} Traceback (most recent call last

Re: Do any of you recommend Python as a first programming language?

2008-03-23 Thread Dustan
On Mar 22, 10:40 am, jmDesktop [EMAIL PROTECTED] wrote: For students 9th - 12th grade, with at least Algebra I. Do you think Python is a good first programming language for someone with zero programming experience? Using Linux and Python for first exposure to programming languages and

Re: List question

2008-03-23 Thread Dustan
On Mar 21, 3:57 pm, Paul Rubin http://[EMAIL PROTECTED] wrote: [EMAIL PROTECTED] writes: if 'one' and 'two' in f: alist.append(f) Use: if 'one' in f and 'two' in f: ... Personally, I would put parentheses around to be clearer: if ('one' in f) and ('two' in f): ...

Re: This actually works.

2008-03-14 Thread Dustan
On Mar 13, 6:19 pm, Dotan Cohen [EMAIL PROTECTED] wrote: On 14/03/2008, Dustan [EMAIL PROTECTED] wrote: you.screw() Ah, you are pushing sex pills. self.thank(God, encapsulation) And bibles? Interesting combination. not self.want_to_know(you.screw.func_code) Unsubscribe? I know

Re: List mutation method gotcha - How well known?

2008-03-14 Thread Dustan
On Mar 13, 1:56 pm, yoz [EMAIL PROTECTED] wrote: This will cause a hidden feature of python and the OS, known as the 'python easter egg', to activate - erasing all data on the hard disk and then reporting how many bytes of data are left. Usually None ;-} - This really is a 'gotcha'

Re: List mutation method gotcha - How well known?

2008-03-13 Thread Dustan
On Mar 13, 2:36 am, Hendrik van Rooyen [EMAIL PROTECTED] wrote: Hi, I am surprised that it took me so long to bloody my nose on this one. It must be well known - and I would like to find out how well known. So here is a CLOSED BOOK multiple choice question - no RTFM, no playing at the

Re: This actually works.

2008-03-13 Thread Dustan
On Mar 13, 3:16 pm, [EMAIL PROTECTED] wrote: not self.believe programming.screw() self.serious; this.works make_money(EASY) anyone.can_do(this) you.screw() self.thank(God, encapsulation) not self.want_to_know(you.screw.func_code) programming.is_good --

Re: iter(lambda:f.read(8192),'')

2008-02-24 Thread Dustan
On Feb 24, 5:11 am, gert [EMAIL PROTECTED] wrote: what is the difference between iter(lambda:f.read(8192), ') and iter(f.read(8192),'') ? One does not work, and one is syntactically incorrect: iter(f.read(8192),'') Traceback (most recent call last): File pyshell#0, line 1, in module

Re: class static variables and __dict__

2008-02-16 Thread Dustan
On Feb 16, 4:40 pm, Zack [EMAIL PROTECTED] wrote: what method can you use on x to find all available attributes for that class? class Foo(object): bar = hello, world! def __init__(self, baz): self.baz = baz x = Foo(42) x.__dict__.keys() # Does not include

Re: class static variables and __dict__

2008-02-16 Thread Dustan
On Feb 16, 5:59 pm, Zack [EMAIL PROTECTED] wrote: Zack wrote: Diez B. Roggisch wrote: Zack schrieb: If I have a class static variable it doesn't show up in the __dict__ of an instance of that class. class C: n = 4 x = C() print C.__dict__ {'__module__': '__main__',

Re: Edit Python code programmatically

2008-02-09 Thread Dustan
On Feb 9, 6:10 am, Alex [EMAIL PROTECTED] wrote: Guilherme Polo wrote: 2008/2/9, Alex [EMAIL PROTECTED]: Which library could you recommend to perform simple editing of Python code (from Python program)? For example, open *.py file, find specific function definition, add another

Re: Why not a Python compiler?

2008-02-05 Thread Dustan
On Feb 5, 2:37 am, Kay Schluehr [EMAIL PROTECTED] wrote: On Feb 5, 9:19 am, Santiago Romero [EMAIL PROTECTED] wrote: ( Surely if this question has been asked for a zillion of times... ) Sure. You can access comp.lang.python via groups .google.com. It has a search function. --

Re: Python feature request : operator for function composition

2008-02-04 Thread Dustan
On Feb 4, 10:11 am, Arnaud Delobelle [EMAIL PROTECTED] wrote: This is nice. Thanks. * I wouldn't choose '' as the composing operator as when I read 'double square' I think 'take an x, double it square it' which is the wrong interpretation (perhaps instead?). A very good point that I

Re: Python feature request : operator for function composition

2008-02-04 Thread Dustan
On Feb 2, 11:09 pm, Kay Schluehr [EMAIL PROTECTED] wrote: [snip] While you're waiting for it to be implemented, you can build your own version as a decorator. Here's an example written in haste: class composer(object): def __init__(self, *funcs): self.funcs = funcs

Re: Dictionary Keys question

2008-01-31 Thread Dustan
On Jan 30, 7:02 pm, FireNWater [EMAIL PROTECTED] wrote: Thank you for the explanation. . . I think I now have a (foggy) understanding of hash tables. It seems to be a way to create order (an index) out of disorder (random numbers or characters) behind the scenes. . The key thing to realize

Re: Dictionary Keys question

2008-01-31 Thread Dustan
On Jan 31, 7:35 am, Ben Finney [EMAIL PROTECTED] wrote: Dustan [EMAIL PROTECTED] writes: On Jan 30, 7:02 pm, FireNWater [EMAIL PROTECTED] wrote: Thank you for the explanation. . . I think I now have a (foggy) understanding of hash tables. It seems to be a way to create order (an index

Re: Dictionary Keys question

2008-01-30 Thread Dustan
On Jan 30, 4:47 pm, FireNWater [EMAIL PROTECTED] wrote: I'm curious why the different outputs of this code. If I make the dictionary with letters as the keys, they are not listed in the dictionary in alphabetical order, but if I use the integers then the keys are in numerical order. I know

Re: py3k feature proposal: field auto-assignment in constructors

2008-01-27 Thread Dustan
On Jan 27, 12:41 pm, Torsten Bronger [EMAIL PROTECTED] wrote: Hallöchen! Wildemar Wildenburger writes: André wrote: Personally, I like the idea you suggest, with the modification that I would use . instead of @, as in class Server(object): def __init__(self, .host, .port,

Re: strange syntax rules on list comprehension conditions

2008-01-18 Thread Dustan
On Jan 18, 1:04 pm, Chris Mellon [EMAIL PROTECTED] wrote: On Jan 18, 2008 12:53 PM, Nicholas [EMAIL PROTECTED] wrote: I was quite delighted today, after extensive searches yielded nothing, to discover how to place an else condition in a list comprehension. Trivial mask example: [True if

Re: anti-spam policy for c.l.py?

2008-01-16 Thread Dustan
On Jan 16, 11:31 am, _wolf [EMAIL PROTECTED] wrote: On Jan 16, 3:11 pm, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Jeroen Ruigrok van der Werven a écrit : -On [20080116 12:51], Bruno Desthuilliers ([EMAIL PROTECTED]) wrote: Apart from checking posts headers and complaining

Re: Simple List division problem

2008-01-12 Thread Dustan
On Jan 12, 2:25 pm, Paul Rubin http://[EMAIL PROTECTED] wrote: marcstuart [EMAIL PROTECTED] writes: what I would like to get is 3 sublists print z[0] = [1,2,3] print z[2] = [4,5,6] print z[3] = [7,8,9,10] Are you SURE you want that? In almost every situation I've seen, print

Re: What is lambda x=x : ... ?

2008-01-10 Thread Dustan
On Jan 10, 12:36 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I've figured it out, it is default argument. print y() gives 13 as result. It's a bit evil though. Why? It's the same syntax as with functions: x=3 def y(x=x): return x+10 print y(2) # prints 12 print y() # prints 13 --

Re: Python's great, in a word

2008-01-07 Thread Dustan
On Jan 7, 7:09 am, [EMAIL PROTECTED] wrote: I'm a Java guy who's been doing Python for a month now and I'm convinced that 1) a multi-paradigm language is inherently better than a mono-paradigm language 2) Python writes like a talented figure skater skates. Would you Python old-timers try

Re: Python's great, in a word

2008-01-07 Thread Dustan
On Jan 7, 11:40 am, Martin Marcher [EMAIL PROTECTED] wrote: it's pythonicness. it is pythonicness??? -- http://mail.python.org/mailman/listinfo/python-list

Re: fastest method to choose a random element

2008-01-06 Thread Dustan
On Jan 5, 4:16 am, [EMAIL PROTECTED] wrote: The warning The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet. means a person, but not a bot, may see my email address, so it is safe to use my real address

Re: Why does __builtins__ mean different things...

2007-12-30 Thread Dustan
On Dec 22, 1:59 pm, James Stroud [EMAIL PROTECTED] wrote: Dustan wrote: On Dec 21, 8:11 pm, James Stroud [EMAIL PROTECTED] wrote: I swear there is another thread going on here of which I am not aware. You just keep on telling yourself that. Is there a cricket here? No, but you can tell

Re: Why does __builtins__ mean different things...

2007-12-22 Thread Dustan
On Dec 21, 8:11 pm, James Stroud [EMAIL PROTECTED] wrote: I swear there is another thread going on here of which I am not aware. You just keep on telling yourself that. -- http://mail.python.org/mailman/listinfo/python-list

Re: Performance on local constants?

2007-12-22 Thread Dustan
On Dec 22, 6:04 am, John Machin [EMAIL PROTECTED] wrote: t3 = re.compile('whatever').search Ack! No! Too Pythonic! GETITOFF! GETITOFF!! -- http://mail.python.org/mailman/listinfo/python-list

Re: Python implementation of include

2007-12-13 Thread Dustan
[EMAIL PROTECTED] wrote: Hello, I've been using the Python-based Karrigell web application framework. It has the very handy word include that inserts a code file into into the stream of execution. E.g. if myFile.py contains the code: print This is a message from myFile.pybr and my

Re: Tuning question

2007-11-29 Thread Dustan
On Nov 28, 3:15 pm, Wally Lepore [EMAIL PROTECTED] wrote: Hi Graham Is this email still good? Not anymore. You just gave it out to millions of spammers on Usenet. Its been awhile since we spoke last on the tuning list. Are you still on Yahoo messenger? Also, what is your email address

Re: How to use list as key of dictionary?

2007-11-06 Thread Dustan
On Nov 6, 3:58 am, Duncan Booth [EMAIL PROTECTED] wrote: Wildemar Wildenburger [EMAIL PROTECTED] wrote: maybe something like this could help: def tupleize(non_tuple): try: return tuple(tupleize(thing) for thing in non_tuple) except TypeError: # non_tuple

Re: how does google search in phrase

2007-11-05 Thread Dustan
On Nov 4, 6:21 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: hi my friends; google can searching in phrase but it is imposible. it have a lot of page in data base and quadrillions sentence it can't search in fulltxt all of them .it need a super algorithm. ý need the algorithm now. if you

Re: how does google search in phrase

2007-11-05 Thread Dustan
On Nov 5, 7:14 am, Jeff [EMAIL PROTECTED] wrote: Here is a detailed explanation: http://www.google.com/technology/pigeonrank.html Ha ha... Hilarious. -- http://mail.python.org/mailman/listinfo/python-list

Re: setting variables in outer functions

2007-11-01 Thread Dustan
On Oct 31, 5:59 pm, Chris Mellon [EMAIL PROTECTED] wrote: On Oct 31, 2007 5:49 PM, Dustan [EMAIL PROTECTED] wrote: [snip] I'm not going to respond to any of this, but I'm just going to say: I'm not claiming that the use of closures is common. I'm just claiming that it can be useful. I have used

Re: setting variables in outer functions

2007-10-31 Thread Dustan
On Oct 30, 11:29 am, Duncan Booth [EMAIL PROTECTED] wrote: Neil Cerutti [EMAIL PROTECTED] wrote: It's allows a standard programming idiom which provides a primitive form of object oriented programming using closures to represent state. def account(opening_balance): balance =

Re: setting variables in outer functions

2007-10-31 Thread Dustan
On Oct 31, 7:08 am, Duncan Booth [EMAIL PROTECTED] wrote: Dustan [EMAIL PROTECTED] wrote: On Oct 30, 11:29 am, Duncan Booth [EMAIL PROTECTED] wrote: Neil Cerutti [EMAIL PROTECTED] wrote: It's allows a standard programming idiom which provides a primitive form of object oriented

Re: A Python 3000 Question

2007-10-30 Thread Dustan
On Oct 29, 7:59 pm, Wildemar Wildenburger [EMAIL PROTECTED] wrote: Bjoern Schliessmann wrote: The inconsistencies arise, IMHO, if an OO language introduces non-object types for performance reasons, after that gets wrapper classes to wrap those primitives, and even later gets the ability

Re: Using msvcrt (in Windows), how to catch Enter key?

2007-10-29 Thread Dustan
On Oct 29, 4:26 am, Dick Moores [EMAIL PROTECTED] wrote: Windows XP Pro, Python 2.5.1 import msvcrt while True: if msvcrt.kbhit(): key = msvcrt.getch() if key == 'Enter' do something Is there a way to catch the pressing of the 'Enter' key? Thanks, Dick

Re: and and or on every item in a list

2007-10-29 Thread Dustan
On Oct 29, 5:57 pm, GHZ [EMAIL PROTECTED] wrote: Is this the best way to test every item in a list? No. The biggest problem is, obviously, you don't take advantage of builtins any() and all(), or write corresponding short-circuiting versions for python versions before 2.5. The second problem

Re: simple question on dictionary usage

2007-10-27 Thread Dustan
On Oct 27, 1:16 am, Frank Millman [EMAIL PROTECTED] wrote: On Oct 27, 8:02 am, Frank Millman [EMAIL PROTECTED] wrote: This should work - egt = dict([i for i in d.items() if i[0].startswith('E')]) Of course I meant record.items(), not d.items(). Sorry. Frank On reflection, although

Re: dynamic invoke

2007-10-22 Thread Dustan
On Oct 19, 6:34 am, Nils [EMAIL PROTECTED] wrote: Use apply(): http://docs.python.org/lib/non-essential-built-in-funcs.html Did you actually read the title of the page you linked to (Non- essential Built-in Functions)? -- http://mail.python.org/mailman/listinfo/python-list

Re: calling a function from string

2007-10-22 Thread Dustan
On Oct 22, 4:41 am, Francesco Guerrieri [EMAIL PROTECTED] wrote: On 10/22/07, james_027 [EMAIL PROTECTED] wrote: hi, i have a function that I could like to call, but to make it more dynamic I am constructing a string first that could equivalent to the name of the function I wish to

Re: calling a function from string

2007-10-22 Thread Dustan
On Oct 22, 5:46 am, Jarek Zgoda [EMAIL PROTECTED] wrote: Do not use eval(). Not only it's deprecated, it's also unsafe. I don't think it's deprecated; it doesn't say so: http://docs.python.org/lib/built-in-funcs.html#l2h-25 -- http://mail.python.org/mailman/listinfo/python-list

Re: Noob: Loops and the 'else' construct

2007-10-19 Thread Dustan
On Oct 19, 3:12 am, Thorsten Kampe [EMAIL PROTECTED] wrote: So a for/else loop is exactly the same thing as a for loop with the else clause outside the loop (except for break)? Am I missing something here? It sounds to me like you just described two identical constructs. Guess that's why I

Re: Strange behaviour with reversed()

2007-10-18 Thread Dustan
On Oct 18, 3:52 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Thu, 18 Oct 2007 15:24:27 +1000, Ben Finney wrote: Steven D'Aprano [EMAIL PROTECTED] writes: and help(reversed) but neither gives any insight to what happens when you use reversed() on a sequence, then

Re: Last value of yield statement

2007-10-10 Thread Dustan
On Oct 10, 5:19 am, Shriphani [EMAIL PROTECTED] wrote: Hello all, Let us say I have a function like this: def efficientFiller(file): Note that you are shadowing the built-in variable 'file' here. Better use 'filename', or something to that effect. worthless_list = []

Re: hi every one

2007-10-10 Thread Dustan
On Oct 10, 7:19 pm, kasim [EMAIL PROTECTED] wrote: Dear __, __.dear() Traceback (most recent call last): File pyshell#0, line 1, in module __.dear() NameError: name '__' is not defined __ = self __.dear() Traceback (most recent call last): File pyshell#1,

Re: novice list

2007-10-05 Thread Dustan
On Oct 5, 6:01 am, István [EMAIL PROTECTED] wrote: Could somebody suggest me a novice Python list, please? Thanks, Istvan You're there. -- http://mail.python.org/mailman/listinfo/python-list

Re: scope, modyfing outside object from inside the method

2007-09-24 Thread Dustan
On Sep 24, 2:13 am, Peter Otten [EMAIL PROTECTED] wrote: @property def value(self): return self._resultset[self._row][self._col] I remember a thread where someone created a version of property that worked like this, but it's not in the standard python release, unless it is in

Re: Sets in Python

2007-09-20 Thread Dustan
On Sep 19, 10:58 pm, Bryan Olson [EMAIL PROTECTED] wrote: Bad news: Python 3000 has no immutable type for byte-strings. The new bytes type cannot serve for dict keys or set members. Many things one would want to hash are unhashable -- for example, the results of the hash functions in hashlib.

Re: Sets in Python

2007-09-18 Thread Dustan
On Sep 18, 7:39 pm, sapsi [EMAIL PROTECTED] wrote: Hello, I recently tried using the set function in Python and was surprised to find that a=[ 1, 2,3, [1,2] ] doesn't work with 'set', throwing TyperError (unhashable exception). I found out that this is because lists can't be hashed.

Re: Python statements not forcing whitespace is messy?

2007-09-16 Thread Dustan
On Sep 15, 5:11 pm, James Stroud [EMAIL PROTECTED] wrote: Steve Holden wrote: I don't know why you have a bug up your ass about it, as the Americans say. I think most Americans say wild hare up your ass. We do not, in fact, say wild hair up your ass. Many of us can testify that a hair up

Re: Try this

2007-09-16 Thread Dustan
On Sep 16, 3:46 am, GeorgeRXZ [EMAIL PROTECTED] wrote: If you have Microsoft windows 98/2000/ME/XP/2003 Operating System on your PC. Then Open the Notepad and type the following sentence, and save the file and close the notepad. Now reopen the file and you will find out that, Notepad is not

Re: where are the .pyc files?

2007-09-16 Thread Dustan
On Sep 16, 12:28 pm, Summercool [EMAIL PROTECTED] wrote: so i have always heard of the .pyc files but for some reason i don't see them on the Windows platform... when i have a program called try.py and after running it for ages, i still don't have a try.pyc file in my folder even if i

Re: Python with

2007-09-16 Thread Dustan
On Sep 16, 3:07 pm, Ivan Voras [EMAIL PROTECTED] wrote: Hi, I'm looking for a construct that's similar to (Turbo) Pascal's with statement. I read about the Python's new with statement, but I was dissapointed to learn that it does something different (I still don't see how it's better than

Re: unexpected behavior: did i create a pointer?

2007-09-07 Thread Dustan
On Sep 7, 3:07 am, gu [EMAIL PROTECTED] wrote: hi to all! Hi! after two days debugging my code, i've come to the point that the problem was caused by an unexpected behaviour of python. or by lack of some information about the program, of course! i've stripped down the code to reproduce the

Re: an eval()-like exec()

2007-08-28 Thread Dustan
On Aug 27, 6:06 pm, Matt McCredie [EMAIL PROTECTED] wrote: A python interactive interpreter works by having the user type in some code, compiling and running that code, then printing the results. For printing, the results are turned into strings. I would like make an interpreter which

Re: Let's Unite Against Jews and Mongrels!

2007-08-28 Thread Dustan
On Aug 27, 2:13 am, Nenad Milicevic - The Aryan Serb [EMAIL PROTECTED] wrote: Let's break the chains of Jewish and black domination! A) Why? B) What chains? -- http://mail.python.org/mailman/listinfo/python-list

Re: How to parse this line of code manually

2007-08-28 Thread Dustan
On Aug 28, 2:59 am, A.T.Hofkamp [EMAIL PROTECTED] wrote: On 2007-08-28, Davy [EMAIL PROTECTED] wrote: On Aug 28, 11:00 am, Davy [EMAIL PROTECTED] wrote: Hi all, It is well known that Python is appreciated for its merit of concise. However, I found the over concise code is too hard to

Re: Check for dict key existence, and modify it in one step.

2007-08-28 Thread Dustan
On Aug 28, 1:13 pm, rodrigo [EMAIL PROTECTED] wrote: evan, yes, it does help. Works like it should: class CountingDictionary(dict): def increment(self, key, delta=1): self[key] = self.get(key, 0) + delta d = CountingDictionary() d.increment('cat') d.increment('dog',72)

Re: accessing keys in dict

2007-08-25 Thread Dustan
On Aug 25, 7:41 am, Lawrence D'Oliveiro [EMAIL PROTECTED] central.gen.new_zealand wrote: In message [EMAIL PROTECTED], james_027 wrote: is there any difference between .. for key in a_dict: from for key in a_dict.keys(): I'm assuming the former is equivalent to for key in

Re: How to optimise this code?

2007-08-21 Thread Dustan
On Aug 21, 11:20 am, J. Cliff Dyer [EMAIL PROTECTED] wrote: I suspect lambda might be your friend here too for making the code less verbose, though I never really got the hang of lambdas, even though my first programming experience was a scheme class way back when Ah well. That's because

Re: Where we need to use Python ?

2007-08-20 Thread Dustan
On Aug 20, 3:02 am, [EMAIL PROTECTED] wrote: Hi Iam new to Python I know Perl, JScript,C,C++,Java But i want to know where excatly this python come in to picture And Is it a interpreted language or a programming language It comes in which category I very keen to know this please tell

Re: Where we need to use Python ?

2007-08-20 Thread Dustan
On Aug 20, 10:13 am, Wildemar Wildenburger [EMAIL PROTECTED] wrote: Michael Bentley wrote: On Aug 20, 2007, at 1:02 AM, [EMAIL PROTECTED] wrote: And Is it a interpreted language or a programming language It comes in which category I very keen to know this please tell [ open on

Re: Guitar Reviews

2007-08-15 Thread Dustan
On Aug 15, 7:32 am, [EMAIL PROTECTED] wrote: snip op.mother.speak() Congratulations! You've just given your email address to millions of people across Usenet! What do you have to say for yourself? op.respond() Awww, jeez, why'd y'all have to bring my mother into this? op.mother.speak() You're

Re: A dumb question about a class

2007-08-12 Thread Dustan
On Aug 12, 5:09 pm, Steven Bethard [EMAIL PROTECTED] wrote: def iter_primes(): # an iterator of all numbers between 2 and +infinity numbers = itertools.count(2) # generate primes forever while True: # get the first number from the

Re: Complexity of methods etc

2007-08-12 Thread Dustan
On Aug 12, 7:04 pm, Nathan Harmston [EMAIL PROTECTED] wrote: Hi, I was wondering if anyone knew of any resources, where I might be able to find information about the complexity of certain python functions or little tips on how to reduce complexity. I mean like the .join(), kind of thing? I

Re: A dumb question about a class

2007-08-12 Thread Dustan
On Aug 12, 7:35 pm, Dustan [EMAIL PROTECTED] wrote: On Aug 12, 5:09 pm, Steven Bethard [EMAIL PROTECTED] wrote: def iter_primes(): # an iterator of all numbers between 2 and +infinity numbers = itertools.count(2) # generate primes forever while

Re: Deleting objects on the fly

2007-08-11 Thread Dustan
On Aug 10, 1:49 pm, Terry Reedy [EMAIL PROTECTED] wrote: Campbell Barton [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]| Michele Simionato wrote: | Probably not, 'del x' just decrements the reference count, Or ashttp://docs.python.org/ref/del.html puts it, Deletion of a name

Re: Metaclass v.s. Property function.

2007-08-11 Thread Dustan
On Aug 11, 7:33 am, Jens Thiede [EMAIL PROTECTED] wrote: I don't like the property function, usable in the new-style classes, because having to remember to manage a list of foo = property(...) assignments just plain sucks, so I wrote a metaclass that does things a little differently. Please

Re: python 2.5 bug

2007-08-11 Thread Dustan
On Aug 11, 12:32 am, Thorsten Kampe [EMAIL PROTECTED] wrote: 4. don't do something you don't fully understand (in this case installing Python 2.5 and uninstalling Python 2.4) If we were all limited by that rule, none of us would never have used a computer in the first place. Operating a

Re: Question about properties.

2007-08-10 Thread Dustan
On Aug 10, 5:31 am, [EMAIL PROTECTED] wrote: On Aug 10, 12:21 pm, king kikapu [EMAIL PROTECTED] wrote: Hi, i read in a book the following code snippet that is dealing with properties: class ProtectAndHideX(object): def __init__(self, x): assert isinstance(x, int), 'x

Re: programmatically define a new variable on the fly

2007-08-09 Thread Dustan
On Aug 9, 5:11 pm, Lee Sander [EMAIL PROTECTED] wrote: Hi, I would like to define a new variable which is not predefined by me. For example, I want to create an array called X%s where %s is to be determined based on the data I am processing. So, for example, if I the file I'm reading has g

Re: programmatically define a new variable on the fly

2007-08-09 Thread Dustan
On Aug 9, 5:30 pm, Dustan [EMAIL PROTECTED] wrote: given the variables data (the dictionary), name (in your example, 'g') and *size* (in your example, 99), you can add it data as shown: erm... make that: given the variables data (the dictionary), name (in your example, 'g') and size (in your

Re: simple string backspace question

2007-07-31 Thread Dustan
On Jul 31, 7:17 am, John Machin [EMAIL PROTECTED] wrote: On Jul 31, 8:01 pm, [EMAIL PROTECTED] wrote: On 31 srp, 11:44, [EMAIL PROTECTED] wrote: Hello, I have one simple string, backspace character question.Here is my example: text=Hello\bworld print text HelloBSworld

Re: a_list.count(a_callable) ?

2007-06-16 Thread Dustan
On Jun 16, 12:04 pm, Wildemar Wildenburger [EMAIL PROTECTED] wrote: class SmartCountingList(list): def count(self, item, func=lambda x: x): return len([item for item in self if func(item) is True]) A less bug-prone and (I would think) speedier example, although still untested:

Re: a_list.count(a_callable) ?

2007-06-16 Thread Dustan
On Jun 16, 3:37 pm, Dustan [EMAIL PROTECTED] wrote: class SmartCountingList(list): def count(self, item, func=lambda x: x): return sum(1 for i in self if func(item)==item) Then, you would call it as follows: a_list.count(True, a_function) I need to learn to think things through

Re: a_list.count(a_callable) ?

2007-06-15 Thread Dustan
On Jun 15, 9:15 am, Ping [EMAIL PROTECTED] wrote: sum(1 for i in a_list if a_callable(i)) -- Carsten Haesehttp://informixdb.sourceforge.net This works nicely but not very intuitive or readable to me. First of all, the generator expression makes sense only to trained eyes. Secondly,

Re: a_list.count(a_callable) ?

2007-06-15 Thread Dustan
On Jun 15, 12:52 pm, Ping [EMAIL PROTECTED] wrote: On 6 15 , 11 17 , Dustan [EMAIL PROTECTED] wrote: On Jun 15, 9:15 am, Ping [EMAIL PROTECTED] wrote: sum(1 for i in a_list if a_callable(i)) -- Carsten Haesehttp://informixdb.sourceforge.net This works nicely but not very

Re: Should: for k,v in **dictionary_instance work?

2007-06-15 Thread Dustan
On Jun 15, 2:17 pm, [EMAIL PROTECTED] wrote: Does it make sense to provide this syntax for iterating key/value pairs from a dictionary? for k,v in **dict(): print k,v why is this not the same as: for k,v in dict().items(): print k,v for that matter, why the heck doesn't a

Re: a_list.count(a_callable) ?

2007-06-14 Thread Dustan
On Jun 14, 2:53 pm, Ping [EMAIL PROTECTED] wrote: Hi, I'm wondering if it is useful to extend the count() method of a list to accept a callable object? What it does should be quite intuitive: count the number of items that the callable returns True or anything logically equivalent

Re: a_list.count(a_callable) ?

2007-06-14 Thread Dustan
On Jun 14, 3:37 pm, Dustan [EMAIL PROTECTED] wrote: map and filter are basically obsolete after the introduction of list comprehensions It is probably worth noting that list comprehensions do not require that you write a new function; they take any expression where appropriate. For more

Re: a_list.count(a_callable) ?

2007-06-14 Thread Dustan
On Jun 14, 3:37 pm, Dustan [EMAIL PROTECTED] wrote: Which can then be converted into a generator expression (round brackets instead of square brackets) to avoid the intermediate list: len((i for i in a_list if a_callable(i))) Sorry for the excess of posts everybody. I just realized

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 anyway. ;-)

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 a lot.

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 to

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.randint(0,

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. 0. 1. 4. 1.

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 the

Re: c[:]()

2007-05-30 Thread Dustan
On May 30, 5:37 pm, Warren Stringer [EMAIL PROTECTED] wrote: Hey many thanks for the replies! Ah, so is seems that c[:][:][:][:][:][:][:][:][:][:][:][0]() also work ... Ah well, can't have everything. Guess I was inspired by the alphabetically adjacent message Call for Ruby Champion. Would

Re: NEWBIE: Extending a For Statement.

2007-05-21 Thread Dustan
On May 21, 7:22 am, Jean-Paul Calderone [EMAIL PROTECTED] wrote: On 21 May 2007 05:10:46 -0700, mosscliffe [EMAIL PROTECTED] wrote: I keep seeing examples of statements where it seems conditionals are appended to a for statement, but I do not understand them. I would like to use one in the

Re: NEWBIE: Extending a For Statement.

2007-05-21 Thread Dustan
On May 21, 7:22 am, Jean-Paul Calderone [EMAIL PROTECTED] wrote: On 21 May 2007 05:10:46 -0700, mosscliffe [EMAIL PROTECTED] wrote: I keep seeing examples of statements where it seems conditionals are appended to a for statement, but I do not understand them. I would like to use one in the

Re: NEWBIE: Extending a For Statement.

2007-05-21 Thread Dustan
On May 21, 9:21 am, mosscliffe [EMAIL PROTECTED] wrote: On 21 May, 15:02, [EMAIL PROTECTED] wrote: mosscliffe: if key in xrange (60,69) or key == 3: I keep seeing again and again code like this, mostly from people not much expert of Python, but the PEP 260 shows the fast in was

Re: converting strings to most their efficient types '1' -- 1, 'A' --- 'A', '1.2'--- 1.2

2007-05-18 Thread Dustan
On May 18, 6:07 pm, py_genetic [EMAIL PROTECTED] wrote: Hello, I'm importing large text files of data using csv. I would like to add some more auto sensing abilities. I'm considing sampling the data file and doing some fuzzy logic scoring on the attributes (colls in a data base/ csv file,

Re: try

2007-05-17 Thread Dustan
On May 16, 4:22 pm, Robert Kern [EMAIL PROTECTED] wrote: HMS Surprise wrote: I read in the ref man that try-except-finally did not work in earlier versions, I am using jython 2.2. Does this imply that try-except without finally does not work either? I get a syntax error on the else below.

  1   2   3   >