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

Re: dictionary of list from a file

2006-10-04 Thread keirr
[EMAIL PROTECTED] wrote: > 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 us

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'

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: > 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 coul

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 di

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) > > > works for most people :-) > Ahem, who use python. For

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) works for most people :-) All the best, Keir -- http://mail.python.org/mailman/listinfo/python-list

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 cas

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

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 af

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: 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 unboun

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 = socket(s

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: which reg values modified my python installer under windows

2005-09-06 Thread keirr
Philippe, You wrote: I wish to associate *.pyc with pythonw.exe is there some reason why Tools->Folder Options->File Types (from a Windows Explorer menu) won't work? You could do it from a cmd prompt with assoc and ftype if you needed to script it. All the best, Keir. -- http://mail.pyth

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 recen

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 allocated/dealloca

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. -- http://mail.python.org/mailman/listinfo/pytho