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

2013-09-01 Thread anntzer . lee
On Sunday, September 1, 2013 2:03:56 PM UTC-7, Chris Angelico wrote: > > I tried using netifaces (https://pypi.python.org/pypi/netifaces) which > > seems to rely on getifaddrs (according to the doc, I didn't check the > > source). Again, it returns nearly instantaneously the correct IP address.

Re: Encapsulation unpythonic?

2013-09-01 Thread Ethan Furman
On 09/01/2013 05:59 PM, Roy Smith wrote: Ethan Furman wrote: On 09/01/2013 02:54 PM, Tim Delaney wrote: Roy Smith wrote: Nothing is accessible in Python except via getters and setters. The only difference between Python and, say, C++ in this regard is that the Python compiler writes them f

A Pragmatic Case for Static Typing

2013-09-01 Thread Russ P.
I just stumbled across this video and found it interesting: http://vimeo.com/72870631 My apologies if it has been posted here already. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to split with "\" character, and licence copyleft mirror of ©

2013-09-01 Thread materile11
El domingo, 1 de septiembre de 2013 19:34:16 UTC-5, Tim Chase escribió: > On 2013-09-01 17:03, materil...@gmail.com wrote: > > > Hello everybody > > > I'm trying to run this: > > > > > > > > > >>> a = 'E:\Dropbox\jjfsdjjsdklfj\sdfjksdfkjslkj\flute.wav' > > > >>> a.split('\') > > > > >

Re: UnicodeDecodeError issue

2013-09-01 Thread Ferrous Cranus
Στις 2/9/2013 2:14 πμ, ο/η Dave Angel έγραψε: On 1/9/2013 18:23, Ferrous Cranus wrote: i still wonder how come the invalid byte messge dissapeared Too bad you never bothered to narrow it down to its source. if only i knew how up until yesterday when they were appearing. It coul

Re: How to split with "\" character, and licence copyleft mirror of (c)

2013-09-01 Thread Zero Piraeus
: On 1 September 2013 22:40, Tim Roberts wrote: > Another altrnative is to use "raw" strings, in which backslashes are not > interpreted: > a = r'E:\Dropbox\jjfsdjjsdklfj\sdfjksdfkjslkj\flute.wav' > a.split(r'\') Acually, that doesn't work: >>> a = r'E:\Dropbox\jjfsdjjsdklfj\sdfjksd

Re: Encapsulation unpythonic?

2013-09-01 Thread Steven D'Aprano
On Sun, 01 Sep 2013 20:59:25 -0400, Roy Smith wrote: > In article , > Ethan Furman wrote: > >> On 09/01/2013 02:54 PM, Tim Delaney wrote: >> > Roy Smith wrote: >> >> >> >> Nothing is accessible in Python except via getters and setters. The >> >> only difference between Python and, say, C++ in

Re: How to split with "\" character, and licence copyleft mirror of �

2013-09-01 Thread Tim Roberts
materil...@gmail.com wrote: >Hello everybody >I'm trying to run this: > > a = 'E:\Dropbox\jjfsdjjsdklfj\sdfjksdfkjslkj\flute.wav' a.split('\') > >SyntaxError: EOL while scanning string literal > > >I think that the character '\' is the problem, but unfortunately I'm >developing a small

Re: Encapsulation unpythonic?

2013-09-01 Thread Steven D'Aprano
On Sun, 01 Sep 2013 15:13:06 -0400, Roy Smith wrote: > In article , > Ethan Furman wrote: > >> On 09/01/2013 03:09 AM, Fabrice Pombet wrote: >> > >> > So I guess that we are actually all agreeing on this one. >> >> No, we are not. >> >> "encapsulation" != "inaccessible except by getters/sette

Simplex Algorithm

2013-09-01 Thread Tommy Vee
Anyone know where I can get an easy to use Python class or algorithm for the Simplex optimization algorithm? I've tried the one in the link below, but I can't figure out if a) I'm using it properly, or b) where to get the solution. BTW, I tried some test scenarios using MS Excel's "Solver" an

Re: Encapsulation unpythonic?

2013-09-01 Thread Roy Smith
In article , Ethan Furman wrote: > On 09/01/2013 02:54 PM, Tim Delaney wrote: > > Roy Smith wrote: > >> > >> Nothing is accessible in Python except via getters and setters. The > >> only difference between Python and, say, C++ in this regard is that the > >> Python compiler writes them for you

Re: Encapsulation unpythonic?

2013-09-01 Thread Roy Smith
In article , Ben Finney wrote: > One of the more annoying traits of humanity is that whatever context we > first encounter a term is disproportionately privileged, causing us to > irrationally dismiss better (more useful, more reasonable, more > pedagogically appropriate, more historically corre

Re: Encapsulation unpythonic?

2013-09-01 Thread Ethan Furman
On 09/01/2013 02:54 PM, Tim Delaney wrote: Roy Smith wrote: Nothing is accessible in Python except via getters and setters. The only difference between Python and, say, C++ in this regard is that the Python compiler writes them for you most of the time and doesn't make you put ()'s at the end

Re: How to split with "\" character, and licence copyleft mirror of ©

2013-09-01 Thread Tim Chase
On 2013-09-02 10:23, Cameron Simpson wrote: > | I also want to know how to mirror a character, in my case this > | one ©, because I'll use the Copyleft > http://en.wikipedia.org/wiki/Copyleft | to distribute my app. > > Isn't that a copyright symbol? I'd have a look at the "uncidoedata" > module,

Re: How to split with "\" character, and licence copyleft mirror of ©

2013-09-01 Thread Tim Chase
On 2013-09-01 17:03, materil...@gmail.com wrote: > Hello everybody > I'm trying to run this: > > > >>> a = 'E:\Dropbox\jjfsdjjsdklfj\sdfjksdfkjslkj\flute.wav' > >>> a.split('\') > > SyntaxError: EOL while scanning string literal > > > I think that the character '\' is the problem, but unfortu

Re: How to split with "\" character, and licence copyleft mirror of ©

2013-09-01 Thread Cameron Simpson
On 01Sep2013 17:03, materil...@gmail.com wrote: | | >>> a = 'E:\Dropbox\jjfsdjjsdklfj\sdfjksdfkjslkj\flute.wav' | >>> a.split('\') | SyntaxError: EOL while scanning string literal | | | I think that the character '\' is the problem, but unfortunately I'm developing a small app for windows and

How to split with "\" character, and licence copyleft mirror of ©

2013-09-01 Thread materile11
Hello everybody I'm trying to run this: >>> a = 'E:\Dropbox\jjfsdjjsdklfj\sdfjksdfkjslkj\flute.wav' >>> a.split('\') SyntaxError: EOL while scanning string literal I think that the character '\' is the problem, but unfortunately I'm developing a small app for windows and I need to show only

Re: Encapsulation unpythonic?

2013-09-01 Thread Ben Finney
Steven D'Aprano writes: > […] programmers have been using the *principle* of encapsulation since > before Grace Hopper was an admiral. […] > Encapsulation and information hiding are distinct things -- you can > have one without the other. […] > One of the most obnoxious and annoying traits of O

Re: semicolon at end of python's statements

2013-09-01 Thread MRAB
On 01/09/2013 20:58, Antoon Pardon wrote: Op 31-08-13 02:09, Steven D'Aprano schreef: On Fri, 30 Aug 2013 11:32:17 +0100, Fábio Santos wrote: We really are spoiled for choice here. We can write any of these: # Option 1 for spam in sequence: if predicate(spam): process(spam)

Re: UnicodeDecodeError issue

2013-09-01 Thread Dave Angel
On 1/9/2013 18:23, Ferrous Cranus wrote: >> > i still wonder how come the invalid byte messge dissapeared > Too bad you never bothered to narrow it down to its source. It could be anywhere on those three lines. If I had to guess, I'd figure it was one of those environment variables. The L

Re: UnicodeDecodeError issue

2013-09-01 Thread Ferrous Cranus
Στις 1/9/2013 7:10 μμ, ο/η Ferrous Cranus έγραψε: Στις 1/9/2013 6:36 μμ, ο/η Dave Angel έγραψε: On 1/9/2013 10:08, Ferrous Cranus wrote: Here is it: errout = open( '/tmp/err.out', 'w' )# opens and truncates the error output file try: gi = pygeoip.GeoIP('/usr/local/share/GeoI

Re: Encapsulation unpythonic?

2013-09-01 Thread Roy Smith
In article , Tim Delaney wrote: > On 2 September 2013 06:33, Ethan Furman wrote: > > > > > class PlainPython: > > > > value = None > > > > > > In the Javaesque class we see the unPythonic way of using getters/setters; > > in the ProtectedPython* class we see the pythonic way of providing >

Re: Encapsulation unpythonic?

2013-09-01 Thread Tim Delaney
On 2 September 2013 06:33, Ethan Furman wrote: > > class PlainPython: > > value = None > > > In the Javaesque class we see the unPythonic way of using getters/setters; > in the ProtectedPython* class we see the pythonic way of providing > getters/setters**; in the PlainPython class we have th

Re: Encapsulation unpythonic?

2013-09-01 Thread Ethan Furman
On 09/01/2013 12:13 PM, Roy Smith wrote: In article , Ethan Furman wrote: On 09/01/2013 03:09 AM, Fabrice Pombet wrote: So I guess that we are actually all agreeing on this one. No, we are not. "encapsulation" != "inaccessible except by getters/setters" Nothing is accessible in Python

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

2013-09-01 Thread Chris Angelico
On Mon, Sep 2, 2013 at 6:37 AM, wrote: > On Sunday, September 1, 2013 4:37:34 AM UTC-7, Chris Angelico wrote: > >> Yes, it most definitely CAN be a network config issue. The C function >> you want to be calling is getifaddrs(), and I don't think there's a >> way to call that from core Python. But

Re: semicolon at end of python's statements

2013-09-01 Thread Antoon Pardon
Op 31-08-13 02:09, Steven D'Aprano schreef: On Fri, 30 Aug 2013 11:32:17 +0100, Fábio Santos wrote: We really are spoiled for choice here. We can write any of these: # Option 1 for spam in sequence: if predicate(spam): process(spam) Adding a fourth option: for spam in se

MySQL data types vs Django/Python data types

2013-09-01 Thread Gary Roach
Hi all, System: Debian Wheezy Linux Python 2.7 Django 1.5 MySql 5.5 I am new to Python and Django and am having trouble matching Python data types with those of MySQL. MySQL has about 7 basic data types including Blobs, Binaries, etc. It also has a rich selectio

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

2013-09-01 Thread anntzer . lee
On Sunday, September 1, 2013 4:37:34 AM UTC-7, Chris Angelico wrote: > Yes, it most definitely CAN be a network config issue. The C function > you want to be calling is getifaddrs(), and I don't think there's a > way to call that from core Python. But a Google search for 'python > getifaddrs' show

Re: Reading from stdin first, then use curses

2013-09-01 Thread Antoon Pardon
Op 11-08-13 14:05, Timo Schmiade schreef: Hi all, I wrote a replacement for urlview to properly extract URLs from emails. You can find the first draft here: https://github.com/the-isz/pyurlview When I call it with an email file passed to the '-f' argument, it does pretty much what I want al

Re: connecting clicked signal to different slots depending on function executing

2013-09-01 Thread tausciam
Nevermind. I found that it would let me create the connection again then when I disconnected, it would disconnect all of the instances... so I ended up with: self.tableWidget.cellClicked.connect(self.videocell_clicked) self.tableWidget.cellClicked.disconnect(self.videocel

Re: connecting clicked signal to different slots depending on function executing

2013-09-01 Thread tausciam
I should add that I know about: self.tableWidget.cellClicked.disconnect(self.videocell_clicked) but, when I do that, if the connection is not there, then the program crashes. So, how could I check to see if the connection is there then break it? -- http://mail.python.org/mailman/listinfo/pyth

connecting clicked signal to different slots depending on function executing

2013-09-01 Thread tausciam
I have one tablewidget I want to use for two different uses, audio and video. If cover art is displayed and the user clicks the cover art, it emits a cell clicked and gets the list of the songs. If video thumbnails are displayed, it emits a cell clicked and plays the video fullscreen. So, I hav

Re: Encapsulation unpythonic?

2013-09-01 Thread Roy Smith
In article , Ethan Furman wrote: > On 09/01/2013 03:09 AM, Fabrice Pombet wrote: > > > > So I guess that we are actually all agreeing on this one. > > No, we are not. > > "encapsulation" != "inaccessible except by getters/setters" Nothing is accessible in Python except via getters and setters

Re: Encapsulation unpythonic?

2013-09-01 Thread Ethan Furman
On 09/01/2013 03:09 AM, Fabrice Pombet wrote: So I guess that we are actually all agreeing on this one. No, we are not. "encapsulation" != "inaccessible except by getters/setters" -- ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: What does mean @ sign in first of statement

2013-09-01 Thread Chris “Kwpolska” Warrick
On Sun, Sep 1, 2013 at 8:53 PM, Mohsen Pahlevanzadeh wrote: > Dear all, > > What does mean @ sign in first of statement such as: > > // > @hybrid_property > def fullname(self): > return self.firstname + " " + self.lastname > /// > > Sorry for cheap question. > >

What does mean @ sign in first of statement

2013-09-01 Thread Mohsen Pahlevanzadeh
Dear all, What does mean @ sign in first of statement such as: // @hybrid_property def fullname(self): return self.firstname + " " + self.lastname /// Sorry for cheap question. Yours, Mohsen -- http://mail.python.org/mailman/listinfo/python-list

Re: semicolon at end of python's statements

2013-09-01 Thread Antoon Pardon
Op 31-08-13 02:09, Steven D'Aprano schreef: On Fri, 30 Aug 2013 11:32:17 +0100, Fábio Santos wrote: On 29 Aug 2013 23:20, "Ben Finney" wrote: Fábio Santos writes: It is a shame that this is not possible in python. for..if exists in comprehensions and not in regular loops but that would be

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

2013-09-01 Thread anntzer . lee
On Saturday, August 31, 2013 10:06:43 PM UTC-7, Michael Torrie wrote: > 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 gethostby

Re: UnicodeDecodeError issue

2013-09-01 Thread Ferrous Cranus
Στις 1/9/2013 6:36 μμ, ο/η Dave Angel έγραψε: On 1/9/2013 10:08, Ferrous Cranus wrote: Here is it: errout = open( '/tmp/err.out', 'w' )# opens and truncates the error output file try: gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat') city = gi.time_zone_by_

Re: UnicodeDecodeError issue

2013-09-01 Thread Dave Angel
On 1/9/2013 09:59, Ferrous Cranus wrote: > Στις 1/9/2013 1:35 μμ, ο/η Dave Angel έγραψε: >> This is my first crack at it (untested): >> >> errout = open("/tmp/err.out", "w") #opens and truncates the error >> output file >> try: >> gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat') >>

Re: UnicodeDecodeError issue

2013-09-01 Thread Dave Angel
On 1/9/2013 10:08, Ferrous Cranus wrote: > Here is it: > > > errout = open( '/tmp/err.out', 'w' ) # opens and truncates the error > output file > try: > gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat') > city = gi.time_zone_by_addr( os.environ['REMOTE_ADDR'] ) or > g

Re: UnicodeDecodeError issue

2013-09-01 Thread Ferrous Cranus
Στις 1/9/2013 5:08 μμ, ο/η Ferrous Cranus έγραψε: Στις 1/9/2013 11:35 πμ, ο/η Steven D'Aprano έγραψε: On Sat, 31 Aug 2013 23:50:23 -0700, Ferrous Cranus wrote: Τη Σάββατο, 31 Αυγούστου 2013 9:41:27 π.μ. UTC+3, ο χρήστης Ferrous Cranus έγραψε: Suddenly my webiste superhost.gr running my main p

Re: UnicodeDecodeError issue

2013-09-01 Thread Ferrous Cranus
Στις 1/9/2013 11:35 πμ, ο/η Steven D'Aprano έγραψε: On Sat, 31 Aug 2013 23:50:23 -0700, Ferrous Cranus wrote: Τη Σάββατο, 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:

Re: UnicodeDecodeError issue

2013-09-01 Thread Ferrous Cranus
Στις 1/9/2013 1:35 μμ, ο/η Dave Angel έγραψε: This is my first crack at it (untested): errout = open("/tmp/err.out", "w") #opens and truncates the error output file try: gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat') city = gi.time_zone_by_addr( os.environ['REMOTE_ADDR'] ) or g

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

2013-09-01 Thread Chris Angelico
On Sun, Sep 1, 2013 at 10:03 AM, wrote: > 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 understa

Re: Newbie: use of built-in exceptions

2013-09-01 Thread Chris “Kwpolska” Warrick
On Sun, Sep 1, 2013 at 1:17 PM, Rui Maciel wrote: > Are there any guidelines on the use (and abuse) of Python's built-in > exceptions, telling where > it's ok to raise them and where it's preferable to define custom exceptions > instead? There are no rules. You should use common sense instead:

Newbie: use of built-in exceptions

2013-09-01 Thread Rui Maciel
Are there any guidelines on the use (and abuse) of Python's built-in exceptions, telling where it's ok to raise them and where it's preferable to define custom exceptions instead? Thanks in advance, Rui Maciel -- http://mail.python.org/mailman/listinfo/python-list

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

2013-09-01 Thread Roy Smith
In article <48c8f8ca-d8c1-4a60-ba7f-8e8b00993...@googlegroups.com>, 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). First, please stop posting with Google Groups. It mak

Re: UnicodeDecodeError issue

2013-09-01 Thread Chris Angelico
On Sun, Sep 1, 2013 at 8:35 PM, Dave Angel wrote: > Your file mode is 'w' which will wipe out anything written earlier. Yet > if the exception does not happen, the file will still contain error(s) > from some earlier run. You should open (and truncate) the file before > the first use, then use t

Re: UnicodeDecodeError issue

2013-09-01 Thread Dave Angel
On 1/9/2013 03:23, Ferrous Cranus wrote: > Στις 1/9/2013 10:12 πμ, ο/η Chris Angelico έγραψε: >> On Sun, Sep 1, 2013 at 4:50 PM, Ferrous Cranus wrote: >>> Ye i'm aware that i need to define variables before i try to make use of >>> them. >>> I have study all of your examples and then re-view my

Re: Encapsulation unpythonic?

2013-09-01 Thread Fabrice Pombet
> That said, though, when you consider the language ecosystem rather > > than just the language, there is a strong tendency for Java and C++ > > code to wrap everything up with functions (no public data members), > > whereas Python code is far more likely to have external code directly > > acc

Re: UnicodeDecodeError issue

2013-09-01 Thread Steven D'Aprano
On Sat, 31 Aug 2013 23:50:23 -0700, Ferrous Cranus wrote: > Τη Σάββατο, 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

Re: Encapsulation unpythonic?

2013-09-01 Thread Chris Angelico
On Sun, Sep 1, 2013 at 6:10 PM, Steven D'Aprano wrote: > Java and C++ allow you to declare members as public, so it is *not true* > that calling methods is the only way to change members. If you accept > Steve Holden's (wrong) definition above, Java and C++ don't have > encapsulation either. That

Re: Encapsulation unpythonic?

2013-09-01 Thread Steven D'Aprano
On Sat, 31 Aug 2013 05:57:47 -0700, Fabrice Pombet wrote: > Steve, I think that your definition of encapsulation is too wide to give > a reasonable answer to the question at hand. My definition of encapsulation is based on the plain language definition. It is also common in computer programming

Re: UnicodeDecodeError issue

2013-09-01 Thread Chris Angelico
On Sun, Sep 1, 2013 at 5:23 PM, Ferrous Cranus wrote: > Let alone that i when i try to set the 'host' variable i get this line at my > '/tmp/err.out' > > > ni...@superhost.gr [~]# cat /tmp/err.out > > UnicodeDecodeError('utf-8', b'\xb6\xe3\xed\xf9\xf3\xf4\xef > \xfc\xed\xef\xec\xe1 \xf3\xf5\xf3\xf

Re: UnicodeDecodeError issue

2013-09-01 Thread Ferrous Cranus
Στις 1/9/2013 10:12 πμ, ο/η Chris Angelico έγραψε: On Sun, Sep 1, 2013 at 4:50 PM, Ferrous Cranus wrote: Ye i'm aware that i need to define variables before i try to make use of them. I have study all of your examples and then re-view my code and i can *assure* you that the line statement that

Re: UnicodeDecodeError issue

2013-09-01 Thread Chris Angelico
On Sun, Sep 1, 2013 at 4:50 PM, Ferrous Cranus wrote: > Ye i'm aware that i need to define variables before i try to make use of them. > I have study all of your examples and then re-view my code and i can *assure* > you that the line statement that tied to set the 'host' variable is very > earl