Re: Extending the 'function' built-in class

2013-12-01 Thread Steven D'Aprano
On Sun, 01 Dec 2013 19:18:58 +, G. wrote: > Hi, I can't figure out how I can extend the 'function' built-in class. I > tried: > class test(function): > def test(self): > print("test") > but I get an error. Is it possible ? You cannot subclass the function type directly, but you c

Re: Checking Common File Types

2013-12-01 Thread rusi
On Monday, December 2, 2013 5:11:15 AM UTC+5:30, jade wrote: > > To: pytho...@python.org > > From: wlf...@ix.netcom.com > > Subject: Re: Checking Common File Types > > Date: Sun, 1 Dec 2013 18:23:22 -0500 > > > > On Sun, 1 Dec 2013 18:27:16 +, jade declaimed the > > following: > > > > >Hello

RE: Checking Common File Types

2013-12-01 Thread jade
> To: python-list@python.org > From: wlfr...@ix.netcom.com > Subject: Re: Checking Common File Types > Date: Sun, 1 Dec 2013 18:23:22 -0500 > > On Sun, 1 Dec 2013 18:27:16 +, jade declaimed the > following: > > >Hello, > >I'm trying to create a script that checks all the files in my 'down

Re: Extending the 'function' built-in class

2013-12-01 Thread alex23
On 2/12/2013 5:18 AM, G. wrote: Hi, I can't figure out how I can extend the 'function' built-in class. I tried: class test(function): def test(self): print("test") but I get an error. Is it possible ? Others have pointed out that you cannot subclass the function type. Could you

Re: Extending the 'function' built-in class

2013-12-01 Thread Mark Janssen
> Hi, I can't figure out how I can extend the 'function' built-in class. I > tried: > class test(function): > def test(self): > print("test") > but I get an error. Is it possible ? It has to do with differing models of computation, and python isn't designed for this. Perhaps you're s

Re: Need help with programming in python for class (beginner level)

2013-12-01 Thread Julio Schwarzbeck
On 11/29/2013 04:31 PM, farhan...@gmail.com wrote: It's for a school assignment. Basically, I need to roll 5 dies with 6 sides each. So basically, 6 random numbers. That part is easy. Then I need to add it up. Ok, done that. However, I also need to say something along the lines of "your total n

Re: Python Unicode handling wins again -- mostly

2013-12-01 Thread Mark Lawrence
On 01/12/2013 22:50, Ethan Furman wrote: On 12/01/2013 02:06 PM, Mark Lawrence wrote: I don't remember him [jmf] ever having a valid point, so FTR can we have a reference please. I do remember Steven D'Aprano showing that there was a regression which I flagged up here http://bugs.python.org/is

Re: Python Unicode handling wins again -- mostly

2013-12-01 Thread Ethan Furman
On 12/01/2013 02:06 PM, Mark Lawrence wrote: I don't remember him [jmf] ever having a valid point, so FTR can we have a reference please. I do remember Steven D'Aprano showing that there was a regression which I flagged up here http://bugs.python.org/issue16061. It was fixed by Serhiy Storch

Re: Python Unicode handling wins again -- mostly

2013-12-01 Thread Mark Lawrence
On 01/12/2013 22:29, Tim Delaney wrote: On 2 December 2013 09:06, Mark Lawrence mailto:breamore...@yahoo.co.uk>> wrote: I don't remember him ever having a valid point, so FTR can we have a reference please. I do remember Steven D'Aprano showing that there was a regression which I fl

Re: Checking Common File Types

2013-12-01 Thread Chris Angelico
On Mon, Dec 2, 2013 at 5:27 AM, jade wrote: > file_sigs = {'\xFF\xD8\xFF':('JPEG','jpg'), > '\x47\x49\x46':('GIF','gif')} > > file_sig = fh.read(4) You're reading in four bytes, but your signatures are three bytes long. :) After that, all you need to do is look up file_sig in the file_sigs

Re: Python Unicode handling wins again -- mostly

2013-12-01 Thread Tim Delaney
On 2 December 2013 09:06, Mark Lawrence wrote: > I don't remember him ever having a valid point, so FTR can we have a > reference please. I do remember Steven D'Aprano showing that there was a > regression which I flagged up here http://bugs.python.org/issue16061. It > was fixed by Serhiy Storc

Re: wiimote IR tracking in python

2013-12-01 Thread Johannes Findeisen
On Mon, 2 Dec 2013 05:59:07 +0800 martin koh wrote: > Hi all..may i know how to do the IR tracking by using wiimote? i did tried > the source code from > (http://ph-elec.com/archives/simple-python-wii-mote-test/) using command > prompt but i can't compile successfully, i think is because i don'

Re: Python Unicode handling wins again -- mostly

2013-12-01 Thread Mark Lawrence
On 01/12/2013 20:54, Tim Delaney wrote: On 2 December 2013 07:15, mailto:wxjmfa...@gmail.com>> wrote: 0.11.13 02:44, Steven D'Aprano написав(ла): > (2) If you reverse that string, does it give "lëon"? The implication of > this question is that strings should operate on grapheme

wiimote IR tracking in python

2013-12-01 Thread martin koh
Hi all..may i know how to do the IR tracking by using wiimote? i did tried the source code from (http://ph-elec.com/archives/simple-python-wii-mote-test/) using command prompt but i can't compile successfully, i think is because i don't have any idea how to import the cwiid module. Can anyone p

Checking Common File Types

2013-12-01 Thread jade
Hello, I'm trying to create a script that checks all the files in my 'downloaded' directory against common file types and then tells me how many of the files in that directory aren't either a GIF or a JPG file. I'm familiar with basic Python but this is the first time I've attempted anything li

Re: Python Unicode handling wins again -- mostly

2013-12-01 Thread Tim Delaney
On 2 December 2013 07:15, wrote: > 0.11.13 02:44, Steven D'Aprano написав(ла): > > (2) If you reverse that string, does it give "lëon"? The implication of > > this question is that strings should operate on grapheme clusters rather > > than code points. ... > > > > BTW, a grapheme cluster *is* a

Re: Python Unicode handling wins again -- mostly

2013-12-01 Thread wxjmfauth
0.11.13 02:44, Steven D'Aprano написав(ла): > (2) If you reverse that string, does it give "lëon"? The implication of > this question is that strings should operate on grapheme clusters rather > than code points. ... > BTW, a grapheme cluster *is* a code points cluster. jmf -- https://mail.pyth

Re: Extending the 'function' built-in class

2013-12-01 Thread Robert Kern
On 2013-12-01 19:43, Tim Chase wrote: I'm not quite sure *why* one might want to subclass FunctionType, but I'm also not sure why you should be *prevented* from subclassing it. Previously: http://grokbase.com/t/python/python-list/033r5nks47/type-function-does-not-subtype#20030324rcnwbkfedhzba

Re: Extending the 'function' built-in class

2013-12-01 Thread G.
Le 01-12-2013, Gary Herron a écrit : > And in particular: What 'function' built-in class? I know of no such > thing, and the error message I get with your code says exactly that: >NameError: name 'function' is not defined > Did you not get that same error? Yes, indeed. The 'function' built-

Re: Extending the 'function' built-in class

2013-12-01 Thread Gary Herron
On 12/01/2013 11:18 AM, G. wrote: Hi, I can't figure out how I can extend the 'function' built-in class. I tried: class test(function): def test(self): print("test") but I get an error. Is it possible ? Regards, G. What error do you get? What version of Python? What OS? And in

Re: Extending the 'function' built-in class

2013-12-01 Thread Tim Chase
On 2013-12-01 19:18, G. wrote: > Hi, I can't figure out how I can extend the 'function' built-in > class. I tried: class test(function): > def test(self): > print("test") > but I get an error. Is it possible ? While I don't have an answer, I did find this interesting. First, "function"

Re: Extending the 'function' built-in class

2013-12-01 Thread G.
Le 01-12-2013, Roy Smith a écrit : > > class foo(type(open)): > pass > > I get: > > Traceback (most recent call last): > File "", line 1, in > TypeError: Error when calling the metaclass bases > type 'builtin_function_or_method' is not an acceptable base type > > So, we're back to askin

Re: Extending the 'function' built-in class

2013-12-01 Thread Roy Smith
In article <529b8ba2$0$2270$426a7...@news.free.fr>, "G." wrote: > Hi, I can't figure out how I can extend the 'function' built-in class. I > tried: > class test(function): > def test(self): > print("test") > but I get an error. Is it possible ? > > Regards, G. It really helps to g

Extending the 'function' built-in class

2013-12-01 Thread G.
Hi, I can't figure out how I can extend the 'function' built-in class. I tried: class test(function): def test(self): print("test") but I get an error. Is it possible ? Regards, G. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Unicode handling wins again -- mostly

2013-12-01 Thread Serhiy Storchaka
30.11.13 02:44, Steven D'Aprano написав(ла): (2) If you reverse that string, does it give "lëon"? The implication of this question is that strings should operate on grapheme clusters rather than code points. Python fails this test: py> print("noe\u0308l"[::-1]) leon >>> print(unicodedata.norma

Re: Python Unicode handling wins again -- mostly

2013-12-01 Thread wxjmfauth
Le dimanche 1 décembre 2013 00:07:36 UTC+1, Ned Batchelder a écrit : > On 11/30/13 5:37 PM, Gregory Ewing wrote: > > > wxjmfa...@gmail.com wrote: > > >> And do you know the origin of this typographical feature? > > >> Because, mechanically, the dot of the "i" broke too often. > > >> > > >> In

Re: Change a file type in Python?

2013-12-01 Thread Steven D'Aprano
On Sun, 01 Dec 2013 16:03:17 +1100, Chris Angelico wrote: > Most of it is getting annoyed at the results of 3, and then attacking 3. I know the feeling. I've never trusted 3, I've always felt that it's plotting something. And it looks like half an 8, but it's not. What's with that? -- Steven

Re: Change a file type in Python?

2013-12-01 Thread Mark Lawrence
On 01/12/2013 00:04, Eamonn Rea wrote: Thanks for the help! Ok, I'll look into the mailing list. It's very useful, you can even see things in context, which is conspicious by its absence above :) -- Python is the second best programming language in the world. But the best has yet to be inv