Re: bicycle repair man help

2007-06-27 Thread Rob Weir
On 6/24/07, Rustom Mody <[EMAIL PROTECTED]> wrote:
> Does someone know that when using bicycle repair man to refactor python code
> what exactly extract local variable means?

It means extracting a part (or all of) an expression and replacing it
with a sensibly-named local variable.

Shamelessly copied from c2:

> For example:
>
>  if ( (x==0) || ((y<17) && name == null) ) {
>..
>  }
>
> becomes:
>
>  final boolean outOfActiveAreal = (x==0) || ((y<17) && name == null) ;
>  if (outOfActiveAreal ) {
>..
>  }

Some more articles:

http://refactoring.com/catalog/introduceExplainingVariable.html and
http://c2.com/cgi-bin/wiki?IntroduceExplainingVariable have
discussions of them.

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


Re: formatting number of bytes to human readable format

2008-08-12 Thread Rob Weir
On 13 Aug 2008, rkmr wrote:
> is there any library /  function that prints number of bytes in human
> readable format?
> for example
>
> a=XX(1048576)
> print a
>
> should output
> 1 MB

http://mail.python.org/pipermail/python-list/1999-December/018519.html
is a good start - just need to change the table to something like::

_abbrevs = [
(2 ** 30L - 1, 'G'),
(2 ** 20L - 1, 'M'),
(2 ** 10L - 1, 'K'), 
(1, '')
   ]

(and add a 'B').

-- 
-rob

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


Re: Downloading and Installing gasp

2008-08-12 Thread Rob Weir
On 13 Aug 2008, Cyprian Kumwaka wrote:
> I am a beginner in Python. Please tell me how to go about in
> downloading and installing the module gasp.I am using Python 2.5.2.

What OS are you using?  Do you have PyGame installed already?

-- 
-rob

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


Re: Checking a file's time stamp -- followup

2008-08-12 Thread Rob Weir
On 13 Aug 2008, Virgil Stokes wrote:
> Is it possible to change the time stamp of a file (Win2K platform)? If
> yes, how?

os.utime, http://docs.python.org/lib/os-file-dir.html.

-- 
-rob

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


Re: Using Timer or Scheduler in a Class

2008-08-13 Thread Rob Weir
On 14 Aug 2008, William Battersea wrote:
> Both run once and end. I'm obviously missing something here.

That's how both ('sched' and threading.Timer) of the them work.
Depending on what you're doing, your toolkit/framework (Twisted, GTK,
etc) might have a better solution.  Or
http://www.gossamer-threads.com/lists/python/python/652793?page=last.

-- 
-rob

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


Re: print "%s"

2008-08-17 Thread Rob Weir
On 18 Aug 2008, Beema Shafreen wrote:
> Hi ALL,
>
> In my script i have to print a series of string , so
>
> print "%s\t%s\t%s\t%s\t%s\t%s\t" %("a","v","t","R","s","f")

print "\t".join(("a","v","t","R","s","f")) + "\t"

Note the double brackets.

-- 
-rob

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


Re: Python Substitute for PHP GD, Resizing an image on the client side

2008-08-18 Thread Rob Weir
On 19 Aug 2008, [EMAIL PROTECTED] wrote:
> Hi Folks,
>
> I am using cherrypy and python. I am trying to get a user profile
> image to resize on the client side before uploading to the server. PHP
> has a gd library that does it it seems. 

PIL?  http://www.pythonware.com/products/pil/.

-- 
-rob

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


Re: Newbie Question:Please help

2008-09-08 Thread Rob Weir
On  9 Sep 2008, Karthik Krishnan wrote:
> File "", line 1
> python main_test.py
>
> Syntax Error: invalid syntax

I get:

  File "/tmp/x.py", line 11
if __name__ = "__main__":
^
SyntaxError: invalid syntax

> if __name__ = "__main__":
  ^
= is used for assignment in Python, you want ==.

-- 
-rob

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