Re: tkinter and gtk problem

2014-09-27 Thread dieter
Paula Estrella  writes:

> Hello, we are working on ubuntu 12.04 LTS; we use gtk to take screenshots
> and we added a simple interface to select a file using tkFileDialog but it
> doesn't work; is it possible that tkinter and gtk are incompatible? a test
> script to open a file with tkFileDialog works fine but if we import gtk
> even if we don't use it, the dialog box doesn't respond to mouse events
> anymore; if we comment the import gtk it does work 

UI toolkits (like "tk" and "gtk") usually use a so called event loop
which gets information about user interaction events
(e.g. keyboard/mouse events) and dispatches appropriate application callbacks.

When you use two (or more) such toolkits in the same application,
you need a special event loop which multiplexes the events
to the various toolkits.

The implementation of such a multiplexing event loop might
be difficult (and likely will be dependent on the UI toolkits
to be integrated). Therefore, if possible, try to avoid
combining multiple UI toolkits in the same application.

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


Re:Leap year

2014-09-27 Thread Dave Angel
Seymore4Head  Wrote in message:
> Still practicing.  Since this is listed as a Pseudocode, I assume this
> is a good way to explain something.  That means I can also assume my
> logic is fading with age.
> http://en.wikipedia.org/wiki/Leap_year#Algorithm
> 

> 
> I didn't have any problem when I did this:
> 
> if year % 400 == 0:
>   print ("Not leap year")
> elif year % 100 == 0:
>   print ("Leap year")
> elif year % 4 == 0:
>   print ("Leap year")
> else:
>   print ("Not leap year")
> 

But the first two prints are incorrect, so I'm not sure what you
 mean by "didn't have any problem."

Incidentally, it's usually easier to test a function that does one
 thing. So if you replace all those prints with appropriate return
 True or return False, then it's easy to exhaustively compare two
 variations. 

-- 
DaveA

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


ANN: python-ldap 2.4.17

2014-09-27 Thread Michael Ströder
Find a new release of python-ldap:

  http://pypi.python.org/pypi/python-ldap/2.4.17

python-ldap provides an object-oriented API to access LDAP directory
servers from Python programs. It mainly wraps the OpenLDAP 2.x libs for
that purpose. Additionally it contains modules for other LDAP-related
stuff (e.g. processing LDIF, LDAP URLs and LDAPv3 schema).

Project's web site:

  http://www.python-ldap.org/

Ciao, Michael.


Released 2.4.17 2014-09-27

Changes since 2.4.16:

Lib/
* New hook syncrepl_refreshdone() in ldap.syncrepl.SyncReplConsumer
  (thanks to Petr Spacek and Chris Mikkelson)

Modules/
* Added support for getting file descriptor of connection
  with ldap.OPT_DESC

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


Re: Storage Cost Calculation

2014-09-27 Thread Skip Montanaro
On Sep 27, 2014 1:06 AM, "Chris Angelico"  wrote:
>

> We are not going to do your homework for you.

Perhaps it was a take home test... What then? :-)

Skip
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Storage Cost Calculation

2014-09-27 Thread Chris Angelico
On Sat, Sep 27, 2014 at 9:14 PM, Skip Montanaro
 wrote:
> On Sep 27, 2014 1:06 AM, "Chris Angelico"  wrote:
>>
>
>> We are not going to do your homework for you.
>
> Perhaps it was a take home test... What then? :-)

Then we are not going to do his take home test for you.

I feel like I'm using a Hungarian phrasebook here...

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Storage Cost Calculation

2014-09-27 Thread Larry Martell
On Sat, Sep 27, 2014 at 7:18 AM, Chris Angelico  wrote:

> On Sat, Sep 27, 2014 at 9:14 PM, Skip Montanaro
>  wrote:
> > On Sep 27, 2014 1:06 AM, "Chris Angelico"  wrote:
> >>
> >
> >> We are not going to do your homework for you.
> >
> > Perhaps it was a take home test... What then? :-)
>
> Then we are not going to do his take home test for you.
>
> I feel like I'm using a Hungarian phrasebook here...
>  


My hovercraft is full is eels.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Storage Cost Calculation

2014-09-27 Thread Larry Martell
On Sat, Sep 27, 2014 at 7:18 AM, Chris Angelico  wrote:

> On Sat, Sep 27, 2014 at 9:14 PM, Skip Montanaro
>  wrote:
> > On Sep 27, 2014 1:06 AM, "Chris Angelico"  wrote:
> >>
> >
> >> We are not going to do your homework for you.
> >
> > Perhaps it was a take home test... What then? :-)
>
> Then we are not going to do his take home test for you.
>
> I feel like I'm using a Hungarian phrasebook here...
>

My hovercraft is full of eels.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Understanding co_lnotab

2014-09-27 Thread Ned Batchelder
On 9/26/14 7:13 AM, Shiyao Ma wrote:
> When reading the notes on co_lnotab
> 
> I totally got lost at this
> line:https://hg.python.org/cpython/file/fd0c02c3df31/Objects/lnotab_notes.txt#l31
> 
> It says,"In case #b, there's no way to know
>   from looking at the table later how many were written."
> 
> 
> No way to know "what" is written?
> And why no way to know "how many" times?
> 

I'm not sure what that sentence means, and I've written code that uses
co_lnotab.  I think they are trying to explain the difficulties with
abandoned approaches.  Don't worry about that.  Look at the code in the
comment there to see how to interpret the bytes in co_lnotab.

Here's the code in coverage.py that reads it:
https://bitbucket.org/ned/coveragepy/src/a69ae93817be94e400df257e1b1e41cf37c9b146/coverage/parser.py?at=default#cl-377
if that helps.

Just out of curiosity, what are you writing, it sounds interesting! :)

--Ned.

> 
> Regards
> 
> 


-- 
Ned Batchelder, http://nedbatchelder.com

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


Re: Understanding co_lnotab

2014-09-27 Thread Skip Montanaro
On Sat, Sep 27, 2014 at 7:08 AM, Ned Batchelder 
wrote:

> Just out of curiosity, what are you writing, it sounds interesting! :)


Ned would say that. I think he has an unusual fondness for static code
analysis tools. :-)

Skip
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Storage Cost Calculation

2014-09-27 Thread Ian Kelly
On Fri, Sep 26, 2014 at 12:53 PM, Abohfu venant zinkeng
 wrote:
> This site was written by a person (in 2009) who had considered this amazing
> trend. He collected a lot of data about hard drive capacity and price. The
> formula he extrapolated by using the data he found is
>
> cost per gigabyte = 10-0.2502(year-1980) + 6.304
> where year is the year for which the extrapolated cost was desired. This
> formula is based on data from 1980 to 2010.

A nice illustration in the perils of extrapolation. Per the formula,
hard drives should be $0.006 per gigabyte now. I don't see anything on
newegg.com for less than $0.03 per gigabyte; the best deals appear to
be at the 2 TB level. And we're only 4 years out of the data range.

It also seems odd to quantify technical advancement in a way that is
easily affected by fluctuations in the strength of the US dollar.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Storage Cost Calculation

2014-09-27 Thread MRAB

On 2014-09-27 15:30, Ian Kelly wrote:

On Fri, Sep 26, 2014 at 12:53 PM, Abohfu venant zinkeng
 wrote:

This site was written by a person (in 2009) who had considered this
amazing trend. He collected a lot of data about hard drive capacity
and price. The formula he extrapolated by using the data he found
is

cost per gigabyte = 10-0.2502(year-1980) + 6.304 where year is the
year for which the extrapolated cost was desired. This formula is
based on data from 1980 to 2010.


A nice illustration in the perils of extrapolation. Per the formula,
hard drives should be $0.006 per gigabyte now. I don't see anything
on newegg.com for less than $0.03 per gigabyte; the best deals appear
to be at the 2 TB level. And we're only 4 years out of the data
range.

It also seems odd to quantify technical advancement in a way that is
easily affected by fluctuations in the strength of the US dollar.


I once did a calculation of my own about the cost of RAM.

In 1981 the BBC Micro was released. There were 2 versions, model A with
16K and model B was 32K. The price difference was £100, so that's £100
for 16K of RAM.

Today you can get 16GB of RAM for about the same price.

If you'd wanted that much RAM 30 years ago, it would've cost you £100m!
--
https://mail.python.org/mailman/listinfo/python-list


Re: Storage Cost Calculation

2014-09-27 Thread Seymore4Head
On Fri, 26 Sep 2014 11:53:32 -0700, Abohfu venant zinkeng
 wrote:

>
>   QUESTION
>
>   -
>
>   Could someone help me with a design and a python program to
>implement that design to solve the above problem?

As a side note, it would be handy to compare HD cost to CD cost.
I am still trying to get my own personal copy of the Internet.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Storage Cost Calculation

2014-09-27 Thread Chris Angelico
On Sun, Sep 28, 2014 at 3:01 AM, Seymore4Head
 wrote:
> As a side note, it would be handy to compare HD cost to CD cost.
> I am still trying to get my own personal copy of the Internet.

If you set your sights a bit lower, Google might be able to help. They
pretty much have their own copy of the World Wide Web, indexed and
cached. I've no idea how many dollars they annually spend on hard
drives, but probably it uses SI prefixes most of the world has never
heard of...

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Storage Cost Calculation

2014-09-27 Thread Ian Kelly
On Sat, Sep 27, 2014 at 11:12 AM, Chris Angelico  wrote:
> On Sun, Sep 28, 2014 at 3:01 AM, Seymore4Head
>  wrote:
>> As a side note, it would be handy to compare HD cost to CD cost.
>> I am still trying to get my own personal copy of the Internet.
>
> If you set your sights a bit lower, Google might be able to help. They
> pretty much have their own copy of the World Wide Web, indexed and
> cached. I've no idea how many dollars they annually spend on hard
> drives, but probably it uses SI prefixes most of the world has never
> heard of...

http://what-if.xkcd.com/63/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Storage Cost Calculation

2014-09-27 Thread Chris Angelico
On Sun, Sep 28, 2014 at 3:21 AM, Ian Kelly  wrote:
>> If you set your sights a bit lower, Google might be able to help. They
>> pretty much have their own copy of the World Wide Web, indexed and
>> cached. I've no idea how many dollars they annually spend on hard
>> drives, but probably it uses SI prefixes most of the world has never
>> heard of...
>
> http://what-if.xkcd.com/63/

Yes, I've seen that. Probably the most readable financial figures that
anyone's ever put together. :)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Python unittesting method call issue

2014-09-27 Thread Milson Munakami
I am trying to set the precondition for the test first prior to test other test 
cases. But as you can see in my code the precondition print command is not 
fired! Can you explain the cause and solution how to fire the code with in that 
method i.e. SetPreConditionFirewall() with setup variable self. 
in this fucntion. Here is my code:

import json
import urllib
#import time
#from util import *
import httplib

#import sys
#from scapy.all import *

import unittest

import os, sys, socket, struct, select, time 
from threading import Thread

import logging
import traceback

class testFirewallS1( unittest.TestCase ):
def setUp(self):
self.controllerIp="127.0.0.1"
def tearDown(self):
if self.failed:
return
duration = time.time() - self.startTime_
self.cleanup(True)
if self.reportStatus_:
self.log.info("=== Test %s completed normally (%d sec)", 
self.name_, duration)

def cleanup(self, success):
sys.excepthook = sys.__excepthook__
try:
return
except NameError:
self.log.error("Exception hit during cleanup, bypassing:\n%s\n\n" % 
traceback.format_exc())
pass
else:

fail("Expected a NameError")

def SetPreConditionFirewall(self):
command = "http://%s:8080/wm/firewall/module/enable/json"; % 
self.controllerIp
urllib.urlopen(command).read()
print self.controllerIp
print "Test Pre-condition setting here"

#Precondition Test
def testPreConditionFirewall(self):
print "Test pass"   

def suite():

suite = unittest.TestSuite()

suite.addTest(unittest.makeSuite(testFirewallS1))

return suite


if __name__ == '__main__':

suiteFew = unittest.TestSuite()

testFirewallS1("SetPreConditionFirewall")

suiteFew.addTest(testFirewallS1("testPreConditionFirewall"))


#Testing the Test Cases Begins Here
unittest.TextTestRunner(verbosity=2).run(suiteFew)

How can I do access that method on __main__ and how can that method can access 
the setup variable.

Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python unittesting method call issue

2014-09-27 Thread Chris Angelico
On Sun, Sep 28, 2014 at 9:25 AM, Milson Munakami  wrote:
> I am trying to set the precondition for the test first prior to test other 
> test cases. But as you can see in my code the precondition print command is 
> not fired! Can you explain the cause and solution how to fire the code with 
> in that method i.e. SetPreConditionFirewall() with setup variable 
> self. in this fucntion. Here is my code:
>

The first thing to do is to cut down your code - for instance, what
happens if you remove the urlopen call and just have the print in
there? (And while you're at it, I think suite() is completely
superfluous.) You should be able to get your code down to being
identical to a working example, except for one difference, and then
you'll be able to either spot the issue yourself, or ask for very
specific help.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python unittesting method call issue

2014-09-27 Thread Ian Kelly
On Sat, Sep 27, 2014 at 5:25 PM, Milson Munakami  wrote:
> I am trying to set the precondition for the test first prior to test other 
> test cases. But as you can see in my code the precondition print command is 
> not fired! Can you explain the cause and solution how to fire the code with 
> in that method i.e. SetPreConditionFirewall() with setup variable 
> self. in this fucntion. Here is my code:

The method doesn't run because you never called it, and the name has
no special meaning to unittest, so unittest is not going to call it
for you.

The method that gets called prior to each test is setUp. So if you
want SetPreConditionFirewall to be called before each test, then call
it from setUp.
-- 
https://mail.python.org/mailman/listinfo/python-list


Question about uninstallation.

2014-09-27 Thread Gregory Johannes-Kinsbourg
Hello, 

This whole world of Python language is completely new to me (never programmed 
before in my life) - anyway sort of besides the point. Anyway, I’ve sort of 
been learning ‘all over the place’, that is to say that ill read something do 
it and then find out i should have done something else first. 
Anyway, I’ve basically ended up installing both Python 2 & 3 (I’m on OS X 10.10 
btw) and first of all was curious to know if they will clash with each when 
being used in terminal and how do i safely remove 3 (figure i’ll learn 2 first, 
then re-install 3). According to the manual I should remove the files from the 
application folder (fair enough) but also the framework (surely I should leave 
that for python 2?)

Thanks in advance for the response you can provide me.

Kind regards,
Greg.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about uninstallation.

2014-09-27 Thread Chris Angelico
On Sun, Sep 28, 2014 at 11:07 AM, Gregory Johannes-Kinsbourg
 wrote:
> Anyway, I’ve basically ended up installing both Python 2 & 3 (I’m on OS X 
> 10.10 btw) and first of all was curious to know if they will clash with each 
> when being used in terminal and how do i safely remove 3 (figure i’ll learn 2 
> first, then re-install 3). According to the manual I should remove the files 
> from the application folder (fair enough) but also the framework (surely I 
> should leave that for python 2?)
>

They shouldn't clash. You'll invoke one as python2 and the other as
python3. However, as Yosemite hasn't been released yet, you may find
that you have problems that nobody's run into yet. To get a better
understanding of Python, separately from any OS X issues, you may want
to make yourself a Linux computer to test on - it's usually not hard
to install a virtualization system and create a Linux machine inside
your Mac (or just get an actual physical machine). There have been
some issues with OS X and Python, in various versions; not being a Mac
person myself, I can't say what the least problematic version is.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Storage Cost Calculation

2014-09-27 Thread Steven D'Aprano
MRAB wrote:

> In 1981 the BBC Micro was released. There were 2 versions, model A with
> 16K and model B was 32K. The price difference was £100, so that's £100
> for 16K of RAM.

That doesn't follow. The model A might have been £1 (in which case you could
get 16K for £1) or it might have been £1. All your calculation shows is
that model B was £100 more expensive.

There are three more-or-less equally valid statistics you could have used to
calculate the price of RAM: the average, minimum, or maximum. With only two
data points, it doesn't matter whether you use the mean or median to
calculate the average. Of the three, the minimum is probably the most
useful.

> Today you can get 16GB of RAM for about the same price.

Funny that you say that. I just googled for "price of RAM", and the very
first result talks about how much the price of RAM has *increased*
recently:

Other components show similar increases — Kingston 8GB packs 
have gone from $66 to $79, and Corsair's 16GB RAM packs are 
up to $150, from $130. A year ago, 16GB of DDR3-1600 from 
Corsair was $67, which gives you some idea of just how much 
prices have already risen.

... And my browser just crashed and I can't be bothered restarting it,
so you can do your own googling if you want the source :-)


-- 
Steven

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


Re: Storage Cost Calculation

2014-09-27 Thread Chris Angelico
On Sun, Sep 28, 2014 at 11:14 AM, Steven D'Aprano
 wrote:
> MRAB wrote:
>
>> In 1981 the BBC Micro was released. There were 2 versions, model A with
>> 16K and model B was 32K. The price difference was £100, so that's £100
>> for 16K of RAM.
>
> That doesn't follow. The model A might have been £1 (in which case you could
> get 16K for £1) or it might have been £1. All your calculation shows is
> that model B was £100 more expensive.
>
> There are three more-or-less equally valid statistics you could have used to
> calculate the price of RAM: the average, minimum, or maximum. With only two
> data points, it doesn't matter whether you use the mean or median to
> calculate the average. Of the three, the minimum is probably the most
> useful.

The RAM was presumably the only difference between the two models, so
as long as Model A cost at least £100 (which seems likely; a bit of
quick Googling suggests that it may have been of the order of £400), a
£100 difference can plausibly be called the price of the RAM.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python unittesting method call issue

2014-09-27 Thread Steven D'Aprano
Milson Munakami wrote:

> I am trying to set the precondition for the test first prior to test other
> test cases. But as you can see in my code the precondition print command
> is not fired! Can you explain the cause and solution how to fire the code
> with in that method i.e. SetPreConditionFirewall() with setup variable
> self. in this fucntion. Here is my code:

Unfortunately, your code has many issues. See comments below, interleaved
between the lines of code:


[snip imports]
> class testFirewallS1( unittest.TestCase ):
> def setUp(self):
> self.controllerIp="127.0.0.1"
> def tearDown(self):
> if self.failed:
> return

I cannot see that self.failed is defined anywhere, so your tearDown method
will fail every single time a test runs.

> duration = time.time() - self.startTime_

I cannot see that self.startTime_ is defined anywhere either.

> self.cleanup(True)
> if self.reportStatus_:

Nor self.reportStatus_.

> self.log.info("=== Test %s completed normally (%d sec)",
>   self.name_, duration)

And the same for self.log, self.name_.

> def cleanup(self, success):
> sys.excepthook = sys.__excepthook__

I don't know why you are doing this. Your code never changes the excepthook,
so why are you restoring it? It seems unnecessary.

> try:
> return
> except NameError:

A bare return cannot possibly fail. It certainly won't fail with NameError,
so your "except NameError" clause is dead code and will never run.

> self.log.error("Exception hit during cleanup,
>bypassing:\n%s\n\n" % traceback.format_exc())
> pass

But if it did run, the "pass" here is pointless and unnecessary.

> else:
> fail("Expected a NameError")

This code will never run, since you've already returned out of the method.
It is dead code.

If you want to raise an exception, the right way is with the "raise"
keyword:

raise NameError

not to invent some fake name which you hope will fail.


> def SetPreConditionFirewall(self):
> command = "http://%s:8080/wm/firewall/module/enable/json"; %
self.controllerIp
> urllib.urlopen(command).read() 
> print self.controllerIp
> print "Test Pre-condition setting here"


Here you have a test method, which the unittest framework will automatically
detect, if you allow it. But later, you explicitly provide a method name
for the test suite to run, so there is a conflict: will the unittest
framework call your explicitly named method, or your test* methods, or
both? I'm afraid I don't know that answer to that, but I expect that the
solution is to use one, or the other, not both.

> #Precondition Test
> def testPreConditionFirewall(self):
> print "Test pass"
> 
> def suite():
> suite = unittest.TestSuite()
> suite.addTest(unittest.makeSuite(testFirewallS1))
> return suite

I'm not sure why you are manually instantiating TestSuite here, instead of
allowing unittest to do so on your behalf. But since you never actually
call suite(), it doesn't matter, it doesn't get used.


> if __name__ == '__main__':
> suiteFew = unittest.TestSuite()
> testFirewallS1("SetPreConditionFirewall")

Here you create a testFirewallS1 instance, but it is immediately garbage
collected since you don't do anything with it.


> suiteFew.addTest(testFirewallS1("testPreConditionFirewall"))

Again, I'm not sure why you are bothering to manually create test suites.
Can you explain what you are trying to do?


> #Testing the Test Cases Begins Here
> unittest.TextTestRunner(verbosity=2).run(suiteFew)
> 
> How can I do access that method on __main__ and how can that method can
> access the setup variable.

What method on __main__? I don't understand your question.

In my opinion, I don't see anything that requires you to manually
instantiate the test suites. I think you should let the unittest framework
handle all the grunt work. Start by defining one or more test suites, by
inheriting from TestCase, then let unittest auto-detect and auto-run them.
The simplest way is to just name your tests "testFoo" (for any value of
Foo).


class TestFirewallS1(unittest.TestCase):
# Write your setUp and tearDown methods, if you need them.
# Make sure you initialise all the attributes you need. The best
# place for that is in the setUp method.

def setUp(self):
self.variable = "World"

# Now write your tests. Prefix them with the word "test".
def test_this(self):
# Write a self-contained test. It can call any helper methods
# you like, access any instance attributes you have.
result = self.helper() + self.variable
self.assertEqual(result, "HelloWorld!")

# Methods not starting with "test" are not special.
def helper(self, arg=None):
return "Hello"

# 

Re: Storage Cost Calculation

2014-09-27 Thread Steven D'Aprano
Chris Angelico wrote:

> The RAM was presumably the only difference between the two models, so
> as long as Model A cost at least £100 (which seems likely; a bit of
> quick Googling suggests that it may have been of the order of £400), a
> £100 difference can plausibly be called the price of the RAM.

Hah! I read MRAB as saying the *RAM* came in two models, "Model A RAM"
and "Model B RAM". I wondered why they didn't just say "16K" versus "32K",
but it was the 1980s, who knows why people did anything back then...

But no, you can't put the £100 difference down to the price of the RAM even
if RAM were the only difference between the two model Micros. There's not
enough information to tell how much of that £100 represents the cost of
RAM, and how much is pure profit on the part of the vendor, Acorn. In fact,
there were considerable differences apart from RAM:

The Model B supported more graphics modes, had a six-pin DIN connector for a
monitor (both the A and B had UHF output for connecting to a television,
but only the B supported a dedicated monitor), had support for an optional
floppy disk controller and even an optional hard drive controller. It also
had RS-232 and Centronics parallel interfaces, a 20-pin "user port" for
I/O, and even support for a second CPU! The Model A didn't support any of
those.

http://www.theregister.co.uk/Print/2011/11/30/bbc_micro_model_b_30th_anniversary/

At the time, the BBC Micro memory was (I think) expandable: the Model B
could be upgraded to 128K of memory, double what Bill Gates allegedly said
was the most anyone would ever need. (He probably didn't say that.) So what
we need is to find out what an upgrade would have cost.

http://www.progettoemma.net/mess/system.php?machine=bbca



-- 
Steven

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


Re: Storage Cost Calculation

2014-09-27 Thread Chris Angelico
On Sun, Sep 28, 2014 at 12:47 PM, Steven D'Aprano
 wrote:
> Chris Angelico wrote:
>
>> The RAM was presumably the only difference between the two models, so
>> as long as Model A cost at least £100 (which seems likely; a bit of
>> quick Googling suggests that it may have been of the order of £400), a
>> £100 difference can plausibly be called the price of the RAM.
>
> Hah! I read MRAB as saying the *RAM* came in two models, "Model A RAM"
> and "Model B RAM". I wondered why they didn't just say "16K" versus "32K",
> but it was the 1980s, who knows why people did anything back then...
>
> But no, you can't put the £100 difference down to the price of the RAM even
> if RAM were the only difference between the two model Micros. There's not
> enough information to tell how much of that £100 represents the cost of
> RAM, and how much is pure profit on the part of the vendor, Acorn. In fact,
> there were considerable differences apart from RAM:

I don't care about "pure profit on the part of the vendor" - that's
part of the end-user cost of RAM. But if my presumption is incorrect,
there's no way to put a price on just the RAM.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Storage Cost Calculation

2014-09-27 Thread Steven D'Aprano
Chris Angelico wrote:

> On Sun, Sep 28, 2014 at 12:47 PM, Steven D'Aprano
>  wrote:
[...]
>> But no, you can't put the £100 difference down to the price of the RAM
>> even if RAM were the only difference between the two model Micros.
>> There's not enough information to tell how much of that £100 represents
>> the cost of RAM, and how much is pure profit on the part of the vendor,
>> Acorn. In fact, there were considerable differences apart from RAM:
> 
> I don't care about "pure profit on the part of the vendor" - that's
> part of the end-user cost of RAM.

No, it's part of the end-user cost of the BBC Micro model B. What we want to
know is the cost in 1981 of buying a 16K memory chip, without the rest of
the computer.

Even that's not necessarily a good indication, since there are all sorts of
things which could distort the price. Historically, both IBM and Apple are
well known for (ab)using monopoly power to keep the price of spare parts
extremely high. If (say) Acorn charged £85 for a 16KB memory chip, while
other manufacturers charged £15, we wouldn't want to treat Acorn's prices
as "the cost of RAM in 1981". We want to compare typical, competitive
prices, not RTBO ("Rip The Bastards Off") prices.

I used to work for a company that made and sold electronic sensor taps.
There were four components: a spout, a solenoid, a transformer, and a
sensor. If you bought the four components individually, as spare parts, it
would cost you about twice as much as buying the entire kit. Some of that
reflects the fact that there's about the same amount of overhead (ordering,
billing, storage, packing, delivery...) whether it's a $300 kit or a $30
spout, but most of it reflects monopoly power. When selling the kit, we
were competing with other brands of electronic and hands-free taps. When
selling the parts, we had a monopoly on the parts: other brands of parts
wouldn't fit our taps, and our parts wouldn't fit theirs. I don't quite
remember the exact figures, but markup on the entire unit was about 30%,
and markup on the parts were about 100-200%, I think.

And this is partly why, for a long time, Apple spare parts were so much more
expensive than non-Apple spares that wouldn't fit in your Macintosh. You
had a choice of RAM from three or four manufacturers for your PC, and no
choice at all for your Mac. (I don't know if this is still the case now, I
haven't used a Mac seriously since System 7.)

> But if my presumption is incorrect, 
> there's no way to put a price on just the RAM.

My point exactly :-)


-- 
Steven

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


Re: Storage Cost Calculation

2014-09-27 Thread Ian Kelly
On Sat, Sep 27, 2014 at 8:47 PM, Steven D'Aprano
 wrote:
> http://www.theregister.co.uk/Print/2011/11/30/bbc_micro_model_b_30th_anniversary/
>
> At the time, the BBC Micro memory was (I think) expandable: the Model B
> could be upgraded to 128K of memory, double what Bill Gates allegedly said
> was the most anyone would ever need. (He probably didn't say that.) So what
> we need is to find out what an upgrade would have cost.

Actually it was 640K in the alleged Bill Gates quote, although I do
believe that quote has pretty much been debunked. It was allegedly
stated in 1981, but there doesn't seem to be any evidence of it
circulating prior to about 1992. Gates himself denies ever having said
it, and maintains that he in fact held the opposite opinion.
-- 
https://mail.python.org/mailman/listinfo/python-list


please suggest me best way to learn REST API call with CLI

2014-09-27 Thread Unix SA
Hello,

I am intermediate to python and i am familier with OOP, but sometime i lost
some where looking at OOP in class and objects  :(

I am looking at https://github.com/pulp/pulp ..

basically it uses okaara to generate CLI and calls API.


so for example if i run "pulp-admin -u admin -p admin rpm repo list" it
produces list of all repositories ...

now i want to write similar thing .. but without producing all repository i
just want to list single repo and below is the API for that ..

http://pulp-dev-guide.readthedocs.org/en/pulp-2.2/integration/rest-api/repo/retrieval.html

Not sure what's the best way to write it ... i want to do in OO way.. i
know how to use requests/httplib module and generate data and produce
output .

but i am not able to build URL ...

can someone help to suggest best way to learn and write it ?

Regards,
DJ
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Leap year

2014-09-27 Thread Steven D'Aprano
Seymore4Head wrote:

> Still practicing.  Since this is listed as a Pseudocode, I assume this
> is a good way to explain something.  That means I can also assume my
> logic is fading with age.
> http://en.wikipedia.org/wiki/Leap_year#Algorithm
> 
> Me trying to look at the algorithm, it would lead me to try something
> like:
> if year % 4 !=0:
>   return False
> elif year % 100 !=0:
>   return True
> elif year % 400 !=0:
>   return False

You can only have the "return" statement inside a function, not in top-level
code, and that looks like top-level code. So you need to start with
something like:

def is_leapyear(year):
if year % 4 != 0:
return False
...


>    Since it is a practice problem I have the answer:
> def is_leap_year(year):
> return ((year % 4) == 0 and ((year % 100) != 0 or (year % 400) == 0))

Or in English:

- years which are divisible by 4 are leap years, *unless* they are also
divisible by 100, in which case they aren't leap years, *except* that years
divisible by 400 are leap years.

Converting to Python code:

def is_leap_year(year):
return (
# Years which are divisible by 4
(year % 4 == 0)
# and not divisible by 100
and (year % 100 != 0)
# unless divisible by 400
or (year % 400 == 0)
)


> I didn't have any problem when I did this:
> 
> if year % 400 == 0:
>   print ("Not leap year")
> elif year % 100 == 0:
>   print ("Leap year")
> elif year % 4 == 0:
>   print ("Leap year")
> else:
>   print ("Not leap year")

You might not have had any problems, but neither did you get the right
answers. According to your code, 2000 is not a leap year (since 2000 % 400
equals 0) but in reality it is. On the other hand, your code says 1900 was
a leap year, which it was not.

The lesson here is, code isn't working until you've actually tested it, and
to test it sufficiently you need to check the corner cases, not just the
obvious ones.



-- 
Steven

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