google sheet and google app engine(GAE) python

2016-06-09 Thread lee
how do connect my google sheet and my GAE application made in python so that i 
can read , update and delete cells , any step by instruction for newbie?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-27 Thread lee


> >Instead, your function should examine the "kind" parameter and decide 
> >what to do. So it would reasonably look like this (untested):
> >
> > def manipulate_data(kind, data):
> >   if kind == 'list':
> > ... do stuff with data using it as a list ...
> >   elif kind == 'set':
> > ... do stuff with data using it as a set ...
> >   if kind == 'dictionary':
> > ... do stuff with data using it as a dictionary ...
> >   else:
> > raise ValueError("invalid kind %r, expected 'list', 'set' or 
> > 'dictionary'" % (kind,))
> >
> >Try starting with that and see how you go.
> >
> >Cheers,
> >Cameron Simpson 
> >-- 
> >https://mail.python.org/mailman/listinfo/python-list





the question again


>Create a function manipulate_data that does the following
>Accepts as the first parameter a string specifying the data structure to be 
>>used "list", "set" or "dictionary"
>Accepts as the second parameter the data to be manipulated based on the data 
>>structure specified e.g [1, 4, 9, 16, 25] for a list data structure
>Based off the first parameter

>return the reverse of a list or
>add items `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set and return the 
> >resulting set
>return the keys of a dictionary.



unittest for the question



>import unittest
>class DataStructureTest(TestCase):
>  def setUp(self):
>self.list_data = [1,2,3,4,5]
>self.set_data = {"a", "b", "c", "d", "e"}
>self.dictionary_data = {"apples": 23, "oranges": 15, "mangoes": 3, 
> >"grapes": 45}
>
>  def test_manipulate_list(self):
>result = manipulate_data("list", self.list_data)
>self.assertEqual(result, [5,4,3,2,1], msg = "List not manipulated 
> >correctly")
>
>  def test_manipulate_set(self):
>result = manipulate_data("set", self.set_data)
>self.assertEqual(result, {"a", "b", "c", "d", "e", "ANDELA", "TIA", 
> >"AFRICA"}, msg = "Set not manipulated correctly")
>  
>  def test_manipulate_dictionary(self):
>result = manipulate_data("dictionary", self.dictionary_data)
>self.assertEqual(result, ["grapes", "mangoes", "apples", "oranges"], msg = 
> >"Dictionary not manipulated correctly")



the code i have tested base on Cameron's code




def manipulate_data(kind, data):
   if kind == 'list':
return list(data)[::-1]
 
   elif kind == 'set':
return set(data)
   elif kind == 'dictionary':
 return dict( data)
 
manipulate_data("list", range(1,6))
a = manipulate_data("set", {"a", "b", "c", "d", "e"})
a.add("ANDELA")
a.add("TIA")
a.add("AFRICA")
b = manipulate_data("dictionary", {"apples": 23, "oranges": 15, "mangoes": 3, 
"grapes": 45})
list(b.keys()) 






this is the result i got from the unittest




Total Specs: 3 Total Failures: 2
1 .  test_manipulate_dictionary

Failure in line 23, in test_manipulate_dictionary self.assertEqual(result, 
["grapes", "mangoes", "apples", "oranges"], msg = "Dictionary not manipulated 
correctly") AssertionError: Dictionary not manipulated correctly
2 .  test_manipulate_set

Failure in line 19, in test_manipulate_set self.assertEqual(result, {"a", "b", 
"c", "d", "e", "ANDELA", "TIA", "AFRICA"}, msg = "Set not manipulated 
correctly") AssertionError: Set not manipulated correctly 




i guess i passed the first requirement to return the reversed order of the list 
and believe i messed up when creating a set then add data to the set, also 
something is wrong with returning the keys of the dictionary


can someone point out the error in my code and the meaning of the unittes error?
thanks in advance
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-27 Thread lee
> 
> After you've called the function, anything you do to the result is not 
> done BY the function and will therefore not be done when called by other 
> code.
> 
> The unit test that calls the function will not do those things. It 
> expects them to already be done.
> 
> So ... what changes to your function do you think would fix that?
> 
> Regards,
> E.




i modified my code a little but still no luck, the same unit test error 
surfaced again.


here is the modified code

 

def manipulate_data(kind, data):
if kind == 'list':
return list(data)[::-1]

elif kind == 'set':
return set(data)
elif kind == 'dictionary':
return dict( data)
manipulate_data("list", range(1,6))
manipulate_data("set", {"a", "b", "c", "d", "e", "ANDELA", "TIA", "AFRICA"})
manipulate_data("dictionary", {"apples": 23, "oranges": 15, "mangoes": 3, 
"grapes": 45}).keys()



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


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-27 Thread lee
On Sunday, December 27, 2015 at 9:32:24 PM UTC+1, Prince Udoka wrote:
> thanks mr cameron simpson, finally at i got the solution, God bless you:
> def manipulate_data(kind, data):
> if kind == 'list':
> for data in [1, 2, 3, 4, 5]:
> return data.reverse()
> elif kind == 'set':
> for data in {"a", "b", "c", "d", "e"}:
> data.add("ANDELA")
> data.add("TIA")
> data.add("AFRICA")
> return data
> elif kind == 'dictionary':
> for data in  {"apples": 23, "oranges": 15, "mangoes": 3, "grape": 45}:
> return data.key()

so how did you call the function because just pasting your code as it is did 
not work for me. sorry if question sounds dumb
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-28 Thread lee
I'm still stuck on this, any Rescuer?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-28 Thread lee
On Monday, December 28, 2015 at 10:38:47 AM UTC+1, Ben Finney wrote:
> lee writes:
> 
> > I'm still stuck on this, any Rescuer?
> 
> You appear to be yet another different person asking about this homework
> assignment.
> 
> Please:
> 
> * This forum is not suitable for the kind of close attention to very
>   basic learning. Take this discussion to the 'tutor' forum
>   https://mail.python.org/mailman/listinfo/tutor>, which is much
>   better focussed on close collaborative mentoring of beginners.
> 
> * Choose a single spokesperson, and have that person provide continuity
>   in the discussion by responding consistently from the same email
>   address.
> 
> * Learn proper email etiquette (plain text messages, quoted material,
>   give sufficient context, etc.) to help the community understand what
>   each message is about.
> 
> -- 
>  \"Holy uncanny photographic mental processes, Batman!" --Robin |
>   `\   |
> _o__)  |
> Ben Finney


if you have followed this thread from the beginning , you should have  been 
aware that different people have contributed in asking/answering on this same 
discussion and nobody has any problem with that, so please if someone ( same or 
different) needs help on a single problem , allow them contribute, they could 
be the source of getting the problem solved. thanks prince( botic) , will try 
you suggestion
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-29 Thread lee
On Monday, December 28, 2015 at 11:30:18 PM UTC+1, Cameron Simpson wrote:
> On 28Dec2015 01:34, Prince Udoka  wrote:
> >bu i have come up with a solution, that will work but encounter a problem in 
> >the set, giving set not manipulated correctly:
> >
> >def manipulate_data(kind, data):
> >if kind == 'list':
> >return list(data)[::-1]
> >elif kind == 'set':
> >return set(data)
> >elif kind == 'dictionary':
> >return dict.keys(data)
> >manipulate_data("list", range(1,6))
> >manipulate_data("set", {"a", "b", "c", "d", "e", "ANDELA", "TIA", "AFRICA"})
> >manipulate_data("dictionary", {"apples": 23, "oranges": 15, "mangoes": 3, 
> >"grapes": 45})
> >
> >the thing now is the function to use in adding "ANDELA", "TIA", "AFRICA"
> >pls 4give my use of language
> 
> You are very close. Let me remind you of the original task text:
> 
>   add items `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set and return the 
>   resulting set
> 
> Your previous attempt (with hardwired values inside the function) actually 
> had 
> code to do it.
> 
> While you have pulled out all the hardwired values from the function (good) 
> and 
> put them in the external calls, note that the task explicitly says "add items 
> `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set". So _those_ values _are_ 
> supposed to be hardwired inside the function - they are a fixed part of the 
> task. So move them back in, as in your previous attempt.
> 
> There is some ambiguity in that part of the question: should you return a 
> _new_ 
> set consistint of the original set plus the three new values, or simply add 
> the 
> three values to the original set? Your prior code modified the original set, 
> which may fit the task specification.
> 
> However, it is a common design objective that functions do not, _normally_, 
> modify their arguments. So, consider this code:
> 
>   set1 = {"a", "b", "c", "d", "e"}
>   set2 = manipulate_data("set", set1)
> 
> After running this, set2 should look like this:
> 
>   {"a", "b", "c", "d", "e", "ANDELA", "TIA", "AFRICA"}
> 
> (in some order -- sets are not ordered). However, what about set1? In your 
> current code, set1 is modified, so it will be the same. But you can imagine 
> that it would be more useful for the caller if set1 were unchanged.
> 
> In python, the convention is usually that if a function returns the new value 
> then it should not modify the original. So you should probably construct a 
> copy 
> of the original set and modify that:
> 
>   data = set(data)
>   ... add the new values ...
>   return data
> 
> Cheers,
> Cameron Simpson 

thumbs up Cameron  , you and others here are really wonderful 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-29 Thread lee
On Tuesday, December 29, 2015 at 11:48:42 AM UTC+1, Cameron Simpson wrote:
> On 29Dec2015 00:49, lee wrote:
> >thumbs up Cameron  , you and others here are really wonderful
> >https://mail.python.org/mailman/listinfo/python-list
> 
> Hi Lee,
> 
> While we're generally happy to help, these questions are better taken to the 
> tutor list here:
> 
>   https://mail.python.org/mailman/listinfo/tutor
> 
> Please join that list and ask you questions there.
> 
> The "python-list" list is more for people who are already competent with 
> Python 
> and programming and who are asking broader questions. The tutor list is 
> specificly aimed at people like yourself who are either very new to Python or 
> new to programming (and learning to program in Python).
> 
> Note that I have directed replies to this specific message to myself, we're 
> off 
> topic for python-list now...
> 
> Cheers,
> Cameron Simpson 


thanks Cameron,
i really appreciate your polite response and effort, i will join that list as 
you suggested.
Thanks again  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-01-12 Thread lee
You're still struggling with this question because you didn't take your time to 
read the previous comments here , the solution to this and other  question has 
being posted long ago before new year here , just read previous comments. 
Remember don't use print , instead  use return .
-- 
https://mail.python.org/mailman/listinfo/python-list


which book to read next??

2014-04-21 Thread lee
Hi, I have read the book 'a byte of python' and now I want to read another 
book. But I just get confused about which one to read next.
There is a book list below:
1, pro python
2, python algorithms
3, python cookbook
4, the python standard library by examples
which one is suitable for me??
Or I need to start a project with pygame or flask?
Thanks for your help!



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


which book to read next??

2014-04-21 Thread lee
Thanks for all of the respones, Writing a game in pygame is a good idea. Thank 
you! -- 发自 Android 网易邮箱-- 
https://mail.python.org/mailman/listinfo/python-list


Exception Handling (C - extending python)

2011-10-22 Thread Lee
Hi all,

Where does PyExc_TypeError (and alike) points to? I can see its
declaration - PyAPI_DATA(PyObject *) PyExc_TypeError; - in pyerrors.h
but I cannot figure out what it is its value, where it is
initialized.

Any help is greatly appreciated.

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


Re: Exception Handling (C - extending python)

2011-10-23 Thread Lee
Thanks Stefan,

I am just interested to understand the mechanism inside python.

If it points to an object that means I can defered it (through
ob_type).
>From there, how a function like PyErr_SetString knows what exception
is?
Where its value is kept?

Lee


On Oct 23, 10:06 pm, Stefan Behnel  wrote:
> Lee, 23.10.2011 06:09:
>
> > Where does PyExc_TypeError (and alike) points to? I can see its
> > declaration - PyAPI_DATA(PyObject *) PyExc_TypeError; - in pyerrors.h
> > but I cannot figure out what it is its value, where it is
> > initialized.
>
> It gets initialised inside of the interpreter core and then points to a
> Python object.
>
> > Any help is greatly appreciated.
>
> The question is: why do you ask? What exactly do you want to do?
>
> If you ask a more targeted question, you will get an answer that will help
> you further.
>
> Stefan

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


Re: Exception Handling (C - extending python)

2011-10-23 Thread Lee
For a moment, back to the basics...

I am using the example provided by docs at 2.1.2
"Providing finer control...". Using say:

mynoddy = noddy2.Noddy()
mynoddy.first = "a"
mynoddy.last = 0

the last line causes an ugly crash (on python 2.6.5 on winxp).
No way to catch the exception.

As I understand from the docs, all PyErr_SetString does is to set an
exception,
what one has to do to raise this exception (in C)?

If I replace "return -1" in the Noddy_setlast() function with "return
NULL"
(well, the compiler will complain...) the program passes by without
raising an exception.

Any explanations?...

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


newbieee

2007-01-08 Thread lee
I getting familiarised with python...can any one suggest me a good
editor available for python which runs on windows xpone more
request guys...can nyone tell me a good reference manual for python..

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


Subprocess Not Working on Solaris

2007-06-15 Thread Lee
Has anyone ran into this problem? I've done extensive googling and
research and I cannot seem to find the answer.

I downloaded the source for 2.5.1 from python.org compiled and
installed it on a Solaris box,

uname -a returns

SunOS unicom5 5.8 Generic_117350-26 sun4u sparc SUNW,Sun-Fire-V210

When I launch the python interpreter, I try the following:

"
Python 2.5.1 (r251:54863, Jun 13 2007, 13:40:52)
[GCC 3.2.3] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python2.5/subprocess.py", line 401, in 
import select
ImportError: No module named select
"

The subprocess module works just fine on a BSD box I have and after
doing a 'find' I notice there is a select.so module. This does not
exist on the Solaris box, only subprocess exists. Within subprocess.py
on the Solaris box, exists the following:

"
else:
import select
import errno
    import fcntl
import pickle
"

Any ideas? I'd like to get the subprocess module working...

-Lee

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


modules...n methods

2007-01-12 Thread lee
First of all thnx guys for ur cover on ma questionsOk some more
then...whats the way to read the sourcecode of methods and built in
functions?

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


indentation in python

2007-01-13 Thread lee
Can anyone tell me the basics about indentation in python..how we
use it in loops and constructs..etc

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


running applications in python

2007-01-25 Thread lee
how can i run or open a windows application from the python prompt?for
e.g.mediaplayer opening,folder acess etc

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


import from future

2007-01-27 Thread lee
what are the things that we can do with import from future usage.i 
heard its very interesting..thanks

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


from future module!!!!!!!

2007-01-28 Thread lee
Guys whats the from future module in python?thanks

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


electronics and python

2007-02-06 Thread lee
Hi guys.Is there any software written using python for
electronics.i mean any simulation software or something??

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


RE: How to get all the variables in a python shell

2008-05-30 Thread Lee
Hi, thank your for your reply. I will try iPython.

I did try sage for a while, but I found it quite heavy, and I'm not sure
whether it's easy to expand like python or not. New libraries can be
easily imported in python, and those libraries could be build in almost
any popular computer 
language. Can sage do that? 

The reason why I want to work on this is the same with you. I'm an
automotive engineer. What I need is a powerful 
yet light-weight computation software, which can help me in analyzing
datas on the engine test bench. Matlab is powerful, but it contains so
much stuff that I actually don't need but have to buy, and you know that

it's quite expansive. 

So my idea is to build a GUI with python first, and then intergrate as
many exsiting computation libraries as possible. There also has to be a
plotting app, which is quite important and need to think about. I did
try Gnuplot-python combination and matplotlib,  but found both terrible
inferior to Matlab plotting functionality.  Do you know any plotting
programs written in 
python?


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of [EMAIL PROTECTED]
Sent: Friday, May 30, 2008 9:55 PM
To: python-list@python.org
Subject: Re: How to get all the variables in a python shell


  Your project interests me. Actually I was thinking about doing the
same. I hadn't worked on it at all, but I though about it and had the
idea about reading the session namespace directly, which I though would
be stored in the __dict__ attribute of something.

  After reading your post, I have been trying a little bit, and I have
found a way to do it with ipython. If you open an ipython console, press
_ then hit TAB, you'll see it stores some useful information, including
all input, all output, and after some searching, a dictionary matching
all variables to its values.

__IPYTHON__.user_ns

  There is a little extra stuff in there that you don't want, but that
can be easily filtered (the extra stuff is either 'In', 'Out', 'help' or
starts with '_'). I've tried it, and you can change the value in that
dict to alter the value of the real variable. Say you have a variable
'test':

test=5
__IPYTHON__.user_ns['test']=4
print test #prints 5

  If I get it right, python is a dynamic language, and you won't break
things by messing around with its inner stuff like this, but you better
check it.

  Is this what you had in mind?
--
http://mail.python.org/mailman/listinfo/python-list

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


help needed with dictionary

2008-08-29 Thread lee
  hi all,
i am a newbie in python.  i was trying to work with dictionaries.  i
wanted to input values  through command line and store the values in a
dictionary. i mean for the same key , multiple values. can any1
suggest me how can i do it.thank you

i tried this, but the old value is replaced by new one, but i want to
store al values entered by user.
kev = {}
if kev.has_key('Name'):
kev['Name'].append(person_name)
print 'name is ', kev['Name']
else:
kev['Name'] = [person_name]
print "kevin's name is %s" % kev['Name']

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


Re: help needed with dictionary

2008-08-29 Thread lee
hi,
thank you, ur code was helpful   :)




On Aug 29, 2:18 pm, Bruno Desthuilliers  wrote:
> lee a écrit :
>
>
>
> >   hi all,
> > i am a newbie in python.  i was trying to work with dictionaries.  i
> > wanted to input values  through command line and store the values in a
> > dictionary. i mean for the same key , multiple values. can any1
> > suggest me how can i do it.thank you
>
> > i tried this, but the old value is replaced by new one, but i want to
> > store al values entered by user.
> > kev = {}
> > if kev.has_key('Name'):
> >kev['Name'].append(person_name)
> >print 'name is ', kev['Name']
> > else:
> >kev['Name'] = [person_name]
> > print "kevin's name is %s" % kev['Name']
>
> Please post the minimal *running* code exhibiting your problem. The
> above snippet raises a NameError about person_name on line 3.
>
> Anyway, looking at my crystal ball, I'd say that you're (re)binding the
> variable 'kev' to a new empty dict each time.
>
> Here's a working snippet:
>
> import sys
>
> kev = {}
> try:
>  while True:
>  answer = raw_input("type a name :")
>  answer = answer.strip()
>  if answer:
>  try:
>  kev['name'].append(answer)
>  except KeyError:
>  kev['name'] = [answer]
>  print "name is now : %s" % " ".join(kev['name'])
>  print ""
>
> except KeyboardInterrupt:
>  sys.exit("bye")

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


how to find position of dictionary values

2008-09-01 Thread lee
hi,
i have a dictionary as follows :
kev :  {'phno': ['dgsd', 'gsdg', 'dfsdf', 'g'], 'email': ['dg',
'sgsd', 'sdfsdf', 'gdf'], 'name': ['ds', 'dsg', 'dsfds', 'fgdf'],
'address': ['sdg', 'dsgsdg', 'sdf', 'dfg']}

if user is enters the 3rd item of key phno, ie "dfsdf" in my dict,
how can i find it is the third  item in the internal list of phno of
that dictionary?  thanks you.
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to find position of dictionary values

2008-09-01 Thread lee
On Sep 1, 1:21 pm, Alexandru Palade
<[EMAIL PROTECTED]> wrote:
> lookfor = 'dfsdf'
> for item, value in kev.items():
> if lookfor in value:
> print item
> print value.index(lookfor)
> break   # assuming you only want one result
>
> You can also skip the 'if' verification in which case you need to catch
> ValueError exception in case there is no such entry in the current list.
>
> Hope it helps.
>
> lee wrote:
> > hi,
> > i have a dictionary as follows :
> > kev :  {'phno': ['dgsd', 'gsdg', 'dfsdf', 'g'], 'email': ['dg',
> > 'sgsd', 'sdfsdf', 'gdf'], 'name': ['ds', 'dsg', 'dsfds', 'fgdf'],
> > 'address': ['sdg', 'dsgsdg', 'sdf', 'dfg']}
>
> > if user is enters the 3rd item of key phno, ie "dfsdf" in my dict,
> > how can i find it is the third  item in the internal list of phno of
> > that dictionary?  thanks you.
> > --
> >http://mail.python.org/mailman/listinfo/python-list

hi, thank u your solution is exactly wat i wanted  :)
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to find position of dictionary values

2008-09-01 Thread lee
On Sep 1, 1:45 pm, Bruno Desthuilliers  wrote:
> lee a écrit :
>
> > hi,
> > i have a dictionary as follows :
> > kev :  {'phno': ['dgsd', 'gsdg', 'dfsdf', 'g'], 'email': ['dg',
> > 'sgsd', 'sdfsdf', 'gdf'], 'name': ['ds', 'dsg', 'dsfds', 'fgdf'],
> > 'address': ['sdg', 'dsgsdg', 'sdf', 'dfg']}
>
> > if user is enters the 3rd item of key phno,
> > ie "dfsdf" in my dict,
> > how can i find it is the third  item in the internal list of phno of
> > that dictionary?
>
> It's quite simple (hint : read the FineManual(tm) for dict.items() and
> list.index()), but  1/totally inefficient and 2/not garanteed to yield a
> single value (what if 'dfsdf' happens to be also the 4th item of the
> list bound to key 'address'   ?).
>
> May I suggest you rethink your data structure instead ? What you have
> here is obviously a collection of 'phno/email/name/address'records.
> These records shouldn't be split across different objects. Assuming
> 'phno' is a unique identifier for each record, a better data structure
> would be:
>
> records =  {
> 'dgsd' : {'email': 'dg', 'name' : 'ds', 'address' : 'sdg'},
> 'gsdg' : {'email': 'sgsd', 'name':'ds', 'address' : 'dsgsdg'},
> # etc
>
> }
>
> This way, the lookup is as simple and efficient as possible.
>
> My 2 cents

hi,
 i agree with u, my data strusture is not efficient. but all the
records,viz...name,phno, email,address are all generated at runtime ,
when the user enters them. so how can i design my datastructure in
that case?
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to find position of dictionary values

2008-09-01 Thread lee
On Sep 1, 1:45 pm, Bruno Desthuilliers  wrote:
> lee a écrit :
>
> > hi,
> > i have a dictionary as follows :
> > kev :  {'phno': ['dgsd', 'gsdg', 'dfsdf', 'g'], 'email': ['dg',
> > 'sgsd', 'sdfsdf', 'gdf'], 'name': ['ds', 'dsg', 'dsfds', 'fgdf'],
> > 'address': ['sdg', 'dsgsdg', 'sdf', 'dfg']}
>
> > if user is enters the 3rd item of key phno,
> > ie "dfsdf" in my dict,
> > how can i find it is the third  item in the internal list of phno of
> > that dictionary?
>
> It's quite simple (hint : read the FineManual(tm) for dict.items() and
> list.index()), but  1/totally inefficient and 2/not garanteed to yield a
> single value (what if 'dfsdf' happens to be also the 4th item of the
> list bound to key 'address'   ?).
>
> May I suggest you rethink your data structure instead ? What you have
> here is obviously a collection of 'phno/email/name/address'records.
> These records shouldn't be split across different objects. Assuming
> 'phno' is a unique identifier for each record, a better data structure
> would be:
>
> records =  {
> 'dgsd' : {'email': 'dg', 'name' : 'ds', 'address' : 'sdg'},
> 'gsdg' : {'email': 'sgsd', 'name':'ds', 'address' : 'dsgsdg'},
> # etc
>
> }
>
> This way, the lookup is as simple and efficient as possible.
>
> My 2 cents

hi,
 i agree with u, my data strusture is not efficient. but all the
records,viz...name,phno, email,address are all generated at runtime ,
when the user enters them. so how can i design my datastructure in
that case?
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to find position of dictionary values

2008-09-01 Thread lee
On Sep 1, 1:45 pm, Bruno Desthuilliers  wrote:
> lee a écrit :
>
> > hi,
> > i have a dictionary as follows :
> > kev :  {'phno': ['dgsd', 'gsdg', 'dfsdf', 'g'], 'email': ['dg',
> > 'sgsd', 'sdfsdf', 'gdf'], 'name': ['ds', 'dsg', 'dsfds', 'fgdf'],
> > 'address': ['sdg', 'dsgsdg', 'sdf', 'dfg']}
>
> > if user is enters the 3rd item of key phno,
> > ie "dfsdf" in my dict,
> > how can i find it is the third  item in the internal list of phno of
> > that dictionary?
>
> It's quite simple (hint : read the FineManual(tm) for dict.items() and
> list.index()), but  1/totally inefficient and 2/not garanteed to yield a
> single value (what if 'dfsdf' happens to be also the 4th item of the
> list bound to key 'address'   ?).
>
> May I suggest you rethink your data structure instead ? What you have
> here is obviously a collection of 'phno/email/name/address'records.
> These records shouldn't be split across different objects. Assuming
> 'phno' is a unique identifier for each record, a better data structure
> would be:
>
> records =  {
> 'dgsd' : {'email': 'dg', 'name' : 'ds', 'address' : 'sdg'},
> 'gsdg' : {'email': 'sgsd', 'name':'ds', 'address' : 'dsgsdg'},
> # etc
>
> }
>
> This way, the lookup is as simple and efficient as possible.
>
> My 2 cents

hi,
 i agree with u, my data strusture is not efficient. but all the
records,viz...name,phno, email,address are all generated at runtime ,
when the user enters them. so how can i design my datastructure in
that case?
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to find position of dictionary values

2008-09-01 Thread lee
On Sep 1, 1:45 pm, Bruno Desthuilliers  wrote:
> lee a écrit :
>
> > hi,
> > i have a dictionary as follows :
> > kev :  {'phno': ['dgsd', 'gsdg', 'dfsdf', 'g'], 'email': ['dg',
> > 'sgsd', 'sdfsdf', 'gdf'], 'name': ['ds', 'dsg', 'dsfds', 'fgdf'],
> > 'address': ['sdg', 'dsgsdg', 'sdf', 'dfg']}
>
> > if user is enters the 3rd item of key phno,
> > ie "dfsdf" in my dict,
> > how can i find it is the third  item in the internal list of phno of
> > that dictionary?
>
> It's quite simple (hint : read the FineManual(tm) for dict.items() and
> list.index()), but  1/totally inefficient and 2/not garanteed to yield a
> single value (what if 'dfsdf' happens to be also the 4th item of the
> list bound to key 'address'   ?).
>
> May I suggest you rethink your data structure instead ? What you have
> here is obviously a collection of 'phno/email/name/address'records.
> These records shouldn't be split across different objects. Assuming
> 'phno' is a unique identifier for each record, a better data structure
> would be:
>
> records =  {
> 'dgsd' : {'email': 'dg', 'name' : 'ds', 'address' : 'sdg'},
> 'gsdg' : {'email': 'sgsd', 'name':'ds', 'address' : 'dsgsdg'},
> # etc
>
> }
>
> This way, the lookup is as simple and efficient as possible.
>
> My 2 cents

hi,
 i agree with u, my data strusture is not efficient. but all the
records,viz...name,phno, email,address are all generated at runtime ,
when the user enters them. so how can i design my datastructure in
that case?
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to find position of dictionary values

2008-09-01 Thread lee
On Sep 1, 2:37 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> lee wrote:
> > On Sep 1, 1:45 pm, Bruno Desthuilliers  > [EMAIL PROTECTED]> wrote:
> >> lee a écrit :
>
> >> > hi,
> >> > i have a dictionary as follows :
> >> > kev :  {'phno': ['dgsd', 'gsdg', 'dfsdf', 'g'], 'email': ['dg',
> >> > 'sgsd', 'sdfsdf', 'gdf'], 'name': ['ds', 'dsg', 'dsfds', 'fgdf'],
> >> > 'address': ['sdg', 'dsgsdg', 'sdf', 'dfg']}
>
> >> > if user is enters the 3rd item of key phno,
> >> > ie "dfsdf" in my dict,
> >> > how can i find it is the third  item in the internal list of phno of
> >> > that dictionary?
>
> >> It's quite simple (hint : read the FineManual(tm) for dict.items() and
> >> list.index()), but  1/totally inefficient and 2/not garanteed to yield a
> >> single value (what if 'dfsdf' happens to be also the 4th item of the
> >> list bound to key 'address'   ?).
>
> >> May I suggest you rethink your data structure instead ? What you have
> >> here is obviously a collection of 'phno/email/name/address'records.
> >> These records shouldn't be split across different objects. Assuming
> >> 'phno' is a unique identifier for each record, a better data structure
> >> would be:
>
> >> records =  {
> >> 'dgsd' : {'email': 'dg', 'name' : 'ds', 'address' : 'sdg'},
> >> 'gsdg' : {'email': 'sgsd', 'name':'ds', 'address' : 'dsgsdg'},
> >> # etc
>
> >> }
>
> >> This way, the lookup is as simple and efficient as possible.
>
> >> My 2 cents
>
> > hi,
> >  i agree with u, my data strusture is not efficient. but all the
> > records,viz...name,phno, email,address are all generated at runtime ,
> > when the user enters them. so how can i design my datastructure in
> > that case?
>
> Are "u" short on keystrokes? You are not textmessaging here...
>
> Regarding the actual question: there is no difference in building your or
> the other structure. It's only a question of which key you use first.
> Instead of first looking up the type of the record ("phno" or some such),
> do that with the name of the user. If no record exists, create one. Then
> populate the record with the user's values. Like this:
>
> user = "dsdf"
> phonenumber = "123"
>
> record = records.setdefault(user, {})
> record["phno"] = phonenumber
>
> Diez

i am soory for that keystrokes. can anyone tell me how can i change
the value of key.
suppose i have a dictionary

kev =  {'kabir': ['[EMAIL PROTECTED]', '1234', 'missuri'], 'shri':
['[EMAIL PROTECTED]', '23423', 'india'], 'marsa': ['[EMAIL PROTECTED]',
'2345', 'brazil'], 'sandeep': ['[EMAIL PROTECTED]', '007',
'canada']}


how can i change the key to something like 'sabir' and how can i
change the values of kabir?
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to find position of dictionary values

2008-09-01 Thread lee
On Sep 1, 3:59 pm, Wojtek Walczak <[EMAIL PROTECTED]> wrote:
> On Mon, 1 Sep 2008 03:51:13 -0700 (PDT), lee wrote:
> > i am soory for that keystrokes. can anyone tell me how can i change
> > the value of key.
> > suppose i have a dictionary
>
> > kev =  {'kabir': ['[EMAIL PROTECTED]', '1234', 'missuri'], 'shri':
> > ['[EMAIL PROTECTED]', '23423', 'india'], 'marsa': ['[EMAIL PROTECTED]',
> > '2345', 'brazil'], 'sandeep': ['[EMAIL PROTECTED]', '007',
> > 'canada']}
> > how can i change the key to something like 'sabir' and
>
> kev['sabir'] = kev['kabir']
> del kev['kabir']
>
> > how can i
> > change the values of kabir?
>
> kev['sabir'][0] = '[EMAIL PROTECTED]'
>
> *untested*
>
> --
> Regards,
> Wojtek Walczak,http://tosh.pl/gminick/

thanks wojtek, it worked   :)
--
http://mail.python.org/mailman/listinfo/python-list


Dictionary used to build a Triple Store

2010-01-07 Thread Lee

Definitely a newbie question, so please bear with  me.

I'm reading "Programming the Semantic Web" by Segaran, Evans, and Tayor.

It's about the Semantic Web BUT it uses python to build a "toy" triple 
store claimed to have good performance in the "tens of thousands" of 
triples.


Just in case anybody doesnt know what an RDF triple is (not that it 
matters for my question) think of it as an ordered 3 tuple representing 
a Subject, a Predicate, and an Object eg: (John, loves, Mary) (Mary, 
has-a, lamb) {theSky, has-color,blue}


To build the triple store entirely in Python, the authors recommend
using the Python hash. Three hashes actually (I get that. You
want to have a hash with the major index being the Subject in one hash,
the Predicate in another hash, or the Object for the third hash)

He creates a class SimpleGraph which initializes itself by setting the
three hashes names _spo, _pos, and _osp thus

class SimpleGraph;
  def __init__(self);
 self._spo={};
 self._pos=();
 self._osp={};

So far so good. I get the convention with the double underbars for the 
initializer but


Q1: Not the main question but while I'm hereI'm a little fuzzy on 
the convention about the use of the single underbar in the definition of 
the hashes. Id the idea to "underbar" all objects and methods that 
belong to the class? Why do that?


But now the good stuff:

Our authors define the hashes thus: (showing only one of the three 
hashes because they're all the same idea)


self._pos = {predicate:{object:set( [subject] ) }}

Q2: Wha? Two surprises ...
   1) Why not {predicate:{object:subject}} i.e. 
pos[predicate][object]=subjectwhy the set( [object] ) construct? 
putting the object into a list and turning the list into a set to be the 
"value" part of a name:value pair. Why not just use the naked subject 
for the value?


   2) Why not something like pos[predicate][object][subject] = 1 
.or any constant. The idea being to create the set of three indexes. 
If the triple exists in the hash, its "in" your tripple store. If not, 
then there's no such triple.



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


Re: Dictionary used to build a Triple Store

2010-01-07 Thread Lee

Lee wrote:

Definitely a newbie question, so please bear with  me.

I'm reading "Programming the Semantic Web" by Segaran, Evans, and Tayor.

It's about the Semantic Web BUT it uses python to build a "toy" triple 
store claimed to have good performance in the "tens of thousands" of 
triples.


Just in case anybody doesnt know what an RDF triple is (not that it 
matters for my question) think of it as an ordered 3 tuple representing 
a Subject, a Predicate, and an Object eg: (John, loves, Mary) (Mary, 
has-a, lamb) {theSky, has-color,blue}


To build the triple store entirely in Python, the authors recommend
using the Python hash. Three hashes actually (I get that. You
want to have a hash with the major index being the Subject in one hash,
the Predicate in another hash, or the Object for the third hash)

He creates a class SimpleGraph which initializes itself by setting the
three hashes names _spo, _pos, and _osp thus

class SimpleGraph;
  def __init__(self);
 self._spo={};
 self._pos=();
 self._osp={};

So far so good. I get the convention with the double underbars for the 
initializer but


Q1: Not the main question but while I'm hereI'm a little fuzzy on 
the convention about the use of the single underbar in the definition of 
the hashes. Id the idea to "underbar" all objects and methods that 
belong to the class? Why do that?


But now the good stuff:

Our authors define the hashes thus: (showing only one of the three 
hashes because they're all the same idea)


self._pos = {predicate:{object:set( [subject] ) }}

Q2: Wha? Two surprises ...
   1) Why not {predicate:{object:subject}} i.e. 
pos[predicate][object]=subjectwhy the set( [object] ) construct? 
putting the object into a list and turning the list into a set to be the 
"value" part of a name:value pair. Why not just use the naked subject 
for the value?


   2) Why not something like pos[predicate][object][subject] = 1 .or 
any constant. The idea being to create the set of three indexes. If the 
triple exists in the hash, its "in" your tripple store. If not, then 
there's no such triple.




OK, Thanx. That cleares things up.

I had forgotton that once you have a "Cell" in a 2D matrix to represent 
the first two components of the 3 tuple, you then want multiple values 
IN the cell for the possibly multi valued  third component.

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


getlocals and getargs

2009-10-27 Thread Lee
Yes, It's actually quite easy to implement

getlocals = lambda fn: fn.func_code.co_varnames[:]
getargs = lambda fn: getlocals()[:fn.func_code.co_argcount]

Of course, this doesn't take into account *args and **kwargs. To
figure out if a function have args and kwargs, do a binary and (&)
between func_code.co_flags and either 4 (*args) or 8 (**kwargs). The
indices of the two local variables are co_argcount and co_argcount+1
(so the entire expression for *args would just be if
fn.func_code.co_flags&4: fn.func_code.co_varnames[argcount])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to read source code of python?

2010-06-11 Thread Lee
On Jun 10, 7:53 am, Floris Bruynooghe 
wrote:
> On Jun 10, 8:55 am, Thomas Jollans  wrote:
>
> > On 06/10/2010 07:25 AM, Qijing Li wrote:
>
> > > Thanks for your reply.
> > > I'm trying to understand python language deeply and  use it efficiently.
> > > For example: How the operator "in" works on list? the running time is
> > > be O(n)?  if my list is sorted, what the running time would be?
>
> Taking this example, you know you want the "in" operator.  Which you
> somehow need to know is implemented by the "__contains__" protocol
> (you can find this in the "expressions" section of the "Language
> Reference").
>
> Now you can either know how objects look like in C (follow the
> "Extending and Embedding" tutorial, specifically the "Defining New
> Types" section) and therefore know you need to look at the sq_contains
> slot of the PySequenceMethods sturcture.  Or you could just locate the
> list object in Objects/listobjects.c (which you can easily find by
> looking at the source tree) and search for "contains".  Both ways
> will lead you pretty quickly to the list_contains() function in
> Objects/listobject.c.  And now you just need to know the C-API (again
> in the docs) to be able to read it (even if you don't that's a pretty
> straightforward function to read).
>
> Hope that helps
> Floris

It does help, thank you.
I think I know where to start, I found somethings I'm interested in in
listobject.c.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to read source code of python?

2010-06-11 Thread Lee
On Jun 10, 10:26 am, Giampaolo Rodolà  wrote:
> 2010/6/10 Leon :
>
> > Hi, there,
> > I'm trying to read the source code of python.
> > I read around, and am kind of lost, so where to start?
>
> > Any comments are welcomed, thanks in advance.
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> If you're interested in understanding Python internals you might want
> to take a look at 
> this:http://tech.blog.aknin.name/category/my-projects/pythons-innards/
>
> --- Giampaolohttp://code.google.com/p/pyftpdlibhttp://code.google.com/p/psutil

Great stuff, which works for me very well.
-- 
http://mail.python.org/mailman/listinfo/python-list


ValueError: invalid literal for int():

2010-07-26 Thread lee
Hi,

I have a value,

partintid = int(Screw plugg  (91_10 -> untitled))

but i get ValueError: invalid literal for int(): Screw plugg  (91_10 -
> untitled)
any help?

-
Sunny

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


Re: ValueError: invalid literal for int():

2010-07-26 Thread lee
On Jul 26, 4:30 pm, Steven D'Aprano  wrote:
> On Mon, 26 Jul 2010 04:12:33 -0700, Chris Rebert wrote:
> > On Mon, Jul 26, 2010 at 4:03 AM, Sunny chilgod 
> > wrote:
> >> Hi Chris,
> >> Thanks for your help. but i need to to convert the whole string to int.
> >> heres my full code,
> >> ptid = 'item_01bom'
> >> so item_01bom is a field name in form, so i get its value, partintid =
> >> int(form[ptid]).  # the value of form[ptid] is 'Screw plugg
> >>  (91_10 - untitled)'
> >> Hence i get the error. hope i am clear now.
>
> > Nope, still vague. Which is your desired value for partintid: 91? 10?
> > 9110? "91_10"? Something else?
>
> Well, if you interpret 'Screw plugg (91_10 - untitled)' as a base-256
> number, the correct answer is:
>
> 147,334,663,384,405,567,160,096,068,524,905,866,724,622,858,761,848,595,862,392,584,788,047,651,881
>
> Obviously.
>
> --
> Steven

Hi,

i got the value wrong. sorry for the mistake. i get a int value like
"01", so no issue converting it to integer.
thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


obscure problem using elementtree to make xhtml website

2009-09-03 Thread Lee
Elementtree (python xml parser) will transform markup like



into



which is a reasonable thing to do for xml (called minimization, I
think).

But this caused an obscure problem when I used it to create the xhtml
parts of my website,
causing Internet Explorer to display nearly blank pages. I explain the
details at

http://lee-phillips.org/scripttag/

and am writing here as a heads-up to anyone who might be using a
workflow similar to mine: writing documents in xml and using python
and elementtree to transform those into xhtml webpages, and using the
standard kludge of serving them as text/html to IE, to get around the
latter's inability to handle xml. I can't be the only one (and I doubt
this problem is confined to elementtree).


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


Re: obscure problem using elementtree to make xhtml website

2009-09-03 Thread Lee
I went with a space, but a comment is a better idea.

I only mention the 

Re: obscure problem using elementtree to make xhtml website

2009-09-03 Thread Lee
I went with a space, but a comment is a better idea.

I only mention the 

Re: Cutting a deck of cards

2013-05-31 Thread Lee Crocker
Why on Earth would you want to? "Cutting" a deck makes no sense in software. 
Randomize the deck properly (Google "Fisher-Yates") and start dealing. Cutting 
the deck will not make it any more random, and in fact will probably make it 
worse depending on how you choose the cutpoint.

The purpose of "cutting" cards is to make it more difficult for human dealers 
to stack a deck. Simulating it in software makes no more sense than simulating 
the cigars you smoke while playing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cutting a deck of cards

2013-06-01 Thread Lee Crocker

>> and in fact will probably make it worse depending on how you choose
>> the cutpoint.
 
> I'm pretty sure it won't. Otherwise you'd be lowering entropy by doing
> a random thing to a random thing.

Doing a random thing to a random thing usually *does* lower entropy when
the "random" things are actually deterministic algorithms that may have 
unexpected correlations. That's why you don't write your own PRNG unless
you have a very good understanding of the math.

If you are shuffling the deck with, say, numbers from random.org (which uses 
atmospheric noise), then cutting the deck afterward will have precisely 0 
effect, since the (51 * 52!) possible outcomes include 51 copies of each of the 
52! orderings, and so the odds of each end up the same. But if you're choosing 
the cutpoint by getting a value from the same PRNG you used to shuffle, there 
might very well be a correlation that makes some arrangements more likely
than others.
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANNC] pynguin-0.15 python turtle graphics application

2013-06-13 Thread Lee Harr
Pynguin is a python-based turtle graphics application.
    It combines an editor, interactive interpreter, and
    graphics display area.

It is meant to be an easy environment for introducing
    some programming concepts to beginning programmers.


http://pynguin.googlecode.com/


This release makes major changes to the editor to enable
    line numbers and other improvements.


Pynguin is tested with Python 3.3.1 and PyQt 4.10 and
    now requires QsciScintilla (tested with version 2.7.1)

Pynguin is released under GPLv3.


Changes in pynguin-0.15:
    Major change!
        - Now REQUIRES QsciScintilla!
            - included with PyQt4 on windows
            - .deb should pull in dependency automatically
            - other systems may require manual intervention

    Important fixes
        - writes out all document pages every time when saving
            - some pages could have been lost when changing between
                single file method and file + directory method of
                saving files

    Other fixes
        - fixed arc() with pen up
        - fixed loading pages with mixed defs and top-level code

    Pynguin API
        - added pie option to arc
            - draws pie wedges instead of just arcs
            - arc(radius, extent, pie=True)
        - added underline() method
            - pynguin.underline() # start underline for write()
            - pynguin.underline(False) # stop underline

    Canvas

    UI
        - loads .pyn file specified on command line
        - added ability to double-click open .pyn documents
            - tested on Ubuntu Linux only
        - shows better error message when there is a problem loading a file
        - saves/restores main window geometry/location

    Integrated Editor
        - Replaced editor with QsciScintilla text widget
        - Line numbers available now

    Integrated Console
        - Replaced QTextEdit with QsciScintilla text widget

    Examples
        - added fraction example to demonstrate arc(..., pie=True)
            - also demonstrates underline() 
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner - GUI devlopment in Tkinter - Any IDE with drag and drop feature like Visual Studio?

2013-07-22 Thread Cucole Lee
Why Thinter? You can try wxpython.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Has anyone gotten Pyglet to work

2013-07-29 Thread Lee Harr
> $ ./pyglet.py
> Traceback (most recent call last):
>    File "./pyglet.py", line 2, in 
>      import pyglet
>    File "/home/collier/pyglet.py", line 3, in 
>      song = pyglet.media.load('./boot.ogg')
> AttributeError: 'module' object has no attribute 'media'


Name your program something other than "pyglet.py"

import pyglet

is importing your module, instead of the pyglet module. 
  
-- 
http://mail.python.org/mailman/listinfo/python-list


can someone teach me this?

2012-07-20 Thread Menghsiu Lee
Hi, 
I have tried 1000 times to compile this python file to be an exe file by using 
py2exe and gui2exe
But, it does not work out. 
I am thinking if there can be some genius teaching me how to make this happen.
The link in below  is the complete code with all sources. Everything is open to 
everyone since I change this from another expert.

http://dl.dropbox.com/u/63928380/blackjack.rar

Thanks for your help and instructions.

Best regards,

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


[ANNC] pybotwar-0.8

2012-08-15 Thread Lee Harr

pybotwar is a fun and educational game where players
write computer programs to control simulated robots.

http://pybotwar.googlecode.com/


The focus of this release is making all functionality
available from the PyQt interface and making PyQt
the default interface.

pybotwar uses pybox2d for the physical simulation.
It can be run in text-only mode -- useful for longer
tournaments -- or use pyqt or pygame for a graphical
interface and visualization of the action.

pybotwar is released under GPLv3.


Changes in pybotwar-0.8:
    - pybox2d-2.0.2b2 is now the required version

    API
    - Robot.turret() now takes turret speed instead of angle
    - PING sensor now differentiates own bullets from enemy bullets
    - PING differentiates dead robots when remove_dead_robots=False
    - made internal Robot state variables less likely to conflict with user code

    Settings
    - added "robots dir" setting to make it easier to run pybotwar
    from an installed copy, rather than from the unpacked folder
    - logs, lineups, and db all go in robots dir
    - robot modules are now loaded by full path
    - If using Qt settings, remembers most recently used set of robots

    PyQt4 Interface
    - PyQt4 view mode is now the default
    - (text mode and pygame/pygsear still available)
    - all settings are available from PyQt interface
    - remembers most recently used set of robots
    - added debug window showing sensor values, commands, and logs
    - can now start tournaments (and multiple battles) from pyqt
    - can also start tournaments to run in background
    - editor automatically adds .py to robot filename if needed

    Other changes
    - made template.py a valid robot program
    - single battles are now run as 1-battle tournaments
    - renamed kill stat to outlasted
    - started tracking kills as dealing final damage to other robot
    - commandline can now take a list of robots to load
    - added "Super Tournaments"
    - runs tournaments with all possible combinations of robots

    Fixes:
    - made POSition sensor scale same as PING sensor
    - fixed editor backspace between left edge and start of text
    - fixed inability to re-open file once its window was closed
    - fixed crash when cancelling file-open dialog
    - limited motor speed on turret
    - log messages in testmode when using qt4 view
    - fall back to :memory: database if unable to open db file

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


QThread.terminate in Python 3

2012-09-23 Thread Lee Harr

Hi;

I have asked this on the PyQt list, but have not seen any
response yet. Hoping someone will be able to test this
on their system to see if they see the same problem.

The problem I am seeing is that terminating a QThread running
certain code will freeze the program, requiring it to be kill'd.

Adding a sleep will allow the QThread to be terminated, but
for my use I need to be able to terminate any arbitrary code.
I understand that use of QThread.terminate is discouraged,
but it has worked well previously and I would like to continue
this use if possible.

I see the problem on Python 3.2.3 with PyQt 4.9.1 on Ubuntu 12.4

With Python 2.7.3 with PyQt 4.9.1 there is no problem.

I am hoping to find out if this is a bug, and if so, where
I should report it (Python, PyQt, Qt, Linux, etc).

Thanks for any pointers.



Here is a program that shows the problem:


# test_qthread.py

#from __future__ import print_function

import time
from PyQt4 import QtCore


class CmdThread(QtCore.QThread):
    def run(self):
    while True:
    #print 'test'
    print('test')
    #time.sleep(0.2)


if __name__ == '__main__':
    t = CmdThread()
    print('thread set up')
    t.start()
    print('thread started')
    time.sleep(1)
    print('terminating thread')
    t.terminate()
    print('terminated')
    time.sleep(1)
    print('thread is running:', t.isRunning())

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


Re: QThread.terminate in Python 3

2012-09-28 Thread Lee Harr

>> I understand that use of QThread.terminate is discouraged,
>> but it has worked well previously and I would like to continue
>> this use if possible.
>>
>       And now you've encountered the reason it is discouraged.

Ok. Point taken.

What I hear you saying is that once I use .terminate anything
following that is indeterminate. It might work on my system
and nowhere else. Even though it was working for me before,
it was likely causing trouble elsewhere.


So, I need another approach.

The problem I am facing is that I want to run arbitrary
(user-supplied) code in the other thread and need to be
able to stop it at any time.

This is for a python turtle-graphics application:
http://pynguin.googlecode.com/


I found another possible approach here:
http://tomerfiliba.com/recipes/Thread2/

It uses ctypes to raise an exception in the other thread.
For the simple test case, at least, it works (for me).

Is this any safer or more reliable than .terminate ?

Is it portable? ie, if I build this in to my actual application
and it works for me, is it likely to work for everyone?


Thanks for any insight.

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


python wiki gone?

2013-01-05 Thread Lee Harr

Have I just happened across wiki.python.org at a bad time,
or is the wiki gone?

When I go to wiki.python.org I get redirected to
http://wiki.python.org/moin/
which is 404 Not Found.

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


Ubuntu Python -dbg packages

2013-01-06 Thread Lee Harr

I am using:
Ubuntu 12.10
Python 3.2.3
Qt 4.8.2
PyQt 4.9.3
 
I also have the ubuntu -dbg packages:
python3-dbg
python3-pyqt4-dbg
 
 
 
I don't understand why python3-dbg cannot import the PyQt4 modules...
 
$ python3
Python 3.2.3 (default, Oct 19 2012, 19:53:57)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/usr/bin/python3'
>>> import PyQt4
>>> import PyQt4.QtCore
>>>
 
 
$ python3-dbg
Python 3.2.3 (default, Oct 19 2012, 19:58:54)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
[60298 refs]
>>> sys.executable
'/usr/bin/python3-dbg'
[60300 refs]
>>> import PyQt4
[60323 refs]
>>> PyQt4.__file__
'/usr/lib/python3/dist-packages/PyQt4/__init__.py'
[60323 refs]
>>> import PyQt4.QtCore
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named QtCore
[150996 refs]
>>>
 
 
 
Also... The python3-pyqt4-dbg package seems to install to a different
location, so I tried inserting that dir on to sys.path with unexpected results.
 
$ python3-dbg
Python 3.2.3 (default, Oct 19 2012, 19:58:54)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
[60298 refs]
>>> sys.path.insert(1, '/usr/lib/debug/usr/lib/python3/dist-packages/')
[60299 refs]
>>> import PyQt4
[60335 refs]
>>> PyQt4.__file__
'/usr/lib/python3/dist-packages/PyQt4/__init__.py'
[60337 refs]
>>>
 
 
I noticed that there was no __init__.py in
/usr/lib/debug/usr/lib/python3/dist-packages/PyQt4
so I added that and then...
 
$ python3-dbg
Python 3.2.3 (default, Oct 19 2012, 19:58:54)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
[60298 refs]
>>> sys.path.insert(1, '/usr/lib/debug/usr/lib/python3/dist-packages')
[60299 refs]
>>> import PyQt4
[60324 refs]
>>> PyQt4.__file__
'/usr/lib/debug/usr/lib/python3/dist-packages/PyQt4/__init__.py'
[60328 refs]
>>> import PyQt4.QtCore
Segmentation fault (core dumped)
 
 
Clearly, I am doing something wrong.
 
Any hints?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ubuntu Python -dbg packages

2013-01-06 Thread Lee Harr

> On 1/6/2013 8:42 AM, Lee Harr wrote:
>>
>> I am using:
>> Ubuntu 12.10
>> Python 3.2.3
>
> import has been considerably redone, and hopefully upgraded, in 3.3.


Ok, so now I tried python3.3-dbg but I don't think the pyqt
modules are compiled for 3.3 and that may be preventing
the import there.

Those extension modules would need to be compiled for
an exactly matching python interpreter, right?



>> Qt 4.8.2
>> PyQt 4.9.3
>>
>> I also have the ubuntu -dbg packages:
>> python3-dbg
>> python3-pyqt4-dbg
>>
>>
>>
>> I don't understand why python3-dbg cannot import the PyQt4 modules...

> Is PyQtr.__file__ the same here, as below?

Yes. It's the same.

Sorry, that's what I meant to show there.

$ python3
Python 3.2.3 (default, Oct 19 2012, 19:53:57) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4
>>> PyQt4.__file__
'/usr/lib/python3/dist-packages/PyQt4/__init__.py'
>>>



>> $ python3-dbg
>> Python 3.2.3 (default, Oct 19 2012, 19:58:54)
>> [GCC 4.7.2] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>> import sys
>> [60298 refs]
>>>>> sys.executable
>> '/usr/bin/python3-dbg'
>> [60300 refs]
>>>>> import PyQt4
>> [60323 refs]
>>>>> PyQt4.__file__
>> '/usr/lib/python3/dist-packages/PyQt4/__init__.py'
>> [60323 refs]
>>>>> import PyQt4.QtCore
>> Traceback (most recent call last):
>>    File "", line 1, in 
>> ImportError: No module named QtCore
>> [150996 refs]


So, python3-dbg _should_ be able to import this?

Any ideas about the python3-pyqt4-dbg modules mentioned originally?

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


Re: Ubuntu Python -dbg packages

2013-01-07 Thread Lee Harr

>> Ok, so now I tried python3.3-dbg but I don't think the pyqt
>> modules are compiled for 3.3 and that may be preventing
>> the import there.
>>
>> Those extension modules would need to be compiled for
>> an exactly matching python interpreter, right?
>
> For Windows visual C compiler, that is true. I do not know about gcc on 
> *nix. I have gotten the impression that it is not necessarily so, except 
> as the C api has changed in a way that affects the extension library. 
> (Given that 3.3 is 3 months old, after 6 months of alpha/beta releases, 
> and has some major improvements, it is past time for libraries that need 
> recompiling to be so.)


Well... lets just say that with the ubuntu python3.3 package it doesn't work:


$ python3.3
Python 3.3.0 (default, Sep 29 2012, 17:17:45) 
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4
>>> import PyQt4.QtCore
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named 'PyQt4.QtCore'


[plus a whole other problem...]

Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 64, in 
apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 4, in 
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in 
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in 

    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 20, in 

    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 21, in 
    import apt_pkg
ImportError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named 'PyQt4.QtCore'




>> So, python3-dbg _should_ be able to import this?
>
> Given that python3 and python3-dbg import the same PyQt4 file, and that 
> you spell PyQt4.QtCore the same (I checked), I am as surprised as you. 

Ok. I will file a Ubuntu bug report.



> >>> import test.test_imp as t; t.test_main()

This does not work for me:

$ python3
Python 3.2.3 (default, Oct 19 2012, 19:53:57) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import test
>>> test.test_imp
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'test_imp'


$ python3.3
Python 3.3.0 (default, Sep 29 2012, 17:17:45) 
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import test
>>> test.test_imp
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'test_imp'

[plus that whole Error in sys.excepthook thing too...]


Should this be another bug report for the ubuntu packages?

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


object aware of others

2012-01-28 Thread Lee Chaplin
Hi all,

I am trying to create an object that is aware of other objects created
before itself, and when found, then copy some attributes from them,
something like:

class A:
def __init__(self):
self.myname = "IamA"
print 'This is A'
def foo(self):
print "foo"
def update(self):
i = ''
obj = self
for i in globals():
obj = globals()[i]
if hasattr(obj, 'myname'):
print "The only friends I've got are ", i, obj.myname
else:
print "Oops, not my friend."


class B:
def __init__(self):
print 'This is B'
def foo(self):
print "bar"

# a = A()
# b = B()
# c = A()
# c.update()

The last four lines work if they are in the same module as the class
definitions (a000), but it doesn't work if they are called from a
different module, say:

import a000

a = a000.A()
b = a000.B()
c = a000.A()
c.update()

I presume there is something that need to replace the globals() call,
but I cannot find what.
Any help is greatly appreciated.

Thanks,
Lee
-- 
http://mail.python.org/mailman/listinfo/python-list


New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-02-29 Thread Xah Lee
New Science Discovery: Perl Idiots Remain Idiots After A Decade!

A excerpt from the new book 〈Modern Perl〉, just published, chapter 4
on “Operators”. Quote:

«The associativity of an operator governs whether it evaluates from
left to right or right to left. Addition is left associative, such
that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result.
Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3
** 4 first, then raises 2 to the 81st power. »

LOL. Looks like the perl folks haven't changed. Fundamentals of
serious math got botched so badly.

Let me explain the idiocy.

It says “The associativity of an operator governs whether it evaluates
from left to right or right to left.”. Ok, so let's say we have 2
operators: a white triangle △ and a black triangle ▲. Now, by the
perl's teaching above, let's suppose the white triangle is “right
associative” and the black triangle is “left associative”. Now, look
at this:

3 △ 6 ▲ 5

seems like the white and black triangles are going to draw a pistol
and fight for the chick 6 there. LOL.

Now, let me tell you what operator precedence is. First of all, let's
limit ourselfs to discuss operators that are so-called binary
operators, which, in our context, basically means single symbol
operator that takes it's left and right side as operands. Now, each
symbol have a “precedence”, or in other words, the set of operators
has a order. (one easy way to think of this is that, suppose you have
n symbols, then you give each a number, from 1 to n, as their order)
So, when 2 symbols are placed side by side such as 「3 △ 6 ▲ 5」, the
symbol with higher precedence wins. Another easy way to think of this
is that each operator has a stickiness level. The higher its level, it
more sticky it is.

the problem with the perl explanations is that it's one misleading
confusion ball. It isn't about “left/right associativity”. It isn't
about “evaluates from left to right or right to left”. Worse, the word
“associativity” is a math term that describe a property of algebra
that has nothing to do with operator precedence, yet is easily
confused with because it is a property about order of evaluation. (for
example, the addition function is associative, meaning: 「(3+6)+5 =
3+(6+5)」.)

compare it with this:

〈Perl & Python: Complex Numbers〉
http://xahlee.org/perl-python/complex_numbers.html

and for a good understanding of functions and operators, see:

〈What's Function, What's Operator?〉
http://xahlee.org/math/function_and_operators.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-02-29 Thread Xah Lee
i missed a point in my original post. That is, when the same operator
are adjacent. e.g. 「3 ▲ 6 ▲ 5」.

This is pointed out by Kiuhnm 〔kiuhnm03.4t.yahoo.it〕 and Tim Bradshaw.
Thanks.

though, i disagree the way they expressed it, or any sense this is
different from math.

to clarify, amend my original post, here's what's needed for binary
operator precedence:

① the symbols are ordered. (e.g. given a unique integer)

② each symbol is has either one of left-side stickness or right-side
stickness spec. (needed when adjacent symbols are the same.)

About the lisp case mentioned by Tim, e.g.  in「(f a b c)」, whether it
means 「(f (f a b) c)」 or 「(f a (f b c))」 . It is not directly relevant
to the context of my original post, because it isn't about to
operators. It's about function argument eval order. Good point,
nevertheless.

the perl doc, is still misleading, terribly bad written. Becha ass!

 Xah

On Feb 29, 4:08 am, Kiuhnm  wrote:
> On 2/29/2012 9:09, Xah Lee wrote:
>
>
> > New Science Discovery: Perl Idiots Remain Idiots After A Decade!
>
> > A excerpt from the new book 〈Modern Perl〉, just published, chapter 4
> > on “Operators”. Quote:
>
> > «The associativity of an operator governs whether it evaluates from
> > left to right or right to left. Addition is left associative, such
> > that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result.
> > Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3
> > ** 4 first, then raises 2 to the 81st power. »
>
> > LOL. Looks like the perl folks haven't changed. Fundamentals of
> > serious math got botched so badly.
>
> > Let me explain the idiocy.
>
> > It says “The associativity of an operator governs whether it evaluates
> > from left to right or right to left.”. Ok, so let's say we have 2
> > operators: a white triangle △ and a black triangle ▲. Now, by the
> > perl's teaching above, let's suppose the white triangle is “right
> > associative” and the black triangle is “left associative”. Now, look
> > at this:
>
> > 3 △ 6 ▲ 5
>
> > seems like the white and black triangles are going to draw a pistol
> > and fight for the chick 6 there. LOL.
>
> Sorry, but you're wrong and they're right.
> Associativity governs the order of evaluation of a group of operators
> *OF THE SAME PRECEDENCE*.
> If you write
>    2**3**4
> only the fact the '**' is right associative will tell you that the order is
>    2**(3**4)
> and not
>    (2**3)**4
> I remind you that 2^(3^4) != (2^3)^4.
>
> Kiuhnm
-- 
http://mail.python.org/mailman/listinfo/python-list


lang comparison: in-place algorithm for reversing a list in Perl, Python, Lisp

2012-02-29 Thread Xah Lee
fun example.

in-place algorithm for reversing a list in Perl, Python, Lisp
http://xahlee.org/comp/in-place_algorithm.html

plain text follows


What's “In-place Algorithm”?

Xah Lee, 2012-02-29

This page tells you what's “In-place algorithm”, using {python, perl,
emacs lisp} code to illustrate.

Here's Wikipedia In-place algorithm excerpt:

In computer science, an in-place algorithm (or in Latin in situ) is an
algorithm which transforms input using a data structure with a small,
constant amount of extra storage space. The input is usually
overwritten by the output as the algorithm executes. An algorithm
which is not in-place is sometimes called not-in-place or out-of-
place.

Python

Here's a python code for reversing a list. Done by creating a new
list, NOT using in-place:

# python
# reverse a list

list_a = ["a", "b", "c", "d", "e", "f", "g"]

list_length = len(list_a)
list_b = [0] * list_length

for i in range(list_length):
list_b[i] = list_a[list_length -1 - i]

print list_b
Here's in-place algorithm for reversing a list:

# python
# in-place algorithm for reversing a list

list_a = ["a", "b", "c", "d", "e", "f", "g"]

list_length = len(list_a)

for i in range(list_length/2):
x = list_a[i]
list_a[i] = list_a[ list_length -1 - i]
list_a[ list_length -1 - i] = x

print list_a
Perl

Here's a perl code for reversing a list. Done by creating a new list,
NOT using in-place:

# perl

use strict;
use Data::Dumper;

my @listA = qw(a b c d e f g);

my $listLength = scalar @listA;
my @listB = ();

for ( my $i = 0; $i < $listLength; $i++ ) {
 $listB[$i] = $listA[ $listLength - 1 - $i];
}

print Dumper(\@listB);

# perl
# in-place algorithm for reversing a list.

use strict;
use Data::Dumper;
use POSIX; # for “floor”

my @listA = qw(a b c d e f g);

my $listLength = scalar @listA;

for ( my $i = 0; $i < floor($listLength/2); $i++ ) {
  my $x = $listA[$i];
  $listA[$i] = $listA[ $listLength - 1 - $i];
  $listA[ $listLength - 1 - $i] = $x;
}

print Dumper(\@listA);
__END__

emacs lisp

;; emacs lisp
;; reverse a array

(setq arrayA ["a" "b" "c" "d" "e" "f" "g"])

(setq arrayLength (length arrayA))

(setq arrayB (make-vector arrayLength 0))

(dotimes (i arrayLength )
  (aset arrayB i (aref arrayA (- (1- arrayLength) i)) )
  )

(print (format "%S" arrayB))
;; emacs lisp
;; in-place algorithm for reversing a array

(setq arrayA ["a" "b" "c" "d" "e" "f" "g"])

(setq arrayLength (length arrayA))

(dotimes (i (floor (/ arrayLength 2)))
  (let (x)
(setq x (aref arrayA i))
(aset arrayA i (aref arrayA (- (1- arrayLength) i)))
(aset arrayA (- (1- arrayLength) i) x) ) )

(print (format "%S" arrayA))

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


Re: lang comparison: in-place algorithm for reversing a list in Perl, Python, Lisp

2012-02-29 Thread Xah Lee
On Feb 29, 9:01 pm, Steven D'Aprano  wrote:
> You don't need a temporary variable to swap two values in
> Python. A better way to reverse a list using more Pythonic idioms is:
>
> for i in range(len(list_a)//2):
>     list_a[i], list_a[-i-1] = list_a[-i-1], list_a[i]

forgive me sir, but i haven't been at python for a while. :)
i was, actually, refreshing myself of what little polyglot skills i
have.

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


Re: lang comparison: in-place algorithm for reversing a list in Perl,Python, Lisp

2012-03-01 Thread Xah Lee
On Mar 1, 7:04 am, Kaz Kylheku  wrote:
 lisp:
 (floor (/ x y)) --[rewrite]--> (floor x y)

Thanks for this interesting point.

I don't think it's a good lang design, more of a lang quirk.

similarly, in Python 2.x,
x/y
will work when both x and y are integers. Also,
x//y
works too, but that // is just perlish unreadable syntax quirk.

similarly, in perl, either one
require POSIX; floor(x/y);
the require POSIX instead of Math is a quirk. But even, floor should
really be builtin.
or
using a perl hack
int(x/y)

all of the above are quirks. They rely on computer engineering by-
products (such as int), or rely on the lang's idiosyncrasy. One easy
way to measure it is whether a programer can read and understand a
program without having to delve into its idiosyncrasies. Problem with
these lang idioms is that it's harder to understand, and whatever
advantage/optimization they provide is microscopic and temporary.

best is really floor(x/y).

idiomatic programing, is a bad thing. It was spread by perl, of
course, in the 1990s. Idiomatic lang, i.e. lang with huge number of
bizarre idioms, such as perl, is the worst.

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


Re: lang comparison: in-place algorithm for reversing a list in Perl,Python, Lisp

2012-03-02 Thread Xah Lee

Xah Lee wrote:
«… One easy way to measure it is whether a programer can read and
understand a program without having to delve into its idiosyncrasies.
…»

Chris Angelico wrote:
«Neither the behavior of ints nor the behavior of IEEE floating point
is a "quirk" or an "idiosyncracy". …»

they are computer engineering by-products. Are quirks and
idiosyncracies. Check out a advanced lang such as Mathematica. There,
one can learn how the mathematical concept of integer or real number
are implemented in a computer language, without lots by-products of
comp engineering as in vast majority of langs (all those that chalks
up to some IEEE. (which, sadly, includes C, C++, java, perl,
python, lisp, and almost all. (lisp idiots speak of the jargon “number
tower” instead I.) (part of the reason almost all langs stick to
some I stuff is because it's kinda standard, and everyone
understand it, in the sense that unix RFC (aka really fucking common)
is wide-spread because its free yet technically worst. (in a sense,
when everybody's stupid, there arise a cost to not be stupid..

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


Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

2012-03-02 Thread Xah Lee
On Mar 1, 3:00 am, Kiuhnm  wrote:
> They did not make up the terminology, if that is what you are saying.
> The concepts of left and right associativity are well-known and accepted
> in TCS (Theoretical CS).


> Aho, Sethi and Ullman explain it this way in "Compilers: Principles,
> Techniques and Tools":
> "We say that the operator + associates to the left because an operand
> with plus signs on both sides of it is taken by the operator to its
> left. [...]"
> And they also show parse trees similar to the ones I wrote above.

how do they explain when 2 operators are adjacent e.g. 「3 △ 6 ▲ 5 」?

do you happen to know some site that shows the relevant page i can
have a look?

thanks.

 Xah

On Mar 1, 3:00 am, Kiuhnm  wrote:
> On 3/1/2012 1:02, Xah Lee wrote:
>
> > i missed a point in my original post. That is, when the same operator
> > are adjacent. e.g. 「3 ▲ 6 ▲ 5」.
>
> > This is pointed out by Kiuhnm 〔kiuhnm03.4t.yahoo.it〕 and Tim Bradshaw.
> > Thanks.
>
> > though, i disagree the way they expressed it, or any sense this is
> > different from math.
>
> They did not make up the terminology, if that is what you are saying.
> The concepts of left and right associativity are well-known and accepted
> in TCS (Theoretical CS).
>
> If you change the terminology, no one will understand you unless you
> provide your definitions every time (and then they may not accept them).
>
> Another way of saying that an operator is left-associative is that its
> parse tree is a left-tree, i.e. a complete tree where each right child
> is a leaf.
> For instance, (use a monospaced font)
>    1 + 2 + 3 + 4
> gives you this left-tree:
>        +
>      +   4
>    +   3
>   1 2
> while 1**2**3**4
> gives you this right-tree:
>    **
> 1    **
>     2    **
>         3  4
>
> Aho, Sethi and Ullman explain it this way in "Compilers: Principles,
> Techniques and Tools":
> "We say that the operator + associates to the left because an operand
> with plus signs on both sides of it is taken by the operator to its
> left. [...]"
> And they also show parse trees similar to the ones I wrote above.
>
> Kiuhnm
-- 
http://mail.python.org/mailman/listinfo/python-list


are int, float, long, double, side-effects of computer engineering?

2012-03-05 Thread Xah Lee
some additional info i thought is relevant.

are int, float, long, double, side-effects of computer engineering?

Xah Lee wrote:
«… One easy way to measure it is whether a programer can read and
understand a program without having to delve into its idiosyncrasies.
…»

Chris Angelico wrote:
«Neither the behavior of ints nor the behavior of IEEE floating point
is a "quirk" or an "idiosyncracy". …»

they are computer engineering by-products. Are quirks and
idiosyncracies. Check out a advanced lang such as Mathematica. There,
one can learn how the mathematical concept of integer or real number
are implemented in a computer language, without lots by-products of
comp engineering as in vast majority of langs (all those that chalks
up to some IEEE. (which, sadly, includes C, C++, perl, python,
lisp, and almost all. (Common/Scheme lisp idiots speak of the jargon
“number tower” instead I.) (part of the reason almost all langs
stick to some I stuff is because it's kinda standard, and
everyone understand it, in the sense that unix RFC (aka really fucking
common) is wide-spread because its free yet technically worst. (in a
sense, when everybody's stupid, there arise a cost to not be
stupid..


A friend asked: «Can you enlighten us as to Mathematica's way of
handling numbers, either by a post or a link to suitable
documentation? …»

what i meant to point out is that Mathematica deals with numbers at a
high-level human way. That is, one doesn't think in terms of float,
long, int, double. These words are never mentioned. Instead, you have
concepts of machine precision, accuracy. The lang automatically handle
the translation to hardware, and invoking exact value or infinite
precision as required or requested.

in most lang's doc, words like int, long, double, float are part of
the lang, and it's quick to mention IEEE. Then you have the wide-
spread overflow issue in your lang. In M, the programer only need to
think in terms of math, i.e. Real number, Integer, complex number,
precision, accuracy, etc.

this is what i meat that most lang deals with computer engineering by-
products, and i wished them to be higher level like M.

http://reference.wolfram.com/mathematica/guide/PrecisionAndAccuracyControl.html

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


Re: are int, float, long, double, side-effects of computer engineering?

2012-03-05 Thread Xah Lee

On Mar 5, 9:26 pm, Tim Roberts  wrote:
> Xah Lee  wrote:
>
> >some additional info i thought is relevant.
>
> >are int, float, long, double, side-effects of computer engineering?
>
> Of course they are.  Such concepts violate the purity of a computer
> language's abstraction of the underlying hardware.  We accept that
> violation because of performance reasons.  There are, as you point out,
> languages that do maintain the purity of the abstraction, but that purity
> is ALWAYS at the expense of performance.
>
> I would also point out pre-emptively that there is nothing inherently wrong
> with asking us to accept an impure abstraction in exchange for performance.
> It is a performance choice that we choose to make.

while what you said is true, but the problem is that 99.99% of
programers do NOT know this. They do not know Mathematica. They've
never seen a language with such feature. The concept is alien. This is
what i'd like to point out and spread awareness.

also, argument about raw speed and fine control vs automatic
management, rots with time. Happened with auto memory management,
managed code, compilers, auto type conversion, auto extension of
array, auto type system, dynamic/scripting languages, etc.

i'd share this these talks:

〈Programing Language: Steve Yegge on Dynamic Languages〉
http://xahlee.org/comp/Steve_Yegge_on_dynamic_languages.html

〈Guy Steele on Parallel Programing: Get rid of cons!〉
http://xahlee.org/comp/Guy_Steele_parallel_computing.html

〈Ocaml Use in Industry (Janestreet Talk by Yaron Minsky)〉
http://xahlee.org/comp/Yaron_Minsky_Janestreet_talk.html

〈Stephen Wolfram: The Background and Vision of Mathematica 〉
http://xahlee.blogspot.com/2011/10/stephen-wolfram-background-and-vision.html

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


a interesting Parallel Programing Problem: asciify-string

2012-03-06 Thread Xah Lee
here's a interesting problem that we are discussing at comp.lang.lisp.

〈Parallel Programing Problem: asciify-string〉
http://xahlee.org/comp/parallel_programing_exercise_asciify-string.html

here's the plain text. Code example is emacs lisp, but the problem is
general.

for a bit python relevancy… is there any python compiler that's
parallel-algorithm aware?

---
Parallel Programing Problem: asciify-string

Here's a interesting parallel programing problem.

Problem Description

The task is to change this function so it's parallelable. (code
example in emacs lisp)

(defun asciify-string (inputStr)
  "Make Unicode string into equivalent ASCII ones."
  (setq inputStr (replace-regexp-in-string "á\\|à\\|â\\|ä" "a"
inputStr))
  (setq inputStr (replace-regexp-in-string "é\\|è\\|ê\\|ë" "e"
inputStr))
  (setq inputStr (replace-regexp-in-string "í\\|ì\\|î\\|ï" "i"
inputStr))
  (setq inputStr (replace-regexp-in-string "ó\\|ò\\|ô\\|ö" "o"
inputStr))
  (setq inputStr (replace-regexp-in-string "ú\\|ù\\|û\\|ü" "u"
inputStr))
  inputStr
  )

Here's a more general description of the problem.

You are given a Unicode text file that's a few peta bytes. For certain
characters in the file, they need to be changed to different char.
(For example of practical application, see: IDN homograph attack ◇
Duplicate characters in Unicode.)

One easy solution is to simply use regex, as the above sample code, to
search thru the file sequentially, and perform the transfrom of a
particular set of chars, then repeat for each char chat needs to be
changed.

But your task is to use a algorithm parallelizable. That is, in a
parallel-algorithm aware language (e.g. Fortress), the compiler will
automatically span the computation to multiple processors.

Refer to Guy Steele's video talk if you haven't seen already. See: Guy
Steele on Parallel Programing.
Solution Suggestions

A better way to write it for parallel programing, is to map a char-
transform function to each char in the string. Here's a pseudo-code in
lisp by Helmut Eller:

(defun asciify-char (c)
  (case c
((? ? ? ?) ?a)
((? ? ? ?) ?e)
((? ? ? ?) ?i)
((? ? ? ?) ?o)
((? ? ? ?) ?u)
(t c)))

(defun asciify-string (string) (map 'string #'asciify-string string))

One problem with this is that the function “asciify-char” itself is
sequential, and not 100% parallelizable. (we might assume here that
there are billions of chars in Unicode that needs to be transformed)

It would be a interesting small project, if someone actually use a
parallel-algorithm-aware language to work on this problem, and report
on the break-point of file-size of parallel-algorithm vs sequential-
algorithm.

Anyone would try it? Perhaps in Fortress, Erlang, Ease, Alice, X10, or
other? Is the Clojure parallel aware?

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


Daemonization / Popen / pipe issue

2012-03-16 Thread Lee Clemens
Hello,

I am new to the list, have many years of Java experience but an fairly new to 
Python. I am hoping this is an issue caused by my  misuse of Python in a 
multi-threaded way, but so far no one has identified such to me.

I have a multi-threaded application, each thread has an instance of a class 
which calls Popen. The command(s) being executed (shell=True) include pipes. 
The errors I have seen involve "broken pipe" and unexepected output (as 
demonstrated in the test case).

This issues only seem to occur when the application is "daemonized", using a 
double-fork and os.dup2, as shown here:
http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

I have provided a test-case here: https://gist.github.com/2054194

Please test how flipping DAEMONIZE between True and False yield different 
results.

I have used this on Red Hat/CentOS/Fedora using Python 2.6.x (latest) and 2.7.1 
and on Solaris with 2.6.4.

I know it's a bit long, but I have added comments to explain where the oddities 
appear and how it is called (fairly straight-forward multi-threaded). Please 
keep in mind this is a test-case based on a much larger application - I 
understand a lot of pieces included here are not necessary in this case.

Any assistance/advice would be greatly appreciated.

Thanks,
Lee

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


Re: Daemonization / Popen / pipe issue

2012-03-17 Thread Lee Clemens
On 03/16/2012 11:37 PM, John O'Hagan wrote:
> On Fri, 16 Mar 2012 22:12:14 -0400
> Lee Clemens  wrote:
>
>> I have a multi-threaded application
>>
>> I have provided a test-case here: https://gist.github.com/2054194
> I haven't looked at your test case yet, but a possible cause is the fact that
> the main application (or main thread) exits if it has finished executing and
> only daemon threads remain. This can  abruptly terminate threads which may be
> busy, for example, communicating via a pipe. The best solution IMO is not to
> use daemon threads, but to give all threads a way to terminate cleanly before
> the main thread does, even if this means using a flag or the like.
>
> HTH,
>
> John
>
I call .join() on each spawned thread, whether it is daemonized or not.
The code is available here:

https://gist.github.com/2054194


Is it generally not recommended to daemonize Python applications using
this method? Do you have any references or data to support your opinion?
Do you have any references which specifically state - "Daemonizing
Python applications cause Python to work in unexpected ways."? As that
is what seems to be happening - data corrupting pipe redirection at an
underlying level
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: cmd2, an extenstion of cmd that parses its argument line

2012-03-18 Thread anntzer . lee
Dear all,

I would like to announce the first public release of cmd2, an extension of the 
standard library's cmd with argument parsing, here: 
https://github.com/anntzer/cmd2.

Cmd2 is an extension built around the excellent cmd module of the standard
library.  Cmd allows one to build simple custom shells using ``do_*`` methods,
taking care in particular of the REPL loop and the interactive help.  However,
no facility is given for parsing the argument line (do_* methods are passed the
rest of the line as a single string argument).

With Cmd2, ``do_*`` methods are type-annotated, either using Python 3's
function annotation syntax, or with an ad-hoc ``annotate`` decorator, allowing
the dispatcher to parse the argument list for them.

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


Re: Daemonization / Popen / pipe issue

2012-03-21 Thread Lee Clemens
On 03/18/2012 12:15 AM, Cameron Simpson wrote:
> BTW, Lee, there is an external module for daemonising things in the UNIX
> sense:
>   http://pypi.python.org/pypi/python-daemon
> I recommend you use it.
>
> Cheers,
I haven't updated the gist yet, but I did try it with the code below -
but I get the same results (inconsistent termination, logs still match
up as though everything worked fine. If I'm not in DAEMONIZE mode and
hold down enter, I can get stdout from the Popen process too - which I
have seen with and without the DaemonContext package. There seems to be
something odd going on with the way pipes are handled...

Added after if __name__ == "__main__":
if DAEMONIZE:
import daemon
myDaemon = daemon.DaemonContext()
myDaemon.open()
...
-- 
http://mail.python.org/mailman/listinfo/python-list


perldoc: the key to perl

2012-03-26 Thread Xah Lee
〈Perl Documentation: The Key to Perl〉
http://xahlee.org/perl-python/key_to_perl.html

plain text follows
-

So, i wanted to know what the option perl -C does. So, here's perldoc
perlrun. Excerpt:

-C [*number/list*]
 The -C flag controls some of the Perl Unicode features.

 As of 5.8.1, the -C can be followed either by a number or
a list of
 option letters. The letters, their numeric values, and
effects are
 as follows; listing the letters is equal to summing the
numbers.

 I 1   STDIN is assumed to be in UTF-8
 O 2   STDOUT will be in UTF-8
 E 4   STDERR will be in UTF-8
 S 7   I + O + E
 i 8   UTF-8 is the default PerlIO layer for input
streams
 o16   UTF-8 is the default PerlIO layer for
output streams
 D24   i + o
 A32   the @ARGV elements are expected to be
strings encoded
   in UTF-8
 L64   normally the "IOEioA" are unconditional,
   the L makes them conditional on the locale
environment
   variables (the LC_ALL, LC_TYPE, and LANG,
in the order
   of decreasing precedence) -- if the
variables indicate
   UTF-8, then the selected "IOEioA" are in
effect
 a   256   Set ${^UTF8CACHE} to -1, to run the UTF-8
caching code in
   debugging mode.

 For example, -COE and -C6 will both turn on UTF-8-ness on
both
 STDOUT and STDERR. Repeating letters is just redundant,
not
 cumulative nor toggling.

 The "io" options mean that any subsequent open() (or
similar I/O
 operations) in the current file scope will have the
":utf8" PerlIO
 layer implicitly applied to them, in other words, UTF-8
is expected
 from any input stream, and UTF-8 is produced to any
output stream.
 This is just the default, with explicit layers in open()
and with
 binmode() one can manipulate streams as usual.

 -C on its own (not followed by any number or option
list), or the
 empty string "" for the "PERL_UNICODE" environment
variable, has
 the same effect as -CSDL. In other words, the standard I/
O handles
 and the default "open()" layer are UTF-8-fied *but* only
if the
 locale environment variables indicate a UTF-8 locale.
This
 behaviour follows the *implicit* (and problematic) UTF-8
behaviour
 of Perl 5.8.0.

 You can use -C0 (or "0" for "PERL_UNICODE") to explicitly
disable
 all the above Unicode features.

 The read-only magic variable "${^UNICODE}" reflects the
numeric
 value of this setting. This variable is set during Perl
startup and
 is thereafter read-only. If you want runtime effects, use
the
 three-arg open() (see "open" in perlfunc), the two-arg
binmode()
 (see "binmode" in perlfunc), and the "open" pragma (see
open).

 (In Perls earlier than 5.8.1 the -C switch was a Win32-
only switch
 that enabled the use of Unicode-aware "wide system call"
Win32
 APIs. This feature was practically unused, however, and
the command
 line switch was therefore "recycled".)

 Note: Since perl 5.10.1, if the -C option is used on the
"#!" line,
 it must be specified on the command line as well, since
the
 standard streams are already set up at this point in the
execution
 of the perl interpreter. You can also use binmode() to
set the
 encoding of an I/O stream.

reading that is like a adventure. It's like this:

The -C is a key to unlock many secrets. Just get it, and you'll be
all
good to go, except in cases you may need the inner key. You'll
find a
hinge in the key, open it, then there's a subkey. On the subkey,
there's a number. Take that number to the lock, it will open with
keyX. When you use keyX, it must be matched with the previous
inner
key with 8th bit. keyX doesn't have a ID, but you can make one by
finding the number at the place you found the key C. Key C is
actually
optional, but when inner key and keyX's number matches, it changes
the
nature of the lock. This is when you need to turn on keyMode …

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


Is Programing Art or Science?

2012-04-02 Thread Xah Lee
the refreshen of the blood, from Xah's Entertainment Enterprise, i
bring you:

〈Is Programing Art or Science〉
http://xahlee.org/UnixResource_dir/writ/art_or_science.html

penned in the year of our lord two thousand and two, plain text
version follows.


Is Programing Art or Science?

Dear friends,

You mentioned the title of Donald Knuth's magnum opus Art of
Programming in the context of discussion that fringes on whether
programing is science or art. I'm quite pissed off at work at the
moment, so let me take the time to give some guide on this matter to
the daily programers.

At the bottom rung of programers, there's no question about whether
programing is science or art. Because monkey coders could not care
less. These folks ain't be reading this post, for they hardly will
have heard of lisp.

This leaves us with elite programers who have a smattering of
interests on cogitation and philosophical conundrums. So, is
programing a science or art?

For the programing morons, this question is associated with erudition.
It certainly is a hip subject among hackers such as those hardcore
Perl advocates and unix proponents, who would casually hint on such
realization, impressing a sophistication among peers.

Such a question is not uncommon among those curious. For example, “Is
mathematics science or art?”, is the same type of question that has
been broached by dabblers now and then. We can also detect such
dilemma in the titles conferred to blathering computer jockeys: which
one are thee: baccalaureate of science or baccalaureate of arts? It
really makes no fucking difference.

Ultimately, fantastically stupid questions like these are not
discussed by mathematicians nor philosophers. These are natural
language side-effects, trapping dummies to fuzz about nothing; not
unlike quotations.

For these computing jockeys, there remains the question of why Knuth
named his books the “Art” of Computer Programing, or why some
computing luminaries litter the caution that programing is as much a
art as science. What elite dimwits need to realize is that these
authors are not defining or correcting, but breaking precepts among
the automatons in programing industry.

To the readers of hip literature, words like science and art are
spellbinding, and the need to pigeonhole is imminent. Of these
ruminating class of people, the problem lies in their wanting of
originality. What fills their banal brain are the stale food of
thought that has been chewed and spewed. These above-average eggheads
mop up the scholastic tidbits of its day to mull and muse with fellow
eggheads. They could not see new perspectives. Could not understand
gists. Could not detect non-questions. They are the holder and passer
of knowledge, a bucket of pre-digested purees. Their train of thought
forever loops around established tracks — going nowhere, anytime!

So, is programing a art or science? is it art or science? I really
need to know.

 • Theory vs Practice
 • Jargons of IT Industry
 • The Lambda Logo Tour
 • English Lawers

PS don't forget to checkout: 〈From Why Not Ruby to Fuck Python, Hello
Ruby〉 @ http://xahlee.org/UnixResource_dir/writ/why_not_Ruby.html

yours humbly,

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


Google Tech Talk: lisp at JPL

2012-04-02 Thread Xah Lee
Dearly beloved lisperati,

I present you, Ron Garret (aka Erann Gat — aka Naggum hater and enemy
of Kenny Tilton), at Google Tech Talk

〈The Remote Agent Experiment: Debugging Code from 60 Million Miles
Away〉
Google Tech Talk, (2012-02-14) Presented by Ron Garret. @
http://www.youtube.com/watch?v=_gZK0tW8EhQ

i just started watching, havn't done yet.

(thx jcs's blog for the news)

PS posted to python and perl forums too, because i think might be
interesting for lang aficionados . Reply to just your community
please.

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


Re: Is Programing Art or Science?

2012-04-03 Thread Xah Lee
On Apr 3, 8:22 am, Rainer Weikusat  wrote:
> Xah Lee  writes:
>
> [...]
>
> > For example, “Is mathematics science or art?”, is the same type of
> > question that has been broached by dabblers now and then.
>

 http://en.wikipedia.org/wiki/Liberal_arts

this is the best reply in this thread!

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


how i loved lisp cons and UML and Agile and Design Patterns and Pythonic and KISS and YMMV and stopped worrying

2012-04-07 Thread Xah Lee
OMG, how i loved lisp cons and macros and UML and Agile eXtreme
Programing and Design Patterns and Anti-Patterns and Pythonic and KISS
and YMMV and stopped worrying.

〈World Multiconference on Systemics, Cybernetics and Informatics???〉
http://xahlee.org/comp/WMSCI.html

highly advanced plain text format follows, as a amenity for tech
geekers.

---
World Multiconference on Systemics, Cybernetics and Informatics ???

Xah Lee, 2010-04-04

Starting in 2004, i regularly receive email asking me to participate a
conference, called “World Multiconference on Systemics, Cybernetics
and Informatics” (WMSCI). Here's one of such email i got today:


Dear Xah Lee:

As you know the Nobel Laureate Herbert Simon affirmed that design is
an essential ingredient of the Artificial Sciences Ranulph Glanville,
president of the American Society for Cybernetics and expert in design
theory, affirms that “Research is a variety of design. So do research
as design. Design is key to research. Research has to be designed.” An
increasing number of authors are stressing the relationships between
Design and Research. Design is a mean for Research, and Research is a
mean for Design. Design and research are related via cybernetic loops
in the context of means-ends logic. Consequently, we invite you to
submit a paper/abstract and/ot to organize an invited session in the
International Symposium on Design and Research in the Artificial and
the Natural Sciences: DRANS 2010 (http://www.sysconfer.org/drans)
which is being organized in the context of The 14th World Multi-
Conference on Systemics, Cybernetics and Informatics: WMSCI 2010
(http://www.sysconfer.org/wmsci), 2010 in Orlando, Florida, USA.

…

Here's the first email i got from them from my mail archive:

 From: sci2...@iiis.org
Subject: Inviting you to participate in SCI 2005
Date: October 20, 2004 1:39:48 PM PDT
To: x...@xahlee.org

 Dear Dr. Xah Lee:

On behalf of the SCI 2005 Organizing Committee, I would like to invite
you to participate in the 9th World Multi-Conference on Systemics,
Cybernetics and Informatics (http://www.iiisci.org/sci2005), which
will take place in Orlando, Florida, USA, from July 10-13, 2005.

Full text wmsci.txt.

I do not know this organization. I don't know how they got my email or
how they know that i'm involved in the computer science community.
(surely from trawling email addresses in science forums) Though, after
getting a few of their emails, one clearly gets a sense that it is a
scam, soliciting innocent idiotic academicians (many PhDs are
idiots.).

Here's what Wikipedia has to say about them: World Multiconference on
Systemics, Cybernetics and Informatics. Here's a juicy quote:


WMSCI attracted publicity of a less favorable sort in 2005 when three
graduate students at MIT succeeded in getting a paper accepted as a
“non-reviewed paper” to the conference that had been randomly
generated by a computer program called SCIgen.[8] Documents generated
by this software have been used to submit papers to other similar
conferences. Compare to the Sokal affair.

WMSCI has been accused of using spam to advertise its conferences.[8]

Now and then, whenever i got their email, the curiosity in me do
lookup the several terms they used in the email, partly to check the
validity. For example, in this one, it mentions Herbert Simon. Another
one i recall i got recently mentioned Science 2.0. Both of the terms i
haven't heard of before.

One'd think that it is easy to tell scam from real science, but with
today's science proliferation, it's actually not that easy. Even if
you are a academic, it's rather common that many new science terms you
never heard of, because there are tremendous growth of new disciplines
or cross disciplines, along with new jargons. Cross-discipline is
rather common and natural, unlike in the past where science is more or
less clearly delineated hierarchy like Physics, Math, Chemistry,
Biology, etc and their sub-branches. However, many of today's new
areas is a bit questionable, sometimes a deliberate money-making
scheme, which i suppose is the case for WMSCI. Many of these, use
terms like “post-modern”, “science 2.0” to excuse themselves from the
rather strict judgment of classic science. Many of these terms such as
“systemics”, “cybernetics”, “infomatics” are vague. Depending on the
context, it could be a valid emerging science discipline, but it could
also be pure new-age hogwash. And sometimes, nobody really knows
today. Fledgling scientific fields may started off as pseudo-science
but later became well accepted with more solid theories. (e.g.
evolutionary psychology)

In the past 2 decades, there are quite a few cases where peer reviewed
papers published in respected journals are exposed as highly
questionable or deliberate hoax, arose massive debate on the peer
review system. The peer-review system itself can't hold all the blame,
bu

f python?

2012-04-08 Thread Xah Lee
hi guys,

sorry am feeling a bit prolifit lately.

today's show, is: 〈Fuck Python〉
http://xahlee.org/comp/fuck_python.html


Fuck Python
 By Xah Lee, 2012-04-08

fuck Python.

just fucking spend 2 hours and still going.

here's the short story.

so recently i switched to a Windows version of python. Now, Windows
version takes path using win backslash, instead of cygwin slash. This
fucking broke my find/replace scripts that takes a dir level as input.
Because i was counting slashes.

Ok no problem. My sloppiness. After all, my implementation wasn't
portable. So, let's fix it. After a while, discovered there's the
「os.sep」. Ok, replace 「"/"」 to 「os.sep」, done. Then, bang, all hell
went lose. Because, the backslash is used as escape in string, so any
regex that manipulate path got fucked majorly. So, now you need to
find a quoting mechanism. Then, fuck python doc incomprehensible
scattered comp-sci-r-us BNF shit. Then, fuck python for “os.path” and
“os” modules then string object and string functions inconsistent
ball. And FUCK Guido who wants to fuck change python for his idiotic
OOP concept of “elegance” so that some of these are deprecated.

So after several exploration of “repr()”, “format()”, “‹str›.count()”,
“os.path.normpath()”, “re.split()”, “len(re.search().group())” etc,
after a long time, let's use “re.escape()”. 2 hours has passed. Also,
discovered that “os.path.walk” is now deprecated, and one is supposed
to use the sparkling “os.walk”. In the process of refreshing my
python, the “os.path.walk” semantics is really one fucked up fuck.
Meanwhile, the “os.walk” went into incomprehensible OOP object and
iterators fuck.

now, it's close to 3 hours. This fix is supposed to be done in 10 min.
I'd have done it in elisp in just 10 minutes if not for my
waywardness.

This is Before

def process_file(dummy, current_dir, file_list):
   current_dir_level = len(re.split("/", current_dir)) -
len(re.split("/", input_dir))
   cur_file_level = current_dir_level+1
   if min_level <= cur_file_level <= max_level:
  for a_file in file_list:
 if re.search(r"\.html$", a_file, re.U) and
os.path.isfile(current_dir + "/" + a_file):
replace_string_in_file(current_dir + "/" + a_file)

 This is After

def process_file(dummy, current_dir, file_list):
   current_dir = os.path.normpath(current_dir)
   cur_dir_level = re.sub( "^" + re.escape(input_dir), "",
current_dir).count( os.sep)
   cur_file_level = cur_dir_level + 1
   if min_level <= cur_file_level <= max_level:
  for a_file in file_list:
 if re.search(r"\.html$", a_file, re.U) and
os.path.isfile(current_dir + re.escape(os.sep) + a_file):
replace_string_in_file(current_dir + os.sep + a_file)
# print "%d %s" % (cur_file_level, (current_dir + os.sep +
a_file))

 Complete File

# -*- coding: utf-8 -*-
# Python

# find & replace strings in a dir

import os, sys, shutil, re

# if this this is not empty, then only these files will be processed
my_files  = []

input_dir = "c:/Users/h3/web/xahlee_org/lojban/hrefgram2/"
input_dir = "/cygdrive/c/Users/h3/web/zz"
input_dir = "c:/Users/h3/web/xahlee_org/"

min_level = 2; # files and dirs inside input_dir are level 1.
max_level = 2; # inclusive

print_no_change = False

find_replace_list = [

(
u"""http://xahlee.org/
footer.html">""",
u"""""",
),

]

def replace_string_in_file(file_path):
   "Replaces all findStr by repStr in file file_path"
   temp_fname = file_path + "~lc~"
   backup_fname = file_path + "~bk~"

   # print "reading:", file_path
   input_file = open(file_path, "rb")
   file_content = unicode(input_file.read(), "utf-8")
   input_file.close()

   num_replaced = 0
   for a_pair in find_replace_list:
  num_replaced += file_content.count(a_pair[0])
  output_text = file_content.replace(a_pair[0], a_pair[1])
  file_content = output_text

   if num_replaced > 0:
  print "◆ ", num_replaced, " ", file_path.replace("\\", "/")
  shutil.copy2(file_path, backup_fname)
  output_file = open(file_path, "r+b")
  output_file.read() # we do this way instead of “os.rename” to
preserve file creation date
  output_file.seek(0)
  output_file.write(output_text.encode("utf-8"))
  output_file.truncate()
  output_file.close()
   else:
  if print_no_change == True:
 print "no change:", file_path

#  os.remove(file_path)
#  os.rename(temp_fname, file_path)

def process_file(dummy, current_dir, file_list):
   current_dir = os.path.normpath(current_dir)
   cur_dir_level = re.sub( "^" + re.escape

Re: f python?

2012-04-08 Thread Xah Lee
On Apr 8, 4:34 am, Steven D'Aprano  wrote:
> On Sun, 08 Apr 2012 04:11:20 -0700, Xah Lee wrote:
>
> [...]
>
> I have read Xah Lee's post so that you don't have to.
>
> Shorter Xah Lee:
>
>     "I don't know Python very well, and rather than admit I made
>      some pretty lousy design choices in my code, I blame Python.
>      And then I cross-post about it, because I'm the most important
>      person in the Universe."
>
> When the only tool you know how to use is a hammer, everything looks like
> a nail. Instead of using regexes ("now you have two problems"), use the
> right tool: to count path components, split the path, then count the
> number of path components directly.
>
> import os
> components = os.path.split(some_path)
> print len(components)
>
> No matter what separator the OS users, os.path.split will do the right
> thing. There's no need to mess about escaping separators so you can
> hammer it with the regex module, when Python comes with the perfectly
> functional socket-wrench you actually need.

Lol. i think you tried to make fun of me too fast.

check your code.

O, was it you who made fun of my python tutorial before? i was busy,
i'll have to get back on that down the road.

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


Re: f python?

2012-04-08 Thread Xah Lee
Xah Lee wrote:

« http://xahlee.org/comp/fuck_python.html »

David Canzi wrote

«When Microsoft created MS-DOS, they decided to use '\' as the
separator in file names.  This was at a time when several previously
existing interactive operating systems were using '/' as the file name
separator and at least one was using '\' as an escape character.  As a
result of Microsoft's decision to use '\' as the separator, people
have had to do extra work to adapt programs written for Windows to run
in non-Windows environments, and vice versa.  People have had to do
extra work to write software that is portable between these
environments.  People have done extra work while creating tools to
make writing portable software easier.  And people have to do extra
work when they use these tools, because using them is still harder
than writing portable code for operating systems that all used '/' as
their separator would have been.»

namekuseijin wrote:

> yes, absolutely.  But you got 2 inaccuracies there:  1) Microsoft didn't 
> create DOS; 2) fucking DOS was written in C, and guess what, it uses \ as 
> escape character.  Fucking microsoft.
>
> > So, when you say fuck Python, are you sure you're shooting at the
> > right target?
>
> I agree.  Fuck winDOS and fucking microsoft.

No. The choice to use backslash than slash is actually a good one.

because, slash is one of the useful char, far more so than backslash.
Users should be able to use that for file names.

i don't know the detailed history of path separator, but if i were to
blame, it's fuck unix. The entirety of unix, unix geek, unixers, unix
fuckheads. Fuck unix.

〈On Unix Filename Characters Problem〉
http://xahlee.org/UnixResource_dir/writ/unix_filename_chars.html

〈On Unix File System's Case Sensitivity〉
http://xahlee.org/UnixResource_dir/_/fileCaseSens.html

〈UNIX Tar Problem: File Length Truncation, Unicode Name Support〉
http://xahlee.org/comp/unix_tar_problem.html

〈What Characters Are Not Allowed in File Names?〉
http://xahlee.org/mswin/allowed_chars_in_file_names.html

〈Unicode Support in File Names: Windows, Mac, Emacs, Unison, Rsync,
USB, Zip〉
http://xahlee.org/mswin/unicode_support_file_names.html

〈The Nature of the Unix Philosophy〉
http://xahlee.org/UnixResource_dir/writ/unix_phil.html

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


Emacs Lisp vs Perl: Validate Local File Links

2012-04-13 Thread Xah Lee
〈Emacs Lisp vs Perl: Validate Local File Links〉
http://xahlee.org/emacs/elisp_vs_perl_validate_links.html

a comparison of 2 scripts.

lots code, so i won't paste plain text version here.

i have some comments at the bottom. Excerpt:

--

«One thing interesting is to compare the approaches in perl and emacs
lisp.»

«For our case, regex is not powerful enough to deal with the problem
by itself, due to the nested nature of html. This is why, in my perl
code, i split the file by < into segments first, then, use regex to
deal with now the non-nested segment. This will break if you have math. This cannot be worked
around unless you really start to write a real parser.»

«The elisp here is more powerful, not because of any lisp features,
but because emacs's buffer datatype. You can think of it as a
glorified string datatype, that you can move a cursor back and forth,
or use regex to search forward or backward, or save cursor positions
(index) and grab parts of text for further analysis.»

--

If you are a perl coder, and disagree, let me know your opinion.
(showing working code is very welcome) My comment about perl there
applies to python too. (python code welcome too.)

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


sort by column a csv file case insensitive

2012-04-15 Thread Lee Chaplin
Hi all,

I am trying to sort, in place, by column, a csv file AND sort it case
insensitive.
I was trying something like this, with no success:

import csv
import operator

def sortcsvbyfield(csvfilename, columnnumber):
  with open(csvfilename, 'rb') as f:
readit = csv.reader(f)
thedata = list(readit)

  thedata = sorted(thedata, key = lambda x:
(operator.itemgetter(columnnumber) ,x[0].lower()))  #!!!
  with open(csvfilename, 'wb') as f:
writeit = csv.writer(f)
writeit.writerows(thedata)

The line marked is the culprit.
Any help is greatly appreciated.

Thanks,
Lee
-- 
http://mail.python.org/mailman/listinfo/python-list


sort by column a csv file case insensitive

2012-04-16 Thread Lee Chaplin
Well, if I have a file like this one:

EWIENER,
edit,
edgard,
evan,
erick,
elliott,
enquiries,
Elliott,

I would like to get something like this (sorted by column 4 and case
insensitive):

edgard,
edit,
elliott,
Elliott,
enquiries,
erick,
evan,
EWIENER,

(Obviously, there are more data in the other columns, I edited the
file for clarity.)

>From the previous email I would like to call:
sortcsvbyfield('e.txt', 4)

I am on python 2.6 on Win.

Thanks,
Lee
-- 
http://mail.python.org/mailman/listinfo/python-list


A Design Pattern Question for Functional Programers

2012-04-18 Thread Xah Lee
Functional programing is getting the presses in mainstream. I ran
across this dialogue where a imperative coder was trying to get into
functional programing:

  A: What are the design patterns that help structure functional
systems?

  B: Design patterns? Hey everyone, look at the muggle try to get the
wand to work!

from:
〈Code Watch: Functional programming's smugness problem〉 (2012-04-16)
By By Larry O'brien. @ 
http://www.sdtimes.com/content/article.aspx?ArticleID=36534

hi, my dearly beloved C++ java perl python hackers, design pattern
your mom!

further readings:

〈Why Software Suck〉
http://xahlee.org/UnixResource_dir/writ/why_software_suck.html

〈What is a Tech Geeker?〉
http://xahlee.org/UnixResource_dir/writ/tech_geeker.html

〈Book Review: Patterns of Software〉
http://xahlee.org/PageTwo_dir/Personal_dir/bookReviewRichardGabriel.html

〈Are You Intelligent Enough to Understand HTML5?〉
http://xahlee.org/UnixResource_dir/writ/html5_vs_intelligence.html

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


Re: ANN: cmd2, an extenstion of cmd that parses its argument line

2012-04-26 Thread anntzer . lee
I have renamed the project to parsedcmd, which is also a better description of 
what the module does.
https://github.com/anntzer/parsedcmd

On Monday, March 19, 2012 6:14:44 AM UTC-7, xDog Walker wrote:
> On Sunday 2012 March 18 22:11, anntzer@gmail.com wrote:
> > I would like to announce the first public release of cmd2, an extension of
> > the standard library's cmd with argument parsing, here:
> > https://github.com/anntzer/cmd2.
> 
> There already is a cmd2 package at PyPI and has been for a long time.
> 
> http://packages.python.org/cmd2/
> 
> -- 
> I have seen the future and I am not in it.

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


Re: cmd2, an extenstion of cmd that parses its argument list

2012-04-26 Thread anntzer . lee
On Sunday, March 18, 2012 10:12:24 PM UTC-7, anntz...@gmail.com wrote:
> Dear all,
> 
> I would like to announce the first public release of cmd2, an extension of 
> the standard library's cmd with argument parsing, here: 
> https://github.com/anntzer/cmd2.
> 
Due to an already existing Cmd2 on PyPI, I have renamed the project to 
parsedcmd, which is also a better description of what the module does.
https://github.com/anntzer/parsedcmd 

> Cmd2 is an extension built around the excellent cmd module of the standard
> library.  Cmd allows one to build simple custom shells using ``do_*`` methods,
> taking care in particular of the REPL loop and the interactive help.  However,
> no facility is given for parsing the argument line (do_* methods are passed 
> the
> rest of the line as a single string argument).
> 
> With Cmd2, ``do_*`` methods are type-annotated, either using Python 3's
> function annotation syntax, or with an ad-hoc ``annotate`` decorator, allowing
> the dispatcher to parse the argument list for them.
> 
> Antony Lee

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


John Carmack glorifying functional programing in 3k words

2012-04-26 Thread Xah Lee
John Carmack glorifying functional programing in 3k words

http://www.altdevblogaday.com/2012/04/26/functional-programming-in-c/

where was he ten years ago?

O, and btw, i heard that Common Lispers don't do functional
programing, is that right?

Fuck Common Lispers. Yeah, fuck them. One bunch of Fuckfaces. (and
Fuck Pythoners. Python fucking idiots.)

O, don't forget,

〈Programing: What are OOP's Jargons and Complexities (Object Oriented
Program as Functional Program)〉
http://xahlee.org/Periodic_dosage_dir/t2/oop.html

please you peruse of it.

your servant, humbly

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


Learn Technical Writing from Unix Man in 10 Days

2012-04-28 Thread Xah Lee
Learn Technical Writing from Unix Man in 10 Days

Quote from man apt-get:

remove
remove is identical to install except that packages are
removed
instead of installed.

Translation:

kicking
kicking is identical to kissing except that receiver is kicked
instead of kissed.

further readings:

• 〈The Idiocy of Computer Language Docs〉
http://xahlee.org/comp/idiocy_of_comp_lang.html

• 〈Why Open Source Documentation is of Low Quality〉
http://xahlee.org/UnixResource_dir/writ/gubni_papri.html

• 〈Python Documentation Problems〉
http://xahlee.org/perl-python/python_doc_index.html



DISAPPEARING URL IN DOC

so, i was reading man git. Quote:

Formatted and hyperlinked version of the latest git documentation
can
be viewed at http://www.kernel.org/pub/software/scm/git/docs/.

but if you go to that url, it shows a list of over one hundred fourty
empty dirs.

I guess unix/linux idiots can't be bothered to have correct
documentation. Inability to write is one thing, but they are unable to
maintain a link or update doc?

does this ever happens to Apple's docs? If it did, i don't ever recall
seeing it from 18 years of using Mac.

more records of careless dead link:

• 〈Hackers: Dead Links and Human Compassion?〉
http://xahlee.org/comp/hacker_dead_links_and_compassion.html

• 〈Why Qi Lisp Fails and Clojure Succeeds〉
http://xahlee.org/UnixResource_dir/writ/qi_lang_marketing.html

• 〈unix: Hunspell Path Pain〉
http://xahlee.org/comp/hunspell_spell_path_pain.html

• 〈Python Doc URL disappearance〉
http://xahlee.org/perl-python/python_doc_url_disappearance.html

• 〈A Record of Frustration in IT Industry; Disappearing FSF URLs〉
http://xahlee.org/emacs/gnu_doc.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Learn Technical Writing from Unix Man in 10 Days

2012-04-29 Thread Xah Lee
On Apr 29, 7:43 pm, Jason Earl  wrote:
> On Sat, Apr 28 2012, Steven D'Aprano wrote:
> > On Sat, 28 Apr 2012 14:55:42 -0700, Xah Lee wrote:
>
> >> Learn Technical Writing from Unix Man in 10 Days
>
> >> Quote from man apt-get:
>
> >>     remove
> >>         remove is identical to install except that packages are
> >> removed
> >>         instead of installed.
>
> > Do you also expect the documentation to define "except", "instead", "is",
> > "to" and "the"?
>
> > If you don't know what "install" and "remove" means, then you need an
> > English dictionary, not a technical manual.
>
> It is considerably worse than that.  If you look at what the
> documentation for apt-get actually says, instead of just the badly
> mangled version that Xah shares you would realize that the post was
> basically a bald-face troll.
>
> The rest of Xah's links in this particular article was even worse.  For
> the most part he was criticizing documentation flaws that have
> disappeared years ago.
>
> Heck, his criticism of Emacs' missing documentation has been fixed since
> Emacs 21 (the Emacs developers are currently getting ready to release
> Emacs 24).  His criticism of git's documentation is also grossly
> misleading.  kernel.org still has the empty directories, but git-scm.org
> has been the official home for git's documentation for years.
>
> I am sure that the rest of the examples are just as ridiculous.  I tend
> to like Xah's writing.  Heck, I even sent a few bucks his way as thanks
> for his Emacs Lisp tutorials.  However, that particular post was simply
> ridiculous.
>
> Jason

jason, are you trolling me, or me you?

☺

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


issubclass(C, Mapping) not behaving as expected

2012-05-30 Thread anntzer . lee
from collections import *
class C(object):
def __iter__(self): pass
def __contains__(self, i): pass
def __len__(self): pass
def __getitem__(self, i): pass
issubclass(C, Mapping) => False
[issubclass(C, cls) for cls in Mapping.__mro__] => [False, True, True, True, 
True]
i.e. C does implement Sized, Iterable and Container.

I would have expected that just as issubclass(C, Sized) checks for the presence 
of a "__len__" method, issubclass(C, Mapping) would check for the presence of 
the three methods required by each immediate superclass?

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


Re: cmd2, an extenstion of cmd that parses its argument list

2012-05-31 Thread Antony Lee
I am already using shlex.split() (this is a customizable hook).

On Thu, May 31, 2012 at 03:42:19PM -0400, Adam Tauno Williams wrote:
> On Thu, 2012-05-31 at 15:21 -0400, Adam Tauno Williams wrote: 
> > On Thu, 2012-04-26 at 12:16 -0700, anntzer@gmail.com wrote: 
> > > On Sunday, March 18, 2012 10:12:24 PM UTC-7, anntz...@gmail.com wrote:
> > > > Dear all,
> > > > I would like to announce the first public release of cmd2, an extension 
> > > > of the standard library's cmd with argument parsing, here: 
> > > > https://github.com/anntzer/cmd2.
> > > Due to an already existing Cmd2 on PyPI, I have renamed the project to 
> > > parsedcmd, which is also a better description of what the module does.
> > > https://github.com/anntzer/parsedcmd 
> > > > Cmd2 is an extension built around the excellent cmd module of the 
> > > > standard
> > > > library.  Cmd allows one to build simple custom shells using ``do_*`` 
> > > > methods,
> > > > taking care in particular of the REPL loop and the interactive help.  
> > > > However,
> > > > no facility is given for parsing the argument line (do_* methods are 
> > > > passed the
> > > > rest of the line as a single string argument).
> > > > With Cmd2, ``do_*`` methods are type-annotated, either using Python 3's
> > > > function annotation syntax, or with an ad-hoc ``annotate`` decorator, 
> > > > allowing
> > > > the dispatcher to parse the argument list for them.
> > This is much the same functionality added to Cmd by Cmd2.
> > Perhaps you could collaborate with Cmd2's author and merge your two
> > extensions.
> 
> Since you split() the string in argument parsing document values cannot
> contain whitespace; such as -file="Yo Yo Ma Ma.txt".  Perhaps using
> shlex() or some other means to initially break-up the strings would be a
> better option?
> 


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


Career related question

2012-06-07 Thread Stanley Lee
Hey all,

Can I only post jobs on Python's official website, or can I also
direct the message to the appropriate mailing list in http://mail.python.org/
? Btw, do I have to be a subscriber of a given list in order to submit
messages?

Thanks in advance,

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


[ANNC] vbot-0.3

2012-06-17 Thread Lee Harr

vBot is a visual programming game.
    Use a small set of command tiles to build a program.
    The program must control the vBot and make it activate
    every target using the limited command set.

It is meant to be an easy environment for introducing
    some programming concepts to beginning programmers.


https://bitbucket.org/leeharr/vbot


This release adds several new levels and organizes them by
    level of difficulty. It also adds several new features.


vBot is tested with Python 2.7.3 and PyQt 4.9.1

vBot is released under GPLv3.


Changes in vbot-0.3:
    - Added success dialog with option to go to next level
    - Sorted levels by difficulty and concept
    - Added utility for re-sorting levels by difficulty
    - Backspace key removes last tile in active function
    - Added ability to remember a player's completed levels online
    - server code not included with this distribution...

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


uhmm... your chance to spit on me

2011-06-10 Thread Xah Lee
Dear lisp comrades, it's Friday!

Dear Xah, your writing is:

• Full of bad grammar. River of Hiccups.

• Stilted. Chocked under useless structure and logic.

• WRONG — Filled with uncouth advices.

• Needlessly insulting. You have problems.

• Simply stinks. Worthless.

• Mediocre. Just like everybody, admit it.

• I love it.

• Your writing is pro!

• you are genius! one of the great expositor, eassyist.

• Dude, you are full of shit. I've not seen a crank quite like
you.

Vote at: http://xahlee.blogspot.com/2011/06/xahs-writing-is.html.

 Xah
 (i code python small time too)
-- 
http://mail.python.org/mailman/listinfo/python-list


Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-11 Thread Xah Lee
(a lil weekend distraction from comp lang!)

in recent years, there came this Colemak layout. The guy who created
it, Colemak, has a site, and aggressively market his layout. It's in
linuxes distro by default, and has become somewhat popular.

I remember first discovering it perhaps in 2007. Me, being a Dvorak
typist since 1994, am curious on what he has to say about comparison.
I recall, i was offended seeing how he paints a bias in peddling his
creation.

So, here, let me repaint his bias. Here it is, and judge for yourself.

〈Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the
Dvorak Layout?〉
http://xahlee.org/kbd/dvorak_vs_colemak.html

here's a interesting excerpt:


Just How Much Do You Type?

Many programers all claim to type 8 or 10 hours a day. They may be
sitting in front of the computer all day, but the time their fingers
actually dance on keyboard is probably less than 1 hour per day.

Contrast data-entry clerks. They are the real typists. Their fingers
actually type, continuously, for perhaps 6 hours per day.

It is important get a sense of how much you actually type. This you
can do by logging you keystrokes using a software.

Let's assume a pro typist sustain at 60 wpm. 60 wpm is 300 strokes per
min, or 18k per hour. Suppose she works 8 hours a day, and assume just
3 hours actually typing. 18k × 3 = 54k chars per day. With this
figure, you can get a sense of how many “hours” you actually type per
day.

I sit in front of computer on average 13 hours per day for the past
several years. I program and write several blogs. My actual typing is
probably double or triple of average day-job programers. From my emacs
command frequency log for 6 months in 2008, it seems i only type 17k
strokes per day. That's 31% of the data-entry clerk scenario above.
Or, i only type ONE hour a day!

I was quite surprised how low my own figure is. But thinking about it…
it make sense. Even we sit in front of computer all day, but the
actual typing is probably some miniscule percentage of that. Most of
the time, you have to chat, lunch, run errands, browse web, read docs,
run to the bathroom. Perhaps only half of your work time is active
coding or writing (emails; docs). Of that duration, perhaps majority
of time you are digesting the info on screen. Your whole day's typing
probably can be done in less than 20 minutes if you just type
continuously.

If your typing doesn't come anywhere close to a data-entry clerk, then
any layout “more efficient” than Dvorak is practically meaningless.

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


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-13 Thread Xah Lee

On Jun 13, 6:45 pm, Gregory Ewing  wrote:
> Chris Angelico wrote:
> > And did any of the studies take into account the fact that a lot of
> > computer users - in all but the purest data entry tasks - will use a
> > mouse as well as a keyboard?
>
> What I think's really stupid is designing keyboards with two
> big blocks of keys between the alphabetic keys and the mouse.
> Back when standard-grade keyboards didn't usually have a
> built-in numeric keypad, it was much easier to move one's
> right hand back and forth between the keyboard and mouse.
>
> Nowadays I find myself perpetually prone to off-by-one errors
> when moving back to the keyboard. :-(

numerical keypad is useful to many. Most people can't touch type. Even
for touch typist, many doesn't do the number keys. So, when they need
to type credit, phone number, etc, they go for the number pad. Also, i
think the number pad esentially have become a calculator for vast
majority of computer users. These days, almost all keyboard from
Microsoft or Logitech has a Calculator button near the number pad to
launch it.

i myself, am a qwerty typist since ~1987, also worked as data entry
clerk for a couple of years. Am a dvorak touch typist since 1994. (and
emacs since 1997) However, i never learned touch type the numbers on
the main section till i think ~2005. Since about 2008, the numerical
keypad is used as extra function keys.

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


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-14 Thread Xah Lee
On Jun 13, 6:19 am, Steven D'Aprano 〔steve
+comp.lang.pyt...@pearwood.info〕 wrote:

│ I don't know if there are any studies that indicate how much of a
│ programmer's work is actual mechanical typing but I'd be surprised
if it
│ were as much as 20% of the work day. The rest of the time being
thinking,
│ planning, debugging, communicating with customers or managers,
reading
│ documentation, testing, committing code, sketching data schemas on
the
│ whiteboard ... to say nothing of the dreaded strategy meetings.

you can find the study on my site. URL in the first post of this
thread.

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


Re: Keyboard Layout: Dvorak vs. Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-14 Thread Xah Lee


Ba Wha 13, 7:23 nz, Ehfgbz Zbql 〔ehfgbzcz...@tznvy.pbz〕 jebgr:
│ Qibenx -- yvxr djregl naq nal bgure xrlobneq ynlbhg -- nffhzrf gur
│ pbzchgre vf n glcrjevgre.
│ Guvf zrnaf va rssrpg ng yrnfg gjb pbafgenvagf, arprffnel sbe gur
│ glcrjevgre ohg abg sbe gur pbzchgre:
│
│ n. Gur glcvfg pna glcr bayl 1 xrl ng n gvzr
│ o. Bar (xrl)fgebxr trarengrf rknpgyl 1 yrggre
│
│ Rkprcgvbaf gb [n] ner Fuvsg (Pgey) rgp ohg pyrneyl va ehaavat hfr
gurl
│ ner gur rkprcgvba abg gur ehyr.
│
│ │ Jurer fcrrq ernyyl vf ivgny, fhpu nf sbe pbheg fgrabtencuref,
fcrpvny zrpunavpny
│ │ fubegunaq znpuvarf fhpu nf fgrabglcrf ner hfrq, pbfgvat gubhfnaqf
bs qbyynef ohg nyybjvat
│ │ gur glcvfg gb ernpu fcrrqf bs bire 300 jcz.
│
│ Lrf, vafgehzragf yvxr fgrabglcrf fcrrq hc glcvat ol hanffhzvat [n]
│ Yvxrjvfr cvnavfgf pna or fnvq (naq frra) gb qb zber ng gur cvnab
guna
│ glcvfgf ng n pbzchgre orpnhfr pubeqf ner cneg bs gur 'nyybjrq
│ ynathntr'.
│
│ Nffhzcgvba [o] yvxrjvfr vf haarprffnevyl erfgevpgvir ba n pbzchgre.
│ Guvax bs nyy gur 'nooeri/favccrg/fubegsbez/grzcyngr' flfgrzf yvxr
│ lnfavccrg, grkgzngr-favccrgf, rznpf/iv nooerif rgp.
│
│ Sbe beqvanel Ratyvfu gurer ner guvatf yvxr 
xrlfpevcguggc://jjj.serrjrof.pbz/pnfflwnarx
│
│ Sbe rknzcyr gur zbfg pbzzba jbeqf (rfgvzngrq gb or nebhaq 40% bs
│ Ratyvfu) ner fubegsbezrq nf:
│ o = ohg
│ p = jvgu
│ q = unq
│ r = guvf
│ s = bs
│ t = gung
│ u = gur
│ w = juvpu
│ a = naq
│ ...rgp rgp hcgb
│ m = jnf
│
│ gura pbzzba cuenfrf
│ noyr gb  = po
│ unq orra = qa
│ qb abg   = qk
│ qvq abg  = rk
│ qbrf abg = qfk
│
│ rgp
│
│ Pyrneyl, sbe cebtenzzref guvf vf hayvxryl gb or zhpu hfr --
│ cebtenzzvat ynathntrf ner abg Ratyvfu.
│
│ Ohg ohg vg vf pregnvayl na bcra dhrfgvba jurgure vs gur ercrngvat
│ cnggreaf va cebtenzzvat ynathntrf ner pncgherq vagb fbzr flfgrz, gur
│ erfhygvat orarsvg jbhyq or n zrer zvpeb-bcgvzvmngvba be fbzrguvat
zber
│ fvtavsvpnag.  V unir frra fbzr tbbq cebtenzzref fjrne ol
│ rznpf-lnfavccrgf, grkgzngr-favccrgf rgp.

gurer'f fcrpvny vachg qrivprf qrfvtarq sbe pubeqvat, pnyyrq pubeqvat
xrlobneq. Gurer'f qngnunaq. Ybbx hc Jvxvcrqvn sbe n yvfg.

gurer'f nyfb xvarfvf naq bguref gung jbexf jvgu sbbg crqnyf. Fb, vg'f
yvxr pubeqvat jvgu lbhe srrg gbb. Rire frra gubfr penml betnavfg jvgu
srrg ohfl ba 30 crqnyf?

unir lbh gevrq ibvpr vachg? Jvaqbjf pbzrf jvgu vg. Cerggl tbbq.
Gubhtu, qbrfa'g jbex fb jryy jvgu nccf vzcyrzragrq bhgfvqr bs ZF'f
senzrjbex, fhpu nf rznpf.

fbzr cebtenzre'f fbyhgvbaf:

〈Pryroevgl Cebtenzref jvgu EFV (Ercrgvgvir Fgenva Vawhel)〉
 uggc://knuyrr.bet/rznpf/rznpf_unaq_cnva_pryroevgl.ugzy

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


Re: Keyboard Layout: Dvorak vs. Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-14 Thread Xah Lee
for some reason, was unable to post the previous message. (but can
post others) So, the message is rot13'd and it works. Not sure what's
up with Google groups. (this happened a few years back once.
Apparantly, the message content  might have something to do with it
because rot13 clearly works. Yet, the problem doesnt seem to be my
name or embedded url, since it only happens with the previous message)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-17 Thread Xah Lee
On Jun 14, 7:50 am, Dotan Cohen  wrote:
> On Mon, Jun 13, 2011 at 10:21, Elena  wrote:
> > On 13 Giu, 06:30, Tim Roberts  wrote:
> >> Studies have shown that even a
> >> strictly alphabetical layout works perfectly well, once the typist is
> >> acclimated.
>
> > Once the user is acclimated to move her hands much  more (about 40%
> > more for Qwerty versus Dvorak), that is.
>
> And disproportionate usage of fingers. On QWERTY the weakest fingers
> (pinkies) do almost 1/4 of the keypresses when modifier keys, enter,
> tab, and backspace are taken into account.
>
> I'm developing a QWERTY-based layout that moves the load off the
> pinkies and onto the index 
> fingers:http://dotancohen.com/eng/noah_ergonomic_keyboard_layout.html
>
> There is a Colemak version in the works as well.

u r aware that there are already tens of layouts, each created by
programer, thinking that they can create the best layout?

if not, check
〈Computer Keyboards, Layouts, Hotkeys, Macros, RSI ⌨〉
xahlee.org/Periodic_dosage_dir/keyboarding.html

on layout section. Lots people all creating layouts.

also, you want to put {Enter, Tab}, etc keys in the middle, but I
don't understand from ur website how u gonna do that since it requires
keyboard hardware modification. e.g. r u creating key layout on PC
keyboard or are you creating hardware keyboard Key layout? The former
is a dime a million, the latter is rare but also there are several
sites all trying to do it. Talk is cheap, the hardest part is actually
to get money to finance and manufacture it. The latest one, which i
deem good, is Truely Ergonomic keyboard. It sells for $200 and is in
pre-order only now.

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


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-17 Thread Xah Lee
On Jun 15, 5:43 am, rusi  wrote:
> On Jun 15, 5:32 pm, Dotan Cohen  wrote:
>
> > Thanks. From testing small movements with my fingers I see that the
> > fourth finger is in fact a bit weaker than the last finger, but more
> > importantly, it is much less dexterous. Good to know!
>
> Most of the piano technique-icians emphasis, especially those of the
> last century like Hanon, was to cultivate 'independence' of the
> fingers.  The main target of these attacks being the 4th finger.
>
> The number of potential-pianists who ruined their hands and lives
> chasing this holy grail is unknown

Hi rusi, am afaid going to contradict what u say here.

i pretty much mastered Hanon 60. All of it, but it was now 8 years
ago. The idea that pinky is stronger than 4th is silly. I can't fathom
any logic or science to support that. Perhaps what u meant is that in
many situations the use of pinky can be worked around because it in at
the edge of your hand so you can apply chopping motion or similar.
(which, is BAD if you want to develope piano finger skill) However,
that's entirely different than saying pinky being stronger than 4th.

there's many ways we can cookup tests right away to see. e.g. try to
squeeze a rubber ball with 4th and thumb. Repeat with pink + thumb.
Or, reverse exercise by stretching a rubber band wrapped on the 2
fingers of interest. You can easy see that pinky isn't stronger.

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


  1   2   3   4   5   6   7   8   9   10   >