Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-15 Thread sword
Maybe you're looking for ipython? History, tab-complete, sort of
things in it.

goldtech wrote:
> Hi,
>
> Using Windows. Is there a python shell that has a history of typed in
> commands?
>
> I don't need output of commands just what I typed it. I need it to
> save between sessions - something that no shell seems to do. If I
> reboot there will still be a command history somewhere.
>
> Like bash history in Linux.
>
> Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Stucked with python logging module

2011-11-15 Thread sword
I just scaned through the beginer's guide of logging module, but I
can't get anything from console. The demo just like this:

import logging
logging.debug("This is a demo")

Maybe I should do sth to put the log to stdout in basicConfig first?
Thanks in advance
-- 
http://mail.python.org/mailman/listinfo/python-list


Got some problems when using logging Filter

2011-11-15 Thread sword
The logging cookbook gives an Filter example, explainning how to add
contextural info to log. I can't figure out how to filter log from it.

Suppose I have 3 file, a.py, b.py and main.py
#file: a.py
import logging

logger=logging.getLogger(__name__)
def print_log():
logger.debug("I'm module a")

#file: b.py just like a.py
import logging
logger=logging.getLogger(__name__)
def print_log():
logger.debug("I'm module b")

#file: main.py
import logging
from logging import Filter
logging.basicConfig(level=logging.DEBUG)
logger=logging.getLogger("main")
logger.debug("This is main process")
logger.addFilter(Filter("a"))

And I expected that the console output would contain main and b module
log only. But it turned out that all logs there.  Is it the problem of
root logger?


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Got some problems when using logging Filter

2011-11-16 Thread sword
On Nov 16, 7:40 pm, Jean-Michel Pichavant 
wrote:
> sword wrote:
> > The logging cookbook gives an Filter example, explainning how to add
> > contextural info to log. I can't figure out how to filter log from it.
>
> > Suppose I have 3 file, a.py, b.py and main.py
> > #file: a.py
> > import logging
>
> > logger=logging.getLogger(__name__)
> > def print_log():
> >     logger.debug("I'm module a")
>
> > #file: b.py just like a.py
> > import logging
> > logger=logging.getLogger(__name__)
> > def print_log():
> >     logger.debug("I'm module b")
>
> > #file: main.py
> > import logging
> > from logging import Filter
> > logging.basicConfig(level=logging.DEBUG)
> > logger=logging.getLogger("main")
> > logger.debug("This is main process")
> > logger.addFilter(Filter("a"))
>
> > And I expected that the console output would contain main and b module
> > log only. But it turned out that all logs there.  Is it the problem of
> > root logger?
>
> Hi,
>
> First of all, in the code you provided we can't see where you import a &
> b, and when you call their respective print_log method.
> Secondly,Filter("a") would allow only the "a" log events, not forbid
> them. quoting the docs: "if name is specified, it names a logger which,
> together with its children, will have its events allowed through the
> filter."
>
> As for your problem it may come from the fact that you applied the
> filter to the 'main' logger, while you probably want to add the filter
> to the *root* logger. Your current hierarchy is
>
> root
>   - main
>   - a
>   - b
>
> events fired from 'a' will be handled by the root logger, not the main.
> root = logging.getLogger()
> root.addFilter('main')
> root.addFilter('a')
> root.addFilter('b')
>
> JM

Thanks for your reply. I tried to edit the source a bit, now the
main.py looks like this:
#main.py
import logging
from logging import Filter
import a
import b

logging.basicConfig(level=logging.DEBUG)
root = logging.getLogger()
root.addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg
would pass this filter

logger = logging.getLogger("main")
logger.debug("main process")
a.print_log()
b.print_log()


And It still prints out all the log msg. :(
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Got some problems when using logging Filter

2011-11-17 Thread sword
On Nov 16, 10:50 pm, Peter Otten <[email protected]> wrote:
> sword wrote:
> > Thanks for your reply. I tried to edit the source a bit, now the
> > main.py looks like this:
> > #main.py
> > import logging
> > from logging import Filter
> > import a
> > import b
>
> > logging.basicConfig(level=logging.DEBUG)
> > root = logging.getLogger()
> > root.addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg
> > would pass this filter
>
> > logger = logging.getLogger("main")
> > logger.debug("main process")
> > a.print_log()
> > b.print_log()
>
> > 
> > And It still prints out all the log msg. :(
>
> Here's a little demo to explore how filtering works:
>
> $ cat demo.py
> import logging
> class Filter(logging.Filter):
>     def filter(self, record):
>         print "applying filter", self.name
>         return True
>
> logging.basicConfig()
>
> loggers = [logging.getLogger(path) for path in ["", "a", "a.b"]]
> for logger in loggers:
>     logger.addFilter(Filter("filter@" + logger.name))
>
> [handler] = logging.getLogger().handlers
> handler.addFilter(Filter("filter@handler"))
>
> for logger in loggers:
>     logger.critical("whatever")
> $ python demo.py
> applying filter filter@root
> applying filter filter@handler
> CRITICAL:root:whatever
> applying filter filter@a
> applying filter filter@handler
> CRITICAL:a:whatever
> applying filter [email protected]
> applying filter filter@handler
> CRITICAL:a.b:whatever
> $
>
> As you can infer from the output only the filter(s) of the original logger
> and of the handler(s) are applied.

Thanks, so if I want to see my own log out of all logs produced by
different module in the project, I should addFilter to each
corresponding logger. I thought I could add Filter in root and filter
out only the interested info from it before.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Got some problems when using logging Filter

2011-11-20 Thread sword
On Nov 20, 8:42 am, Vinay Sajip  wrote:
> On Nov 17, 9:06 am, sword  wrote:
>
>
>
>
>
>
>
>
>
> > On Nov 16, 10:50 pm, Peter Otten <[email protected]> wrote:
>
> > > sword wrote:
> > > > Thanks for your reply. I tried to edit the source a bit, now the
> > > > main.py looks like this:
> > > > #main.py
> > > > importlogging
> > > > fromloggingimport Filter
> > > > import a
> > > > import b
>
> > > >logging.basicConfig(level=logging.DEBUG)
> > > > root =logging.getLogger()
> > > > root.addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg
> > > > would pass this filter
>
> > > > logger =logging.getLogger("main")
> > > > logger.debug("main process")
> > > > a.print_log()
> > > > b.print_log()
>
> > > > 
> > > > And It still prints out all the log msg. :(
>
> > > Here's a little demo to explore how filtering works:
>
> > > $ cat demo.py
> > > importlogging
> > > class Filter(logging.Filter):
> > >     def filter(self, record):
> > >         print "applying filter", self.name
> > >         return True
>
> > >logging.basicConfig()
>
> > > loggers = [logging.getLogger(path) for path in ["", "a", "a.b"]]
> > > for logger in loggers:
> > >     logger.addFilter(Filter("filter@" + logger.name))
>
> > > [handler] =logging.getLogger().handlers
> > > handler.addFilter(Filter("filter@handler"))
>
> > > for logger in loggers:
> > >     logger.critical("whatever")
> > > $ python demo.py
> > > applying filter filter@root
> > > applying filter filter@handler
> > > CRITICAL:root:whatever
> > > applying filter filter@a
> > > applying filter filter@handler
> > > CRITICAL:a:whatever
> > > applying filter [email protected]
> > > applying filter filter@handler
> > > CRITICAL:a.b:whatever
> > > $
>
> > > As you can infer from the output only the filter(s) of the original logger
> > > and of the handler(s) are applied.
>
> > Thanks, so if I want to see my own log out of all logs produced by
> > different module in the project, I should addFilter to each
> > corresponding logger. I thought I could add Filter in root and filter
> > out only the interested info from it before.
>
> Or you can add a filter to the handler (but then you can't use
> basicConfig() to configure it - you need to do it explicitly).
>
> Regards,
>
> Vinay Sajip


Thank you! Maybe I should find out another way to manipulate the log,
like wrap the getLogger function and add the filter at the first
time :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Interesting problem about uuid1

2011-11-20 Thread sword
My colleague asks me an interesting problem about uuid library in
python. In multicore system with multiprocessing, is it possible to
get the duplicated uuid with uuid1?

I just check the RFC 4122, and I can't find anything about multicore
environment. Python's uuid1 method generates the uuid with time stamp,
mac address, and algorithm to gen random numbers. So, I think it's
possible to get the duplicate uuid1 at the same time.

What about you? Hope for your reply
-- 
http://mail.python.org/mailman/listinfo/python-list


CLAIM YOUR TWO FREE UNIVERSAL STUDIOS TICKETS!

2007-09-24 Thread Sword, Robyn

how do you claim your tickets?


 


CLAIM YOUR TWO FREE UNIVERSAL STUDIOS TICKETS!

CLAIM YOUR TWO FREE UNIVERSAL STUDIOS TICKETS! lisawill4u at yahoo.com
 
Sat Nov 20 21:35:53 CET 2004 

*   Previous message: Python Tutorials, about 100 and sorted by
Topic or Category


*   Next message: CGI email script


*   Messages sorted by: [ date ]
  [ thread ]
  [ subject ]
  [ author ]
  



An HTML attachment was scrubbed...
URL:
http://mail.python.org/pipermail/python-list/attachments/20041120/341599
3d/attachment.htm 



*   Previous message: Python Tutorials, about 100 and sorted by
Topic or Category


*   Next message: CGI email script


*   Messages sorted by: [ date ]
  [ thread ]
  [ subject ]
  [ author ]
  



More information about the Python-list mailing list
 



This e-mail, including attachments, may include confidential and/or 
proprietary information, and may be used only by the person or entity to 
which it is addressed. If the reader of this e-mail is not the intended 
recipient or his or her authorized agent, the reader is hereby notified 
that any dissemination, distribution or copying of this e-mail is 
prohibited. If you have received this e-mail in error, please notify the 
sender by replying to this message and delete this e-mail immediately.

-- 
http://mail.python.org/mailman/listinfo/python-list