Re: [Tutor] subprocess and su

2007-08-22 Thread Michael Meier
> how I thought that it was supposed to work was it would allow me to use
> sbp.communicate() to
> send stuff to the stdin, and get information out. What do get is a prompt
> ask for my password. 

I believe that su does not read its input from stdin but from its
controlling tty. So you'd have to open a pseudo terminal: have a look at
the pty module.

cheers,
Michael

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] urllib2 and cookies

2007-10-25 Thread Michael Meier
Hi

ASPN has a very verbose example of cookielib usage at
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302930

Many things are very OS, especially Windows, specific. You can surely
phase out the relevant parts :)
Probably the solution with cookielib is the easiest way to go. Cookielib
is documented at
http://docs.python.org/lib/module-cookielib.html


Cheers,
Michael

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] IDLE Crashing

2006-08-05 Thread Michael Meier
I'm also having trouble when running IDLE under Debian 3.1 (Kernel
2.6.12). I often run into the same problem (IDLE not responding with the
only solution to killall idle) as Adam Gomaa just after starting up IDLE
and typing in some characters.

E.g. I'm starting up IDLE and typing in "import soc" when IDLE suddenly
stops responding. This happens while I'm typing and _not_ when executing
a line or a bunch of code.

This phenomenon is not reproducable, it just happens from time to time.
Unfortunately it happens rather often which does not amuse me ;)


Does anyone experience the same problem as I? Is there a common solution
to Adams and my problems?

Thanks,
Michael Meier

P.S. I'm new to this list... I think its a very interesting and friendly
place to be :)
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Lamdas and locality

2007-03-03 Thread Michael Meier
Hello

I ran the following code in python:

>>> ls = [(lambda op: op + i) for i in [1,2,3]]
>>> ls
[ at 0xb7de4cdc>,  at 0xb7de4d14>,
 at 0xb7de4d4c>]
>>> for l in ls:
... print l(5)
...
8
8
8
>>> 


I am quite surprised of the result. I'm generating three lamdas. What I
want to do is that the first lamda adds 1 to the operand and returns it,
the second lamda return 2 plus the operand and so on.
However all the three lamdas, despite being not the same object in
memory, are all adding 3, so they've got to have a reference to and not
to 1,2,3 respectively.

Why are the lamdas having a reference to the same integer? What am I
getting wrong here? :P


On Sat, 2007-03-03 at 17:24 +0100, [EMAIL PROTECTED] wrote:
> Send Tutor mailing list submissions to
>   tutor@python.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>   http://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
>   [EMAIL PROTECTED]
> 
> You can reach the person managing the list at
>   [EMAIL PROTECTED]
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
> 
> 
> Today's Topics:
> 
>1. Re: geeks like us and the rest of THEM (Andrei)
>2. Re: dictionaries and memory handling (Andrei)
>3. Re: Yet another list comprehension question (Kent Johnson)
>4. trouble understanding the python environment in OSX
>   (Clay Wiedemann)
>5. Re: trouble understanding the python environment in OSX
>   (Alan Gauld)
>6. Re: trouble understanding the python environment in OSX
>   (Kent Johnson)
>7. Re: Yet another list comprehension question (Andrei)
>8. Re: Yet another list comprehension question (Kent Johnson)
> 
> 
> --
> 
> Message: 1
> Date: Sat, 03 Mar 2007 13:40:05 +0100
> From: Andrei <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] geeks like us and the rest of THEM
> To: tutor@python.org
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> 
> > That's part of it. a good installer is another, and I am loo]king at a 
> > couple.  A solid and drool-proof server is the remaining leg of the 
> > tripod. So far, none of the servers I have seen are satisfactory on all 
> > scores- simplicity to install, reliability, economy of cost, (free or 
> > unlimited license to me for a modest fee) and ease to configure if the 
> > use\r so wishes. the closest I have yet seen SMALL HTTP SERVER. And it 
> > is very good.
> > http://smallsrv.com/
> 
> You could have a look at Aprelium's Abyss server (X1, which is freely 
> distributable in unmodified form IIRC, but closed source). It has a good 
> looking webbased configuration console and is cross-platform if you ever 
> need that. However, you'll probably end up digging in its config 
> programmatically to set up paths and such for the user - shouldn't be 
> too hard using some webscraping if the files are not readily modifiable. 
> Its setup is about 350 kB.
> 
> In terms of installers, NSIS (with the package to make it look modern, 
> instead of that awful default look - forgot its name) or InnoSetup are 
> the usual suspects. NSIS has a smaller overhead, but an uglier language.
> 
> -- 
> Yours,
> 
> Andrei
> 
> =
> Mail address in header catches spam. Real contact info:
> ''.join([''.join(s) for s in zip(
> "[EMAIL PROTECTED] pmfe!Pes ontuei ulcpss  edtels,s hr' one oC.",
> "rjc5wndon.Sa-re laed o s npbi ot.Ira h it oteesn edt C")])
> 
> 
> 
> --
> 
> Message: 2
> Date: Sat, 03 Mar 2007 14:18:24 +0100
> From: Andrei <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] dictionaries and memory handling
> To: tutor@python.org
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=windows-1252; format=flowed
> 
> > But most of my dictionaries are nested, and since both keys and values 
> > in the dbm 'dictionaries' have to be strings, I can't immediately see 
> > how I could get it to work.
> > 
> > A bit more detail: I deal with conditional probabilities, with up to 4 
> > parameters. These parameters are numbers or words and determine the 
> > value (which is always a number). E.g. I have a dictionary 
> > {p1:{p2:{p3:{p4:value, where the p's are different parameters. I 
> > sometimes need to sum over one or more of the parameters ? for now I 
> > have managed to structure the dictionaries so that I only need to sum 
> > over the innermost parameter, although this has been a bit cumbersome.
> 
> Depends a bit on how many keys each of the dictionaries is going to have 
> and in what order they're filled. You can pickle/cPickle an arbitrary 
> amount of data as one value, so the whole {p2:{p3:{p4:value}}} story 
> could be a value of the p1 key in the bsddb. However, you may not like 
> this if you need to retrieve p1 and add new stuff to it all the time, 
> because the pickling and

Re: [Tutor] Lamdas and locality

2007-03-04 Thread Michael Meier
Thanks for your answer and your workaround! There's always something to
learn about lambdas and variable scope in Python ;)

I'm sorry I didn't delete the quoted Tutor Digest part, it was a stupid
mistake :(


cheers,
Michael

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor