Re: Need help to sort out the below code...

2013-09-14 Thread Terry Reedy

On 9/14/2013 2:34 AM, mnishpsyched wrote:

Hello guys,
i am new to programming and trying to solve this small coding: my purpose is to 
take in values from the user based on a menu provided for selection

the output looks like this...

please select from the following menu:
1. pizza
2. steak
3. pasta
4. burger
type in any number from above for selection..

you have selected: 1. Pizza
The bill amounted for Pizza is $20 along with tax of $0.15 will make upto $20.15

the code i have written for this is as follows:

print """
Please select from the following menu:
1. pizza
2. steak
3. pasta
4. burger
type in any number from above for selection..
"""

pz = raw_input()
pz = int(pz)

st = raw_input()
st = int(st)

ps = raw_input()
ps = int(ps)

bg = raw_input()
bg = int(bg)



There should only be one input statement:
choice = int(raw_input())

The program now requires 4 inputs, which is not what you want.

Since you are starting, consider using 3.3 insteadd of Python 2 unless 
you have a very good reason.



if pz == 1 :


if choice == 1:
etc.


 print "You have selected", pz, ".pizza"
 pr_pz = 20
 tx_pz = 0.15
 tot = pr_pz + tx_pz
 print "The bill amounted for Pizza is $", pr_pz, "along with tax of $", tx_pz, 
"willmake upto $", tot


Take out 'amounted'

elif st == 2 :
 print "You have selected", st, ".Steak"
 pr_st = 40
 tx_st = 0.20
 print "The bill amounted for Steak is $", pr_st, "along with tax of $", tx_st, 
"will make upto $", tot.
...
but my program doesn't output the selection once i type in any number from the 
list.


Because it is waiting for 3 more inputs. See above. Now, you can shorten 
and improve the program after the one input statement.


data = (
('Pizza', 20.0, 0.15),
('Steak', 40.0, 0.20),
('Pasta', 14.0, 0.12),
('Burger', 23.0, 0.17),
)

if 1 <= choice <= len(data):
product, price, tax = data[choice]
bill = "The bill for {} is {}, along with tax of {}, total {}"
print(bill.format(product, price, tax, price + tax))
else:
print('I do not know what you mean.')

print() is for 3.x, but works here for 2.x also.


--
Terry Jan Reedy

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


PEP-442 - Python 3.4 and finalizations (__del__)

2013-09-14 Thread Marco Buttu
Hi all. Will the following code in Python 3.4 print "Goodbye from B()" 
and "Goodbye from A():


class A:
def __init__(self, a):
self.a = a
print('In A.__init__()')
def __del__(self):
print('Goodbye from A()')

class B:
def __init__(self):
self.b = A(self) # Reference cycle
print('In B.__init__()')
def __del__(self):
print('Goodbye from B()')

b = B()
del b

Regards, Marco

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


Re: Need help to sort out the below code...

2013-09-14 Thread Jugurtha Hadjar

Hello, mnishpsyched..

You also want the VAT to be computed as a percentage _of_ something, and 
not hard-coded, so that if you change the price of the pizza, you only 
have to change one value (pr_pz) instead of two values pr_pz and tx_tz 
(as the second is computed from the first).


You only multiply by coefficients, and these coefficients (the 
percentage the state charges) is less likely to change than the costs of 
ingredients or your margins (money moves faster than legislation).




--
~Jugurtha Hadjar,
--
https://mail.python.org/mailman/listinfo/python-list


How to display ReST properly on pypi?

2013-09-14 Thread Michel Albert
In general, I write my README files using the ReST syntax. But when I do, they 
don't show up formatted on pypi (see for example 
https://pypi.python.org/pypi/config_resolver/3.3.0).

How do I get it to be formatted properly?

Also, is there a way to specify that the "description" field in setup.py is 
formatted as ReST?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP-442 - Python 3.4 and finalizations (__del__)

2013-09-14 Thread Steven D'Aprano
On Sat, 14 Sep 2013 10:14:27 +0200, Marco Buttu wrote:

> Hi all. Will the following code in Python 3.4 print "Goodbye from B()"
> and "Goodbye from A():

Perhaps you should try it and find out.


[steve@ando ~]$ python3.4 -E
Python 3.4.0a1+ (default:becbb65074e1, Aug 26 2013, 03:57:58)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> class A:
...  def __init__(self, a):
...  self.a = a
...  print('In A.__init__()')
...  def __del__(self):
...  print('Goodbye from A()')
...
>>> class B:
...  def __init__(self):
...  self.b = A(self) # Reference cycle
...  print('In B.__init__()')
...  def __del__(self):
...  print('Goodbye from B()')
...
>>> b = B()
In A.__init__()
In B.__init__()
>>> del b
>>>
>>>
>>> import gc
>>> gc.collect()
Goodbye from B()
Goodbye from A()
4
>>>



Does that answer your question?



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


Re: How to display ReST properly on pypi?

2013-09-14 Thread Chris “Kwpolska” Warrick
On Sat, Sep 14, 2013 at 11:08 AM, Michel Albert  wrote:
> In general, I write my README files using the ReST syntax. But when I do, 
> they don't show up formatted on pypi (see for example 
> https://pypi.python.org/pypi/config_resolver/3.3.0).
>
> How do I get it to be formatted properly?
>
> Also, is there a way to specify that the "description" field in setup.py is 
> formatted as ReST?
> --
> https://mail.python.org/mailman/listinfo/python-list

rst2html crashes with your file.  Also, `py:class` is Sphinx-only and
won’t work with the Cheeseshop and produce garbage in the output.

[kwpolska@kwpolska-lin config_resolver-3.3.0]% rst2html README.rst
README.rst:67: (WARNING/2) Inline emphasis start-string without end-string.
README.rst:108: (ERROR/3) Unknown interpreted text role "py:class".
README.rst:115: (ERROR/3) Unknown interpreted text role "py:class".
README.rst:121: (ERROR/3) Unknown interpreted text role "py:class".
README.rst:142: (SEVERE/4) Problems with "include" directive path:
InputError: [Errno 2] No such file or directory: 'CHANGES'.
Exiting due to level-4 (SEVERE) system message.
[kwpolska@kwpolska-lin config_resolver-3.3.0]% echo $?
1
[kwpolska@kwpolska-lin config_resolver-3.3.0]%

-- 
Chris “Kwpolska” Warrick 
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to display ReST properly on pypi?

2013-09-14 Thread Michel Albert
Ah... I understand. Makes sense.

I was confused that it worked properly on github, but not on pypi, so I never 
even thought about checking it in rst2html. I thought I would need to specify 
somewhere manually that it was formatted as ReST instead of plain-text.

Thanks for the info.

On Saturday, 14 September 2013 11:53:12 UTC+2, Chris “Kwpolska” Warrick  wrote:
> On Sat, Sep 14, 2013 at 11:08 AM, Michel Albert wrote:
> 
> > In general, I write my README files using the ReST syntax. But when I do, 
> > they don't show up formatted on pypi (see for example 
> > https://pypi.python.org/pypi/config_resolver/3.3.0).
> 
> >
> 
> > How do I get it to be formatted properly?
> 
> >
> 
> > Also, is there a way to specify that the "description" field in setup.py is 
> > formatted as ReST?
> 
> > --
> 
> > https://mail.python.org/mailman/listinfo/python-list
> 
> 
> 
> rst2html crashes with your file.  Also, `py:class` is Sphinx-only and
> 
> won’t work with the Cheeseshop and produce garbage in the output.
> 
> 
> 
> [kwpolska@kwpolska-lin config_resolver-3.3.0]% rst2html README.rst
> 
> README.rst:67: (WARNING/2) Inline emphasis start-string without end-string.
> 
> README.rst:108: (ERROR/3) Unknown interpreted text role "py:class".
> 
> README.rst:115: (ERROR/3) Unknown interpreted text role "py:class".
> 
> README.rst:121: (ERROR/3) Unknown interpreted text role "py:class".
> 
> README.rst:142: (SEVERE/4) Problems with "include" directive path:
> 
> InputError: [Errno 2] No such file or directory: 'CHANGES'.
> 
> Exiting due to level-4 (SEVERE) system message.
> 
> [kwpolska@kwpolska-lin config_resolver-3.3.0]% echo $?
> 
> 1
> 
> [kwpolska@kwpolska-lin config_resolver-3.3.0]%
> 
> 
> 
> -- 
> 
> Chris “Kwpolska” Warrick 
> 
> PGP: 5EAAEA16
> 
> stop html mail | always bottom-post | only UTF-8 makes sense

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


Re: PEP-442 - Python 3.4 and finalizations (__del__)

2013-09-14 Thread Marco Buttu

On 09/14/2013 11:42 AM, Steven D'Aprano wrote:



Perhaps you should try it and find out.


Hi Steven, thanks for your answer. I tried it with Python 3.4a2, but I 
did not see any output from __del__().



[steve@ando ~]$ python3.4 -E
Python 3.4.0a1+ (default:becbb65074e1, Aug 26 2013, 03:57:58)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>>
>>>class A:

  def __init__(self, a):
  self.a = a
  print('In A.__init__()')
  def __del__(self):
  print('Goodbye from A()')


>>>class B:

  def __init__(self):
  self.b = A(self) # Reference cycle
  print('In B.__init__()')
  def __del__(self):
  print('Goodbye from B()')


>>>b = B()

In A.__init__()
In B.__init__()

>>>del b
>>>
>>>
>>>import gc
>>>gc.collect()

Goodbye from B()
Goodbye from A()
4


I thought in this case, the __del__() methods should have called 
automatically...



Does that answer your question?


Yes, thanks a lot Steven, I saw the gc.collect() does not call the 
__del__() method in Python 3.3, so I think I will look at the 
documentation of gc in order to understand better. Thanks again, Marco



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


Appending data to an excel sheet by python code

2013-09-14 Thread Manoj Rout
hi
  i want to append some data to an existing excel sheet by reading from  
file.But here i am facing 2 problem.first is when i am reading from file.


import re

file=open("C:\Workspace\WS2\P1\Dave\Generated\src\UART001\UART001_Conf.c","r")
strings=re.search(r'(?<=(.Mode = UART_))\w+',file.read())
string=re.search(r'(?<=(.StopBit = UART_))\w+',file.read())

print strings.group()
print string.group()

workbook.close()



Here if i will read only once then it is fine and not showing any error.But if 
i will do it for second time i.e.2nd string i have to search and print both of 
them,then it is showing error.

And one more problem how to append some data to an existing excel sheet by 
python code.

so can u please help me on this problem.

Thanks and with regards 
Manoj Rout
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python GUI?

2013-09-14 Thread eamonnrea
On Saturday, September 14, 2013 2:23:03 AM UTC+1, Ben Finney wrote:
> [email protected] writes:
> 
> 
> 
> > But is it efficient to use an axe?
> 
> 
> 
> Which criterion is more important to *you* — fun, or efficiency?
> 
> 
> 
> > Is it sensible to use an axe when there is a chainsaw? No.
> 
> 
> 
> Which criterion is more important to *you* — fun, or sensibility?
> 
> 
> 
> > Eventually, everyone will be using chainsaws, and no one will be using
> 
> > axes.
> 
> 
> 
> Which criterion is more important to *you* — fun, or popularity?
> 
> 
> 
> > This is my point: to have fun and be productive, but apparently it's
> 
> > not possible.
> 
> 
> 
> Who has said that's not possible? If you find using a tool to be both
> 
> fun and productive, use it and be happy. If not, use something else.
> 
> 
> 
> -- 
> 
>  \   “They can not take away our self respect if we do not give it |
> 
>   `\to them.” —Mohandas Gandhi |
> 
> _o__)  |
> 
> Ben Finney

I hadn't thought of it that way! Thanks! :) I suppose it's like saying "Why use 
a MacBook when you could use X computer instead? Because I prefer Macs".

Also, this thread hasn't been a troll. I'm completely serious. Why is it when I 
ask things like this people think I'm trolling?? :(
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python GUI?

2013-09-14 Thread Chris Angelico
On Sat, Sep 14, 2013 at 9:54 PM,   wrote:
> Also, this thread hasn't been a troll. I'm completely serious. Why is it when 
> I ask things like this people think I'm trolling?? :(

This is python-list. We're used to duck-typing. If it looks like a
file, we can write to it... if it looks like a troll, we can "throw
eggs" to try to get it to move away from the rickety bridge, then type
"fee; fie; foe; foo" to get the eggs back.

Hmm. Am I showing my age, or my nerdiness?

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


Re: Need help to sort out the below code...

2013-09-14 Thread John Gordon
In <[email protected]> mnishpsyched 
 writes:

> print """
> Please select from the following menu:
> 1. pizza
> 2. steak
> 3. pasta
> 4. burger
> type in any number from above for selection..
> """

> pz = raw_input()
> pz = int(pz)

> st = raw_input()
> st = int(st)

> ps = raw_input()
> ps = int(ps)

> bg = raw_input()
> bg = int(bg)

> but my program doesn't output the selection once i type in any number
> from the list..Please help me to sort it out...

That's because you're calling raw_input() four times, thus the user must
type in a number four times.

You probably want something like this:

user_choice = raw_input()
user_choice = int(user_choice)

if user_choice == 1:
print "You have selected", user_choice, ".pizza"


elif user_choice == 2:
print "You have selected", st, ".Steak"



-- 
John Gordon   A is for Amy, who fell down the stairs
[email protected]  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Issue in installing xlwt package

2013-09-14 Thread varun nayyar
Hello,I am using windows 7 32 bit and installed python 2.7.5When i am trying to 
install xlwt 0.7.5 package from cmd prompt it shows Access Denied.When i run 
the cmd in administrator mode I am getting the following error:
Fatal Python error: Py_Initialize: can't initialize sys standard 
streamsImportError: No module named encodings.utf_8
This application has requested the Runtime to terminate it in an unusual 
way.Please contact the application's support team for more information. 
 -- 
https://mail.python.org/mailman/listinfo/python-list


Re: Appending data to an excel sheet by python code

2013-09-14 Thread MRAB

On 14/09/2013 12:33, Manoj Rout wrote:

hi
   i want to append some data to an existing excel sheet by reading from  
file.But here i am facing 2 problem.first is when i am reading from file.


import re


It's a good idea to use raw string literals for file paths on
Windows. Alternatively, you could use forward slashes instead of
backslashes.


file=open("C:\Workspace\WS2\P1\Dave\Generated\src\UART001\UART001_Conf.c","r")


Here you're reading the entire file:


strings=re.search(r'(?<=(.Mode = UART_))\w+',file.read())


Here you're trying to read the entire file again, but you're already
read to its end, so you'll now get an empty string:


string=re.search(r'(?<=(.StopBit = UART_))\w+',file.read())

print strings.group()
print string.group()


What's 'workbook'? Don't you mean 'file'?


workbook.close()



Here if i will read only once then it is fine and not showing any error.But if 
i will do it for second time i.e.2nd string i have to search and print both of 
them,then it is showing error.


You haven't shown the traceback, so I have to guess what the error was.


And one more problem how to append some data to an existing excel sheet by 
python code.

so can u please help me on this problem.



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


Re: Python GUI?

2013-09-14 Thread Wolfgang Keller
> As complexity rises, though, I'd rather just code the creative parts
> of things, and not busy-code, which is what gui code becomes.  Much
> of it is boiler-plate, cut and pasted, etc.

If much of the code for a GUI is boiler-plate, busy-code etc. than I
would suggest that the framework is not really as efficient as it
should be.

In fact that's one of the issues I still have with Python: The language
in general is very efficient, allows to do a lot with very little code.
But all GUI frameworks that I had a look at seem to be not "pythonic"
at all in this regard. Except for PyGUI maybe, but that's far from being
as extensive as wxPython or PyQt. So for GUI applications, Python
doesn't seem to have any advantage over #§$%&! like C++ etc. concerning
code efficiency.

X-( 

Sincerely,

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


Re: Appending data to an excel sheet by python code

2013-09-14 Thread petmertens
Did you consider using xlrd and xlwt?
I guess these package provide a solution to your problem.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python + LÖVE?

2013-09-14 Thread eamonnrea
As you may know, there is a fantastic Lua game development engine called LÖVE. 
There is also a way to integrate Lua and Python. So, is it possible to use LÖVE 
and Python together?

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


Re: Monitor key presses in Python?

2013-09-14 Thread eamonnrea
It might sound strange, but I'd need this to run without the user knowing.I 
believe I can do this by making the file a .pyw file, and use a GUI library to 
monitor the key presses. I think I could use PyGame, PyGlet and/or Cocos2d as 
well.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Monitor key presses in Python?

2013-09-14 Thread Roy Smith
In article <[email protected]>,
 [email protected] wrote:

> It might sound strange, but I'd need this to run without the user knowing.

It's called a keylogger.  And after all the revelations about the NSA 
over the past few weeks, it doesn't sound strange at all.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Monitor key presses in Python?

2013-09-14 Thread eamonnrea
I didnt wanna say that, in case people threw a fit and stuff.

So yeah, how would I monitor the key presses?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Monitor key presses in Python?

2013-09-14 Thread Paul Rubin
[email protected] writes:
> I'd need this to run without the user knowing.

You are asking for programming advice when you should probably be asking
for legal advice instead, about interception of electronic
communications.  We are not qualified to give legal advice here.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python + LÖVE?

2013-09-14 Thread Terry Reedy

On 9/14/2013 1:39 PM, [email protected] wrote:

As you may know, there is a fantastic Lua game development engine called LÖVE. 
There is also a way to integrate Lua and Python. So, is it possible to use LÖVE 
and Python together?


Have you asked the LÖVE folks?


--
Terry Jan Reedy


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


Re: better and user friendly IDE recommended?

2013-09-14 Thread memilanuk

On 09/12/2013 02:15 PM, Adrián Espinosa wrote:


I suggest you to use IntelliJ IDEA. It has a plugin for Python and Django (web 
framework). It works flawlessly.



If one were inclined to go that route, wouldn't PyCharm typically be a 
better choice?


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


Re: Monitor key presses in Python?

2013-09-14 Thread Dave Angel
On 14/9/2013 14:10, [email protected] wrote:

> I didnt wanna say that, in case people threw a fit and stuff.
>
> So yeah, how would I monitor the key presses?

There's a huge difference between monitoring key presses within your own
process, and intercepting them system-wide.  if you need to see
keystrokes even when your window does not have the focus, then you need
to call some system DLL function, (some kind of "system hook", which
you can probably do using the platform module, or the ctypes module, or
some module that I wouldn't have on Linux.  This type of code is not the
least bit portable, which just means I can't test things here to try to
help.

Note also that if you get one of the ActivePython implementations from
ActiveState, you'll get PyWin32, which may well have a function just for
the purpose.  See:

http://docs.activestate.com/activepython/2.5/pywin32/PyWin32.HTML

I'm sure it can be separately downloaded, but when I used to run
Windows, I just got the whole package.  The ActivePython also had the
best offline documentation I was able to find at the time.

See also Tim Golden's win32 web page:

http://timgolden.me.uk/python/win32_how_do_i.html

There is a separate win32 mailing list;  see:

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

Possibly the most frequent poster there is Tim Golden, so search his
site first.


-- 
DaveA


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


Re: Language design

2013-09-14 Thread Mark Janssen
 Really?  Are you saying you (and the community at-large) always derive
 from Object as your base class?
>>>
>>> Not directly, that would be silly.
>>
>> Silly?  "Explicit is better than implicit"... right?
>
> If I'm inheriting from str, I inherit from str explicitly:
>
> class MyStr(str): ...
>
> and then str in turn inherits from object explicitly. I certainly do not
> inherit from object and then re-implement all the string methods from
> scratch:

I know that.  Str already inherits from object (due to the language
definition).  Your inheritance from object is implied by your
inheritance from a child class (str), but note there is an implied
directionality:  you don't say str is the parent of object.  But tell
me this:  is str the superclass of object or is it the other way
around?

> class MyStr(object):
> def __new__(cls, value): ...
> def upper(self): ...
> def lower(self): ...
> # and so on...
>
> That would be ridiculous, and goes against the very idea of inheritance.
> But nor do I feel the need to explicitly list the entire superclass
> hierarchy:
>
> class MyStr(str, object):
> ...

Now you've lost your marbles.  You are arguing points that a python
programmer would not argue.  Now, since I know you to be a decent
python programmer, I can only conclude that your sanity is in
question.

> which would be silly. Only somebody who doesn't understand how
> inheritance works in Python would do that. There's simply no need for it,
> and in fact it would be actively harmful for larger hierarchies.

Explicitly inheriting from object ("class myBase(object):" rather than
"class myBase():") would not be "actively harmful" in any way.

 But wait is it the "base" (at the bottom of the hierarchy) or is it
 the "parent" at the top?  You see, you, like everyone else has been
 using these terms loosely, confusing yourself.
>>>
>>> Depends on whether I'm standing on my head or not.
>>>
>>> Or more importantly, it depends on whether I visualise my hierarchy
>>> going top->down or bottom->up. Both are relevant, and both end up with
>>> the *exact same hierarchy* with only the direction reversed.
>>
>> Ha,  "only the direction reversed".  That little directionality that
>> you're passing by so blithely is the difference between whether you're
>> talking about galaxies or atoms.
>
> It makes no difference whether I write:
>
> atoms -> stars -> galaxies
>
> or
>
> galaxies <- stars <- atoms
>
> nor does it make any difference if I write the chain starting at the top
> and pointing down, or at the bottom and pointing up.

Here again, your sanity is questioned.  You are simply wrong.  Atoms
lie within galaxies, but galaxies do not lie within atoms (poetic
license excluded); i.e. there is a difference, whether your talking
about syntactically by the parser or conceptually by a human being.
Somewhere you have to put yourself in the middle.  And that point
defines how you relate to the machine -- towards abstraction (upwards)
or towards the concrete (to the machine itself).

>> The simplicity of Python has seduced you into making an "equivocation"
>> of sorts.  It's subtle and no one in the field has noticed it.  It crept
>> in slowly and imperceptively.
>
> Ah, and now we come to the heart of the matter -- people have been
> drawing tree-structures with the root at the top of the page for
> centuries, and Mark Janssen is the first person to have realised that
> they've got it all backwards.

I'll be waiting for your apology once you simply grasp the simple
(however inconvenient and unbelievable) truth. ;*)

 By inheriting from sets you get a lot of useful functionality for
 free.  That you don't know how you could use that functionality is a
 failure of your imagination, not of the general idea.
>>>
>>> No you don't. You get a bunch of ill-defined methods that don't make
>>> sense on dicts.
>>
>> They are not necessarily ill-defined.  Keep in mind Python already chose
>> (way back in 1.x) to arbitrary overwrite the values in a key collision.
>> So this problem isn't new.  You've simply adapted to this limitation
>> without knowing what you were missing.
>
> No, Python didn't "arbitrarily" choose this behaviour.

Perhaps you don't recall the discussion.

> It is standard,
> normal behaviour for a key-value mapping, and it is the standard
> behaviour because it is the only behaviour that makes sense for a general
> purpose mapping.

No.  Please don't propagate your limited sense of things as if it "the
only way to do it".

> Python did not invent dicts (although it may have invented the choice of
> name "dict").
>
> If you think of inheritance in the Liskov Substitution sense, then you
> might *consider* building dicts on top of sets. But it doesn't really
> work, because there is no way to sensibly keep set-behaviour for dicts.

There's no need to preserve LSP -- it's just one way to think about
class relations.  In fact, I'll argue that one should not -- because

How to get time (milisecond) of a python IO execution

2013-09-14 Thread Tal Bar-Or
Hi All

i am trying to test measure some IO execution in milliseconds , but bit confuse 
about best method achive that under windows 7
i am using following code but not sure if its best or correct way since i have 
two different results, which one should i take as results
and which is best way
please advice
Thanks

code exec results 
1 loops, best of 3: 0.00925 usec per loop
3.827947176762156


run code
import timeit ,time
import datetime
import os


def main():
   
   
os.path.getsize("c:/video-2011-09-09-09-32-29.mp4")
   

if __name__ == '__main__':

t = timeit.Timer('main()')

print (t.timeit(1))
-- 
https://mail.python.org/mailman/listinfo/python-list