Walter Prins | 1 Jan 03:50 2012
Picon

Re: ez_setup.py for Python3 64-bit on Vista

Hi,

On 31 December 2011 23:22, Mark Lybrand <mlybrand <at> gmail.com> wrote:
> I have found this script:
>
> http://peak.telecommunity.com/dist/ez_setup.py
>
> But I can see that this is Python 2.x  Is there a Python 3 version, or
> should I be doing something else to install an .egg on my system?

There isn't an official version of setuptools for Python 3.x.  Use
"distribute" instead, which is a fork of setuptools and is available
for Python 3.x:
http://pypi.python.org/pypi/distribute#disclaimers

... and/or use "Pip":
http://www.pip-installer.org/en/latest/index.html

To install "distribute", download the "distribute_setup.py" file from
the above pages, then open a command prompt and run the downloaded
Python script with your Python 3.2 interpreter.  The command wil be
something like:
C:\Python32\Python.exe C:\Users\Mark\Downloads\distribute_setup.py

(here I'm assuming your Python interpreter path is C:\Python32 and
that you've downloaded the distribute_setup.py file to
C:\Users\Mark\Downloads.  You'll have to adjust this accordingly.
Once this is done, you'll have a new command/script in
C:\Python32\Scripts.  So, if you do:
cd c:\Python32\Scripts
(Continue reading)

Mark Lybrand | 1 Jan 04:13 2012
Picon

Re: ez_setup.py for Python3 64-bit on Vista

... you'll see the newly installed script.  Additionally you can then

trivially also install "pip", by executing:

easy_install pip


Does this triviality depend on where the pip files are that I wish to "easy install"?  I would assume that the answer is "yes". In which case, if those pip files are in my Download folder, will the easy install put them in the right place or reference them from the Download folder?

Mark
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Mark Lybrand | 1 Jan 04:21 2012
Picon

Re: ez_setup.py for Python3 64-bit on Vista

I think I got it actually.  Thanks.

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Walter Prins | 1 Jan 06:02 2012
Picon

Re: ez_setup.py for Python3 64-bit on Vista

Hi Mark

On 1 January 2012 03:13, Mark Lybrand <mlybrand <at> gmail.com> wrote:
> ... you'll see the newly installed script.  Additionally you can then
>>
>> trivially also install "pip", by executing:
>>
>> easy_install pip
>>
>
> Does this triviality depend on where the pip files are that I wish to "easy
> install"?  I would assume that the answer is "yes". In which case, if those
> pip files are in my Download folder, will the easy install put them in the
> right place or reference them from the Download folder?

No -- easy_install does everything for you.  The command:

easy_install pip

both downloads and installs the package named "pip" for you.  (It so
happens that "pip" is another package management tool, but the point
is that you can install any Python package this way, simply by
specifying the package name that you want to install.)

That's part of the beauty of the inbuilt package management support in
Python.  You merely have to specify the package you'd like to install,
and distribute (via the command "easy_install") or pip (via the
command "pip") will (in general) go and locate the correct version of
a python package and install it for you.  Packages with C modules are
however much more problematic since you need a C compiler to install
them, and so in general it's far easier for such packages to find a
pre-packages Windows installer package witht he C modules already
compiled for you.  (If you're sufficiently familiar with C compilers
on Windows and projects like MinGW or tools like Visual Studio on
Windows, as well as how Windows works generally, then it's possible to
set your system up to have pip or distribute install your C based
Python modules as well.)

Hope that clarifies things,

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

Wayne Watson | 1 Jan 20:29 2012
Picon
Picon

Re: Which libraries for Python 2.5.2 [SOLVED]

This problem was solved when my wife noticed that there was a second 
install disk for the 5 year old XP zx6000 PC she had given me, which I 
will now give to a friend.

The problem originally was a missing dll that Python wanted.  All is 
well now.

--

-- 
            Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

              (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
               Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet

                      CE 1955 October 20 07:53:32.6 UT
                     -- "The Date" The mystery unfolds.

                     Web Page:<www.speckledwithstars.net/>

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Stayvoid | 1 Jan 20:40 2012
Picon

Class vs. instance

Hi there!

>>> class Sample:
>>>     def method(self): pass

>>> Sample().method()

What's the difference between class __main__.Sample and
__main__.Sample instance?
Why should I write "Sample().method" instead of "Sample.method"?

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

Hugo Arts | 1 Jan 23:03 2012
Picon

Re: Class vs. instance

On Sun, Jan 1, 2012 at 8:40 PM, Stayvoid <stayvoid <at> gmail.com> wrote:
> Hi there!
>
>>>> class Sample:
>>>>     def method(self): pass
>
>>>> Sample().method()
>
> What's the difference between class __main__.Sample and
> __main__.Sample instance?
> Why should I write "Sample().method" instead of "Sample.method"?
>

The difference can be illustrated as such:

>>> Sample().method
<bound method Sample.method of <__main__.Sample instance at 0x1004d1638>>
>>> Sample().method()
>>> Sample.method
<unbound method Sample.method>
>>> Sample.method()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unbound method method() must be called with Sample instance
as first argument (got nothing instead)
>>>

That is, the difference between the methods is that the accessed
through the instance is also attached to that instance. It will
automagically get Sample() passed to it as its first argument (that
would be self). The one attached to the class is unbound, which means
that you can do this:

>>> Sample.method(Sample())
>>>

With any Sample instance, of course. This exposes a bit of syntax
sugar in python and how classes are really implemented, essentially
the fact that, if "a" is a sample instance, a.method(arg1, arg2, arg3)
is actually just Sample.method(a, arg1, arg2, arg3)

HTH,
Hugo
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Stayvoid | 1 Jan 23:26 2012
Picon

Re: Class vs. instance

Thanks.

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

brian arb | 2 Jan 03:48 2012
Picon

while loop ends prematurly

Hello,
Can some please explain this to me?
My while loop should continue while "owed" is greater than or equal to "d"

first time the function is called
the loop exits as expected 
False: 0.000000 >= 0.010000
the next time it does not
False: 0.010000 >= 0.010000

Below is the snippet of code, and the out put.

Thanks!

def make_change(arg):
  denom = [100.0, 50.0, 20.0, 10.0, 5.0, 1.0, 0.25, 0.10, 0.05, 0.01]
  owed = float(arg)
  payed = []
  for d in denom:
    while owed >= d:
      owed -= d
      b = owed >= d
      print '%s: %f >= %f' % (b, owed, d)
      payed.append(d)
  print sum(payed), payed
  return sum(payed)
  
if __name__ == '__main__':
  values = [21.48, 487.69] #, 974.41, 920.87, 377.93, 885.12, 263.47, 630.91, 433.23, 800.58]
  for i in values:
    make_change(i))


False: 1.480000 >= 20.000000
False: 0.480000 >= 1.000000
False: 0.230000 >= 0.250000
True: 0.130000 >= 0.100000
False: 0.030000 >= 0.100000
True: 0.020000 >= 0.010000
True: 0.010000 >= 0.010000
False: 0.000000 >= 0.010000
21.48 [20.0, 1.0, 0.25, 0.1, 0.1, 0.01, 0.01, 0.01]
True: 387.690000 >= 100.000000
True: 287.690000 >= 100.000000
True: 187.690000 >= 100.000000
False: 87.690000 >= 100.000000
False: 37.690000 >= 50.000000
False: 17.690000 >= 20.000000
False: 7.690000 >= 10.000000
False: 2.690000 >= 5.000000
True: 1.690000 >= 1.000000
False: 0.690000 >= 1.000000
True: 0.440000 >= 0.250000
False: 0.190000 >= 0.250000
False: 0.090000 >= 0.100000
False: 0.040000 >= 0.050000
True: 0.030000 >= 0.010000
True: 0.020000 >= 0.010000
False: 0.010000 >= 0.010000
487.68 [100.0, 100.0, 100.0, 100.0, 50.0, 20.0, 10.0, 5.0, 1.0, 1.0, 0.25, 0.25, 0.1, 0.05, 0.01, 0.01, 0.01]


_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Dave Angel | 2 Jan 04:25 2012

Re: while loop ends prematurly

On 01/01/2012 09:48 PM, brian arb wrote:
> Hello,
> Can some please explain this to me?
> My while loop should continue while "owed" is greater than or equal to "d"
>
> first time the function is called
> the loop exits as expected
> False: 0.000000>= 0.010000
> the next time it does not
> False: 0.010000>= 0.010000
>
> Below is the snippet of code, and the out put.
>
> Thanks!
>
> def make_change(arg):
>    denom = [100.0, 50.0, 20.0, 10.0, 5.0, 1.0, 0.25, 0.10, 0.05, 0.01]
>    owed = float(arg)
>    payed = []
>    for d in denom:
>      while owed>= d:
>        owed -= d
>        b = owed>= d
>        print '%s: %f>= %f' % (b, owed, d)
>        payed.append(d)
>    print sum(payed), payed
>    return sum(payed)
>
> if __name__ == '__main__':
>    values = [21.48, 487.69] #, 974.41, 920.87, 377.93, 885.12, 263.47,
> 630.91, 433.23, 800.58]
>    for i in values:
>      make_change(i))
>
>
> False: 1.480000>= 20.000000
> False: 0.480000>= 1.000000
> False: 0.230000>= 0.250000
> True: 0.130000>= 0.100000
> False: 0.030000>= 0.100000
> True: 0.020000>= 0.010000
> True: 0.010000>= 0.010000
> False: 0.000000>= 0.010000
> 21.48 [20.0, 1.0, 0.25, 0.1, 0.1, 0.01, 0.01, 0.01]
> True: 387.690000>= 100.000000
> True: 287.690000>= 100.000000
> True: 187.690000>= 100.000000
> False: 87.690000>= 100.000000
> False: 37.690000>= 50.000000
> False: 17.690000>= 20.000000
> False: 7.690000>= 10.000000
> False: 2.690000>= 5.000000
> True: 1.690000>= 1.000000
> False: 0.690000>= 1.000000
> True: 0.440000>= 0.250000
> False: 0.190000>= 0.250000
> False: 0.090000>= 0.100000
> False: 0.040000>= 0.050000
> True: 0.030000>= 0.010000
> True: 0.020000>= 0.010000
> False: 0.010000>= 0.010000
> 487.68 [100.0, 100.0, 100.0, 100.0, 50.0, 20.0, 10.0, 5.0, 1.0, 1.0, 0.25,
> 0.25, 0.1, 0.05, 0.01, 0.01, 0.01]
>
You're using float values and pretending that they can accurately 
represent dollars and cents. 0.19 (for example) cannot be exactly 
represented in a float, and when you start adding up multiple of these, 
sooner or later the error will become visible.  This is a problem with 
binary floating point, and I first encountered it in 1967, when the 
textbook for Fortran made an important point about never comparing 
floating point values for equals, as small invisible errors are bound to 
bite you.

Easiest answer is to use integers.  Scale everything up by a factor of 
100, and you won't need floats at all.  Just convert when printing (and 
even then you may get into trouble).

Another answer is to use Decimal class, which CAN represent decimal 
values exactly.

BTW, if this is supposed to represent US legal tender, you left out the 
fifty-cent piece as well as the two dollar bill.

--

-- 

DaveA

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


Gmane