Re: How to check what is holding reference to object

2010-05-05 Thread Marius Gedminas
e to do that just looking to the code > or debugging it because it is pretty complicated, but I am able to > invoke this situation again. I wrote http://pypi.python.org/pypi/objgraph for this purpose. -- Marius Gedminas -- http://mail.python.org/mailman/listinfo/python-list

Re: How to check what is holding reference to object

2010-05-05 Thread Marius Gedminas
ed >>> import gc >>> gc.get_referrers(42) ? Marius Gedminas -- http://mail.python.org/mailman/listinfo/python-list

Re: Python-URL! - weekly Python news and links (Feb 9)

2010-02-09 Thread Marius Gedminas
  Call-By-Reference?" thread of the year! >        http://groups.google.com/group/comp.lang.pythonfd36962c4970ac487ea/ Any chance of getting them fixed? Regards, -- Marius Gedminas -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Ruby

2010-02-04 Thread Marius Gedminas
way. Someone already did: "Advanced Python or Understanding Python" http://video.google.com/videoplay?docid=7760178035196894549 (76 minutes). Worth watching. Regards, -- Marius Gedminas -- http://mail.python.org/mailman/listinfo/python-list

Re: Application-global "switches"?

2009-09-17 Thread Marius Gedminas
On Sep 4, 9:29 pm, kj wrote: > The only solution I can come up with is to define a "dummy module", > say _config.py, which contains only upper-case variables representing > these global switches, and is imported by all the other modules in > the application with the line "from _config import *".  

Re: your favorite debugging tool?

2009-09-03 Thread Marius Gedminas
On Aug 25, 2:55 pm, Esmail wrote: > Re pdb, if you have a 'pointer' (ie reference) to an object, is there > an easy way to dump out its contents, ie all of its members short of > writing a method that does that and then calling it? Usually pp vars(your_object) does what you want -- http://ma

Re: Q's on my first python script

2009-05-14 Thread Marius Gedminas
!") The warnings module is used for warnings about program code, not user input. import logging logging.warn("Oh noes, you passed me two arguments instead of one!") -- Marius Gedminas -- http://mail.python.org/mailman/listinfo/python-list

Re: Q's on my first python script

2009-05-14 Thread Marius Gedminas
eString, e: >             print usage >             print e >             sys.exit(1) I would recommend printing error messages to sys.stderr. BTW, in this particular case you may want to use parser.error(e) instead of print + sys.exit. -- Marius Gedminas -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Generators

2008-03-18 Thread Marius Gedminas
;> concat([[1,2], [3, 4], [5], [6, 7, 8]]) >>> list(concat([[1,2], [3, 4], [5], [6, 7, 8]])) [1, 2, 3, 4, 5, 6, 7, 8] wondering if google groups will add a .sig or not-ly, Marius Gedminas -- http://mail.python.org/mailman/listinfo/python-list

Re: Collections of non-arbitrary objects ?

2007-06-25 Thread Marius Gedminas
On Jun 24, 2:12 pm, Bjoern Schliessmann wrote: > 7stud wrote: > > if hasattr(elmt, some_func): > >elmt.some_func() > > Personally, I prefer > > try: > elmt.some_func() > except AttributeError: > # do stuff That also hides attribute errors that occur within some_func. I think I'd rath

Re: *Naming Conventions*

2007-06-11 Thread Marius Gedminas
On Jun 6, 3:18 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: > > Since 'i' and 'j' are canonically loop indices, I find it > > totally confusing to use them to name the iteration variable - > > which is not an index. > > Certainly i and j are just as generic, but they have the > advantage over 'item'

Re: days since epoch

2006-02-17 Thread Marius Gedminas
The datetime module is usually more convenient for date/time arithmetic. However in your particular case, you may find the time.time() function convenient. It returns the number of seconds since the epoch. To get the number of days divide the number of seconds by 86400. -- http://mail.python.o

Re: understanding stat module names

2006-01-18 Thread Marius Gedminas
David Bear wrote: > I'm trying to use os.chmod and am refered to the stat module. > > Is there are explanation of: > * S_ISUID ... > * S_IXOTH These come from the POSIX standard. See http://www.opengroup.org/onlinepubs/007908799/xsh/sysstat.h.html HTH, Mariu

Re: python coding contest

2005-12-30 Thread Marius Gedminas
I managed it with vim. -- http://mail.python.org/mailman/listinfo/python-list

Re: python coding contest

2005-12-29 Thread Marius Gedminas
I cannot reach the contest site at since all this morning. :-( -- http://mail.python.org/mailman/listinfo/python-list

Re: python coding contest

2005-12-29 Thread Marius Gedminas
I cannot not reach the contest site at since all this morning. :-( -- http://mail.python.org/mailman/listinfo/python-list

Re: python coding contest

2005-12-28 Thread Marius Gedminas
Jean-Paul Calderone wrote: > On Tue, 27 Dec 2005 14:02:57 -0700, Tim Hochberg <[EMAIL PROTECTED]> wrote: > >Shane Hathaway wrote: > >> Paul McGuire wrote: > >> > >> > >> Also, here's another cheat version. (No, 7seg.com does not exist.) > >> > >>import urllib2 > >>def seven_seg(x):return u

Re: efficient 'tail' implementation

2005-12-15 Thread Marius Gedminas
Magnus Lycka wrote: > To read the last x bytes of a file, you could do: > > >>> import os > >>> x = 2000 # or whatever... > >>> f=open('my_big_file') > >>> l=os.fstat(f.fileno()).st_size > >>> f.seek(l-x) > >>> f.read() You don't need fstat/st_size, you can ask seek to move to an offset rela