PyYaml is an option too. [1]
[1] - http://pyyaml.org/
It´s very readable and is converted to a Python native structure/object.
On Fri, May 2, 2008 at 12:12 PM, Bryan Fodness <[EMAIL PROTECTED]>
wrote:
> I am trying to figure out the best way to get external data.
>
> Using the following data in
Mihai Iacob wrote:
Hello,
Can anyone tell me how to start a program directly
from the interpreter (i'm using IDLE). Usually i open
a new window , write the lines of code and press F5 to
run the program in the interpreter.
The problem is that i need to to that directly from
the interpreter.
"Stephanie" <[EMAIL PROTECTED]> wrote
programs via the Macintosh Unix Terminal. I was trying to quickly
see which
version of Python I am running and typed in the command "python -v".
uppercase:
python -V
Alan G.
___
Tutor maillist - Tutor@
"Mihai Iacob" <[EMAIL PROTECTED]> wrote
Can anyone tell me how to start a program directly
from the interpreter (i'm using IDLE). Usually i open
a new window , write the lines of code and press F5 to
run the program in the interpreter.
You mean the results show up in the interactive shell
w
> On Fri, May 2, 2008 at 7:11 PM, Mihai Iacob <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Can anyone tell me how to start a program directly
> from the interpreter (i'm using IDLE). Usually i open
> a new window , write the lines of code and press F5 to
> run the program in the interpreter.
> The pro
i guess :
START > RUN then type : python your_script.py arg_1 arg_2
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Hello,
Can anyone tell me how to start a program directly
from the interpreter (i'm using IDLE). Usually i open
a new window , write the lines of code and press F5 to
run the program in the interpreter.
The problem is that i need to to that directly from
the interpreter. (I'm running windows).
On Fri, May 2, 2008 at 3:08 PM, Ross Glover <[EMAIL PROTECTED]> wrote:
> I'm assuming this falls under the rubric of text parsing. Here's what I
> want to make:
> A way to create a set of user defined tags or markers that can be applied
> to any section of a text document. Then I want a functio
If you give some examples of what you want to parse we can give more
specific advice.
Kent
I'm assuming this falls under the rubric of text parsing. Here's what I
want to make:
A way to create a set of user defined tags or markers that can be
applied to any section of a text document.
I think I'm beginning to understand how classes/methods work now, I'm
sure further understanding will come with practice.
Thanks for the help and suggestions!
-Wayne
On Fri, May 2, 2008 at 1:42 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> On Fri, May 2, 2008 at 2:20 PM, W W <[EMAIL PROTECTED]>
bob gailer wrote:
Or even simplre
f = open('file.txt',r).readlines()
print [f[x+1] for x, line in enumerate(f) if line.rstrip() == "3"][0]
--
Bob Gailer
919-636-4239 Chapel Hill, NC
___
Tutor maillist - Tutor@python.org
http://mail.python.org/ma
On Fri, May 2, 2008 at 2:20 PM, W W <[EMAIL PROTECTED]> wrote:
> I knew/guessed the alias bit from my experience with C++, but I
> couldn't figure out exactly what I needed. I've seen the "self"
> reference before, but I never really understood it.
'self' is roughly like 'this' in C++. Unlike
i had tough time understanding classes ... hope this helps :
http://www2.lib.uchicago.edu/keith/courses/python/class/5/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On Fri, May 2, 2008 at 12:17 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> This just makes x an alias for the class object. Should be
> x = myClass()
>
> > x.myMethod()
>
> then this will work.
Ah! Thank you!
I knew/guessed the alias bit from my experience with C++, but I
couldn't figure o
On Fri, May 2, 2008 at 1:38 PM, Spencer Parker <[EMAIL PROTECTED]> wrote:
> Well...it gives me the entire path...I am not running this script from the
> actual directory...I am running it from a secure user directory that only
> has certain access rights. During the os.path.dirname gives me the en
dir = '/xen/domains2/machinename/disk.img'
a = dir.split('/')[3]
is what I would use...
On Fri, May 2, 2008 at 12:38 PM, Spencer Parker <[EMAIL PROTECTED]>
wrote:
> Well...it gives me the entire path...I am not running this script from the
> actual directory...I am running it from a secure user
Well...it gives me the entire path...I am not running this script from the
actual directory...I am running it from a secure user directory that only
has certain access rights. During the os.path.dirname gives me the entire
directory path...I just need to last part of it is all. out of
'/xen/domain
On Fri, May 2, 2008 at 12:55 PM, W W <[EMAIL PROTECTED]> wrote:
> I'm playing around with pyGTK, and I have a question to see if I'm
> understanding things correctly.
>
> Is a method just a function inside a class?
Pretty much. It also has a required 'self' parameter which gets the
value of the
I'm playing around with pyGTK, and I have a question to see if I'm
understanding things correctly.
Is a method just a function inside a class?
i.e.
def myFunction():
print "This is a function"
class myClass:
def myMethod():
print "This is a method"
and to call:
myFunction()
I
On Fri, May 2, 2008 at 12:08 PM, Spencer Parker <[EMAIL PROTECTED]> wrote:
> I need to use a regular expression to get a couple of items for my python
> script. So far the script is running an 'ls' command to get a few items
> that I need
>
> I run an 'ls -sk /xen/domains2/machinename/disk.img'
>
Thank you to everyone for your help. I'm sorry to waste your time with such
a silly question. I am now back up and running! I really appreciate your
responses.
On Fri, May 2, 2008 at 11:16 AM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> On Fri, May 2, 2008 at 11:33 AM, Stephanie <[EMAIL PROTECTE
On Fri, May 2, 2008 at 12:08 PM, Spencer Parker <[EMAIL PROTECTED]> wrote:
> I need to use a regular expression to get a couple of items for my python
> script. So far the script is running an 'ls' command to get a few items
> that I need
Why do you need to use regular expressions? This problem
On Fri, May 2, 2008 at 11:33 AM, Stephanie <[EMAIL PROTECTED]> wrote:
> Hi,
> I'm at a very beginning level of Python knowledge, but I use several Python
> programs via the Macintosh Unix Terminal. I was trying to quickly see which
> version of Python I am running and typed in the command "python
On Fri, May 2, 2008 at 11:42 AM, Paul McGuire <[EMAIL PROTECTED]> wrote:
> f=open('file.txt',r)
> print_line = False
> for line in f:
>if print_line:
> print line
> print_line = False
>if line == "3":
Don't forget about the newline...(that makes four!)
Kent
_
On Fri, May 2, 2008 at 11:33 AM, Stephanie <[EMAIL PROTECTED]> wrote:
> Hi,
> I'm at a very beginning level of Python knowledge, but I use several Python
> programs via the Macintosh Unix Terminal. I was trying to quickly see which
> version of Python I am running and typed in the command "python
I need to use a regular expression to get a couple of items for my python
script. So far the script is running an 'ls' command to get a few items
that I need
I run an 'ls -sk /xen/domains2/machinename/disk.img'
Output
2454112 /xen/domains2/machinename/disk.img
Then I have it running an 'ls -lk
Hi,
I'm at a very beginning level of Python knowledge, but I use several Python
programs via the Macintosh Unix Terminal. I was trying to quickly see which
version of Python I am running and typed in the command "python -v". That
was obviously not the correct command to use. It installed several
Augghh! I can't stand it!!! If position is a boolean, then *why* must we
test if it is equal to True?!!! It's a boolean! Just test it! For that
matter, let's rename "position" to something a little more direct,
"print_line" perhaps?
Did you know that files are now iterators? If going through
On Fri, May 2, 2008 at 11:12 AM, Bryan Fodness <[EMAIL PROTECTED]> wrote:
> I am trying to figure out the best way to get external data.
1. Put the data in a Python module and import it
2. Put the data in a .ini file and read it with the ConfigParser
module http://docs.python.org/lib/module-Config
On Fri, May 2, 2008 at 10:34 AM, Brain Stormer <[EMAIL PROTECTED]> wrote:
> f=open('file.txt',r)
> position =False
>
> for line in f.read().split():
Note that split() splits on any whitespace, not just line endings. In
your case it doesn't much matter I guess.
Kent
_
I am trying to figure out the best way to get external data.
Using the following data in a file
1
2
3
I have used,
fi = open(infile, 'r')
s = fi.readlines()
fi.close()
a = s[0]
b = s[1]
c = s[2]
but, if I have,
x = 1
y = 2
z = 3
I h
f=open('file.txt',r)
position =False
for line in f.read().split():
if position == True
print line
position = False
if line == "3":
position = True
else:
position = False
f.close()
On Fri, May 2, 2008 at 10:28 AM, Brain Stormer <[EMAIL PROTECTED]> wrot
You are correct. It is missing the ":" and it will print "3"
On Fri, May 2, 2008 at 10:18 AM, bob gailer <[EMAIL PROTECTED]> wrote:
> Brain Stormer wrote:
>
> > Well,
> > I was somewhat confused with all of the answers so I decided to go with
> > my/following method. Kent's method has 4 fewer
Brain Stormer wrote:
Well,
I was somewhat confused with all of the answers so I decided to go
with my/following method. Kent's method has 4 fewer lines of code
than mine and cleaner. Please correct me if I am fundamentally wrong.
f=open('file.txt',r)
for line in f.read().split():
if l
Well,
I was somewhat confused with all of the answers so I decided to go with
my/following method. Kent's method has 4 fewer lines of code than mine and
cleaner. Please correct me if I am fundamentally wrong.
f=open('file.txt',r)
for line in f.read().split():
if line == "3"
positi
On Thu, May 1, 2008 at 11:42 PM, Ross Glover <[EMAIL PROTECTED]> wrote:
> Thanks all for your in[put]. It did take me a minute to figure out that 2
> variables could get assigned using this method. Thanks to your help, I
> managed to cobble together a fully functional GUI based dictionary program
On Fri, May 2, 2008 at 3:55 AM, Roel Schroeven
<[EMAIL PROTECTED]> wrote:
> Shouldn't it even be 'line = f.next()'?
Wow, I think Brain Stormer should get a prize. I'm not sure what the
prize is, but his short program has elicited incomplete and inaccurate
answers from three of the top posters to
"Ross Glover" <[EMAIL PROTECTED]> wrote
That said, it would seem that I do need to understand files better.
Does anyone have a suggestion for a solid and detailed explanation?
Either online or a book?
Reading the Python tutorial section might be enough.
If you understand the books you mention
Alan Gauld schreef:
if line == "3":
line.next
this then becomes f.next() # next is a method not
an attribute so needs the () to call it
Shouldn't it even be 'line = f.next()'?
--
The saddest aspect of life right now is that science gathers knowledge
faster than society gathe
39 matches
Mail list logo