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
[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
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
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'
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
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
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
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
[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
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
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
[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
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
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
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
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
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
>> 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
> 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
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
20 matches
Mail list logo