Re: newbie problem with str.replace

2010-08-04 Thread Anthony Tolle
On Aug 4, 9:10 am, BobAalsma bob.aal...@aalsmacons.nl wrote:                         #                         bestandsnaam_nieuw = bestandsnaam                         bestandsnaam_nieuw.replace(KLANTNAAM_OUT,KLANTNAAM_IN) The replace method does not modify the string (strings are immutable).

Re: Need debugging knowhow for my creeping Unicodephobia

2010-02-10 Thread Anthony Tolle
On Feb 10, 2:09 pm, kj no.em...@please.post wrote: Some people have mathphobia.  I'm developing a wicked case of Unicodephobia. [snip] Some general advice (Looks like I am reiterating what MRAB said -- I type slower :): 1. If possible, use unicode strings for everything. That is, don't use

Re: A silly question on file opening

2010-02-10 Thread Anthony Tolle
On Feb 10, 3:42 pm, joy99 subhakolkata1...@gmail.com wrote: Dear Group, [snip] I tried to change the location to D:\file and as I saw in Python Docs the file reading option is now r+ so I changed the statement to    file_open=open(D:\file,r+) but it is still giving error. Only use r+ if you

Re: interaction of mode 'r+', file.write(), and file.tell(): a bug or undefined behavior?

2010-01-28 Thread Anthony Tolle
On Jan 28, 7:12 am, Lie Ryan lie.1...@gmail.com wrote: In the code: f = open('input.txt', 'r+') for line in f:     s = line.replace('python', 'PYTHON')     # f.tell()     f.write(s) [snip] My guess is that there are a few possible problems: 1) In this case, writing to file opened

Re: Python OOP Problem

2009-12-28 Thread Anthony Tolle
On Dec 28, 7:29 am, Martin v. Loewis mar...@v.loewis.de wrote: In this case (you just started to learn Python), I recommend to take an explicit approach. Create a dictionary that maps class names to classes: name2class = { MyObject : MyObject,                MyOtherObject : MyOtherObject,  

Re: Windows file paths, again

2009-10-21 Thread Anthony Tolle
On Oct 21, 3:20 pm, Dan Guido dgu...@gmail.com wrote: Hi Diez, The source of the string literals is ConfigParser, so I can't just mark them with an 'r'. config = ConfigParser.RawConfigParser() config.read(filename) crazyfilepath = config.get(name, ImagePath) normalfilepath =

Re: set using alternative hash function?

2009-10-16 Thread Anthony Tolle
On Oct 16, 12:24 pm, Ethan Furman et...@stoneleaf.us wrote: [snip] As for what you want:  No, it's not currently possible.  If it's so big a deal that the various methods presented don't meet with your approval, break out the C and write your own.  Then you could give that back to the

Re: set using alternative hash function?

2009-10-15 Thread Anthony Tolle
On Oct 15, 7:24 am, Austin Bingham austin.bing...@gmail.com wrote: [snip] I'd like to create a set of these objects where the hashing is done on these names. [snip] Why not use a dict? The key would be the object name. Pretty much the same behavior as a set (via the key), and you can still

Re: set using alternative hash function?

2009-10-15 Thread Anthony Tolle
On Oct 15, 10:42 am, Austin Bingham austin.bing...@gmail.com wrote: On Thu, Oct 15, 2009 at 4:06 PM, Anthony Tolle To reiterate, dict only gets me part of what I want. Whereas a set with uniqueness defined over 'obj.name' would guarantee no name collisions, dict only sorta helps me keep

Re: set using alternative hash function?

2009-10-15 Thread Anthony Tolle
On Oct 15, 12:11 pm, Austin Bingham austin.bing...@gmail.com wrote: To put it in code, I want this:   s = set(hash_func = lambda obj: hash(obj.name), eq_func = ...)   ...   x.name = 'foo'   y.name = 'foo'   s.add(x)   s.add(y) # no-op because of uniqueness criteria   assert len(s) == 1 I

Re: set using alternative hash function?

2009-10-15 Thread Anthony Tolle
On Oct 15, 1:49 pm, Ethan Furman et...@stoneleaf.us wrote: I'm still not sure I understand your concern about the values in a set, though.  Sets keep the first object of a given key, dicts keep the last object of a given key; in both cases, all other objects with the same key are lost. So is

Re: Move dictionary from instance to class level

2009-08-27 Thread Anthony Tolle
To take things one step further, I would recommend using decorators to allow symbolic association of functions with the message identifiers, as follows: == (MESSAGE_ONE ,MESSAGE_TWO ,MESSAGE_THREE ) = xrange(3) class MyClass(object): method_dict = {}

Re: Help understanding the decisions *behind* python?

2009-07-20 Thread Anthony Tolle
On Jul 20, 12:27 pm, Phillip B Oldham phillip.old...@gmail.com wrote: ... Specifically the differences between lists and tuples have us confused and have caused many discussions in the office. We understand that lists are mutable and tuples are not, but we're a little lost as to why the two

Re: missing 'xor' Boolean operator

2009-07-16 Thread Anthony Tolle
On Jul 15, 8:32 pm, Paul Rubin http://phr...@nospam.invalid wrote: Among other things, that uses quadratic time!  Why do you want to keep popping items from that list instead of iterating through it anyway? Anyway, I think you wrote something close to this: ... Very true! I didn't think

Re: missing 'xor' Boolean operator

2009-07-15 Thread Anthony Tolle
On Jul 14, 2:25 pm, Dr. Phillip M. Feldman pfeld...@verizon.net wrote: Current Boolean operators are 'and', 'or', and 'not'.  It would be nice to have an 'xor' operator as well. My $0.02 on this discussion: There would be nothing gained by having non-bitwise XOR operator. You can't

Re: why cannot assign to function call

2008-12-29 Thread anthony . tolle
On Dec 29, 1:01 am, scsoce scs...@gmail.com wrote: I have a function return a reference, and want to assign to the reference, simply like this:  def f(a)           return a      b = 0     * f( b ) = 1* but the last line will be refused as can't assign to function call. In my thought , the

Re: How to read stdout from subprocess as it is being produced

2008-12-19 Thread anthony . tolle
On Dec 19, 9:34 am, Alex alex.pul...@gmail.com wrote: Hi, I have a Pyhon GUI application that launches subprocess. I would like to read the subprocess' stdout as it is being produced (show it in GUI), without hanging the GUI. I guess threading will solve the no-hanging issue, but as far as

Re: Guido's new method definition idea

2008-12-08 Thread anthony . tolle
On Dec 6, 4:15 pm, Carl Banks [EMAIL PROTECTED] wrote: On Dec 6, 12:47 am, Patrick Mullen [EMAIL PROTECTED] wrote: Could I do something like this: def a.add(b): return a+b Outside of a class?  Of course then that makes you think you could do 5.add(6) or something crzy like that.  

Re: Guido's new method definition idea

2008-12-08 Thread anthony . tolle
On Dec 6, 4:15 pm, Carl Banks [EMAIL PROTECTED] wrote: On Dec 6, 12:47 am, Patrick Mullen [EMAIL PROTECTED] wrote: Could I do something like this: def a.add(b): return a+b Outside of a class?  Of course then that makes you think you could do 5.add(6) or something crzy like that.  

Re: Guido's new method definition idea

2008-12-08 Thread anthony . tolle
): def self.func(arg): return arg + 1 - Anthony Tolle -- http://mail.python.org/mailman/listinfo/python-list