Re: Values and objects

2014-05-09 Thread Steven D'Aprano
On Sat, 10 May 2014 12:33:28 +1000, Chris Angelico wrote: > On Sat, May 10, 2014 at 12:19 PM, Rustom Mody > wrote: >> For me, Marko's comment that variables in python are not first-class >> whereas in C they are is for me the most important distinction Ive seen >> (in a long time of seeing these

Re: The � debate

2014-05-09 Thread Gregory Ewing
Steven D'Aprano wrote: some_function(x, y+1)[key].attribute[num](arg)[spam or eggs] = 42 I'm pretty sure that it isn't common to call the LHS of that assignment a variable. A better way of putting it might be "something in the data model that can be assigned to". -- Greg -- https://mail.pyth

Re: Why isn't my re.sub replacing the contents of my MS Word file?

2014-05-09 Thread Rustom Mody
On Saturday, May 10, 2014 1:21:04 AM UTC+5:30, scott...@gmail.com wrote: > Hi, > > > > here is a snippet of code that opens a file (fn contains the path\name) and > first tried to replace all endash, emdash etc characters with simple dash > characters, before doing a search. > > But the re

Re: Values and objects

2014-05-09 Thread Mark H Harris
On 5/9/14 10:05 PM, Rustom Mody wrote: Likewise python's name-spaces go almost all the way to first-classing variables but not quite as Marko discovered when locals() looks like a dict, waddles like a dict but does not quack like a dict. QOTWeekEnd -- https://mail.python.org/mailman/listinfo/p

Re: How to implement key of key in python?

2014-05-09 Thread eckhleung
On Saturday, May 10, 2014 10:30:06 AM UTC+8, MRAB wrote: > On 2014-05-10 02:22, I wrote: > > > I'm migrating from Perl to Python and unable to identify the equivalent of > > key of key concept. The following codes run well, > > > import csv > > > attr = {} > > > with open('test.txt','rb') as t

Re: Values and objects

2014-05-09 Thread Rustom Mody
On Saturday, May 10, 2014 8:03:28 AM UTC+5:30, Chris Angelico wrote: > > 2) Returning them. This is a lot more dodgy, owing to the > dangling-pointer issue, but as long as you accept that the reference > to a variable doesn't ensure its continued life, I suppose this might > be acceptable. Maybe.

Re: The � debate

2014-05-09 Thread Mark H Harris
On 5/9/14 8:34 PM, Steven D'Aprano wrote: Nobody seems to complain about using the term "assigment" in relation to Python, despite it meaning something a bit different from what it means in some other languages, so I don't see anything wrong with using the term "variable" with the above definitio

Re: Values and objects

2014-05-09 Thread Chris Angelico
On Sat, May 10, 2014 at 12:19 PM, Rustom Mody wrote: > For me, Marko's comment that variables in python are not first-class > whereas in C they are is for me the most important distinction Ive seen > (in a long time of seeing these discussions). > https://en.wikipedia.org/wiki/First-class_citizen

Re: How to implement key of key in python?

2014-05-09 Thread MRAB
On 2014-05-10 02:22, eckhle...@gmail.com wrote: I'm migrating from Perl to Python and unable to identify the equivalent of key of key concept. The following codes run well, import csv attr = {} with open('test.txt','rb') as tsvin: tsvin = csv.reader(tsvin, delimiter='\t') for row i

Re: How to implement key of key in python?

2014-05-09 Thread CHIN Dihedral
On Saturday, May 10, 2014 9:22:43 AM UTC+8, eckh...@gmail.com wrote: > I'm migrating from Perl to Python and unable to identify the equivalent of > key of key concept. The following codes run well, > > > > import csv > > >

Re: Abstractions [was Re: Pass variable by reference]

2014-05-09 Thread Mark H Harris
On 5/9/14 7:58 PM, Steven D'Aprano wrote: {snip} at which point we're now talking about a concrete, physical description of the process, not an abstraction. There really is a bottom-most turtle that holds up all the rest.) hi Steven, heh... yup, there really is a bottom-most turtle (and who c

Re: Values and objects

2014-05-09 Thread Rustom Mody
On Saturday, May 10, 2014 6:31:49 AM UTC+5:30, Steven D'Aprano wrote: > On Sat, 10 May 2014 01:34:58 +0300, Marko Rauhamaa wrote: > > > and you can't pass references to them. > > > That at least you have got right. > And that's Marko's main point > > > > Right, Python's variables aren't li

Re: Values and objects

2014-05-09 Thread Chris Angelico
On Sat, May 10, 2014 at 8:34 AM, Marko Rauhamaa wrote: > Right, Python's variables aren't like variables in C. Rather, Python's > variables are like CPU registers. They cannot hold typed or structured > objects and you can't pass references to them. Are you thinking that a Python variable is neit

Re: The � debate

2014-05-09 Thread Steven D'Aprano
On Fri, 09 May 2014 13:10:41 +1200, Gregory Ewing wrote: > Steven D'Aprano wrote: >> Today we routinely call horseless carriages "cars", and nobody would >> blink if I pointed at a Prius or a Ford Explorer and said "that's not a >> carriage, it's a car" except to wonder why on earth I thought some

How to implement key of key in python?

2014-05-09 Thread eckhleung
I'm migrating from Perl to Python and unable to identify the equivalent of key of key concept. The following codes run well, import csv attr = {}

Re: The “does Python have variables?” debate

2014-05-09 Thread Steven D'Aprano
On Fri, 09 May 2014 17:34:17 -0500, Mark H Harris wrote: > On 5/7/14 8:27 PM, Steven D'Aprano wrote: >>> In almost every other language you know A and B each "contain" by >>> reference (and almost always by static type) macTruck. But NOT python. >> >> Nor Javascript, Ruby, Perl, PHP, Lua, or (I th

Re: Values and objects

2014-05-09 Thread Steven D'Aprano
On Sat, 10 May 2014 01:34:58 +0300, Marko Rauhamaa wrote: > Right, Python's variables aren't like variables in C. Rather, Python's > variables are like CPU registers. They cannot hold typed or structured > objects Surely you cannot mean that? It is *trivially simple* to disprove that statement:

Abstractions [was Re: Pass variable by reference]

2014-05-09 Thread Steven D'Aprano
On Fri, 09 May 2014 17:30:10 -0500, Mark H Harris wrote: > On 5/7/14 8:31 PM, Chris Angelico wrote: >> On Thu, May 8, 2014 at 4:11 AM, Mark H Harris >> wrote: >>> And we must never forget that CPython's underpinnings, uhm C, uses >>> variables, C ones... (never mind) >> >> Be careful of this one

Re: Why isn't my re.sub replacing the contents of my MS Word file?

2014-05-09 Thread Steven D'Aprano
On Fri, 09 May 2014 13:49:56 -0700, scottcabit wrote: > On Friday, May 9, 2014 4:09:58 PM UTC-4, Tim Chase wrote: > >> A Word doc (as your subject mentions) is a binary format. There's the >> older .doc and the newer .docx (which is actually a .zip file with a >> particular content-structure ren

Re: Values and objects

2014-05-09 Thread Ben Finney
Marko Rauhamaa writes: > Right, Python's variables aren't like variables in C. Rather, Python's > variables are like CPU registers. What is the salient difference between those two? I don't see the point of the distinction. Why have you chosen an analogy – CPU registers – that still uses the mi

Re: Why isn't my re.sub replacing the contents of my MS Word file?

2014-05-09 Thread Steven D'Aprano
On Fri, 09 May 2014 12:51:04 -0700, scottcabit wrote: > Hi, > > here is a snippet of code that opens a file (fn contains the path\name) > and first tried to replace all endash, emdash etc characters with > simple dash characters, before doing a search. > But the replaces are not having any e

Re: The “does Python have variables?â€瑩 debate

2014-05-09 Thread Mark Lawrence
On 10/05/2014 00:51, Dennis Lee Bieber wrote: On Thu, 08 May 2014 22:21:25 -0400, Roy Smith declaimed the following: In article <536c3049$0$29965$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: Although Fortran is still in use, and widely so, it is mostly used for accessing exis

Re: trailing underscores naming convention_

2014-05-09 Thread Steven D'Aprano
On Fri, 09 May 2014 10:35:09 -0600, Michael Torrie wrote: > On 05/08/2014 11:49 PM, Metallicow wrote: >> I guess to be more clear here is a small code snippet that shows what >> is happening more readably. Hence the underscores question. > > In a case like this I'd probably prefer to number the m

Re: The “does Python have variables?” debate

2014-05-09 Thread Mark H Harris
On 5/7/14 8:27 PM, Steven D'Aprano wrote: In almost every other language you know A and B each "contain" by reference (and almost always by static type) macTruck. But NOT python. Nor Javascript, Ruby, Perl, PHP, Lua, or (I think) Lisp or Java. To mention only a few. I think it is easy to exagg

Re: Values and objects

2014-05-09 Thread Marko Rauhamaa
Mark H Harris : > Typically when I think about variables (particularly from the > past, say Pascal, Basic, C, Fortran, Cobol &c) I am thinking about > modeling memory is some way where the variable (some naming > convention) is a value handle or value pointer of some chunk of memory > (by type

Re: Pass variable by reference

2014-05-09 Thread Mark H Harris
On 5/7/14 8:31 PM, Chris Angelico wrote: On Thu, May 8, 2014 at 4:11 AM, Mark H Harris wrote: And we must never forget that CPython's underpinnings, uhm C, uses variables, C ones... (never mind) Be careful of this one. It's utterly irrelevant to your point, and may be distracting. I could im

Re: Values and objects [was Re: Pass variable by reference]

2014-05-09 Thread Mark H Harris
On 5/7/14 8:08 PM, Steven D'Aprano wrote: In Python, all values *are* objects. It isn't a matter of choosing one or the other. The value 1 is an object, not a native (low-level, unboxed) 32 or 64 bit int. Unlike C# or Java, there is no direct language facility to box native values into objects o

Re: Python Internet Database

2014-05-09 Thread Ian Kelly
On Fri, May 9, 2014 at 2:45 PM, wrote: > 1 - Internet servers. In Lisp, one has hunchentoot. In Racket, one has the > Racket Web Framework. Bigloo has hiphop. twisted, tornado, Django, pylons, turbogears, bottle, flask among many others. > 2 - Jit compiler for using from a web server. I mean,

Re: Python Internet Database

2014-05-09 Thread Terry Reedy
On 5/9/2014 4:45 PM, jun...@gmail.com wrote: I am writing a PhD thesis comparing computer languages, and Python and Ruby is among the languages I am working with. I am using the Rasch Model to measure latent traits and like productivity, expressivity, referential transparency and efficiency. If

Re: Python Internet Database

2014-05-09 Thread Ian Kelly
On Fri, May 9, 2014 at 2:45 PM, wrote: > I am writing a PhD thesis comparing computer languages, and Python and Ruby > is among the languages I am working with. I am using the Rasch Model to > measure latent traits and like productivity, expressivity, referential > transparency and efficiency

Re: Python Internet Database

2014-05-09 Thread Chris Angelico
On Sat, May 10, 2014 at 6:45 AM, wrote: > To keep with my work, I need an Internet Data Base from where a person > writing a program in Python could fetch libraries, applications, compilers, > etc. One of the things I need to measure is how complete and easy to use is > such a data base. I wil

Re: Why isn't my re.sub replacing the contents of my MS Word file?

2014-05-09 Thread scottcabit
On Friday, May 9, 2014 4:09:58 PM UTC-4, Tim Chase wrote: > A Word doc (as your subject mentions) is a binary format. There's > the older .doc and the newer .docx (which is actually a .zip file > with a particular content-structure renamed to .docx). > I am using .doc files only.. > > F

Re: Why isn't my re.sub replacing the contents of my MS Word file?

2014-05-09 Thread scottcabit
> > re.sub _returns_ its result (strings are immutable). Ahhso I tried this for each re.sub fStr = re.sub(b'‒','-',fStr) No errors running it, but it still does nothing. -- https://mail.python.org/mailman/listinfo/python-list

Python Internet Database

2014-05-09 Thread junnia
I am writing a PhD thesis comparing computer languages, and Python and Ruby is among the languages I am working with. I am using the Rasch Model to measure latent traits and like productivity, expressivity, referential transparency and efficiency. If a member of this list wants to read a short

Re: Why isn't my re.sub replacing the contents of my MS Word file?

2014-05-09 Thread Tim Chase
On 2014-05-09 12:51, scottca...@gmail.com wrote: > here is a snippet of code that opens a file (fn contains the > path\name) and first tried to replace all endash, emdash etc > characters with simple dash characters, before doing a search. But > the replaces are not having any effect. Obviously a

Re: Why isn't my re.sub replacing the contents of my MS Word file?

2014-05-09 Thread Chris Angelico
On Sat, May 10, 2014 at 5:51 AM, wrote: > But the replaces are not having any effect. Obviously a syntax > problemwwhat silly thing am I doing wrong? > > Thanks! > > fn = 'z:\Documentation\Software' > def processdoc(fn,outfile): > fStr = open(fn, 'rb').read() > re.sub(b'‒','-',fS

Re: Why isn't my re.sub replacing the contents of my MS Word file?

2014-05-09 Thread MRAB
On 2014-05-09 20:51, scottca...@gmail.com wrote: Hi, here is a snippet of code that opens a file (fn contains the path\name) and first tried to replace all endash, emdash etc characters with simple dash characters, before doing a search. But the replaces are not having any effect. Obvious

Why isn't my re.sub replacing the contents of my MS Word file?

2014-05-09 Thread scottcabit
Hi, here is a snippet of code that opens a file (fn contains the path\name) and first tried to replace all endash, emdash etc characters with simple dash characters, before doing a search. But the replaces are not having any effect. Obviously a syntax problemwwhat silly thing am I doing

Re: parsing multiple root element XML into text

2014-05-09 Thread Stefan Behnel
Burak Arslan, 09.05.2014 18:52: > On 05/09/14 16:55, Stefan Behnel wrote: >> ElementTree has gained a nice API in >> Py3.4 that supports this in a much saner way than SAX, using iterators. >> Basically, you just dump in some data that you received and get back an >> iterator over the elements (and

Re: parsing multiple root element XML into text

2014-05-09 Thread Stefan Behnel
Marko Rauhamaa, 09.05.2014 20:04: > I think the worst part of XML is that you can't parse it without a DTD > or schema. Nonsense. > I was very hopeful about json until I discovered they require the parser > to dynamically support five different character encodings. > > XML at least standardized

Re: parsing multiple root element XML into text

2014-05-09 Thread Marko Rauhamaa
Alain Ketterlin : > How do you specify the encoding of sexprs? How can you require that an > attribute value must match the value of an id-attribute? or whatever > insanely complex integrity rule that XML Schemas lets you express? And > so on. I don't suppose there is a universal schema language

Re: parsing multiple root element XML into text

2014-05-09 Thread Alain Ketterlin
Marko Rauhamaa writes: > Alain Ketterlin : > >> which does an exact traversal of potential the DOM tree... (assuming a >> DOM is even defined on a non well-formed XML document). >> >> Anyway, my point was only to warn the OP that he is not doing XML. > > I consider that one of the multitude of fl

Re: parsing multiple root element XML into text

2014-05-09 Thread Burak Arslan
On 05/09/14 16:55, Stefan Behnel wrote: > ElementTree has gained a nice API in > Py3.4 that supports this in a much saner way than SAX, using iterators. > Basically, you just dump in some data that you received and get back an > iterator over the elements (and their subtrees) that it generated fro

Re: trailing underscores naming convention_

2014-05-09 Thread Michael Torrie
On 05/08/2014 11:49 PM, Metallicow wrote: > I guess to be more clear here is a small code snippet that shows what > is happening more readably. Hence the underscores question. In a case like this I'd probably prefer to number the methods rather than add underscores to the end of the names. My cur

Re: parsing multiple root element XML into text

2014-05-09 Thread Marko Rauhamaa
Alain Ketterlin : > which does an exact traversal of potential the DOM tree... (assuming a > DOM is even defined on a non well-formed XML document). > > Anyway, my point was only to warn the OP that he is not doing XML. I consider that one of the multitude of flaws in XML. Compare that with the

Re: The "does Python have variables?" debate

2014-05-09 Thread Rustom Mody
On Friday, May 9, 2014 7:59:14 PM UTC+5:30, Chris Angelico wrote: > The similarities and differences between the variable models are no > more relevant. What becomes relevant are the PyObject* pointer (the C > interface to a Python object (not variable)) and the various functions > for manipulating

Re: parsing multiple root element XML into text

2014-05-09 Thread Alain Ketterlin
Marko Rauhamaa writes: > Alain Ketterlin : > >> Marko Rauhamaa writes: >>> Sometimes the XML elements come through a pipe as an endless >>> sequence. You can still use the wrapping technique and a SAX parser. >>> However, the other option is to write a tiny XML scanner that >>> identifies the en

Re: parsing multiple root element XML into text

2014-05-09 Thread Marko Rauhamaa
Stefan Behnel : > ElementTree has gained a nice API in Py3.4 that supports this in a > much saner way than SAX, using iterators. Good to know. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Add "Received:" header to email msg in correct position?

2014-05-09 Thread Grant Edwards
On 2014-05-08, Tim Chase wrote: > On 2014-05-08 18:39, Grant Edwards wrote: >> > Looks like a Zippy the Pinhead quote to me... >> >> Yep. > > I'm kinda disappointed having the curtain pulled back like that. I'd > just assumed it was some nifty tool that turned a GPG/PGP signature > into MadLib

Re: The "does Python have variables?" debate

2014-05-09 Thread Chris Angelico
On Sat, May 10, 2014 at 12:09 AM, Rustom Mody wrote: > Yes thats the point -- its a real valued spectrum, not a yes/no. eg. > > You write an app with Tkinter. Are you not using Tcl/Tk? I'm not familiar enough with Tkinter to be sure, but I think you'd be using Tk but not Tcl. There are a few leak

Re: trailing underscores naming convention_

2014-05-09 Thread Albert Visser
On Fri, 09 May 2014 12:22:56 +0200, Metallicow wrote: On Friday, May 9, 2014 3:10:26 AM UTC-6, Peter Otten wrote: Metallicow wrote: > I guess to be more clear here is a small code snippet that shows what is > happening more readably. Hence the underscores question. Working with multiple

Re: The "does Python have variables?" debate

2014-05-09 Thread Rustom Mody
On Friday, May 9, 2014 11:21:37 AM UTC+5:30, Chris Angelico wrote: > On Fri, May 9, 2014 at 3:40 PM, Rustom Mody wrote: > > >> I'd like to argue that you're not using Fortran, then. You're making > >> use of it in the same way that I might make use of Ruby, PHP, and Perl > >> when I browse the web

Re: parsing multiple root element XML into text

2014-05-09 Thread Stefan Behnel
Marko Rauhamaa, 09.05.2014 14:38: > Marko Rauhamaa: >> Alain Ketterlin: >>> Marko Rauhamaa writes: Sometimes the XML elements come through a pipe as an endless sequence. You can still use the wrapping technique and a SAX parser. However, the other option is to write a tiny XML scanne

PyPy updated

2014-05-09 Thread Mark Lawrence
Might interest some of you fine folk out there :- http://morepypy.blogspot.co.uk/2014/05/pypy-23-terrestrial-arthropod-trap.html -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and mal

Re: parsing multiple root element XML into text

2014-05-09 Thread Marko Rauhamaa
Marko Rauhamaa : > Alain Ketterlin : > >> Marko Rauhamaa writes: >>> Sometimes the XML elements come through a pipe as an endless >>> sequence. You can still use the wrapping technique and a SAX parser. >>> However, the other option is to write a tiny XML scanner that >>> identifies the end of ea

Re: parsing multiple root element XML into text

2014-05-09 Thread Marko Rauhamaa
Alain Ketterlin : > Marko Rauhamaa writes: >> Sometimes the XML elements come through a pipe as an endless >> sequence. You can still use the wrapping technique and a SAX parser. >> However, the other option is to write a tiny XML scanner that >> identifies the end of each element. Then, you can

Re: parsing multiple root element XML into text

2014-05-09 Thread Alain Ketterlin
Marko Rauhamaa writes: > Alain Ketterlin : > >> Technically speaking, this is not a well-formed XML document (it is a >> well-formed external general parsed entity, though). If you have other >> XML processors in your workflow, they will/should reject it. > > Sometimes the XML elements come throu

Re: trailing underscores naming convention_

2014-05-09 Thread Peter Otten
Metallicow wrote: > On Friday, May 9, 2014 3:10:26 AM UTC-6, Peter Otten wrote: >> Metallicow wrote: >> >> > I guess to be more clear here is a small code snippet that shows what >> > is happening more readably. Hence the underscores question. >> >> Working with multiple names with small differe

Re: parsing multiple root element XML into text

2014-05-09 Thread Marko Rauhamaa
Alain Ketterlin : > Technically speaking, this is not a well-formed XML document (it is a > well-formed external general parsed entity, though). If you have other > XML processors in your workflow, they will/should reject it. Sometimes the XML elements come through a pipe as an endless sequence.

Re: trailing underscores naming convention_

2014-05-09 Thread Metallicow
On Friday, May 9, 2014 3:10:26 AM UTC-6, Peter Otten wrote: > Metallicow wrote: > > > I guess to be more clear here is a small code snippet that shows what is > > happening more readably. Hence the underscores question. > > Working with multiple names with small differences is error-prone. > You

Re: parsing multiple root element XML into text

2014-05-09 Thread Alain Ketterlin
Percy Tambunan writes: > Hai, I would like to parse this multiple root element XML > > [...] > > [...] > Technically speaking, this is not a well-formed XML document (it is a well-formed external general parsed entity, though). If you have other XML processors in your workflow, they will/sh

Re: trailing underscores naming convention_

2014-05-09 Thread Peter Otten
Metallicow wrote: > I guess to be more clear here is a small code snippet that shows what is > happening more readably. Hence the underscores question. Working with multiple names with small differences is error-prone. You should give a method a name that describes what it does rather than when

Re: parsing multiple root element XML into text

2014-05-09 Thread Chris Angelico
On Fri, May 9, 2014 at 7:13 PM, Stefan Behnel wrote: > Chris Angelico, 09.05.2014 11:02: >> On Fri, May 9, 2014 at 6:59 PM, Percy Tambunan wrote: >>> Hai, I would like to parse this multiple root element XML >> >> Easy fix might be to wrap it in and , which will give >> you a new root. > > Elemen

Re: parsing multiple root element XML into text

2014-05-09 Thread Stefan Behnel
Chris Angelico, 09.05.2014 11:02: > On Fri, May 9, 2014 at 6:59 PM, Percy Tambunan wrote: >> Hai, I would like to parse this multiple root element XML > > Easy fix might be to wrap it in and , which will give > you a new root. ElementTree's XMLParser() can be use efficiently for this. Something

Re: parsing multiple root element XML into text

2014-05-09 Thread Marko Rauhamaa
Percy Tambunan : > Hai, I would like to parse this multiple root element XML How about creating a file-like object that wraps the multi-root file into a single-root document? Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: parsing multiple root element XML into text

2014-05-09 Thread Chris Angelico
On Fri, May 9, 2014 at 6:59 PM, Percy Tambunan wrote: > Hai, I would like to parse this multiple root element XML Easy fix might be to wrap it in and , which will give you a new root. Would that help? ChrisA -- https://mail.python.org/mailman/listinfo/python-list

parsing multiple root element XML into text

2014-05-09 Thread Percy Tambunan
Hai, I would like to parse this multiple root element XML 343741014 nu 343741015 nu into this create enumdnsched 4.1.0.1.4.7.3.4.3.2.6.e164.arpa -set naptrFlags=nu create enumdnsched 5.1.0.1.4.7.3.4.3.2.6.e164.arpa -set naptrFlags=nu Anyone can great

Re: The “does Python have variables?” debate

2014-05-09 Thread Mark Lawrence
On 09/05/2014 02:02, Dennis Lee Bieber wrote: On 08 May 2014 16:04:51 GMT, Steven D'Aprano declaimed the following: Personally, I think that trying to be general and talk about "many other languages" is a failing strategy. Better to be concrete: C, Pascal, Algol, Fortran, VB (I think) are good