Re: Short-circuit Logic

2013-05-31 Thread Steven D'Aprano
On Fri, 31 May 2013 17:09:01 +1000, Chris Angelico wrote: > On Fri, May 31, 2013 at 3:13 PM, Steven D'Aprano > wrote: >> What makes you think that the commutative law is relevant here? >> >> > Equality should be commutative. If a == b, then b == a. Also, it&#x

Re: Getting Error can't find '__main__' module in 'X'

2013-06-02 Thread Steven D'Aprano
On Sun, 02 Jun 2013 04:04:50 -0700, meakaakka wrote: > Hey I am newbie in python.I have installed python 2.7.5 correctly.It is > working fine but I am having some issues.I have set windows Enviroment > variables. Any particular environment variables? Shall we guess which ones? > The problem is

Re: PyWart: The problem with "print"

2013-06-02 Thread Steven D'Aprano
On Sun, 02 Jun 2013 10:04:00 -0700, Rick Johnson wrote: > Many > languages provide a function, method, or statement by which users can > write easily to stdout, and Python is no exception with it's own "print" > function. However, whilst writing to stdout via "print" is slightly less > verbose tha

Re: PyWart: The problem with "print"

2013-06-02 Thread Steven D'Aprano
On Sun, 02 Jun 2013 11:09:12 -0700, Rick Johnson wrote: > Maybe you don't care about destroying someone's CPU, however, i do! And yet here you are, destroying millions of people's CPUs by sending them email or usenet messages filled with garbage. -- Steven -- http://mail.python.org/mailman/l

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-02 Thread Steven D'Aprano
On Sun, 02 Jun 2013 22:05:28 -0700, Νικόλαος Κούρας wrote: > Why subprocess fails when it has to deal with a greek flename? and that > an indirect call too It doesn't. The command you are calling fails, not subprocess. The code you show is this: /home/nikos/public_html/cgi-bin/metrites.p

Interactive interpreter hooks

2013-06-03 Thread Steven D'Aprano
The sys module defines two hooks that are used in the interactive interpreter: * sys.displayhook(value) gets called with the result of evaluating the line when you press ENTER; * sys.excepthook(type, value, traceback) gets called with the details of the exception when your line raises an excep

Re: PyWart: The problem with "print"

2013-06-03 Thread Steven D'Aprano
On Mon, 03 Jun 2013 15:09:48 -0400, Jason Swails wrote: > But unlike RR, who suggests some elaborate interpreter-wide, ambiguous > ignore-rule to squash out all of these functions, I'm simply suggesting > that sometimes it's worth commenting-out debug print calls instead of > 'just leaving them th

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-03 Thread Steven D'Aprano
(Note: this post is sent using UTF-8. If anyone reading this sees mojibake, please make sure your email or news client is set to use UTF-8.) On Mon, 03 Jun 2013 05:54:30 -0700, rusi wrote: > On Jun 3, 2:12 pm, Νικόλαος Κούρας wrote: >> You are right Steven, i just renames the file 'Euxi tou I

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-03 Thread Steven D'Aprano
On Mon, 03 Jun 2013 02:12:31 -0700, Νικόλαος Κούρας wrote: > Τη Δευτέρα, 3 Ιουνίου 2013 9:46:46 π.μ. UTC+3, ο χρήστης Steven D'Aprano > έγραψε: > >> If I am right, the solution is to fix the file names to ensure that >> they are all valid UTF-8 names. If you vie

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-03 Thread Steven D'Aprano
On Mon, 03 Jun 2013 02:32:42 -0700, Νικόλαος Κούρας wrote: > Here is the whole code of files.py in case someone wants to comment on > somethign about how to properly encode/decode the filanames, which seems > to be the problem. > > http://pastebin.com/qXasy5iU Second line in the file says: imp

Re: PyWart: The problem with "print"

2013-06-03 Thread Steven D'Aprano
On Tue, 04 Jun 2013 05:16:13 +0200, Vito De Tullio wrote: > Rick Johnson wrote: > >> Take your >> standard yes/no/cancel dialog, i would expect it to return >> True|False|None respectively, > > you clearly mean True / False / FileNotFound. > > ( http://thedailywtf.com/Articles/What_Is_Truth_0x3

Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-03 Thread Steven D'Aprano
On Mon, 03 Jun 2013 18:37:24 -0700, Rick Johnson wrote: > On Sunday, June 2, 2013 1:58:30 PM UTC-5, Steven D'Aprano wrote: >> On Sun, 02 Jun 2013 10:04:00 -0700, Rick Johnson wrote: >> > A "wise programmer" may think he's solved the problem by writing a

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-03 Thread Steven D'Aprano
On Mon, 03 Jun 2013 21:35:13 -0700, rusi wrote: > On Jun 4, 3:37 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> (Note: this post is sent using UTF-8. If anyone reading this sees >> mojibake, please make sure your email or news client is set to use >>

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-04 Thread Steven D'Aprano
On Mon, 03 Jun 2013 23:28:21 -0700, nagia.retsina wrote: > ni...@superhost.gr [~]# locale > LANG=en_US.UTF-8 [...] Okay, this is good. This means that your system is currently using UTF-8. > Hese is also how the terminal presents my filenames. [...] > ni...@superhost.gr [~]# ls -l www/data/ap

Re: Beginner question

2013-06-04 Thread Steven D'Aprano
On Tue, 04 Jun 2013 14:53:29 +0300, Carlos Nepomuceno wrote: > That's exactly the same! dict(**{a:0,b:1})=={a:0,b:1} > True Of course it is. Isn't that what you wanted? It's also a waste of time, because you create a dict literal using {}, then unpack it into keyword arguments, then call d

Re: Beginner question

2013-06-04 Thread Steven D'Aprano
On Tue, 04 Jun 2013 14:23:39 +0300, Carlos Nepomuceno wrote: > Started answering... now I'm asking! lol > > I've tried to use dict() to create a dictionary to use like the switch > statement providing variable names instead of literals, such as: > a='A' b='B' {a:0,b:1}#here th

Re: PyWart: The problem with "print"

2013-06-04 Thread Steven D'Aprano
On Tue, 04 Jun 2013 05:23:19 -0700, jmfauth wrote: > How is is possible to arrive to such a situation ? The answer if far > beyond my understanding Truer words have never been spoken. > (although I have my opinion on the subject). http://en.wikipedia.org/wiki/Dunning–Kruger_effect -- Stev

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-04 Thread Steven D'Aprano
On Wed, 05 Jun 2013 02:27:26 +1000, Chris Angelico wrote: > On Wed, Jun 5, 2013 at 2:19 AM, Rick Johnson > wrote: >> On Jun 4, 11:00 am, Chris Angelico wrote: >>> You know, if you want a language with strict type declarations and >>> extreme run-time efficiency, there are some around. >> >> I do

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-04 Thread Steven D'Aprano
On Tue, 04 Jun 2013 10:23:33 -0700, Νικόλαος Κούρας wrote: > What on eart is this damn error: Michael tried to explain to me about > surrogates but dont think i understand it. > > Encoding giving me trouble years now. > > [Tue Jun 04 20:19:53 2013] [error] [client 46.12.95.59] Original > excepti

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-04 Thread Steven D'Aprano
On Tue, 04 Jun 2013 21:15:23 -0700, Νικόλαος Κούρας wrote: > One of my Greek filenames is "Ευχή του Ιησού.mp3". Just a Greek filename > with spaces. > Is there a problem when a filename contain both english and greek > letters? Isn't it still a unicode string? No problem, and Unicode includes bot

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-04 Thread Steven D'Aprano
On Tue, 04 Jun 2013 08:47:01 +, Steven D'Aprano wrote: > Please run these commands, and show what result they give: > > alias ls > > printf %q\\n *.mp3 > > ls -b *.mp3 Do you have an answer for this yet? Better still, change the last two commands to thi

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-05 Thread Steven D'Aprano
On Wed, 05 Jun 2013 09:15:01 -0700, Russ P. wrote: > On Wednesday, June 5, 2013 1:59:01 AM UTC-7, Mark Lawrence wrote: >> On 05/06/2013 07:11, Russ P. wrote: >> >> > But then, what would you expect of a language that allows you to >> > write >> > >> > x = 1 >> > x = "Hello" >> > >> > It's all loo

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-05 Thread Steven D'Aprano
On Wed, 05 Jun 2013 14:59:31 -0700, Russ P. wrote: > I'm not an Ada guy, but Ada advocates claim that it reduces development > time by half in the long run compared to C and C++ due to reduced > debugging time and simpler maintenance. They may be right. Far too many people think that C and C++

Re: I just wrote my first Python program a guessing game and it exits with an error I get this.

2013-06-05 Thread Steven D'Aprano
On Wed, 05 Jun 2013 07:40:52 -0700, Armando Montes De Oca wrote: > Traceback (most recent call last): > File "Guessing_Game.py", line 32, in > input (enter) > File "", line 0 > ^ > SyntaxError: unexpected EOF while parsing Your problem is that you should not be using input(), but ra

Re: Apache and suexec issue that wont let me run my python script

2013-06-05 Thread Steven D'Aprano
On Wed, 05 Jun 2013 03:32:42 -0700, Νικόλαος Κούρας wrote: [...] > You spare it from the list because you wanted to bitch in private. Now > sod off. Νικόλαος, please stop trading insults with people who you feel have wronged you. If somebody gives you deliberately bad advice, that is one thing.

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-06 Thread Steven D'Aprano
On Thu, 06 Jun 2013 12:29:44 +1000, Chris Angelico wrote: > On Thu, Jun 6, 2013 at 11:56 AM, Steven D'Aprano > wrote: >> On Wed, 05 Jun 2013 14:59:31 -0700, Russ P. wrote: >>> As for Python, my experience with it is that, as your application >>> grows, you st

Speeding up Python

2013-06-06 Thread Steven D'Aprano
Comparing CPython, PyPy, SciPy, Parakeet and Numba for writing image filters: http://www.phi-node.com/2013/06/faster-morphological-image-filters-in.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-06 Thread Steven D'Aprano
On Tue, 04 Jun 2013 02:00:43 -0700, Νικόλαος Κούρας wrote: > Τη Τρίτη, 4 Ιουνίου 2013 11:47:01 π.μ. UTC+3, ο χρήστης Steven D'Aprano > έγραψε: > >> Please run these commands, and show what result they give: [...] > ni...@superhost.gr [~/www/data/apps]# alias ls > ali

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-06 Thread Steven D'Aprano
On Thu, 06 Jun 2013 12:17:16 -0700, Νικόλαος Κούρας wrote: > i can remove the bianry openign from os.listdir but then this will not > work. MRAB has told me that i need to open those paths and filenames as > bytestreams and not as unicode strings. Do you understand why? If you do not understand

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-06 Thread Steven D'Aprano
On Thu, 06 Jun 2013 13:56:36 -0700, Νικόλαος Κούρας wrote: > SyntaxError: invalid syntax > > > Dont know how to add a bytestremed path to a bytestream filename Nikos, READ THE ERROR MESSAGE!!! The error doesn't say anything about *adding*. It is a SyntaxError. Please stop flooding us with do

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-06 Thread Steven D'Aprano
On Thu, 06 Jun 2013 11:46:20 -0700, Νικόλαος Κούρας wrote: > Τη Πέμπτη, 6 Ιουνίου 2013 3:44:52 μ.μ. UTC+3, ο χρήστης Steven D'Aprano > έγραψε: > >> py> s = '999-Eυχή-του-Ιησού' >> py> bytes_as_utf8 = s.encode('utf-8') >> py> t

Re: Beginner question

2013-06-06 Thread Steven D'Aprano
Sorry for the delay in replying. On Tue, 04 Jun 2013 15:51:38 +0300, Carlos Nepomuceno wrote: >> [1] Technically it's a type, not a function, but the difference makes >> no difference here. > Can you explain me the difference of the type and function you've just > mentioned? We were talking ab

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-06 Thread Steven D'Aprano
On Thu, 06 Jun 2013 18:44:49 -0700, Mark Janssen wrote: >>> Python has seduced us all into lazy typing. That's what it is. >> >> Bulshytt. If you have no idea what polymorphism is, you shouldn't even >> be participating in this conversation. > > I am aware of what it means, but Python doesn't re

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-07 Thread Steven D'Aprano
On Fri, 07 Jun 2013 04:53:42 -0700, Νικόλαος Κούρας wrote: > Do you mean that utf-8, latin-iso, greek-iso and ASCII have the 1st > 0-127 codepoints similar? You can answer this yourself. Open a terminal window and start a Python interactive session. Then try it and see what happens: s = ''.joi

Re: Python Game Development?

2013-06-07 Thread Steven D'Aprano
On Fri, 07 Jun 2013 09:28:09 -0700, Eam onn wrote: > Do you know of any tutorial for PyGame? Preferably a video tutorial but > any tutorial at all is fine! I can't seem to find any, even on > pygame.org!!! https://duckduckgo.com/html/?q=pygame+tutorial -- Steven -- http://mail.python.org/mail

Re: Idiomatic Python for incrementing pairs

2013-06-07 Thread Steven D'Aprano
On Fri, 07 Jun 2013 21:32:39 -0500, Tim Chase wrote: > Playing around, I've been trying to figure out the most pythonic way of > incrementing multiple values based on the return of a function. > Something like [...skip misleading and irrelevant calculate() function...] > alpha = beta = 0 > te

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-08 Thread Steven D'Aprano
On Fri, 07 Jun 2013 23:49:17 -0700, Νικόλαος Κούρας wrote: [...] > Oh iam very sorry. > Oh my God i cant beleive i missed a colon *again*: > > I have corrected this: [snip code] Stop posting your code after every trivial edit!!! -- Steven -- http://mail.python.org/mailman/listinfo/python-li

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-08 Thread Steven D'Aprano
On Thu, 06 Jun 2013 23:35:33 -0700, nagia.retsina wrote: >> Working with bytes is only for when the file names are turned to >> garbage. Your file names (some of them) are turned to garbage. Fix >> them, and then use file names as strings. > > Can't '~/data/apps/' is filled every day with more an

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-08 Thread Steven D'Aprano
On Sat, 08 Jun 2013 21:01:23 +0300, Νικόλαος Κούρας wrote: > In the beginning there was ASCII with 0-127 values No, there were encoding systems that existed before ASCII, such as EBCDIC. But we can ignore those, and just start with ASCII. > and then there was > Unicode with 0-127 of ASCII's +

Re: Re-using copyrighted code

2013-06-08 Thread Steven D'Aprano
On Sat, 08 Jun 2013 23:31:10 +0200, Malte Forkel wrote: > Hello, > > I have written a small utility to locate errors in regular expressions > that I want to upload to PyPI. Before I do that, I would like to learn > a litte more about the legal aspects of open-source software. What would > be a g

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-08 Thread Steven D'Aprano
On Sun, 09 Jun 2013 07:46:40 +0300, Νικόλαος Κούρας wrote: > Why does every character in a character set needs to be associated with > a numeric value? Because computers are digital, not analog, and because bytes are numbers. Here are a few of the 256 possible bytes, written in binary, decimal a

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-08 Thread Steven D'Aprano
On Sat, 08 Jun 2013 22:09:57 -0700, nagia.retsina wrote: > chr('A') would give me the mapping of this char, the number 65 while > ord(65) would output the char 'A' likewise. Correct. Python uses Unicode, where code-point 65 ("ordinal value 65") means letter "A". There are older encodings. For e

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-09 Thread Steven D'Aprano
On Sun, 09 Jun 2013 00:00:53 -0700, nagia.retsina wrote: > path = b'/home/nikos/public_html/data/apps/' > files = os.listdir( path ) > > for filename in files: > # Compute 'path/to/filename' > filepath_bytes = path + filename > for encoding in ('utf-8', 'iso-8859-7', 'latin-1'):

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-09 Thread Steven D'Aprano
On Sun, 09 Jun 2013 10:55:43 +0200, Lele Gaifax wrote: > Steven D'Aprano writes: > >> On Sat, 08 Jun 2013 22:09:57 -0700, nagia.retsina wrote: >> >>> chr('A') would give me the mapping of this char, the number 65 while >>> ord(65) would outpu

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-09 Thread Steven D'Aprano
On Sun, 09 Jun 2013 02:00:46 -0700, Νικόλαος Κούρας wrote: > Steven wrote: >>> Since 1 byte can hold up to 256 chars, why not utf-8 use 1-byte for >>> values up to 256? > >>Because then how do you tell when you need one byte, and when you need >>two? If you read two bytes, and see 0x4C 0xFA, does

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-09 Thread Steven D'Aprano
On Sun, 09 Jun 2013 19:16:06 +1000, Cameron Simpson wrote: > If he's lucky the UnicodeEncodeError occurred while trying to print an > error message, That's not what happens at the interactive console: py> assert os.path.exists('Ж1') Traceback (most recent call last): File "", line 1, in Ass

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-09 Thread Steven D'Aprano
On Sun, 09 Jun 2013 02:38:13 -0700, Νικόλαος Κούρας wrote: > s = 'α' > s = s.encode('iso-8859-7').decode('utf-8') > > UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe1 in position 0: > unexpected end of data > > Why this error? because 'a' ordinal value > 127 ? Look at it this way... co

Re: Re-using copyrighted code

2013-06-09 Thread Steven D'Aprano
On Sun, 09 Jun 2013 08:10:13 -0700, Rick Johnson wrote: > The Secret Labs license is very explicit: "All rights reserved". That > line means you can't touch it under pain of lawsuit. It's also very explicit that the code can be redistributed. However, there is no explicit rights to modification

Re: Re-using copyrighted code

2013-06-09 Thread Steven D'Aprano
On Sun, 09 Jun 2013 13:32:00 -0700, Mark Janssen wrote: > On Sun, Jun 9, 2013 at 12:50 PM, Michael Torrie > wrote: >> On 06/09/2013 11:18 AM, Mark Janssen wrote: >>> You actually do not. Attaching a legal document is purely a secondary >>> protection from those who would take away right already

Re: Re-using copyrighted code

2013-06-09 Thread Steven D'Aprano
On Mon, 10 Jun 2013 08:07:57 +1000, Chris Angelico wrote: > On Mon, Jun 10, 2013 at 6:32 AM, Mark Janssen > wrote: >> That's not entirely correct. If he *publishes* his code (I'm using >> this term "publish" technically to mean "put forth in a way where >> anyone of the general public can or is

Re: Re-using copyrighted code

2013-06-09 Thread Steven D'Aprano
On Sun, 09 Jun 2013 14:08:54 -0700, Mark Janssen wrote: > I'm sorry, this is just the way it is -- everyone's just gone along with > the program tacitly because they get intimidated by the legal system. Your definition of "just the way it is" does not agree with mine. You're describing how you

Re: Encoding questions (continuation)

2013-06-10 Thread Steven D'Aprano
On Mon, 10 Jun 2013 14:13:00 +0300, Νικόλαος Κούρας wrote: > Τη Δευτέρα, 10 Ιουνίου 2013 1:42:25 μ.μ. UTC+3, ο χρήστης Andreas > Perstinger έγραψε: > > > >>> s = b'\xce\xb1' > > > > >>> s[0] > > > > 206 > > 's' is a byte object, how can you treat it as a string asking to present > you its

Re: Sorting a set works, sorting a dictionary fails ?

2013-06-10 Thread Steven D'Aprano
On Mon, 10 Jun 2013 03:42:38 -0700, Νικόλαος Κούρας wrote: > for key in sorted( months.values() ): > please tell me Uli why this dont work as expected to. Because values are not keys. You are looking at the values, and trying to use them as keys. months = {'Φεβρουάριος':2, 'Ιανουάριος':1} prin

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-10 Thread Steven D'Aprano
On Mon, 10 Jun 2013 00:10:38 -0700, nagia.retsina wrote: > Τη Κυριακή, 9 Ιουνίου 2013 3:31:44 μ.μ. UTC+3, ο χρήστης Steven D'Aprano > έγραψε: > >> py> c = 'α' >> py> ord(c) >> 945 > > The number 945 is the characters 'α' ordinal v

Re: Re-using copyrighted code

2013-06-10 Thread Steven D'Aprano
On Mon, 10 Jun 2013 08:42:07 +0200, Malte Forkel wrote: > Am 10.06.2013 07:31, schrieb Steven D'Aprano: >> >> But bringing it back to the original topic, I believe that the >> philosophy of FOSS is that we should try our best to honour the >> intentions of th

Re: "Don't rebind built-in names*" - it confuses readers

2013-06-10 Thread Steven D'Aprano
On Mon, 10 Jun 2013 17:20:58 -0700, Mark Janssen wrote: >>> list = [] >>> Reading further, one sees that the function works with two lists, a >>> list of file names, unfortunately called 'list', >> >> That is very good advice in general: never choose a variable name that >> is a keyword.

Re: "Don't rebind built-in names*" - it confuses readers

2013-06-10 Thread Steven D'Aprano
On Mon, 10 Jun 2013 20:14:55 -0400, Terry Jan Reedy wrote: > For instance, open Lib/idlelib/GrepDialog.py in an editor that colorizes > Python syntax, such as Idle's editor, jump down to the bottom and read > up, and (until it is patched) find > list.append(fn) > with 'list' c

Re: "Don't rebind built-in names*" - it confuses readers

2013-06-10 Thread Steven D'Aprano
On Mon, 10 Jun 2013 19:36:44 -0700, rusi wrote: > Pascal introduced the idea of block structure -- introduce a name at one > level, override it at a lower level. [Ok ALgol introduced, Pascal > popularized]. > This has caused more trouble than it has solved. I take it you have never programmed in

Re: "Don't rebind built-in names*" - it confuses readers

2013-06-10 Thread Steven D'Aprano
On Mon, 10 Jun 2013 20:30:41 -0700, rusi wrote: >> Certainly it would be a PITA, and defeat the purpose of having nested >> scopes, if inner names had to be globally unique. Wouldn't it be >> absolutely horrible if adding a global variable "foo"[1] suddenly meant >> that all your functions that us

Re: "Don't rebind built-in names*" - it confuses readers

2013-06-11 Thread Steven D'Aprano
On Tue, 11 Jun 2013 04:12:38 -0700, rusi wrote: [...] > then what the message of the Guido-quote is, is not clear (at least to > me). The relevant part is in the bit that you deleted. Let me quote it for you again: "locals hiding built-ins is okay" -- Guido van Rossum, inventor and BDFL

Re: "Don't rebind built-in names*" - it confuses readers

2013-06-11 Thread Steven D'Aprano
On Tue, 11 Jun 2013 08:22:19 -0700, Rick Johnson wrote: > On Monday, June 10, 2013 9:56:43 PM UTC-5, Steven D'Aprano wrote: >> On Mon, 10 Jun 2013 20:14:55 -0400, Terry Jan Reedy wrote: >> > Reading further, one sees that the function works with two lists, a

Re: Receing a form variable as a list instead of as a string

2013-06-11 Thread Steven D'Aprano
On Tue, 11 Jun 2013 18:29:05 -0700, nagia.retsina wrote: > if page or form.getvalue('show') == 'log': > # it is a python script > page = page.replace( '/home/nikos/public_html/cgi-bin', '' ) > elif page or form.getvalue('show') == 'stats': > page = page.replace( '/home/niko

Re: Turnign greek-iso filenames => utf-8 iso

2013-06-12 Thread Steven D'Aprano
On Wed, 12 Jun 2013 08:02:24 +, Νικόλαος Κούρας wrote: > i tried to insert > print( filename ) > sys.exit(0) That's not very useful. That will just print ONE file name, then stop. You have how many files in there? Two? Twenty? What if the problem does not lie with the first one? > just bef

Re: Turnign greek-iso filenames => utf-8 iso

2013-06-12 Thread Steven D'Aprano
On Wed, 12 Jun 2013 08:02:24 +, Νικόλαος Κούρας wrote: > # Collect directory and its filenames as bytes > path = b'/home/nikos/public_html/data/apps/' > files = os.listdir( path ) [snip code] I realised that the version I gave you earlier, or rather the modified version you came up with, wa

Re: Turnign greek-iso filenames => utf-8 iso

2013-06-12 Thread Steven D'Aprano
On Wed, 12 Jun 2013 12:00:38 +0300, Νικόλαος Κούρας wrote: > On 12/6/2013 11:31 πμ, Steven D'Aprano wrote: >> On Wed, 12 Jun 2013 08:02:24 +, Νικόλαος Κούρας wrote: >>> and the output is just Pacman.exe as seen in >>> >>> http://superhost.gr/

Re: A few questiosn about encoding

2013-06-12 Thread Steven D'Aprano
On Wed, 12 Jun 2013 09:09:05 +, Νικόλαος Κούρας wrote: > Isn't 14 bits way to many to store a character ? No. There are 1114111 possible characters in Unicode. (And in Japan, they sometimes use TRON instead of Unicode, which has even more.) If you list out all the combinations of 14 bits:

Re: Turnign greek-iso filenames => utf-8 iso

2013-06-12 Thread Steven D'Aprano
On Wed, 12 Jun 2013 12:24:24 +0300, Νικόλαος Κούρας wrote: > On 12/6/2013 12:17 μμ, Steven D'Aprano wrote: >> On Wed, 12 Jun 2013 12:00:38 +0300, Νικόλαος Κούρας wrote: >> >>> On 12/6/2013 11:31 πμ, Steven D'Aprano wrote: >>>> On Wed, 12

Re: A few questiosn about encoding

2013-06-12 Thread Steven D'Aprano
On Wed, 12 Jun 2013 14:23:49 +0300, Νικόλαος Κούρας wrote: > So, how many bytes does UTF-8 stored for codepoints > 127 ? Two, three or four, depending on the codepoint. > example for codepoint 256, 1345, 16474 ? You can do this yourself. I have already given you enough information in previous

Re: Turnign greek-iso filenames => utf-8 iso

2013-06-12 Thread Steven D'Aprano
On Wed, 12 Jun 2013 16:18:38 +, Neil Cerutti wrote: > On 2013-06-12, Mark Lawrence wrote: >> On 12/06/2013 13:42, wrote: >>> >>> Something you want me to try? >> >> I'd suggest suicide but that would no doubt start another stream of >> questions along the lines o

Re: Turnign greek-iso filenames => utf-8 iso

2013-06-12 Thread Steven D'Aprano
On Wed, 12 Jun 2013 15:42:07 +0100, Mark Lawrence wrote: > On 12/06/2013 13:42, Νικόλαος Κούρας wrote: >> >> Something you want me to try? > > I'd suggest suicide Mark, not cool. Seriously not cool. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: "Don't rebind built-in names*" - it confuses readers

2013-06-12 Thread Steven D'Aprano
On Thu, 13 Jun 2013 09:53:26 +1000, Chris Angelico wrote: > In Python 2.x, 'print' is actually a keyword. It has its own special > syntax (eg printing to something other than stdout), and absolutely > cannot be overridden: Except that you can: from __future__ import print_function Just to make

Re: "Don't rebind built-in names*" - it confuses readers

2013-06-12 Thread Steven D'Aprano
On Wed, 12 Jun 2013 17:04:48 -0700, Mark Janssen wrote: >> Apart from Erlang, got any other examples? Because it seems to me that >> in languages with nested scopes or namespaces, shadowing higher levels >> is exactly the right thing to do. > > Really? > int="five" [int(i) for i in ["1

Re: "Don't rebind built-in names*" - it confuses readers

2013-06-12 Thread Steven D'Aprano
On Thu, 13 Jun 2013 10:08:14 +1000, Chris Angelico wrote: int="five" [__builtins__.int(i) for i in ["1","2","3"]] Don't use __builtins__, it's an implementation detail. In Python 2.x, there is __builtins__ with an "s" in the global namespace if you are running CPython, but not necessa

Re: "Don't rebind built-in names*" - it confuses readers

2013-06-12 Thread Steven D'Aprano
On Wed, 12 Jun 2013 17:26:43 -0700, Mark Janssen wrote: >> The builtins don't need to be imported, but they're identifiers like >> anything else. They're a namespace that gets searched after >> module-globals. > > Yes, I understand, though for clarity and separability, it seems that > having them

Re: A few questiosn about encoding

2013-06-12 Thread Steven D'Aprano
On Wed, 12 Jun 2013 21:30:23 +0100, Nobody wrote: > The mechanism used by UTF-8 allows sequences of up to 6 bytes, for a > total of 31 bits, but UTF-16 is limited to U+10 (slightly more than > 20 bits). Same with UTF-8 and UTF-32, both of which are limited to U+10 because that is what Un

Re: A certainl part of an if() structure never gets executed.

2013-06-12 Thread Steven D'Aprano
On Wed, 12 Jun 2013 14:17:32 +0300, Νικόλαος Κούρας wrote: > doesn't that mean? > > if '=' not in ( name and month and year ): > > if '=' does not exists as a char inside the name and month and year > variables? > > i think it does, but why it fails then? No. Python is very close

Re: A few questiosn about encoding

2013-06-13 Thread Steven D'Aprano
On Thu, 13 Jun 2013 09:09:19 +0300, Νικόλαος Κούρας wrote: > On 13/6/2013 3:13 πμ, Steven D'Aprano wrote: >> Open an interactive Python session, and run this code: >> >> c = ord(16474) >> len(c.encode('utf-8')) >> >> >> That will

Re: A few questiosn about encoding

2013-06-13 Thread Steven D'Aprano
On Thu, 13 Jun 2013 12:41:41 +0300, Νικόλαος Κούρας wrote: >> In Python 2: > 16474 > typing 16474 in interactive session both in python 2 and 3 gives back > the number 16474 > > while we want the the binary representation of the number 16474 Python does not work that way. Ints *always* displ

Python biases [was Re: My son wants me to teach him Python]

2013-06-13 Thread Steven D'Aprano
On Thu, 13 Jun 2013 06:37:34 -0700, rusi wrote: > Python-the-language has strengths that are undermined by the biases in > the culture of Python. This implies that there are strengths in Python-the-language which are not just missed or ignored by Python programmers immersed in the culture, but

Re: A certainl part of an if() structure never gets executed.

2013-06-13 Thread Steven D'Aprano
On Thu, 13 Jun 2013 17:26:18 +0300, Νικόλαος Κούρας wrote: > i just want 4 cases to examine so correct execute to be run: > > i'm reading and reading and reading this all over: > > if '-' not in ( name and month and year ): > > and i cant comprehend it. Don't just read it. Open the interactive

Re: My son wants me to teach him Python

2013-06-13 Thread Steven D'Aprano
On Thu, 13 Jun 2013 17:37:34 +0200, Tomasz Rola wrote: > If he (son) learns Haskell, he may as well stay with it, because it's > quite decent lang as far as I can tell. And it's compiled, too. So is Python. > I would also consider Racket, which is a Scheme superset. It too, comes > with compile

Re: Turnign greek-iso filenames => utf-8 iso

2013-06-13 Thread Steven D'Aprano
On Thu, 13 Jun 2013 10:16:42 -0400, Zero Piraeus wrote: > : > >> Steven, i can create a normal user account for you and copy files.py >> into your home folder if you want to take a look from within. > > Nikos, please, DO NOT DO THIS. > > It must be clear to you that Steven is *much* more experi

Re: Debugging memory leaks

2013-06-13 Thread Steven D'Aprano
On Thu, 13 Jun 2013 20:15:42 +, Giorgos Tzampanakis wrote: >> Therefore: if the leak seems to be small, it may be much more advicable >> to restart your process periodically (during times where a restart does >> not hurt much) rather than try to find (and fix) the leaks. Only when >> the leak

Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program

2013-06-13 Thread Steven D'Aprano
On Thu, 13 Jun 2013 12:28:09 -0700, buford.lumbar wrote: > Hi, I'm new to Python. Would someone be able to write me and/or to show > me how to write a simple program that: [snip directions] Cannot be done. What you describe is not "simple", and it certainly is not "super simple" like you have in

Re: Turnign greek-iso filenames => utf-8 iso

2013-06-13 Thread Steven D'Aprano
On Thu, 13 Jun 2013 19:20:06 +0300, Νικόλαος Κούρας wrote: > But iam not offering Steven full root access, but restricted user level > access. Are you implying that for example one could elevate his > privileges to root level access form within a normal restricted user > account? Me personally? P

Re: My son wants me to teach him Python

2013-06-13 Thread Steven D'Aprano
On Thu, 13 Jun 2013 20:33:40 -0700, Rick Johnson wrote: > On Thursday, June 13, 2013 3:18:57 PM UTC-5, Joshua Landau wrote: > >> [...] >> GUI is boring. I don't give a damn about that. If I had it my way, I'd >> never write any interfaces again (although designing them is fine). >> Console intera

Re: Eval of expr with 'or' and 'and' within

2013-06-14 Thread Steven D'Aprano
On Fri, 14 Jun 2013 11:14:16 +0100, Robert Kern wrote: > On 2013-06-14 10:50, Nick the Gr33k wrote: [snip question] >> This is all iw ant to know. > > This is all you need to read: > >http://docs.python.org/2/reference/expressions.html#boolean- operations Thank you Robert for contributing

Re: Wrong website loaded when other requested

2013-06-14 Thread Steven D'Aprano
On Fri, 14 Jun 2013 18:37:50 +0300, Nick the Gr33k wrote: >> please take an overall look at my httpd.conf at >> http://pastebin.com/Pb3VbNC9 in case you want to examine somehting >> else. >> >> Thank you very much. >> > PLEASE SUGGEST SOMETHING! Don't shout, it's rude. We're not your servants. T

Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Steven D'Aprano
On Fri, 14 Jun 2013 16:07:56 +0300, Nick the Gr33k wrote: > Thanks for explaining this but i cannot follow its logic at all. My mind > is stuck trying to interpret it as an English sentence: > > if ('Parker' and 'May' and '2001') > > if ('Parker' or 'May' or '2001') > > i just don't get it and

Re: Eval of expr with 'or' and 'and' within

2013-06-14 Thread Steven D'Aprano
On Fri, 14 Jun 2013 10:29:25 -0600, Michael Torrie wrote: > On 06/14/2013 03:50 AM, Nick the Gr33k wrote: >> >>> print(name or month or year) >> abcd >> >>> print(name and month and year) >> ijkl > > Interesting. I'd have thought a boolean expression would return True or > False, not a string.

Re: Eval of expr with 'or' and 'and' within

2013-06-14 Thread Steven D'Aprano
On Sat, 15 Jun 2013 00:09:31 +0100, Nobody wrote: > On Sat, 15 Jun 2013 03:56:28 +1000, Chris Angelico wrote: > >> With a few random oddities: >> > bool(float("nan")) >> True >> >> I somehow expected NaN to be false. Maybe that's just my expectations >> that are wrong, though. > > In gener

Re: Debugging memory leaks

2013-06-14 Thread Steven D'Aprano
On Fri, 14 Jun 2013 22:57:24 +, Giorgos Tzampanakis wrote: > On 2013-06-14, Steven D'Aprano wrote: > >> On Thu, 13 Jun 2013 20:15:42 +, Giorgos Tzampanakis wrote: >> >>>> Therefore: if the leak seems to be small, it may be much more >>>>

Re: how to use two threads to produce even and odd numbers?

2013-06-14 Thread Steven D'Aprano
On Fri, 14 Jun 2013 04:50:05 -0700, Zoe Wendy wrote: > I am going to compile a small python program in order to use Queue to > produce a random with a thread. For example, using one thread to print > odd number, while another thread to print even number. > > Here is my codes, please offer me som

NANs [was Re: Eval of expr with 'or' and 'and' within]

2013-06-14 Thread Steven D'Aprano
On Sat, 15 Jun 2013 12:03:08 +1000, Cameron Simpson wrote: > | ... even taking that into account! *wink* | > | Everyone is aware that there is more than one NAN, right? > > I was not. Interesting. > > | If my > | calculations are correct, there are 9007199254740992 distinct float > | NANs in Pyt

Re: Pattern Search Regular Expression

2013-06-15 Thread Steven D'Aprano
On Sat, 15 Jun 2013 02:42:55 -0700, subhabangalore wrote: > Dear Group, > > I am trying to search the following pattern in Python. > > I have following strings: > > (i)"In the ocean" > (ii)"On the ocean" > (iii) "By the ocean" > (iv) "In this group" > (v) "In this group" > (vi) "By the ne

Re: A few questiosn about encoding

2013-06-15 Thread Steven D'Aprano
On Sat, 15 Jun 2013 17:49:13 +0300, Nick the Gr33k wrote: > What the difference between a byte and a byte's value? Nothing. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Don't feed the troll...

2013-06-15 Thread Steven D'Aprano
On Sat, 15 Jun 2013 07:58:27 -0400, D'Arcy J.M. Cain wrote: > I suggested including the poster that you are replying to. In the name of all that's good and decent in the world, why on earth would you do that when replying to a mailing list??? They're already getting a reply. Sending them TWO id

Re: Don't feed the troll...

2013-06-15 Thread Steven D'Aprano
On Sat, 15 Jun 2013 18:41:41 +0200, Chris “Kwpolska” Warrick wrote: > On Sat, Jun 15, 2013 at 5:40 PM, Steven D'Aprano > wrote: >> On Sat, 15 Jun 2013 07:58:27 -0400, D'Arcy J.M. Cain wrote: >> >>> I suggested including the poster that you are replying to.

Re: Don't feed the troll...

2013-06-15 Thread Steven D'Aprano
On Sat, 15 Jun 2013 19:25:21 +0200, Chris “Kwpolska” Warrick wrote: > On Sat, Jun 15, 2013 at 7:07 PM, D'Arcy J.M. Cain > wrote: >> On Sat, 15 Jun 2013 18:41:41 +0200 >> Chris “Kwpolska” Warrick wrote: >>> On Sat, Jun 15, 2013 at 5:40 PM, Steven D'Aprano

Re: RFD: rename comp.lang.python to comp.support.superhost

2013-06-15 Thread Steven D'Aprano
On Sat, 15 Jun 2013 18:43:42 +0100, Mark Lawrence wrote: > A classic example of the pot calling the kettle black. If you're going to continue making unproductive, off-topic, inflammatory posts that prolong these already excessively large threads, Nikos won't be the only one kill-filed. If you

<    1   2   3   4   5   6   7   8   9   10   >