"Ricardo Aráoz" <[EMAIL PROTECTED]> wrote
> if msvcrt.kbhit() :
> key = msvcrt.getch()
> if key == 'h' :
> print 'Hello'
>
> This is XP with 2.5 in Idle. Any ideas?
IDLE is a GUI app running under Tkinters event loop.
I doubt if msvcrt works under Tkinter.
Try running your code in a DOS box.
Any
"Trey Keown" <[EMAIL PROTECTED]> wrote
> I was wondering, how could I get each value inside of a tuple, say
> it's
> (2,4) .
> The only value I really need is the second one (the tuple will
> always have
> only two values.
Tuples are like any other Python collection or sequence.
You can access
> i was thinking of doing something like
>
>objSprites = pygame.sprite.OrderedUpdates((var1,
> var2, var3).sort)
>
> but i don't think thats gunna work
It won't indeed, because of 3 things:
1. you're trying to sort a tuple. Tuples don't have a sort() method,
use a list instead
2. sort doesn'
Andrew Wu wrote:
>pattern3 = '''
> ^{
> (
> %s
> | {%s} # Possible to have 1 level of nested lists
> ,?)* # Items are comma-delimited, except for the last item
> }$
>''' % (pattern2, pattern2)
The above doesn't allow comma after the first instance
Kent Johnson wrote:
> You might want to look at doing this with pyparsing, I think it will
> make it easier to get the data out vs just recognizing the correct pattern.
Here is a pyparsing version that correctly recognizes all of your
patterns and returns a (possibly nested) Python list in case
Ah - thanks for the correction! I missed the extra grouping and the
extra spacing ... doh! Sorry about the HTML-formatted e-mail ...
Thanks also for the pyparsing variant as well - I didn't know the
module existed before!
Andrew
On 11/1/07, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Andrew Wu
Hello,
If I have multiple Popen calls I need to make, how can I turn these into a
function?
from subprocess import Popen, PIPE
p1 = Popen(['ls', '-l', '-a', '/etc'],stdout=PIPE)
p2 = Popen(['grep', 'hosts'], stdin=p1.stdout, stdout=PIPE)
p3 = Popen(['awk', '{print $1}'], stdin=p2.stdout, stdout=
Hi Jay...
jay wrote:
...
> I would be sending an arbitrary number of PIPES with each function call.
>
> I'm a little stumped as to how to handle the variables. If I have an
> arbitrary number of PIPES, how do I declare my variables (p1, p2, p3,
> etc...) ahead of time in the function??
>
> Tha
jay wrote:
> Hello,
>
> If I have multiple Popen calls I need to make, how can I turn these
> into a function?
Since you're only interested in the output of the last command on the
pipeline, I don't see a reason to keep track of them all. I'd do
something like this:
def pipeline( *commandlist
If i input the following in python:
var1 = 7
var2 = 9
var3 = 5
args = [var1, var2, var3]
args.sort()
then if if type:
args
the output is
[5, 7, 9]
but i want the output to be
[var3, var1, var2]
is there a function that will output the variable
names in the order they
"jay" <[EMAIL PROTECTED]> wrote
> I'm a little stumped as to how to handle the variables. If I have
> an
> arbitrary number of PIPES, how do I declare my variables (p1, p2,
> p3,
> etc...) ahead of time in the function??
How about passing a list of pipes?
Then you can access them as pipes[0]
> If i input the following in python:
>var1 = 7
>var2 = 9
>var3 = 5
>args = [var1, var2, var3]
>args.sort()
>
> then if if type:
>
>args
>
> the output is
>
>[5, 7, 9]
>
> but i want the output to be
>
>[var3, var1, var2]
>
> is there a function that will output the
Eric and Eric :-)
Thanks both for the suggestions! I learned from each!
I believe the small function will work for me. Its simple since I don't
have to track each pipe I open with a variable. I had no idea I could do
that nifty if/then for the stdin, that makes it so easy. :-)
Thanks again!
J
I should begin by explaining I am not a sysadmin, I'm merely one trying to
use the right tool for the right job, and for my job I believe Python to be
that tool. Here is an outline of what I wish to accomplish, pointers to
modules, tools of interest, etc. would be greatly appreciated... Below each
Evert Rol wrote:
> Hm, I don't know directly how to get the name of a variable. I'd
> hoped there was a private method (var3.), but looks
> like there isn't it.
No, the mapping from names to values is one way. It's pretty easy to
have a value associated with no name, or more than one name
ted b wrote:
> If i input the following in python:
>var1 = 7
>var2 = 9
>var3 = 5
>args = [var1, var2, var3]
>args.sort()
>
> then if if type:
>
>args
>
> the output is
>
>[5, 7, 9]
>
> but i want the output to be
>
>[var3, var1, var2]
>
> is there a function t
Hello! I'm creating a dictionary called keywords that has multiple entries
each with a variable list of values eg.
keywords[1] = [1, 4, 6, 3]
keywords[2] = [67,2]
keywords[3] = [2, 8, 5, 66, 3, 23]
etc.
The keys and respective values (both are integers) are read in from a file.
For each key,
> Thanks, i think a dictionary may be the way to go
>
>> in the end, you're going to use the
>> actual values anyway,
>> not their names, right?
>
> yeah, you're right, the way i was thinking about doing
> it probably won't work. The way I am doing it now is
> actually using attibutes of the var's
ted b wrote:
> Here's the code i am using, but its a lot of if /
> thens and i'm trying to find a better way:
>
> if var1.value > var2.value > var3.value:
> objSprites = pygame.sprite.OrderedUpdates
> (var1, var2, var3)
Did you see Evert's reply to your original question? It was
Thanks Kent, and Evert, and everyone,
I really appreciate the advice on etiqutte and all
your help. I will think through my questions much more
thoroughly before any further inquiries and will
'reply to all' as advised.
--- Kent Johnson <[EMAIL PROTECTED]> wrote:
> ted b wrote:
>
> > Here's the c
>
> 1) Maintain a mysql database which contains information, as well as
> 'control' variables, pointers to directories, etc. for various shell
> scripts / fortran code. ->pyMySQL
>
You're on the right track
> 2) Query various servers to see if there is 'idyl' time/resources... send
> a job to t
"Eric Brunson" <[EMAIL PROTECTED]> wrote
>last = Popen( command,
> stdin=last.stdout if last else None,
> stdout=PIPE )
Where does the if/else syntax come from? It doesn't
seem to work on my Python 2.4. Is it a new feature in 2.5?
Alan G.
___
>
>
>
>
> > 2) Query various servers to see if there is 'idyl' time/resources...
> > send a job to the server if it's available...
> >
>
> This and 3 can be helped out with ipython
>
>
>
> > 3) Use python to check the file system for existing files (glob?) ,
> > decide which 'jobs' need to be run,
On Nov 1, 2007, at 3:04 PM, Alan Gauld wrote:
> Where does the if/else syntax come from? It doesn't
> seem to work on my Python 2.4. Is it a new feature in 2.5?
Yes, it's a new feature in 2.5.
- Jeff Younker - [EMAIL PROTECTED]
___
Tutor maillist -
"Dinesh B Vadhia" <[EMAIL PROTECTED]> wrote
keywords[1] = [1, 4, 6, 3]
keywords[2] = [67,2]
keywords[3] = [2, 8, 5, 66, 3, 23]
etc.
The keys and respective values (both are integers) are read
in from a file. For each key, the value is append'ed until
the next key. Here is the code.
..
Dinesh B Vadhia wrote:
> Hello! I'm creating a dictionary called keywords that has multiple
> entries each with a variable list of values eg.
>
> keywords[1] = [1, 4, 6, 3]
> keywords[2] = [67,2]
> keywords[3] = [2, 8, 5, 66, 3, 23]
> etc.
>
> The keys and respective values (both are integers
On Nov 1, 2007, at 12:15 PM, John wrote:
1) Maintain a mysql database which contains information, as well as
'control' variables, pointers to directories, etc. for various
shell scripts / fortran code.
->pyMySQL
Look at an object relational mapper like SQLObject or SQLAlchemy. They
make
Alan Gauld wrote:
> "Ricardo Aráoz" <[EMAIL PROTECTED]> wrote
>
>> if msvcrt.kbhit() :
>> key = msvcrt.getch()
>> if key == 'h' :
>> print 'Hello'
>>
>> This is XP with 2.5 in Idle. Any ideas?
>
> IDLE is a GUI app running under Tkinters event loop.
> I doubt if msvcrt works under Tkinter.
> Try
bob gailer wrote:
> if key not in keywords:
>keywords[key] = []
> keywords[key].append(value)
This can be written more succinctly as
keywords.setdefault(key, []).append(value)
or in Python 2.5:
from collections import defaultdict
keywords = defaultdict(list)
...
keywords[key
* Michael Langford <[EMAIL PROTECTED]> [2007-11-01 01:15:31]:
> That's not really a working solution. My available development platform is a
> Vista machine. I don't have an available XP platform. XP built exes run fine
> on Vista, just not vice versa.
Then the best possible way would be to ask p
30 matches
Mail list logo