Re: writing an email.message.Message in UTF-8

2015-12-07 Thread dieter
Adam Funk writes: > I'm trying to write an instance of email.message.Message, whose body > contains unicode characters, to a UTF-8 file. (Python 2.7.3 & 2.7.10 > again.) > > reply = email.message.Message() > reply.set_charset('utf-8') > ... # set various headers > reply.set_paylo

Re: Help with stale exception Python

2015-12-07 Thread dieter
iverson.z...@gmail.com writes: > ... > I have tried uncountable number of methods (e.g. explicit, implicit wait) but > the stale error still persists as it seems to stays stale as long as it is > staled. > > Have anyone come up with a solution to this and what is the best way to deal > with DOM

Re: manually build a unittest/doctest object.

2015-12-07 Thread Steven D'Aprano
On Tuesday 08 December 2015 14:30, Vincent Davis wrote: > If I have a string that is python code, for example > mycode = "print('hello world')" > myresult = "hello world" > How can a "manually" build a unittest (doctest) and test I get myresult Not easily. Effectively, you would have to re-invent

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread villascape
Based on your responses, it is my understanding that process-state might offer some efficiency benefits, but it is typically not a driving factor. If I misunderstand, please advise. Thanks -- https://mail.python.org/mailman/listinfo/python-list

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Tim Chase
On 2015-12-08 08:40, Chris Angelico wrote: > One advantage of this kind of setup is that your URLs don't depend > on your back end. I could replace all this with a Ruby on Rails > site, and nobody would notice the difference. I could put together > something using Node.js to replace the Ruby site,

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Chris Angelico
On Tue, Dec 8, 2015 at 2:11 PM, Tim Chase wrote: > On 2015-12-08 10:09, Chris Angelico wrote: >> All three are very different. >> >> 1) Process state. >> >> You start up a Python program, and it sits there waiting for a >> request. You give it a request, and get back a response; it goes >> back to

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Tim Chase
On 2015-12-08 10:09, Chris Angelico wrote: > All three are very different. > > 1) Process state. > > You start up a Python program, and it sits there waiting for a > request. You give it a request, and get back a response; it goes > back to waiting for a request. If you change a global variable,

manually build a unittest/doctest object.

2015-12-07 Thread Vincent Davis
If I have a string that is python code, for example mycode = "print('hello world')" myresult = "hello world" How can a "manually" build a unittest (doctest) and test I get myresult I have attempted to build a doctest but that is not working. e = doctest.Example(source="print('hello world')/n", wan

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Chris Angelico
On Tue, Dec 8, 2015 at 12:00 PM, wrote: > Ah, I was confused that process state somehow allowed Python to support > per-connection state without using sessions (which lead me to ask about > websockets). I guess Python could do it without storing the session ID in a > file or database and inst

Re: Help on for loop understanding

2015-12-07 Thread Chris Angelico
On Tue, Dec 8, 2015 at 1:36 PM, Erik wrote: > So, you can write your class's iterator to do anything that makes sense when > someone says "for i in myclassinstance:". > > If your class is a subclass of a class ("is-a") that already has a defined > iterator (such as a list or a dict) and the behavi

Re: Help on for loop understanding

2015-12-07 Thread Erik
On 08/12/15 01:50, Robert wrote: One example, see below please, is in the above mentioned link. I don't see the purpose of the example. OK, so there are two parts to this. The first, is "how do I iterate over something". The answer to that is using "for" or using "iter()" followed by zero or

Re: Help on for loop understanding

2015-12-07 Thread Robert
On Monday, December 7, 2015 at 8:39:48 PM UTC-5, Robert wrote: > On Monday, December 7, 2015 at 8:32:30 PM UTC-5, Robert wrote: > > On Monday, December 7, 2015 at 8:14:46 PM UTC-5, Robin Koch wrote: > > > Am 08.12.2015 um 02:05 schrieb Robert: > > > > Hi, > > > > When I learn for loop with below li

Re: Help on for loop understanding

2015-12-07 Thread Erik
Hi Robert, On 08/12/15 01:39, Robert wrote: I don't find a way to show __next__ yet. Can we explicitly get the iterator for a list? Thanks, Excuse me. I find it as the following: xx.__iter__().next Out[16]: xx.__iter__().next() Out[17]: 1 Robin has told you how things work under the hood

Re: Help on for loop understanding

2015-12-07 Thread Robert
On Monday, December 7, 2015 at 8:32:30 PM UTC-5, Robert wrote: > On Monday, December 7, 2015 at 8:14:46 PM UTC-5, Robin Koch wrote: > > Am 08.12.2015 um 02:05 schrieb Robert: > > > Hi, > > > When I learn for loop with below link: > > > > > > http://www.shutupandship.com/2012/01/understanding-python

Re: Help on for loop understanding

2015-12-07 Thread Robert
On Monday, December 7, 2015 at 8:14:46 PM UTC-5, Robin Koch wrote: > Am 08.12.2015 um 02:05 schrieb Robert: > > Hi, > > When I learn for loop with below link: > > > > http://www.shutupandship.com/2012/01/understanding-python-iterables-and.html > > > > it has such explanation: > > > > \ > >

Re: Help on for loop understanding

2015-12-07 Thread Robin Koch
Am 08.12.2015 um 02:05 schrieb Robert: Hi, When I learn for loop with below link: http://www.shutupandship.com/2012/01/understanding-python-iterables-and.html it has such explanation: \ for loop under the hood First let's look at the for loop under the hood. When Python executes the

Help on for loop understanding

2015-12-07 Thread Robert
Hi, When I learn for loop with below link: http://www.shutupandship.com/2012/01/understanding-python-iterables-and.html it has such explanation: \ for loop under the hood First let's look at the for loop under the hood. When Python executes the for loop, it first invokes the __iter__()

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread villascape
Ah, I was confused that process state somehow allowed Python to support per-connection state without using sessions (which lead me to ask about websockets). I guess Python could do it without storing the session ID in a file or database and instead in process state (i.e. application memory, ri

Re: increment/decrement operators

2015-12-07 Thread Ian Kelly
On Dec 5, 2015 10:21 AM, "BartC" wrote: > > > The latter is not the same. Some of the differences are: > > * ++ and -- are often inside inside expressions and return values (unlike x+=1 in Python) > > * x++ and x-- return the /current/ value of x, unlike x+=1 even if it were to return a val

Re: Accessing container's methods

2015-12-07 Thread Erik
Hi Tony, On 07/12/15 18:10, Tony van der Hoff wrote: A highly contrived example, where I'm setting up an outer class in a Has-a relationship, containing a number of Actors. The inner class needs to access a method of the outer class; here the method get_name. Generally, an object should not ne

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Cameron Simpson
On 07Dec2015 14:27, villasc...@gmail.com wrote: In regards to Chris's statement: "It openly and honestly does NOT reset its state between page requests" With PHP, I have sessions to preserve state. I have a feeling that this is significantly different. Yes? How? Does this somehow relate to

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Ian Kelly
On Mon, Dec 7, 2015 at 3:27 PM, wrote: > Thank you all! > > Okay, the concept of a WSGI along with a framework provides insight on my > main questions. > > In regards to Chris's statement: "It openly and honestly does NOT reset its > state between page requests" > > With PHP, I have sessions to

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Chris Angelico
On Tue, Dec 8, 2015 at 9:27 AM, wrote: > In regards to Chris's statement: "It openly and honestly does NOT reset its > state between page requests" > > With PHP, I have sessions to preserve state. I have a feeling that this is > significantly different. Yes? How? Does this somehow relate to

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread villascape
Thank you all! Okay, the concept of a WSGI along with a framework provides insight on my main questions. In regards to Chris's statement: "It openly and honestly does NOT reset its state between page requests" With PHP, I have sessions to preserve state. I have a feeling that this is signifi

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Chris Angelico
On Tue, Dec 8, 2015 at 8:59 AM, Ian Kelly wrote: > On Mon, Dec 7, 2015 at 2:40 PM, Chris Angelico wrote: >> So that's a quick potted summary of why the URLs don't reflect the >> language used. Python is event-driven, but instead of defining events >> at the file level, the way PHP does, they're d

Re: Accessing container's methods

2015-12-07 Thread Chris Angelico
On Tue, Dec 8, 2015 at 8:38 AM, Terry Reedy wrote: >>def list_actors( self ): >> h=[] >> for n in self.actors: >>h.append( n.get_name() ) >> return h > > > return list(self.actors) # or perhaps even faster > return self.actors[:] Not identical semantics. This is a use-

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Ian Kelly
On Mon, Dec 7, 2015 at 2:40 PM, Chris Angelico wrote: > So that's a quick potted summary of why the URLs don't reflect the > language used. Python is event-driven, but instead of defining events > at the file level, the way PHP does, they're defined at the function > level. Of course, if you *want

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Chris Angelico
On Tue, Dec 8, 2015 at 8:21 AM, wrote: > Per https://wiki.python.org/moin/PythonVsPhp, "The vast majority of Python > Web applications are run in a separate process. This has some important > implications." > > From a PHP background, guess I just don't understand the concept of "separate > pro

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Terry Reedy
On 12/7/2015 4:07 PM, villasc...@gmail.com wrote: Hello all! Just started getting into Python, and am very excited about the prospect. I am struggling on some general concepts. My past experience with server-side code is mostly limited to PHP and websites. I have some file called "whatever.

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Chris Angelico
On Tue, Dec 8, 2015 at 8:07 AM, wrote: > I am struggling on some general concepts. My past experience with > server-side code is mostly limited to PHP and websites. I have some file > called "whatever.php", the browser accesses it, and PHP parses it and returns > HTML, JSON, etc. Every now

Re: Accessing container's methods

2015-12-07 Thread Terry Reedy
On 12/7/2015 1:10 PM, Tony van der Hoff wrote: Hi, I have a class A, containing embedded embedded classes, which need to access methods from A. . A highly contrived example, where I'm setting up an outer class in a Has-a relationship, containing a number of Actors. The inner class needs to acces

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Ian Kelly
On Mon, Dec 7, 2015 at 2:07 PM, wrote: > Hello all! Just started getting into Python, and am very excited about the > prospect. > > I am struggling on some general concepts. My past experience with > server-side code is mostly limited to PHP and websites. I have some file > called "whatever

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Cameron Simpson
On 07Dec2015 13:07, villasc...@gmail.com wrote: Hello all! Just started getting into Python, and am very excited about the prospect. I am struggling on some general concepts. My past experience with server-side code is mostly limited to PHP and websites. I have some file called "whatever.p

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread villascape
Right after I sent my first post, I realized I did not include the following: Per https://wiki.python.org/moin/PythonVsPhp, "The vast majority of Python Web applications are run in a separate process. This has some important implications." >From a PHP background, guess I just don't understand t

Understanding Python from a PHP coder's perspective

2015-12-07 Thread villascape
Hello all! Just started getting into Python, and am very excited about the prospect. I am struggling on some general concepts. My past experience with server-side code is mostly limited to PHP and websites. I have some file called "whatever.php", the browser accesses it, and PHP parses it an

Re: Brief Code Review Please - Learning Python

2015-12-07 Thread Thomas 'PointedEars' Lahn
Joel Goldstick wrote: > On Sun, Dec 6, 2015 at 12:21 PM, wrote: >> * Same question as right above but with the if tests on lines 5-8. >> * I've also used ( ) around the if tests, but I'm not sure if this is >> good Python style or not. >> >> 1 def measure_string(desired_text, >> 2

Re: Accessing container's methods

2015-12-07 Thread Ian Kelly
On Mon, Dec 7, 2015 at 11:10 AM, Tony van der Hoff wrote: > Hi, > > I have a class A, containing embedded embedded classes, which need to access > methods from A. > . > A highly contrived example, where I'm setting up an outer class in a Has-a > relationship, containing a number of Actors. The inn

Re: Accessing container's methods

2015-12-07 Thread Thomas 'PointedEars' Lahn
Michael Torrie wrote: > On 12/07/2015 11:10 AM, Tony van der Hoff wrote: >> I have a class A, containing embedded embedded classes, which need to >> access methods from A. >> . >> A highly contrived example, where I'm setting up an outer class in a >> Has-a relationship, containing a number of Act

Re: Accessing container's methods

2015-12-07 Thread Peter Otten
Tony van der Hoff wrote: > Hi, > > I have a class A, containing embedded embedded classes, which need to > access methods from A. > . > A highly contrived example, where I'm setting up an outer class in a > Has-a relationship, containing a number of Actors. The inner class needs > to access a met

Re: Accessing container's methods

2015-12-07 Thread Thomas 'PointedEars' Lahn
Tony van der Hoff wrote: > I have a class A, containing embedded embedded classes, which need to > access methods from A. Let the name of the "embedded class" (which is not embedded at all in your example code) be E. You could either store the information in the E instance upon or after constr

Re: Accessing container's methods

2015-12-07 Thread Michael Torrie
On 12/07/2015 11:10 AM, Tony van der Hoff wrote: > Hi, > > I have a class A, containing embedded embedded classes, which need to > access methods from A. > . > A highly contrived example, where I'm setting up an outer class in a > Has-a relationship, containing a number of Actors. The inner clas

Re: Accessing container's methods

2015-12-07 Thread Rob Gaddi
Tony van der Hoff wrote: > Hi, > > I have a class A, containing embedded embedded classes, which need to > access methods from A. > . > A highly contrived example, where I'm setting up an outer class in a > Has-a relationship, containing a number of Actors. The inner class needs > to access a m

Accessing container's methods

2015-12-07 Thread Tony van der Hoff
Hi, I have a class A, containing embedded embedded classes, which need to access methods from A. . A highly contrived example, where I'm setting up an outer class in a Has-a relationship, containing a number of Actors. The inner class needs to access a method of the outer class; here the meth

Re: Issue

2015-12-07 Thread Ian Kelly
On Sun, Dec 6, 2015 at 5:16 PM, Steven D'Aprano wrote: > Oh, I can make one guess... if you're using Windows XP, I'm afraid that > Python 3.5 is not supported. You'll have to either downgrade to Python 3.4, > or upgrade to Windows 7 or higher, or another operating system. For the sake of accuracy

Re: python 3.5: upgrading smart_open package

2015-12-07 Thread Terry Reedy
On 12/7/2015 12:15 PM, Anupam Mediratta wrote: Hello, I have to use python 3.5 in my use case and one of the packages I use (gensim), in turn uses smart_open (https://github.com/piskvorky/smart_open/) smart_open depends on boto and boto fails on my machine running ubuntu 15.10. So in order for

Re: python 3.5: upgrading smart_open package

2015-12-07 Thread Laura Creighton
In a message of Mon, 07 Dec 2015 22:45:44 +0530, Anupam Mediratta writes: >Hello, > >I have to use python 3.5 in my use case and one of the packages I use >(gensim), in turn uses smart_open (https://github.com/piskvorky/smart_open/) > >smart_open depends on boto and boto fails on my machine running

Re: writing an email.message.Message in UTF-8

2015-12-07 Thread Terry Reedy
On 12/7/2015 9:57 AM, Adam Funk wrote: I'm trying to write an instance of email.message.Message, whose body contains unicode characters, to a UTF-8 file. (Python 2.7.3 & 2.7.10 again.) The email package was rewritten for, I believe, 3.3. I believe it should handle unicode email encoded as ut

python 3.5: upgrading smart_open package

2015-12-07 Thread Anupam Mediratta
Hello, I have to use python 3.5 in my use case and one of the packages I use (gensim), in turn uses smart_open (https://github.com/piskvorky/smart_open/) smart_open depends on boto and boto fails on my machine running ubuntu 15.10. So in order for me to be able to run gensim, I need to be able t

Re: Packages installing problem

2015-12-07 Thread Laura Creighton
In a message of Mon, 07 Dec 2015 00:32:37 +, lalith writes: >Dear sir. > >I was using Python2.7 and i move to Python3.5. >I face big trouble with installing software packages, i need in my >development. > >Lalith >-- >https://mail.python.org/mailman/listinfo/python-list Do you want to instal

Re: install issue

2015-12-07 Thread Laura Creighton
In a message of Sun, 06 Dec 2015 20:44:03 +, "John Robinson" writes: >When I run the installer (python-3.5.0.exe [win32]) I see this: > > > > > > > >There seems to be "hidden" buttons as clicking in the middle of this dialog >box does continue the process. > >However, when complete, and I st

Re: writing an email.message.Message in UTF-8

2015-12-07 Thread Adam Funk
On 2015-12-07, Adam Funk wrote: > I'm trying to write an instance of email.message.Message, whose body > contains unicode characters, to a UTF-8 file. (Python 2.7.3 & 2.7.10 > again.) > > reply = email.message.Message() > reply.set_charset('utf-8') > ... # set various headers > re

Re: define the area plot

2015-12-07 Thread Laura Creighton
In a message of Mon, 07 Dec 2015 10:51:10 -0200, jorge.conr...@cptec.inpe.br wr ites: > > >Hi, > >I'm changing from the IDL to PYTHON. I would like know how can I define >the size of the window plot in Python. On IDL I define the size of area >plot by: > > >window,1,xsize=1000,ysize=1000 > > >It

writing an email.message.Message in UTF-8

2015-12-07 Thread Adam Funk
I'm trying to write an instance of email.message.Message, whose body contains unicode characters, to a UTF-8 file. (Python 2.7.3 & 2.7.10 again.) reply = email.message.Message() reply.set_charset('utf-8') ... # set various headers reply.set_payload('\n'.join(body_lines) + '\n')

Re: getting fileinput to do errors='ignore' or 'replace'?

2015-12-07 Thread Adam Funk
On 2015-12-04, Oscar Benjamin wrote: > Or you can use fileinput which is designed to be exactly this kind of > context manager and to be used in this way. Although fileinput is slightly > awkward in defaulting to reading stdin. That default is what I specifically like about fileinput --- it's a n

install issue

2015-12-07 Thread John Robinson
When I run the installer (python-3.5.0.exe [win32]) I see this: There seems to be "hidden" buttons as clicking in the middle of this dialog box does continue the process. However, when complete, and I start python, I get an error saying its not a valid win32 application. So, I uninstall

Packages installing problem

2015-12-07 Thread lalith
Dear sir. I was using Python2.7 and i move to Python3.5. I face big trouble with installing software packages, i need in my development. Lalith -- https://mail.python.org/mailman/listinfo/python-list

Twisted 15.4 was the last release to support Python 2.6; or: a HawkOwl Can't Words Situation

2015-12-07 Thread Amber "Hawkie" Brown
Hi everyone! It's been brought to my attention that I misworded something in the release notes and it slipped through the cracks. In the NEWS I said: > This is the last Twisted release where Python 2.6 is supported, on any > platform. However, I meant that this is the first Twisted release to

define the area plot

2015-12-07 Thread jorge . conrado
Hi, I'm changing from the IDL to PYTHON. I would like know how can I define the size of the window plot in Python. On IDL I define the size of area plot by: window,1,xsize=1000,ysize=1000 It is possible define the size of the window before my data is plotted. Conrado -- https://mail.pyt

Re: Unicode failure

2015-12-07 Thread Oscar Benjamin
On Sun, 6 Dec 2015 at 23:11 Quivis wrote: > On Fri, 04 Dec 2015 13:07:38 -0500, D'Arcy J.M. Cain wrote: > > > I thought that going to Python 3.4 would solve my Unicode issues but it > > seems I still don't understand this stuff. Here is my script. > > > > #! /usr/bin/python3 # -*- coding: UTF-8

Help with stale exception Python

2015-12-07 Thread iverson . zhou
I'm new to Python and programming. Been learning it for 3 weeks now but have had lot of obstacles along the way. I found some of your insights very useful as a starter but I have come across many more complicated challenges that aren't very intuitive. For example,I'm trying to scrap this web(vi