> There is a text file that looks like this:
>
> text text text Joseph
> text text text text text text text text text text text
> text text text text text text text text text text text
> text text text text text text text text text text text
> text text text text text text text text text text text
On Fri, Feb 27, 2009 at 6:06 AM, David wrote:
> Hi Everyone,
> I go through the archived [Tutor] mail list to find programs others have
> tried to do. I found one that would keep track of a petty cash fund. please
> point out my misunderstanding.
> Here is what I started with;
>
> #!/usr/bin/pyth
wrote
how does one go about setting a PYTHON path environment variable on
Mac OS X 10.4?
Your subject asks about PYTHONPATH, your text asks about PATH.
These are two different things. Which do you want to know about?
PATH is how Unix (ie MacOS aka Darwin) finds your Python interpreter
PYTHO
HelloFinally I managed to writ a function to format a file.
Thank to everybody for their tips.
def mmm(a):
import os,textwrap
so=open(a)
d=os.path.dirname(a)+os.sep+'temp.txt'
de=open(d,'w')
import textwrap
for line in so:
if len(line)<70:de.write(line+'\n'
On Fri, Feb 27, 2009 at 2:59 AM, wesley chun wrote:
> > There is a text file that looks like this:
> >
> > text text text Joseph
> > text text text text text text text text text text text
> > text text text text text text text text text text text
> > text text text text text text text text text t
"prasad rao" wrote
for line in so:
if len(line)<70:de.write(line+'\n')
if len(line)>70:
da=textwrap.fill(line,width=60)
de.write(da+'\n')
What happens if the line is exactly 70 characters long?
I think you want an else instead of the second
On Fri, Feb 27, 2009 at 2:22 AM, spir wrote:
> Anyway for a startup exploration you can use regular expressions (regex) to
> extract individual data item. For instance:
>
> from re import compile as Pattern
> pattern = Pattern(r""".*(.+)<.+>.*""")
> line = "text text text Joseph"
> print pattern.
On 25/02/2009, Alan Gauld wrote:
>
> "nathan virgil" wrote
>
> > Whenever I try to use the talk method (which reports the mood, and doesn't
> > take parameters), it says I gave it too many parameters.
> >
>
> Sorry, I should have pointed out that you will need to redefine
> all your functions to
Thank you spir and Andre for the explanation. You are very good
teachers. I can now continue. I am sure I will be back. Next I am going
to set up a menu to enter amounts and also a way to store the resulting
balance. Is cPickle a good way to do this?
-david
--
Powered by Gentoo GNU/LINUX
http
Thank you spir and Andre for the explanation. You are very good
teachers. I can now continue. I am sure I will be back. Next I am going
to set up a menu to enter amounts and also a way to store the resulting
balance. Is cPickle a good way to do this?
-david
--
Powered by Gentoo GNU/LINUX
http:/
Hai,
I have file1.dat,file2.dat...file 300.dat in one directory. I want to
concatenate all the files in a single file (total.dat) with a string "END"
separating the file contents.
my total.dat should be
file1.dat contents
END
file2.dat contents
END
file300.dat.
now i have another 400
Emad wrote:
>>>
Since I'm learning Pyparsing, this was a nice excercise. I've written this
elementary script which does the job well in light of the data we have
from pyparsing import *
ID_TAG = Literal("")
FULL_NAME_TAG1 = Literal("")
END_TAG = Literal("', 'Joseph
On Fri, Feb 27, 2009 at 10:01 AM, Paul McGuire wrote:
> Emad wrote:
> >>>
> Since I'm learning Pyparsing, this was a nice excercise. I've written this
> elementary script which does the job well in light of the data we have
>
> from pyparsing import *
> ID_TAG = Li
Your tutorial is awesome...thanks again...
The biggest confusion I have just had is the self.balance kind of thing. I
need to just remember how it is treating each individual statement is all.
Remember how everything is basically an object...just wrapping my brain
around it for the most part.
On
I am beggining to learn Python and I appreciate if you help me with this:
"I want a piece of a program to request the user to input "elements"
(numbers, text, etc) and store them into a list. Then, I want to display all
the elements one-per-line."
I started using this code:
#!/usr/bin/env python
Le Fri, 27 Feb 2009 11:19:50 -0600,
Network Administrator s'exprima ainsi:
> I am beggining to learn Python and I appreciate if you help me with this:
>
> "I want a piece of a program to request the user to input "elements"
> (numbers, text, etc) and store them into a list. Then, I want to displ
Andre Engels wrote:
The more preferable method is to leave the class alone, and call
getbalance by hand:
data = float('100.00')
a = Account(data)
p = a.getbalance()
print 'balance = ', p
remove_data = float('50.00')
a.withdraw(remove_data)
w = a.getbalance()
print "withdraw = ", w
add_data = f
Bala subramanian wrote:
Hai,
I have file1.dat,file2.dat...file 300.dat in one directory. I want to
concatenate all the files in a single file (total.dat) with a string
"END" separating the file contents.
my total.dat should be
file1.dat contents
END
file2.dat contents
END
file300.
David wrote:
but when I change it to;
start_total()
start = start_total()
a = Account(start)
here is the error;
Enter Amount: 100
Traceback (most recent call last):
File "./py_pettycash.py", line 77, in
menu()
File "./py_pettycash.py", line 53, in menu
a.deposit(cash)
File "./py_
I am trying to read a value in a variable from a different class every time
I click on a refresh button for my GUI program. The problem is I am using
statictext so when I refresh, it displays the new value on top of the old
one.
In my main GUI:
def refresh(self, event):
x = refresh_var()
value =
>> I am looking for a good tutorial to walk through that really explains class
>> definition.
>
> I assume from that you have been through the basic tutors like mine?
>:
> OK, I explain self in my OOP tutor topic ( a sub heading under
> "Using Classes"), but again if thats not sufficient th
Hi,
This is both a general question and a specific one.
I want to iterate over a bunch of lines; If any line contains a
certain string, I want to do something, otherwise do something else.
I can store state - eg line 1 - did it contain the string? no.. ok
we're cool, next line
But, I'd like
On Fri, Feb 27, 2009 at 5:09 AM, prasad rao wrote:
> Hello
> Finally I managed to writ a function to format a file.
> Thank to everybody for their tips.
>
> def mmm(a):
> import os,textwrap
> so=open(a)
> d=os.path.dirname(a)+os.sep+'temp.txt'
> de=open(d,'w')
> import te
Turns out I was close but had not combined everything. I never would
have picked up on the map() function. Much more efficient than looping
through the whole mess and converting to int.
x = ['[335, 180, 201, 241, 199]\r\n']
y = map( int, x[0].strip( '[]\r\n' ).split( ', ' ) ) #need an index
"Richard Lovely" wrote
> Sorry, I should have pointed out that you will need to redefine
> all your functions to accept a parameter.
Always makes me smile when (experienced) people redesign the wheel...
From the docs (http://www.python.org/doc/2.6/library/functools.html):
"The partial() is
"Bala subramanian" wrote
I have file1.dat,file2.dat...file 300.dat in one directory. I want
to
concatenate all the files in a single file (total.dat) with a
string "END"
separating the file contents.
my total.dat should be
file1.dat contents
END
file2.dat contents
END
file300.dat
"Bala subramanian" wrote
I have file1.dat,file2.dat...file 300.dat in one directory. I want
to
concatenate all the files in a single file (total.dat) with a
string "END"
separating the file contents.
If you are on Linux (or other *nix variant) you may be better off
using the shell...
fo
"Hi" wrote
In my main GUI:
def refresh(self, event):
x = refresh_var()
value = wx.StaticText(self, -1, str(x.var_rate))
Its not clear how you are positioning Static Text, I suspect you
need it as a opart of your main GUI and then reference it in
here and use the SetLabel() method to update
"Stephen Nelson-Smith" wrote
I want to iterate over a bunch of lines;
for line in
If any line contains a certain string, I want to do something,
otherwise do something else.
if in line:
doSomething()
else:
doSomethingElse()
I can store state - eg line 1 - did it contain th
Kyle Kwaiser wrote:
x = ['[335, 180, 201, 241, 199]\r\n']
y = map( int, x[0].strip( '[]\r\n' ).split( ', ' ) ) #need an index here
print y
[335, 180, 201, 241, 199]
I realize it's not totally secure, but if your string really is in that
format (i.e., a representation of a list), you COULD j
I downloaded python 3.0.1 today and started experimenting with the new
print statement.
>>>import time
>>>for l in 'the answer':
...print(l,end='')
...time.sleep(0.1)
the code is supposed to print "the answer" with a 0.1 second long
pause between the letters. instead, it waits for 1 secon
Le Sat, 28 Feb 2009 06:34:07 +0200,
George Wahid s'exprima ainsi:
> I downloaded python 3.0.1 today and started experimenting with the new
> print statement.
>
> >>>import time
> >>>for l in 'the answer':
> ...print(l,end='')
> ...time.sleep(0.1)
>
> the code is supposed to print "the a
Here is one possible implementation of your project.
*Code:*
#Dont use list as a variable name, its one of the reserved words.
mylist = []
#realize any values captured here are strings
x = raw_input('Enter num or text: ')
mylist.append(x)
x = raw_input('Enter num or text: ')
mylist.append(x)
#ou
"spir" wrote in message
news:20090228081629.36a24...@o...
Le Sat, 28 Feb 2009 06:34:07 +0200,
George Wahid s'exprima ainsi:
I downloaded python 3.0.1 today and started experimenting with the new
print statement.
>>>import time
>>>for l in 'the answer':
...print(l,end='')
...time.sl
34 matches
Mail list logo