Re: How to covert ASCII to integer in Python?

2007-02-22 Thread keirr
On Feb 22, 5:43 pm, John [EMAIL PROTECTED] wrote: Is there any built in function that converts ASCII to integer or vice versa in Python? Thanks! Try int. ie. try: int_val = int(str_val) except ValueError: # conversion failed Keir. -- Keir Robinson Sometimes a scream is better than a

Re: dictionary of list from a file

2006-10-04 Thread keirr
[EMAIL PROTECTED] wrote: snip perl example code in python I tried: b={} a=[] for line in fl.readlines(): info=lines.split() b[info[0]] = a.append(info[1]) and then for i in b: print i,b[i] i get 2 None 7 None data file is: 2 1 2 2 2 3 2 4 7 7 7 8 7 9 7

Re: Modify one character in a string

2006-05-25 Thread keirr
mp wrote: X-No-Archive How do I go about modifying one character in a string elegantly? In other words, I want a function that will change '' to 'aaza', given the index 2 of the character in the string. Also, how do I do this when dealing with a file ; which file mode should I use and

Re: This coding style bad practise?

2006-05-03 Thread keirr
Martin P. Hellwig wrote: Hi all, I created a class which creates a relative unique id string, now my program just works fine and as expected but somehow I get the feeling that I misused the __repr__ since I guess people expect to 'execute' a function in an instance instead of using it's

Re: newbie questions

2006-03-15 Thread keirr
meeper34 wrote: Hi, I'm just starting out with Python, and so far I am thoroughly impressed with what you can do very easily with the language. I'm coming from a C++ background here. A couple of questions came up as I was thinking about dynamically typed languages: 1. If someone

Re: Providing 'default' value with raw_input()?

2005-12-22 Thread keirr
planetthoughtful wrote: I'm wondering if it's possible, using raw_input(), to provide a 'default' value with the prompt? def get_input_with_default(default, prompt= ): result = raw_input('['+str(default)+'] '+str(prompt)) if result == : result = default return default I would like

Re: Providing 'default' value with raw_input()?

2005-12-22 Thread keirr
planetthoughtful wrote: It seems, according to keir, that this simply can't be done via the command line in DOS, which is a shame. Now, I said I couldn't think of a way to do it - not that it wasn't possible :-) If you don't need you program to be portable you can use extensions - in this case

Re: jython: True and False boolean literals?

2005-12-22 Thread keirr
[EMAIL PROTECTED] wrote: Aren't there boolean literals for True and False in Python True != False True type(True) type 'bool' works for most people :-) All the best, Keir -- http://mail.python.org/mailman/listinfo/python-list

Re: jython: True and False boolean literals?

2005-12-22 Thread keirr
keirr wrote: [EMAIL PROTECTED] wrote: Aren't there boolean literals for True and False in Python True != False True type(True) type 'bool' works for most people :-) Ahem, who use python. For jython this looks like True != False 1 type(True) type 'int' Keir. -- http

Re: jython: True and False boolean literals?

2005-12-22 Thread keirr
Kent Johnson wrote: [EMAIL PROTECTED] wrote: Aren't there boolean literals for True and False in Python (jython)? I can't get true, True, false, or False to work. I ended up having to use (1==1) and (1==0). No, there are not. Jython implements Python 2.1 which did not have boolean

Re: Providing 'default' value with raw_input()?

2005-12-22 Thread keirr
planetthoughtful wrote: Hi Kier, Any idea where I'd find documentation on using this extension? I've downloaded and installed, but haven't had any luck finding docs for it. As it's a windows version of the standard readline module (usually available on Unix only) I'd _guess_ that you could

Re: Creating interactive command-line Python app?

2005-12-21 Thread keirr
You may also find the cmd module useful, see: http://docs.python.org/lib/module-cmd.html Cheers, Keir. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it possible to use python to unit test C++ code?

2005-12-21 Thread keirr
[EMAIL PROTECTED] wrote: Is it possible to use python to unit test C++ code? If yes, is there any example available? If I had to use python to test C++ code, I'd use the Boost python library: http://www.boost.org/libs/python/doc/ to expose my C++ classes, and write the unittests in python

Re: UDP socket, need help setting sending port

2005-12-20 Thread keirr
Fred, It is quite possible I've misunderstood the problem :-) but have you tried anything like import socket tc_local_port = tc_remote_port = outgoing_if = 172.16.1.2 # say remote_tc_host = 172.16.1.3 # say # udp is the default for DGRAM tc_sock =

Re: UDP socket, need help setting sending port

2005-12-20 Thread keirr
A few trivial corrections, to my own post :-( tc_sock = socket(socket... should be tc_sock = socket.socket(socket... of course and, (while I'm here) when I stated that calling connect on an unbound socket caused a ephemeral port to be assigned, I should have written calling connect on an

Re: which reg values modified my python installer under windows

2005-09-06 Thread keirr
Philippe, Windows file associations are in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts Hope that helps you. All the best, Keir. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python suitable for a huge, enterprise size app?

2005-05-18 Thread keirr
So, given the very general requirements in the first paragraph, do you think that Python could handle it? If anyone has direct experience developing large apps in Python, I would appreciate your insight. I wouldn't, especially[1] if your thousands of business objects get

Re: Is Python suitable for a huge, enterprise size app?

2005-05-18 Thread keirr
I wouldn't, especially[1] if your thousands of business objects get allocated/deallocated as the system runs. Currently python's memory usage can grow rapidly (from the perspective of the o/s) when large numbers of objects are repeatedly created and freed. Isn't it true that in recent Python

Re: Strings

2005-04-21 Thread keirr
I'd use the int and chr casts. e.g., new_string = a = '012' new_string += chr(int(a)) Just in case the 012 is an octal code I'll mention that to cast to int in general you can pass the base, as in int('034',8) or int('AF',16) Cheers, Keir. --