guan dao | 1 Sep 03:04 2009
Picon

Please delete my mail address from that mail list. Thanks!

 

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor
Ishan Puri | 1 Sep 03:43 2009
Picon
Picon

Easy Problem

Hello,
    I have 2 plain text documents that have uneven spacing. I need to make these single spaced between lines and between words. Basically I need to get them to be equal character length after I abridge the uneven spacing. In Python there is probably one simple command for this for a text file? How do I do this?
E.G.: Hi          how are you?
Fixed: Hi how are you?
        Thanks,
                Ishan
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor
Luke Paireepinart | 1 Sep 04:22 2009
Picon

Re: Easy Problem

>>> txt = "Hi          how are you?"
>>> " ".join(txt.strip().split())
'Hi how are you?'

On Tue, Sep 1, 2009 at 3:43 AM, Ishan Puri <ballerz4ishi <at> sbcglobal.net> wrote:
Hello,
    I have 2 plain text documents that have uneven spacing. I need to make these single spaced between lines and between words. Basically I need to get them to be equal character length after I abridge the uneven spacing. In Python there is probably one simple command for this for a text file? How do I do this?
E.G.: Hi          how are you?
Fixed: Hi how are you?
        Thanks,
                Ishan

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor


_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor
Luke Paireepinart | 1 Sep 04:27 2009
Picon

Re: Please delete my mail address from that mail list. Thanks!

there are directions on how to remove yourself from the list at the bottom of every message that the list sends out.

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

click.
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor
Stefan Behnel | 1 Sep 08:38 2009
Picon

Re: update html pages using python

Alan Gauld wrote:
> "Stefan Behnel" <stefan_ml <at> behnel.de> wrote
>>> "pedro" <pedrooconnell <at> gmail.com> wrote
>>>> Hi, I was wondering if anyone could point me in the right direction as
>>>> far as the best way to use python to update html. 
>>>
>>> There are a number of modules in the standard library that can help but
>>> the best known module for this is BeautifulSoup
>>
>> I would call that statement highly exaggerated.
>>
>> http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/
> 
> There may be a language thing at work here but by "best known module"
> I do not mean Beautiful Soup is the best of all known modules, rather it
> is the module which is most widely known of the non standard HTML
> packages.

I think "non standard HTML package" pretty much hits the nail on the head.

> It is also, arguably, one of the easiest to use
> and well behaved with non compliant html

That, again, is questionable. The task at hand was to "update HTML pages",
in which case it is quite useful to have them fixed up into standard
compliant HTML before working on them. BeautifulSoup will not do that for
you. Instead, it will leave you with whatever tag soup you had at the
beginning, so that you will end up sending out broken HTML again. I
wouldn't call that "well behaved" at all.

Stefan

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Mac Ryan | 1 Sep 10:30 2009
Picon

Re: Please delete my mail address from that mail list. Thanks!

On Tue, 2009-09-01 at 04:27 +0200, Luke Paireepinart wrote:
> there are directions on how to remove yourself from the list at the
> bottom of every message that the list sends out.
>         _______________________________________________

> click. 
> _______________________________________________
> Tutor maillist  -  Tutor <at> python.org
> http://mail.python.org/mailman/listinfo/tutor

May I suggest,

to slightly tweak the signature of the ML with something like:

---
Tutor mailing list  -  tutor <at> python.org
Configuration options (including unsubscribing):
http://mail.python.org/mailman/listinfo/tutor
---

so that the less tech-savvy among the subscribers get a better hint on
how to manage by themselves?

Mac.

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Kent Johnson | 1 Sep 15:25 2009
Picon

Re: Please delete my mail address from that mail list. Thanks!

On Tue, Sep 1, 2009 at 4:30 AM, Mac Ryan<quasipedia <at> gmail.com> wrote:

> May I suggest,
>
> to slightly tweak the signature of the ML with something like:
>
> ---
> Tutor mailing list  -  tutor <at> python.org
> Configuration options (including unsubscribing):
> http://mail.python.org/mailman/listinfo/tutor
> ---

Good idea, see below (I hope)

Kent
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Sander Sweers | 1 Sep 14:46 2009
Picon

Re: Easy Problem

2009/9/1 Luke Paireepinart <rabidpoobear <at> gmail.com>:
>>>> txt = "Hi          how are you?"
>>>> " ".join(txt.strip().split())
> 'Hi how are you?'

txt.strip() only remove leading and trailing white space so does
nothing in your example. However it works because txt.split() removes
the excessive white space between the text.

>>> txt
'Hi          how are you?'
>>> ' '.join(txt.split())
'Hi how are you?'

Greets
Sander
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Kent Johnson | 1 Sep 16:24 2009
Picon

Re: Easy Problem

On Mon, Aug 31, 2009 at 9:43 PM, Ishan Puri<ballerz4ishi <at> sbcglobal.net> wrote:
> Hello,
>     I have 2 plain text documents that have uneven spacing. I need to make
> these single spaced between lines and between words. Basically I need to get
> them to be equal character length after I abridge the uneven spacing.

I don't know what you mean by "equal character length" here.

> In
> Python there is probably one simple command for this for a text file? How do
> I do this?
> E.G.: Hi          how are you?
> Fixed: Hi how are you?

Another way to do this is with regular expressions, for example
In [1]: import re

In [2]: txt = "Hi          how are you?"

In [4]: txt = re.sub(r'  +', ' ', txt)

In [5]: txt
Out[5]: 'Hi how are you?'

You can also replace multiple newlines with single newlines. The
details of that will depend on the line endings in your text; assuming
\n for newline then you could use
  txt = re.sub(r'\n\n+', '\n', txt)
to remove extra newlines.

The split() method won't distinguish between spaces and newlines so
you have to apply it one line at a time. The re.sub() method can work
on the entire text at once.

Kent
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Kristina Ambert | 1 Sep 21:51 2009
Picon

Tracking variable changes in a different application

Hi again,

The question might be a tad confusing, but what I want to ask is, if it's possible to track if and when a variable in an application has changed, and then grab the new content of that variable?
I have my product inventory database application which is attached to another bigger application. Some of the data I need comes from that bigger application, like for instance Consumer information (not handled by the application that I'm working on). So, if the address of a consumer is changed, how my application track the changes without having to do something like:

        class Consumer(objectOfSomething):
                  -----
                  -----
                  def updateConsumerInfo(newAddress):
                          newAddress = newAddress
                          inventory.updateConsumerInfo(newAddress)        #<<<not updating from here

instead only read from class:
        class Consumer(objectOfSomething):
                  -----
                  -----
                  def updateConsumerInfo(newAddress):
                          newAddress = newAddress

and track the change of newAddress from the function updateConsumerInfo in class Consumer.

Is this possible to do? (if my question even make sense)

Thanks for any responses!

Best,
Krissy

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Gmane