"Tim Michelsen" <[EMAIL PROTECTED]> wrote in
>> Another option is to have the config settiongs in a normal
>> Python module and just import it.
> I think that the cfg-files are much more readable for others.
More readable than:
# Section Heading
variable = value
It looks pretty easy to read
"Michael Finlayson" <[EMAIL PROTECTED]> wrote
> I would like to ask the group if it is even possible
> on a Mac before I go through learning Python.
This has less to do with Python than with Macs
Which browser are you thinking of using?
Mac users have a variety with Safari the most
common along
Hi,
At the url http://www.python.org/doc/essays/graphs.html there is some code by
Guido Van Rossum for computing paths through a graph - I have pasted it below
for reference -
Let's write a simple function to determine a path between two nodes. It takes a
graph and the start and end nodes as
I am trying to parse an html page. Have following error while doing that
src = sel.get_html_source()
links = re.findall(r'', src)
for link in links:
print link
==
ERROR: test_new (__main__.NewTest)
Oleg Oltar wrote:
> I am trying to parse an html page. Have following error while doing that
>
>
> src = sel.get_html_source()
> links = re.findall(r'', src)
> for link in links:
> print link
Presumably get_html_source() is returning unicode? So link is a unicode
st
>>> Another option is to have the config settiongs in a normal
>>> Python module and just import it.
>
>> I think that the cfg-files are much more readable for others.
>
> More readable than:
>
> # Section Heading
> variable = value
>
> It looks pretty easy to read to me! :-)
>
> If its very
"Tim Michelsen" <[EMAIL PROTECTED]> wrote
>> import myconfig
>> foo2 = myconfig.SectionFoo['second']
> This seems like reinventing what the ConfigParser
> mdoule [1] already does.
But with the advantage that its pure python, no parsing
needed so its both faster and avouds any string to int
typ
Alan Gauld wrote:
>> But to my optinion Config Parser offers the following advantage:
>> - Readable
>> - All are strings => no strange 'mysetting' is needed.
>
> I'm not sure what you mean. The Python variables and dictionary
> is all strings too. mysetting is just a string...
He means, with Co
I'm really struggling with the datetime module. Trying for a script that
will calculate the number of days between any two dates, I've come up
with this:
import datetime
date1 = raw_input("Enter date1 as year-month-day: ")
year1, month1, day1 = date1.split('-')
date1 = datetime.date(int(year1), i
Dick Moores wrote:
> I'm really struggling with the datetime module. Trying for a script
> that will calculate the number of days between any two dates, I've
> come up with this:
>
> import datetime
> date1 = raw_input("Enter date1 as year-month-day: ")
> year1, month1, day1 = date1.split('-')
>
Dick Moores wrote:
> I'm really struggling with the datetime module. Trying for a script that
> will calculate the number of days between any two dates
How about this:
from datetime import datetime
date1 = raw_input("Enter date1 as year-month-day: ")
date1 = datetime.strptime(date1, '%Y-%m-%d')
"Kent Johnson" <[EMAIL PROTECTED]> wrote
>> I'm not sure what you mean. The Python variables and dictionary
>> is all strings too. mysetting is just a string...
>
> He means, with ConfigParser strings don't need to be quoted, giving
> perhaps a cleaner and more friendly syntax.
Ah, I see, yes th
>>> But to my optinion Config Parser offers the following advantage:
>>> - Readable
>>> - All are strings => no strange 'mysetting' is needed.
>> I'm not sure what you mean. The Python variables and dictionary
>> is all strings too. mysetting is just a string...
>
> He means, with ConfigParser st
> Malcolm Greene wrote:
>> What is the Pythonic way to remove specific chars from a string? The
>> .translate( table[, deletechars]) method seems the most 'politically
>> correct' and also the most complicated.
Why complicated?
import string
myStr = 'some text from which you want to delete some
>> how can I suppress the decimal places for (only those) numbers whos
>> decimal places are zero (0)?
>
> I don't know how to do this with just string formatting but I think
> ('%.4f' % n).rstrip('.0')
> will do what you want.
No.
I tested with
n = 10.0
You code returns '1'
My code returns '10'
At 02:37 PM 4/15/2008, Kent Johnson wrote:
>Dick Moores wrote:
>>I'm really struggling with the datetime module. Trying for a script
>>that will calculate the number of days between any two dates
>
>How about this:
>
>from datetime import datetime
>date1 = raw_input("Enter date1 as year-month-day:
On 16/04/2008, Tim Michelsen <[EMAIL PROTECTED]> wrote:
> Kent wrote:
> > I don't know how to do this with just string formatting but I think
> > ('%.4f' % n).rstrip('.0')
> > will do what you want.
>
> No.
> I tested with
> n = 10.0
> You code returns '1'
>
> My code returns '10'
Good catc
On 16/04/2008, Ricardo Aráoz <[EMAIL PROTECTED]> wrote:
> You just have to use maketrans with empty strings. If string is
> deprecated then I guess some other way of creating translation tables
> will be provided.
Most string.* functions are deprecated, because they've been moved to
methods of
Just testing as recently I'm not seeing my posts even though Receive
your own posts to the list? is Yes.
--
Bob Gailer
919-636-4239 Chapel Hill, NC
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Hi tutors,
I currently have a dictionary like the following:
{'1': ['220', '220', '220''], '2': ['220', '238', '238', '238', '238'], '3':
['220', '238'], '4': ['220', '220'], '5': ['220', '220', '238'], '6':
['238', '238'], '7': ['220']}
I am trying to create a dictionary that would list the cur
Does anyone out have experience with:
- manipulating RTF files?
- or writing OpenOffice macros in Python?
I need to pre-process approximately 10,000 medical reports so they can be
imported into an EMR. (They were originally saved as Word .docs; I'd like
to give hearty thanks to the authors of "
On 16/04/2008, Marc Tompkins <[EMAIL PROTECTED]> wrote:
> Does anyone out have experience with:
> - manipulating RTF files?
Is this any help to you: http://pyrtf.sourceforge.net/
?
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.o
Mark,
Here's how we work with RTF: We create a Word document formatted exactly
like we want with special markers (unique text) inserted in places where
we want to programmatically add text.
We save this document to RTF (this RTF becomes our template file),
remove all the carriage returns and line
GTXY20 wrote:
>
> Hi tutors,
>
> I currently have a dictionary like the following:
>
> {'1': ['220', '220', '220''], '2': ['220', '238', '238', '238', '238'],
> '3': ['220', '238'], '4': ['220', '220'], '5': ['220', '220', '238'],
> '6': ['238', '238'], '7': ['220']}
>
> I am trying to create
On 16/04/2008, GTXY20 <[EMAIL PROTECTED]> wrote:
> I currently have a dictionary like the following:
>
> {'1': ['220', '220', '220''], '2': ['220', '238', '238', '238', '238'], '3':
> ['220', '238'], '4': ['220', '220'], '5': ['220', '220', '238'], '6':
> ['238', '238'], '7': ['220']}
>
> I am tryi
Hi Kent,
Yes I think so I think I am almost there with this:
from collections import defaultdict
d = {'1': ['220', '220', '220''], '2': ['220', '238', '238', '238', '238'],
'3': ['220', '238'], '4': ['220', '220'], '5': ['220', '220', '238'], '6':
['238', '238'], '7': ['220']}
for f, b in d.item
count = lambda x: [{y: x.count(y)} for y in set(x)]
y = {}
for key, val in myDict.items():
y[key] = count(val)
print y
{'1': [{'220': 3}], '3': [{'238': 1}, {'220': 1}], '2': [{'238': 4}, {'220':
1}], '5': [{'238': 1}, {'220': 2}], '4': [{'220': 2}], '7': [{'220': 1}],
'6': [{'238': 2}]}
Thanks John and Kent for the guidance.
This following ends up working perfect for me - instead of print to the
console I will just write this to a text file. I will also wrap it in a
function.
from collections import defaultdict
d = {'1': ['220', '220', '220''], '2': ['220', '238', '238', '238', '
On Tue, Apr 15, 2008 at 7:18 PM, <[EMAIL PROTECTED]> wrote:
> Recommendation: Find a very old version of Word (Word 95) to generate
> your RTF 'templates'. The older versions of Word generate much simpler
> RTF that is forward compatible.
>
Excellent advice! Unfortunately, my case is a bit diffe
On Tue, Apr 15, 2008 at 7:10 PM, John Fouhy <[EMAIL PROTECTED]> wrote:
> Is this any help to you: http://pyrtf.sourceforge.net/
>
Not so much, because it only produces RTF - it doesn't help me pick apart
the stuff I've already got.
(It did cross my mind to try to create in pyRTF the same structur
Sorry, forgot to cc the list.
--- Begin Message ---
On Tue, Apr 15, 2008 at 7:18 PM, <[EMAIL PROTECTED]> wrote:
> Recommendation: Find a very old version of Word (Word 95) to generate
> your RTF 'templates'. The older versions of Word generate much simpler
> RTF that is forward compatible.
>
Exc
On Tue, Apr 15, 2008 at 8:50 PM, Luke Paireepinart <[EMAIL PROTECTED]>
wrote:
> Sorry, forgot to cc the list.
>
Actually, you cc'd the list with my previous post instead of your response
to it. Here's what you sent me:
> I don't know if this is the best way, but given that other guy's
> suggesti
"Marc Tompkins" <[EMAIL PROTECTED]> wrote
> Moving away from the RTF horn of my dilemma, does anyone have any
> experience
> writing OO macros? Or know of any sites with more than ten lines of
> documentation? I'm studying ooconvert itself, but that's only
> getting me so
> far.
Have you con
33 matches
Mail list logo