Hello everyone
Consider the following
>>> l = [1,2]
>>> for i in l:
... i = i + 1
...
>>> l
[1, 2]
I understand (I think!) that this is due to the fact that in Python
what looks like "assignment" really is binding a name to an object. The
result is that inside the loop I am creating an objec
)]
...
This would be awful when, eg, one adds an argument to the function
definition. It would require edition of the code at two different
locations.
Thanks
Mack
MackS wrote:
> Hello everyone
>
> Consider the following
>
> >>> l = [1,2]
> >>> for i in l:
>
Thank you for your reply.
> > 1) Is what I wrote above (minimally) correct?
>
> Correct for what? You can tell if it's *syntactically* correct by
> simply running it.
>
> As for any other "correct", define that. Does it do what you want it
> to do?
I was referring to my attempted explanation, no
Hello
I am writing a small app to learn how to use the curses module. I would
like to know how I can get "composite" key presses, eg, Control+Q.
Currently I am looking at the following code snippet:
import curses.wrapper
def main(stdscr):
x = 0
while True:
key = stdscr.getch(
Hi Dennis,
Thanks for your help, what is happening is clear now. Just found that
calling curses.raw() lets you get all scan codes.
Cheers
Mack
--
http://mail.python.org/mailman/listinfo/python-list
Hello everyone
I am faced with the following problem. For the first time I've asked
myself "might this actually be easier to code in C rather than in
python?", and I am not looking at device drivers. : )
This program is meant to process relatively long strings (10-20 MB) by
selectively modifying
Thank you all for your great help. One of the few things better than
python is the knowledgeable community around it. : )
Regards,
Mack
--
http://mail.python.org/mailman/listinfo/python-list
Hello everyone
Consider the following two simple files. The first is my "program", the
other a file holding some global variable definitions and code shared
by this program and a "twin" program (not shown here):
program1.py:
from shared import *
fun()
print "at top level: " + glo
Hello!
This question does not concern programming in python, but how to manage
python processes. Is there a way to "name" a python process? At least
on Linux, if I have two python programs running, they both run under
the name "python"
#pidof program1.py
[empty line]
#pidof program1.py
[empty lin
Hi Jorgen
You wrote that:
> $ head -1 foo3.py
> #!/usr/bin/python
> $ ./foo3.py
>
> This is the traditional shebang form used for shell and Perl scripts,
> and it names the process 'foo3.py' so you can killall(1) it nicely.
It doesn't work on my system; I just get yet another process called
pyt
Hi Jorgen
THanks for your help. I began writing a wrapper around python did (as
Donn suggested), but then noticed that this was due to not having
educated myself on the options you can pass to ps, pidof and top:
running pidof -x and using the 'c' command in top work pretty nicely.
That way I no l
Hi
I'm new to Python and would like to know if the following is possible.
Say I have one lower-level object A and one user-interface object B.
Suppose B.CallingMethod() calls A.CalledMethod(), the latter method
stumbles upon an IO error and raises an exception. The calling method
detects the exce
Hi
I'm new to Python, I've read the FAQ but still can't get the following
simple example working:
# file main_mod.py:
global_string = 'abc'
def main():
import auxiliary_mod
instance = auxiliary_mod.ClassA()
instance.fun()
return
main()
# file auxiliary_mod.py:
class ClassA:
I'm new to Python. In general I manage to understand what is happening
when things go wrong. However, the small program I am writing now fails
with the following message:
AttributeError: ClassA instance has no attribute '__len__'
Following the traceback,I see that the offending line is
self.x =
Dear all,
I've got several large sets in my program. After performing several
operations on these I wish to present one set to the user [as a list]
sorted according to a certain criterion. Is there any direct way to do
so? Or must I
list = []
for item in set1:
list.append(item)
list.sort(...
Thank you for the pointer. I'll upgrade to 2.4.
Best,
Mack
--
http://mail.python.org/mailman/listinfo/python-list
Dear all,
I just noticed the following behavior when I run
import os
import sys
import readline
histfile = os.path.join(os.environ["HOME"], ".pyhist")
try:
readline.read_history_file(histfile)
except IOError:
pass
import atexit
atexit.register(readline.write_history_file, histfile)
del
Thanks, Dennis, that solved it.
Cheers
Mack
Dennis Lee Bieber wrote:
> On 15 May 2005 16:32:57 -0700, "MackS" <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
>
>
> > while cmd != "":
> >
> > sys.stdout.write(&qu
Dear all,
I'm trying to use Python's readline module but I'm having some trouble.
In particular, autocompletion seems to "get stuck" on white spaces.
Please take a look at this code snippet:
import readline
def completer(text, state):
text = text
list = ['a dog', 'artsy']
if len
19 matches
Mail list logo