Re: UnicodeDecodeError issue

2013-08-31 Thread Ferrous Cranus
Τη Σάββατο, 31 Αυγούστου 2013 9:41:27 π.μ. UTC+3, ο χρήστης Ferrous Cranus έγραψε: > Suddenly my webiste superhost.gr running my main python script presents > > me with this error: > > > > Code: > > UnicodeDecodeError('utf-8', b'\xb6\xe3\xed\xf9\xf3\xf4\xef > > \xfc\xed\xef\xec\xe1 \xf3\xf

Re: argparse - specify order of argument parsing?

2013-08-31 Thread Peter Otten
Eduardo Alvarez wrote: > When using argparse, is there a way to specify in what order arguments > get parsed? I am writing a script whose parameters can be modified in > the following order: > > Defaults -> config file -> command-line switches. > > However, I want to give the option of specifyin

Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow)

2013-08-31 Thread Michael Torrie
On 08/31/2013 10:51 PM, anntzer@gmail.com wrote: > It is the call to gethostbyname_ex that is very slow. The call to > gethostname is quick (and returns the same string as > /usr/bin/hostname). What gethostbyname_ex and /usr/bin/hostname do are very different things. gethostbyname_ex does a

Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow)

2013-08-31 Thread anntzer . lee
It is the call to gethostbyname_ex that is very slow. The call to gethostname is quick (and returns the same string as /usr/bin/hostname). On Saturday, August 31, 2013 6:01:00 PM UTC-7, Roy Smith wrote: > In article , > > anntzer@gmail.com wrote: > > > > > Hi, > > > > > > At startup,

Re: Best practice for generalizing and documenting each method's behaviour

2013-08-31 Thread Steven D'Aprano
On Fri, 30 Aug 2013 11:04:28 -0700, niubao56 wrote: > I'm starting a small project coding in Python as I learn the ropes. As > the project grows bigger, there are more and more overlapping and even > redundant methods. For example, several classes have a > checkAndClean_obj_state() method. If just

Re: Best practice for generalizing and documenting each method's behaviour

2013-08-31 Thread Fábio Santos
On 30 Aug 2013 19:07, wrote: > > I'm starting a small project coding in Python as I learn the ropes. As the project grows bigger, there are more and more overlapping and even redundant methods. For example, several classes have a checkAndClean_obj_state() method. If just one or two such classes, i

Not getting my head around pandas

2013-08-31 Thread Roy Smith
I've got a pandas DataFrame that looks like: Int64Index: 12960 entries, 0 to 12959 Data columns (total 2 columns): date12960 non-null values ms 12960 non-null values dtypes: datetime64[ns](1), float64(1) date ms 12955 2013-08-30 23:20:00 96.868491 12956

Re: How do I process this using Python?

2013-08-31 Thread Steven D'Aprano
On Sat, 31 Aug 2013 18:44:04 -0500, Anthony Papillion wrote: > Hello Everyone, > > I'm writing a processor for Bitmessage messages and I am needing to > parse the following returned JSON string: [...] > For some reason (probably obvious reasons) isn't working. I'm trying to > loop through the JSO

Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow)

2013-08-31 Thread Roy Smith
In article , anntzer@gmail.com wrote: > Hi, > > At startup, IPython (qtconsole) calls > "socket.gethostbyname_ex(socket.gethostname())[2]" to find a list of IP > addresses that point to the machine. On a Linux server that I manage this > call is extremely slow (>20s)... which I have troub

Re: How do I process this using Python? (SOLVED)

2013-08-31 Thread Anthony Papillion
On 08/31/2013 07:32 PM, Chris Angelico wrote: > On Sun, Sep 1, 2013 at 10:19 AM, Anthony Papillion > wrote: >> On 08/31/2013 06:48 PM, Chris Angelico wrote: >>> On Sun, Sep 1, 2013 at 9:44 AM, Anthony Papillion >>> wrote: I'm writing a processor for Bitmessage messages and I am needing to

Re: Interface and duck typing woes

2013-08-31 Thread Roy Smith
In article <5221352b$0$6599$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Heh, everybody has one of two reactions: > > "This is awesome!" [[i.e. what I said]] > > "You'll add type checking to my Python code over my dead body!!!" Duck typing is a funny thing. Sure, I don't ha

Re: How do I process this using Python?

2013-08-31 Thread Anthony Papillion
On 08/31/2013 07:32 PM, Cameron Simpson wrote: > On 31Aug2013 19:19, Anthony Papillion wrote: > | On 08/31/2013 06:48 PM, Chris Angelico wrote: > | > On Sun, Sep 1, 2013 at 9:44 AM, Anthony Papillion > wrote: > | >> I'm writing a processor for Bitmessage messages and I am needing to > | >> parse

Re: How do I process this using Python?

2013-08-31 Thread Cameron Simpson
On 31Aug2013 19:19, Anthony Papillion wrote: | On 08/31/2013 06:48 PM, Chris Angelico wrote: | > On Sun, Sep 1, 2013 at 9:44 AM, Anthony Papillion wrote: | >> I'm writing a processor for Bitmessage messages and I am needing to | >> parse the following returned JSON string: | >> | >> {u'inboxMess

Re: How do I process this using Python?

2013-08-31 Thread Chris Angelico
On Sun, Sep 1, 2013 at 10:19 AM, Anthony Papillion wrote: > On 08/31/2013 06:48 PM, Chris Angelico wrote: >> On Sun, Sep 1, 2013 at 9:44 AM, Anthony Papillion >> wrote: >>> I'm writing a processor for Bitmessage messages and I am needing to >>> parse the following returned JSON string: >>> >>> {

Re: How do I process this using Python?

2013-08-31 Thread Anthony Papillion
On 08/31/2013 06:48 PM, Chris Angelico wrote: > On Sun, Sep 1, 2013 at 9:44 AM, Anthony Papillion wrote: >> I'm writing a processor for Bitmessage messages and I am needing to >> parse the following returned JSON string: >> >> {u'inboxMessages': > > Does the JSON string really have those u prefix

Re: argparse - specify order of argument parsing?

2013-08-31 Thread Cameron Simpson
On 31Aug2013 14:17, Terry Reedy wrote: | On 8/31/2013 2:13 PM, Terry Reedy wrote: | >On 8/31/2013 1:11 PM, Eduardo Alvarez wrote: | >>When using argparse, is there a way to specify in what order arguments | >>get parsed? | > | >I expect argparse to forward iterate the sequence of arguments that it

gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow)

2013-08-31 Thread anntzer . lee
Hi, At startup, IPython (qtconsole) calls "socket.gethostbyname_ex(socket.gethostname())[2]" to find a list of IP addresses that point to the machine. On a Linux server that I manage this call is extremely slow (>20s)... which I have trouble understanding as "ip addr show" seems to give the sa

Re: print function and unwanted trailing space

2013-08-31 Thread Terry Reedy
On 8/31/2013 7:15 PM, Joshua Landau wrote: On 31 August 2013 23:08, Chris Angelico wrote: On Sun, Sep 1, 2013 at 1:43 AM, Oscar Benjamin wrote: On 31 August 2013 16:30, Chris Angelico wrote: but doesn't solve all the cases (imagine a string or an iterator). Similar but maybe simpler, and

Re: MySQLdb Problem

2013-08-31 Thread John Smith
On Sat, 31/8/13, Chris Angelico wrote: Subject: Re: MySQLdb Problem To: python-list@python.org Date: Saturday, 31 August, 2013, 4:18 PM > Do your Python and your MySQLdb match? I haven't confirmed, > but I'm > pretty sure you'll have problems if

Re: How do I process this using Python?

2013-08-31 Thread Chris Angelico
On Sun, Sep 1, 2013 at 9:44 AM, Anthony Papillion wrote: > I'm writing a processor for Bitmessage messages and I am needing to > parse the following returned JSON string: > > {u'inboxMessages': Does the JSON string really have those u prefixes and apostrophes? That's not valid JSON. You may be ab

How do I process this using Python?

2013-08-31 Thread Anthony Papillion
Hello Everyone, I'm writing a processor for Bitmessage messages and I am needing to parse the following returned JSON string: {u'inboxMessages': [{u'fromAddress': u'BM-2DBYkhiBZCyrBa8J7gFRGrFRSGqtHgPtMvwQ', u'toAddress': u'BM-2DC7SCTj2gzgrGgMvUCARdrfrsgLyz3iMyN3', u'read': 0, u'msgid': u'36659a44

Re: Interface and duck typing woes

2013-08-31 Thread Joshua Landau
On 31 August 2013 01:13, Steven D'Aprano wrote: > On Fri, 30 Aug 2013 06:35:47 -0400, Roy Smith wrote: > >> In article <52200699$0$6599$c3e8da3$54964...@news.astraweb.com>, >> Steven D'Aprano wrote: >> >>> These days, it would be relatively simple to implement pre- and post- >>> condition checki

Re: print function and unwanted trailing space

2013-08-31 Thread Joshua Landau
On 31 August 2013 23:08, Chris Angelico wrote: > On Sun, Sep 1, 2013 at 1:43 AM, Oscar Benjamin > wrote: >> On 31 August 2013 16:30, Chris Angelico wrote: but doesn't solve all the cases (imagine a string or an iterator). >>> >>> Similar but maybe simpler, and copes with more arbitrary

Re: MySQLdb Problem

2013-08-31 Thread Chris Angelico
On Sun, Sep 1, 2013 at 8:17 AM, John Smith wrote: > > > On Sat, 31/8/13, Chris Angelico wrote: > > Subject: Re: MySQLdb Problem > To: python-list@python.org > Date: Saturday, 31 August, 2013, 4:18 PM > >> Do your Python and your MySQLdb match? I hav

Re: print function and unwanted trailing space

2013-08-31 Thread Chris Angelico
On Sun, Sep 1, 2013 at 1:43 AM, Oscar Benjamin wrote: > On 31 August 2013 16:30, Chris Angelico wrote: >>> >>> but doesn't solve all the cases (imagine a string or an iterator). >> >> Similar but maybe simpler, and copes with more arbitrary iterables: >> >> it=iter(range(5)) >> print(next(it), en

Re: argparse - specify order of argument parsing?

2013-08-31 Thread Terry Reedy
On 8/31/2013 2:13 PM, Terry Reedy wrote: On 8/31/2013 1:11 PM, Eduardo Alvarez wrote: When using argparse, is there a way to specify in what order arguments get parsed? I expect argparse to forward iterate the sequence of arguments that it receives. Aside from the environment variable soluti

Re: argparse - specify order of argument parsing?

2013-08-31 Thread Terry Reedy
On 8/31/2013 1:11 PM, Eduardo Alvarez wrote: When using argparse, is there a way to specify in what order arguments get parsed? I expect argparse to forward iterate the sequence of arguments that it receives. I am writing a script whose parameters can be modified in the following order: De

Re: argparse - specify order of argument parsing?

2013-08-31 Thread Tim Chase
On 2013-08-31 13:11, Eduardo Alvarez wrote: > When using argparse, is there a way to specify in what order > arguments get parsed? I am writing a script whose parameters can be > modified in the following order: > > Defaults -> config file -> command-line switches. > > However, I want to give the

Re: Encapsulation unpythonic?

2013-08-31 Thread Tim Delaney
On 1 September 2013 03:31, Dennis Lee Bieber wrote: > On Fri, 30 Aug 2013 23:07:47 -0700 (PDT), Fabrice Pombet > > declaimed the following: > > >well, look at that: > > > >a=(1,2) > >a=2+3 ->a is an object and I have changed its type and value from > outside. As far as I am concerned this is one

argparse - specify order of argument parsing?

2013-08-31 Thread Eduardo Alvarez
When using argparse, is there a way to specify in what order arguments get parsed? I am writing a script whose parameters can be modified in the following order: Defaults -> config file -> command-line switches. However, I want to give the option of specifying a config file using a command line s

Re: print function and unwanted trailing space

2013-08-31 Thread candide
Le 31/08/2013 15:59, Peter Otten a écrit : To make it crystal clear, the above was to illustrate the algorithm used in Python 2, not a suggestion. Ok sorry, I misinterpreted. > I still think you should live with a trailing space Are you sure ? The following code #

Re: print function and unwanted trailing space

2013-08-31 Thread candide
Le 31/08/2013 12:31, Peter Otten a écrit : with `softspace` saved as a file attribute, is gone in Python3. After reading http://docs.python.org/3.0/whatsnew/3.0.html#print-is-a-function I understand what you meant by "softspace". Thanks. -- http://mail.python.org/mailman/listinfo/python-l

Re: UnicodeDecodeError issue

2013-08-31 Thread Steven D'Aprano
On Sat, 31 Aug 2013 15:58:11 +0300, Ferrous Cranus wrote: Failure is here, line 135: >> cur.execute('''INSERT INTO files (url, host, city, lastvisit) VALUES >> (%s, %s, %s, %s)''', (filename, host, city, lastvisit) ), [...] > But how is this possible since: > > > host = socket.gethostbyaddr( o

Re: print function and unwanted trailing space

2013-08-31 Thread Oscar Benjamin
On 31 August 2013 16:30, Chris Angelico wrote: >> >> but doesn't solve all the cases (imagine a string or an iterator). > > Similar but maybe simpler, and copes with more arbitrary iterables: > > it=iter(range(5)) > print(next(it), end='') > for i in it: > print('',i, end='') If you want to w

Re: print function and unwanted trailing space

2013-08-31 Thread Chris Angelico
On Sat, Aug 31, 2013 at 11:33 PM, candide wrote: > The if instruction imposes useless testing (we know in advance the problem > to occur at the very end of the loop) and useless writing (writing ''). > > The following is clearer > > # - > n=5 > for i in range(n-1): > pr

Re: print function and unwanted trailing space

2013-08-31 Thread Steven D'Aprano
On Sat, 31 Aug 2013 14:59:17 +0200, candide wrote: > Le 31/08/2013 13:16, Steven D'Aprano a écrit : > > >> Of course it does. Have you actually tried it? > > > Of course I did, redirecting the output to a file in order to spot an > eventually trailing space. I did the same for the Python 3 cod

Re: HMAC encription issue

2013-08-31 Thread Sergio Sanchez
El sábado, 31 de agosto de 2013 16:48:53 UTC+2, Sergio Sanchez escribió: > El sábado, 31 de agosto de 2013 16:39:08 UTC+2, Roy Smith escribió: > > > In article <3479e08e-d435-492b-b2a0-a1c18678f...@googlegroups.com>, > > > > > > sergio7...@gmail.com wrote: > > > > > > > > > > > > > ke

Re: MySQLdb Problem

2013-08-31 Thread Chris Angelico
On Sat, Aug 31, 2013 at 6:38 PM, John Smith wrote: > Hi; > Since there is no list for MySQLdb, I'm hoping you can help me. I have > installed, de-installed and reinstalled this s/w and MySQL itself on my Win8 > box. However, when I go to use it from a script, I get the following error: > > "C:\P

Re: HMAC encription issue

2013-08-31 Thread Roy Smith
In article , Sergio Sanchez wrote: > > To start with, your keys are not the same > > Sorry, that was a problem with the cut & paste. And your credentials are different too: var credentials = "admin:amin"; credentials = "admin:admin" Is this also a cut & paste error? Please, post EXACTlY the

MySQLdb Problem

2013-08-31 Thread John Smith
Hi; Since there is no list for MySQLdb, I'm hoping you can help me. I have installed, de-installed and reinstalled this s/w and MySQL itself on my Win8 box. However, when I go to use it from a script, I get the following error: "C:\Python27\lib\site-packages\MySQLdb\__init.py__", line 27 in imp

Re: HMAC encription issue

2013-08-31 Thread Sergio Sanchez
El sábado, 31 de agosto de 2013 16:39:08 UTC+2, Roy Smith escribió: > In article <3479e08e-d435-492b-b2a0-a1c18678f...@googlegroups.com>, > > sergio7...@gmail.com wrote: > > > > > key="4545453030303743303134462035343733373432363420323031332D30382D33312031343A33353A3035" > > > key="4545453030

Re: HMAC encription issue

2013-08-31 Thread Roy Smith
In article <3479e08e-d435-492b-b2a0-a1c18678f...@googlegroups.com>, sergio7...@gmail.com wrote: > key="4545453030303743303134462035343733373432363420323031332D30382D33312031343A33353A3035" > key="4545453030303743303134462035343733373432363420323031332D30382D33312031343A33353A303$ To start with,

HMAC encription issue

2013-08-31 Thread sergio7654
Hi, I need to create a HMAC in Python just the way the following Javascript code does: var credentials = "admin:amin"; key="4545453030303743303134462035343733373432363420323031332D30382D33312031343A33353A3035" var shaObj = new jsSHA(credentials, "ASCII"); var hash = shaObj.getHMAC(key, "HEX", "HE

Re: print function and unwanted trailing space

2013-08-31 Thread Peter Otten
candide wrote: > Le 31/08/2013 12:31, Peter Otten a écrit : > > softspace = False > > for i in range(5): > > if softspace: > > print(end=" ") > > print(i, end="") > > softspace = True > > print() > > > The if instruction imposes useless testing (we know in advance

Re: print function and unwanted trailing space

2013-08-31 Thread candide
Le 31/08/2013 13:24, Ned Batchelder a écrit : For a beginner course, the trailing space is fine, use this code. I was really expecting there was a trick but I'll follow your advice, after all the trailing space is invisible! Nevertheless, this can be quite annoying. For instance, some autom

Re: print function and unwanted trailing space

2013-08-31 Thread candide
Le 31/08/2013 12:31, Peter Otten a écrit : > softspace = False > for i in range(5): > if softspace: > print(end=" ") > print(i, end="") > softspace = True > print() The if instruction imposes useless testing (we know in advance the problem to occur at the very end of the

Re: UnicodeDecodeError issue

2013-08-31 Thread Ferrous Cranus
Στις 31/8/2013 3:58 μμ, ο/η Ferrous Cranus έγραψε: Στις 31/8/2013 2:28 μμ, ο/η Steven D'Aprano έγραψε: On Sat, 31 Aug 2013 11:31:13 +0300, Ferrous Cranus wrote: Here is the code inside files.py: The code you show is not the ENTIRE code inside of files.py, is it? You are only showing us a sma

Re: print function and unwanted trailing space

2013-08-31 Thread candide
Le 31/08/2013 13:16, Steven D'Aprano a écrit : Of course it does. Have you actually tried it? Of course I did, redirecting the output to a file in order to spot an eventually trailing space. I did the same for the Python 3 code. -- http://mail.python.org/mailman/listinfo/python-list

Re: UnicodeDecodeError issue

2013-08-31 Thread Ferrous Cranus
Στις 31/8/2013 2:28 μμ, ο/η Steven D'Aprano έγραψε: On Sat, 31 Aug 2013 11:31:13 +0300, Ferrous Cranus wrote: Here is the code inside files.py: The code you show is not the ENTIRE code inside of files.py, is it? You are only showing us a small piece, correct? The code you show: try:

Re: Encapsulation unpythonic?

2013-08-31 Thread Fabrice Pombet
On Saturday, August 31, 2013 1:46:52 PM UTC+2, Steven D'Aprano wrote: > On Fri, 30 Aug 2013 23:07:47 -0700, Fabrice Pombet wrote: > > > > > well, look at that: > > > > > > a=(1,2) > > > a=2+3 ->a is an object and I have changed its type and value from > > > outside. > > > > Incorrect. Y

Re: Encapsulation unpythonic?

2013-08-31 Thread Fabrice Pombet
> > http://nedbatchelder.com/text/names.html > > > > --Ned. This is an excellent explanation, thank you. It is mostly of theoretical interest though, and in practice, I still contend that the consequences towards the syntax are (or seem, if you prefer) analogous to those of the lack of enc

Re: Encapsulation unpythonic?

2013-08-31 Thread Ned Batchelder
On 8/31/13 7:46 AM, Steven D'Aprano wrote: On Fri, 30 Aug 2013 23:07:47 -0700, Fabrice Pombet wrote: well, look at that: a=(1,2) a=2+3 ->a is an object and I have changed its type and value from outside. Incorrect. You have not changed the type or value of any object. "a" is not an object, it

Re: print function and unwanted trailing space

2013-08-31 Thread Oscar Benjamin
On 31 August 2013 12:16, Steven D'Aprano wrote: > On Sat, 31 Aug 2013 10:17:23 +0200, candide wrote: > >> What is the equivalent in Python 3 to the following Python 2 code: >> >> # - >> for i in range(5): >> print i, >> # - >> >> ? >> >>

Re: print function and unwanted trailing space

2013-08-31 Thread Peter Otten
Steven D'Aprano wrote: > On Sat, 31 Aug 2013 10:17:23 +0200, candide wrote: > >> What is the equivalent in Python 3 to the following Python 2 code: >> >> # - >> for i in range(5): >> print i, >> # - >> >> ? >> >> Be careful that the

Re: Encapsulation unpythonic?

2013-08-31 Thread Steven D'Aprano
On Fri, 30 Aug 2013 23:07:47 -0700, Fabrice Pombet wrote: > well, look at that: > > a=(1,2) > a=2+3 ->a is an object and I have changed its type and value from > outside. Incorrect. You have not changed the type or value of any object. "a" is not an object, it is a *name*, and while you can ch

Re: UnicodeDecodeError issue

2013-08-31 Thread Steven D'Aprano
On Sat, 31 Aug 2013 11:31:13 +0300, Ferrous Cranus wrote: > Here is the code inside files.py: The code you show is not the ENTIRE code inside of files.py, is it? You are only showing us a small piece, correct? The code you show: > try: > gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat

Re: print function and unwanted trailing space

2013-08-31 Thread Ned Batchelder
On 8/31/13 4:17 AM, candide wrote: What is the equivalent in Python 3 to the following Python 2 code: # - for i in range(5): print i, # - ? Be careful that the above code doesn't add a trailing space after the last number in the lis

Re: print function and unwanted trailing space

2013-08-31 Thread Steven D'Aprano
On Sat, 31 Aug 2013 10:17:23 +0200, candide wrote: > What is the equivalent in Python 3 to the following Python 2 code: > > # - > for i in range(5): > print i, > # - > > ? > > Be careful that the above code doesn't add a trailing spac

Re: print function and unwanted trailing space

2013-08-31 Thread Peter Otten
candide wrote: > Le 31/08/2013 10:43, Andreas Perstinger a écrit : > > > How about > > > > >>> print(" ".join(str(i) for i in range(5))) > > 0 1 2 3 4 > > > > > Thanks for your answer. The output is stricly the same but the code > doesn't suit my needs : > > 1) I'm porting to Python 3 a

Re: semicolon at end of python's statements

2013-08-31 Thread Jussi Piitulainen
Paul Rudin writes: > Jussi Piitulainen writes: > > > # Option 1.5 > > for spam in sequence: > > if not predicate(spam): continue > > process(spam) > > > > This saves an indent level. > > Just out of interest: is saving an indent level a useful thing? It might be if process(spam) is a mor

Re: print function and unwanted trailing space

2013-08-31 Thread candide
Le 31/08/2013 10:43, Andreas Perstinger a écrit : > How about > > >>> print(" ".join(str(i) for i in range(5))) > 0 1 2 3 4 > Thanks for your answer. The output is stricly the same but the code doesn't suit my needs : 1) I'm porting to Python 3 a Python 2 full beginner course : the learner

Re: print function and unwanted trailing space

2013-08-31 Thread Andreas Perstinger
On 31.08.2013 10:17, candide wrote: What is the equivalent in Python 3 to the following Python 2 code: # - for i in range(5): print i, # - ? How about >>> print(" ".join(str(i) for i in range(5))) 0 1 2 3 4 Bye, Andreas -- ht

Re: UnicodeDecodeError issue

2013-08-31 Thread Ferrous Cranus
Here is the code inside files.py: try: gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat') city = gi.time_zone_by_addr( os.environ['REMOTE_ADDR'] ) or gi.time_zone_by_addr( os.environ['HTTP_CF_CONNECTING_IP'] ) host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] ) or socket.getho

Re: Reading from stdin first, then use curses

2013-08-31 Thread Timo Schmiade
Hi again, sorry for replying to my own mail, but is there really no solution? Can curses really not be used in this situation? Thanks again, Timo On Sun, Aug 11, 2013 at 02:05:11PM +0200, Timo Schmiade wrote: > Hi all, > > I wrote a replacement for urlview to properly extract URLs from emails.

print function and unwanted trailing space

2013-08-31 Thread candide
What is the equivalent in Python 3 to the following Python 2 code: # - for i in range(5): print i, # - ? Be careful that the above code doesn't add a trailing space after the last number in the list, hence the following Python 3 code

Re: semicolon at end of python's statements

2013-08-31 Thread Paul Rudin
Jussi Piitulainen writes: > # Option 1.5 > for spam in sequence: > if not predicate(spam): continue > process(spam) > > This saves an indent level. Just out of interest: is saving an indent level a useful thing? I wouldn't lay out my code like that just because if you're coming back to

Re: Encapsulation unpythonic?

2013-08-31 Thread Fabrice Pombet
On Saturday, August 31, 2013 9:42:55 AM UTC+2, Fabrice Pombet wrote: > On Saturday, August 31, 2013 9:03:58 AM UTC+2, Gary Herron wrote: > > > On 08/30/2013 11:07 PM, Fabrice Pombet > > > wrote: > > > > > > > > > ... long discussion elided ... > > > > > > well, look at

Re: UnicodeDecodeError issue

2013-08-31 Thread Ferrous Cranus
Στις 31/8/2013 10:25 πμ, ο/η Peter Otten έγραψε: Ferrous Cranus wrote: Suddenly my webiste superhost.gr running my main python script presents me with this error: Code: UnicodeDecodeError('utf-8', b'\xb6\xe3\xed\xf9\xf3\xf4\xef \xfc\xed\xef\xec\xe1 \xf3\xf5\xf3\xf4\xde\xec\xe1\xf4\xef\xf2',

Re: semicolon at end of python's statements

2013-08-31 Thread Jussi Piitulainen
Steven D'Aprano writes: > We really are spoiled for choice here. We can write any of these: > > # Option 1 > for spam in sequence: > if predicate(spam): > process(spam) # Option 1.5 for spam in sequence: if not predicate(spam): continue process(spam) This saves an indent lev

Re: Encapsulation unpythonic?

2013-08-31 Thread Fabrice Pombet
On Saturday, August 31, 2013 9:03:58 AM UTC+2, Gary Herron wrote: > On 08/30/2013 11:07 PM, Fabrice Pombet > wrote: > > > ... long discussion elided ... > > well, look at that: > > a=(1,2) > a=2+3 ->a is an object and I have changed its type and value from outside. As > far

Re: UnicodeDecodeError issue

2013-08-31 Thread Peter Otten
Ferrous Cranus wrote: > Suddenly my webiste superhost.gr running my main python script presents > me with this error: > Code: > UnicodeDecodeError('utf-8', b'\xb6\xe3\xed\xf9\xf3\xf4\xef > \xfc\xed\xef\xec\xe1 \xf3\xf5\xf3\xf4\xde\xec\xe1\xf4\xef\xf2', 0, 1, > 'invalid start byte') > Does anyo

Re: UnicodeDecodeError issue

2013-08-31 Thread Ferrous Cranus
Στις 31/8/2013 10:02 πμ, ο/η Ferrous Cranus έγραψε: Στις 31/8/2013 9:53 πμ, ο/η Chris Angelico έγραψε: On Sat, Aug 31, 2013 at 4:41 PM, Ferrous Cranus wrote: Suddenly my webiste superhost.gr running my main python script presents me with this error: Code: UnicodeDecodeError('utf-8', b'\xb6\xe

Re: UnicodeDecodeError issue

2013-08-31 Thread Ferrous Cranus
Στις 31/8/2013 9:53 πμ, ο/η Chris Angelico έγραψε: On Sat, Aug 31, 2013 at 4:41 PM, Ferrous Cranus wrote: Suddenly my webiste superhost.gr running my main python script presents me with this error: Code: UnicodeDecodeError('utf-8', b'\xb6\xe3\xed\xf9\xf3\xf4\xef \xfc\xed\xef\xec\xe1 \xf3\xf5\x

Re: Encapsulation unpythonic?

2013-08-31 Thread Gary Herron
On 08/30/2013 11:07 PM, Fabrice Pombet wrote: ... long discussion elided ... well, look at that: a=(1,2) a=2+3 ->a is an object and I have changed its type and value from outside. As far as I am concerned this is one hell of an encapsulation violation... Could you do this -strictly speaking- i