Thanks for your suggestions, I've decided to go with the smart
iterator solution, it's given me the results that I need. The
generator solution also seems interesting and I might try it out at a
later point.
--
The ByteBaker :
http://www.bytebaker.com
___
Alan,
I have been working with the Popen class, and it hangs when I perform the
read on the stdout socket. I am not sure how to read from the file object
after I perform the write into the process. When I use "communicate" it
closes the PIPE and terminates the process. Below are some configurat
"Demonic Software" <[EMAIL PROTECTED]> wrote
(cin, cout_cerror) = os.popen4("/bin/bash")
# write a command on the input pipe of the shell
print "writing ls -all!\n\n"
cin.write("ls -all")
cin.flush()
I would have expected that you needed to pass an
explicit newline at the end of the command?
"Shrutarshi Basu" <[EMAIL PROTECTED]> wrote
for item in block:
where block is a file, then item becomes each line of the file in
turn
But if block in a large string (let's say the actual text that was
in
the file), item becomes each character at a time.
Correct because for iterates over a
Hello,
I am trying to write an interactive shell that will pipe input from one
source to a shell/program, and then return the input to that source. I have
been trying to do this with the os.popen*, and I have not had any success in
getting this to work. Here is a basic piece of the code that dem
On Mon, Jun 9, 2008 at 5:26 PM, Shrutarshi Basu <[EMAIL PROTECTED]> wrote:
> If I do the following:
>
> for item in block:
>
> where block is a file, then item becomes each line of the file in turn
> But if block in a large string (let's say the actual text that was in
> the file), item becomes eac
If I do the following:
for item in block:
where block is a file, then item becomes each line of the file in turn
But if block in a large string (let's say the actual text that was in
the file), item becomes each character at a time. Is there a way to
have a uniform iteration irrespective of wheth
Our configuration language has evolved a bit more over the last few
days and I've decided to right a recursive descent parser for it.
Since this is a learning project for me, I'm writing the parser myself
instead of using one of the available packages. I'll see how this
affects the error handling.
On Jun 9, 2008, at 8:51 AM, W W wrote:
Originally I was planning to use urllib to post/retrieve
the data, but as far as I can tell, the bank uses several variables
and some javascript to authenticate everything, and it seems overly
complicated to try and manually figure it all out.
Raw urllib i
On Mon, Jun 9, 2008 at 3:26 PM, Michael Langford
<[EMAIL PROTECTED]> wrote:
> You're looking for mechanize
> http://wwwsearch.sourceforge.net/mechanize/
Possibly but mechanize emulates a browser, it doesn't control one,
which the OP specifically rejected as an option...
Kent
>> Originally I was
You're looking for mechanize
http://wwwsearch.sourceforge.net/mechanize/
On Mon, Jun 9, 2008 at 11:51 AM, W W <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've done some cursory searches, and it doesn't appear that what I
> want to do is popular, if it's even possible.
>
> I'm trying to control other appl
"W W" <[EMAIL PROTECTED]> wrote
I'm trying to control other applications via python (specifically my
web browser).
The webbrowser module will maybe give you a start?
My hope is there is some way to emulate a series of keypresses.
I know how to do that in Windows but not in Linux!
Is the
2008/6/9 Kent Johnson <[EMAIL PROTECTED]>:
> On Mon, Jun 9, 2008 at 11:54 AM, Dotan Cohen <[EMAIL PROTECTED]> wrote:
>> I must learn about these things, I've discovered, in this order:
>
> I suggest you look at Django, it helps with most of this. Probably
> TurboGears does also but I'm not familiar
2008/6/9 W W <[EMAIL PROTECTED]>:
> On Mon, Jun 9, 2008 at 11:21 AM, Dotan Cohen <[EMAIL PROTECTED]> wrote:
>> 2008/6/9 W W <[EMAIL PROTECTED]>:
>> I was doing this in PHP:
>> $title="Page title";
>> include"/path/to/header.php";
>>
>
> So in your header.php you had some source:
>
> echo "$title\n"
On Mon, Jun 9, 2008 at 11:54 AM, Dotan Cohen <[EMAIL PROTECTED]> wrote:
> I must learn about these things, I've discovered, in this order:
I suggest you look at Django, it helps with most of this. Probably
TurboGears does also but I'm not familiar with it.
> 1) How to use Python as an apache modu
On Mon, Jun 9, 2008 at 2:02 AM, Alan Gauld <[EMAIL PROTECTED]>
wrote:
> "S. Doron" <[EMAIL PROTECTED]> wrote
>
> Hello, I'm new to this list. What I'd like to do is add support for
>> pointers
>> to an old version of python (2.2) in an existing application (a game).
>>
>
> What do you mean by "ad
On Mon, Jun 9, 2008 at 11:21 AM, Dotan Cohen <[EMAIL PROTECTED]> wrote:
> 2008/6/9 W W <[EMAIL PROTECTED]>:
> I was doing this in PHP:
> $title="Page title";
> include"/path/to/header.php";
>
So in your header.php you had some source:
echo "$title\n";
or something to that effect?
> In Python I
Thank you all for the replies.
the 'else' is this necessary, surely when you have an:
>>> if x:
... print 'x'
...print 'y'
is this correct?
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
2008/6/9 W W <[EMAIL PROTECTED]>:
>> Thanks, Wayne, I am actually aware of this method. But it seems that
>> what I really want _is_ a function, and not a simple include.
>
> When you say function, exactly what are you referring to? Because
> really all a function *is* is a set of statements that
>
> Thanks, Wayne, I am actually aware of this method. But it seems that
> what I really want _is_ a function, and not a simple include.
When you say function, exactly what are you referring to? Because
really all a function *is* is a set of statements that
takes input*
does something*
gives output
Hi,
I've done some cursory searches, and it doesn't appear that what I
want to do is popular, if it's even possible.
I'm trying to control other applications via python (specifically my
web browser).
My hope is there is some way to emulate a series of keypresses. My
goal is to have a script that
2008/6/9 Jordan Kanter <[EMAIL PROTECTED]>:
> Another thing you can do is use django templates. they "work" to be
> similarly to php in the browser, and have something called an
> "extends" clause (see
> http://www.djangoproject.com/documentation/templates/) but in the
> background it is completel
2008/6/9 W W <[EMAIL PROTECTED]>:
> Python can *too* import from a txt file (even if it contains HTML):
>
> f = open("myfile.html", "r")
> x = f.read()
> print x
> f.close()
>
> It even retains formatting (as far as I can tell)...
>
> HTH,
> Wayne
>
Thanks, Wayne, I am actually aware of this metho
[EMAIL PROTECTED] ha scritto:
Sorry if this is a basic question, but how do I check if list is empty
or not and return True or False ;)
Normally, in Python, there are these evaluation:
1) True == 1
2) False == 0
3) Empty or have not value == False == 0
4) Not empty or have value == True == 1
On Mon, Jun 9, 2008 at 10:25 AM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> Hello
> Sorry if this is a basic question, but how do I check if list is empty
> or not and return True or False ;)
You can test the list directly, if it is empty it will evaluate to False:
if (myList):
print 'Somet
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Michael Langford
> Sent: Sunday, June 08, 2008 2:39 PM
> To: Dotan Cohen
> Cc: tutor@python.org
> Subject: Re: [Tutor] Why not to use include?
>
> Python makes web pages just fine. There are both embed
One another simple method is to check its count using the *len *method.
eg:
if len(mylist) == 0:
print "empty list"
This is particularly useful in situations where checking emptiness alone is
not enough.
On Mon, Jun 9, 2008 at 8:24 PM, W W <[EMAIL PROTECTED]> wrote:
> >>> def empty_or_not
sorry about the spelling. that second sentence should be "the work out
to be similar to php in the browser".
On Mon, Jun 9, 2008 at 9:57 AM, Jordan Kanter <[EMAIL PROTECTED]> wrote:
> Another thing you can do is use django templates. they "work" to be
> similarly to php in the browser, and have so
Another thing you can do is use django templates. they "work" to be
similarly to php in the browser, and have something called an
"extends" clause (see
http://www.djangoproject.com/documentation/templates/) but in the
background it is completely python (i.e. the template compiler), so it
is not as
>>> def empty_or_not(mylist):
... if mylist:
... print "Not empty"
... elif not mylist:
... print "Empty!"
...
>>> empty_or_not([])
Empty!
>>> foo = []
>>> empty_or_not(foo)
Empty!
>>> foo.append('hi')
>>> empty_or_not(foo)
Not empty
My guess is that if any object is empty,
Hello
Sorry if this is a basic question, but how do I check if list is empty
or not and return True or False ;)
Thanks
David
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On Mon, Jun 9, 2008 at 9:04 AM, dave selby <[EMAIL PROTECTED]> wrote:
> writing smaller file...
>
> and I end up with the remnants of the old larger file at the end.
> any idea how to clip the file to the newer smaller size without
> closing it and reopening it as a 'w' ?
f.truncate() ?
Why not r
Hi ,
Are there any python bindings for sox(sound Exchange).
--
A-M-I-T S|S
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Hi All,
I need to read parse and re-write the parsed file. I am opening with
f = open(file_rc, 'r+')
reading file
f.seek(0)
resetting file pointer ...
print >> f, section
writing smaller file...
and I end up with the remnants of the old larger file at the end.
any idea how to clip the
Python can *too* import from a txt file (even if it contains HTML):
f = open("myfile.html", "r")
x = f.read()
print x
f.close()
It even retains formatting (as far as I can tell)...
HTH,
Wayne
On Sun, Jun 8, 2008 at 4:25 PM, Dotan Cohen <[EMAIL PROTECTED]> wrote:
> 2008/6/8 Kent Johnson <[EMAIL
35 matches
Mail list logo