ANN: Cerridwen 1.0c4 (initial release)

2014-05-12 Thread leslie . polzer
Dear Python friends,

today I'm proud to be

ANNOUNCING: The initial release of a new package, named Cerridwen (1.0c4).

PyPI entry: https://pypi.python.org/pypi/cerridwen


What gives?

  The author perceives a lack of modern open source software
  providing high quality planetary data that is suitable for
  astronomical and astrological purposes.

  So, to start amending that situation I wrote Cerridwen.

  Cerridwen is a moon data API relying on pyswisseph and numpy
  to provide accurate and comprehensive data on the moon.

  With its help you will, for example, be able to get the moon's
  current tropical sign, the dates of the next new and full moons
  and its current absolute and relative diameter.

  Cerridwen offers a JSON HTTP API and comes a simple command-line
  tool. These are built on a library module that you can use to
  develop your own applications.


And you're invited too!

  Please try it if you're interested! :-)

  I've also set up a test server for the API here:

http://cerridwen.viridian-project.de/api/v1/moon

  You can load it in your browser too for a quick peek! Please
  note that the given information may be up to 10 seconds old,
  due to efficiency considerations in the current version of
  Cerridwen.

  All feedback and participation is welcome, including forks and
  patches. Cerridwen's code is on Github.


Need more information?

  Please do take a look at the PyPI page, it contains more detailed
  information. Also feel free to write to me at .


Thanks for reading!

  With Cerridwen I'm trying to give something back to the Python
  community. This is my first publicly released Python package.

Cheers,

  Leslie
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using threads for audio computing?

2014-05-12 Thread lgabiot

Le 12/05/14 08:13, Stefan Behnel a écrit :

This sounds like a use case for double buffering. Use two buffers, start
filling one. When it's full, switch buffers, start filling the second and
process the first. When the second is full, switch again.

Note that you have to make sure that the processing always terminates
within the time it takes to fill the other buffer. If you can't assure
that, however, you have a problem anyway and should see if there's a way to
improve your algorithm.

If the "fill my buffer" call in PyAudio is blocking (i.e. if it returns
only after filling the buffer), then you definitely need two threads for this.



But AFAIK the python GIL (and in smaller or older computers that have only
one core) does not permit true paralell execution of two threads.


Not for code that runs in the *interpreter", but it certainly allows I/O
and low-level NumPy array processing to happen in parallel, as they do not
need the interpreter.

Stefan



Thanks for your answer.

If I follow your explanations, I guess I have to review my understanding 
of python execution model (I have to admit it is quite crude anyway).


In my understanding, without threads, I would have two functions:
- get_audio() would get the 5 seconds of audio from Pyaudio
- process_audio() would process the 5 seconds of audio

the main code would be roughly executing this:
while(True)
get_audio()
process_audio()

so since the audio is a live feed (which makes a difference, say, with 
an audio file analyser program), the get_audio() part must take 5 
seconds to execute. (but most probably the processor stays still most of 
the time during the get_audio() part).

then once get_audio() is done, process_audio() begins.
Process_audio will take some time. If that time is greater that the 
times it takes for the next audio sample to arrive, I have a problem.

(which you already explained differently maybe with:
> If the "fill my buffer" call in PyAudio is blocking (i.e. if it returns
> only after filling the buffer), then you definitely need two threads 
for this.

)

So if I follow you, if the Pyaudio part is "Non-blocking" there would be 
a way to make it work without the two threads things. I'm back to the 
Pyaudio doc, and try to get my head around the callback method, which 
might be the good lead.





--
https://mail.python.org/mailman/listinfo/python-list


Re: parsing multiple root element XML into text

2014-05-12 Thread Peter Otten
Percy Tambunan wrote:

> On Friday, May 9, 2014 4:02:42 PM UTC+7, Chris Angelico wrote:
>> 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
> 
> Thanks chris for the idea.
> Any suggestion to make it print like 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

[Stefan Behnel]

> ElementTree's XMLParser() can be use efficiently for this. Something like
> this should work:
> 
> from xml.etree.ElementTree import XMLParser
> 
> parser = XMLParser()
> parser.feed(b'')
> parser.feed(real_input_data)
> parser.feed(b'')
> root = parser.close()
> 
> for subtree in root:
> ...
 
Have you tried to integrate Stefan's example into your script? If so, what 
is the current state of your code, and what problems prevented you from 
completing it?

Expect help to fix these problems, but not necessarily a ready-to-run 
solution.

If you have not made an attempt yet look here for ideas on how you can use 
XPath to extract interesting data from the subtree:

https://docs.python.org/dev/library/xml.etree.elementtree.html#example


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fortran (Was: The "does Python have variables?" debate)

2014-05-12 Thread Alain Ketterlin
Mark H Harris  writes:

> On 5/11/14 12:05 PM, Alain Ketterlin wrote:
>>> Julia is Matlab and  R, Python, Lisp, Scheme; all rolled together on
>>> steroids. Its amazing as a dynamic language, and its fast, like
>>> lightning fast as well as multiprocessing (parallel processing) at its
>>> core. Its astounding, really.
>>
>> Hmmm...
>>
>>> Its number concept is unified,
>>
>> What exactly is unified? There is no implicit promotion between
>> primitive types and BigInt/Float.
>
>
> The built-in math functions (extensive, by the way) just work, and
> they work consistently the way you might expect across types. Consider
> sqrt():
[...]
> You'll notice that I did not need to import anything to use sqrt(),
> and sqrt() takes all types and does something meaningful with them.

Sorry, i wasn't clear enough: "doing something meaningful with them" is
precisely where the problem is. Every single operation requires
multiple-dispatch (i.e., dynamically testing types, converting to a
common type, and selecting the version of sqrt to use). That's probably
more than the time it takes to actually perform the computation, a bit
like what happens with x+y on integers with Python, where only a
fraction of time is spent on adding integers.

When you are doing scientific computation, this overhead is
unacceptable, because you'll have zillions of computations to perform.

Julia provides a way to make things fast: typing. If you provide
explicit types, the dynamic typing part obviously disappears, and
the overhead is removed.

But then, you're not too far from Fortran, or C/C++.

> The following code will produce over 100,000 digits of π (pi) in less
> than 2 seconds on a low-end processor, like my mac mini dual core
> 2Ghz:

You seem to be discovering the power of the libraries that are behind
all this (MPFR in that case)...

[...]
> But, like lisp, Julia's internal structures are lists, so, it can
> create and modify its own code on-the-fly. [...]

Sorry, I was comparing to Fortran, and it's use in scientific computing.
Self modifying code is totally irrelevant there.

-- Alain.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Plotting multiple datasets with gnuplot

2014-05-12 Thread s . c . wouters
On Friday, October 9, 2009 12:12:54 PM UTC+2, Gabriel Genellina wrote:
> En Fri, 09 Oct 2009 06:36:45 -0300, Rob Garrett   
> escribiï¿oe:
> 
> > I'm trying to get gnuplot to display multiple data series on a single
> > plot using gnuplot in python.  I've searched around and haven't found
> > a solution to how to do this when I have a variable-length list of
> > plots to add.
> >
> > For example, the following code will work:
> >
> > plotData1 = Gnuplot.PlotItems.Data(data1, title="title1")
> > plotData2 = Gnuplot.PlotItems.Data(data2, title="title2")
> > g.plot( plotData1, plotData2 )
> >
> > [I've removed the rest of the code for clarity]
> >
> > But how can I do the following instead:
> >
> > data = []
> > ...
> > # Populate data
> > ...
> > plots = []
> > for dataSet in data:
> >   plots.append(dataSet)
> > g.plot(plots)
> 
> g.plot(*plots) should work; it's like calling g.plot(plots[0], plots[1],  
> plots[2]...)
> 
> See http://docs.python.org/reference/expressions.html#calls for the gory  
> details.
> 
> -- 
> Gabriel Genellina

I just spend an hour searching the web for a similar problem and finally found 
your answer. Thank you, it works great!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fortran

2014-05-12 Thread Mark Lawrence

On 12/05/2014 03:28, Steven D'Aprano wrote:

On Mon, 12 May 2014 01:27:17 +0100, Mark Lawrence wrote:


On 12/05/2014 00:51, Steven D'Aprano wrote:


Cars are standardized -- there are basically two types, manuals and
automatics.



Sadly they can still go wrong due to modern engineering practices.  In
my neck of the woods some years ago people were killed when standing at
a bus stop, because the car driver was desperately pressing down on the
automatic's brake


Perhaps (s)he should have steered the car away from the people. Or I
suppose the steering wheel failed as well?


The entire vehicle was perfectly sound after the event, including the 
brake and accelerator controls.  It was only during the accident that 
the interference played havoc.  Pure coincidence of course.






but EMI overrode the engine controls


EMI? The record company? Wow, I knew they were evil, but I didn't realise
they were *that* evil.


Ho, ho, ho :)





and the car
simply went faster.  At least that is what the defence claimed at the
trial.  With no expert on the prosecution to refute the claim "not
guilty" was the verdict.


Sounds like the prosecution were just going through the motions. They
should have either had an expert able to refute the claim, or not
prosecuted in the first place.


Can't do that if you don't know in advance what the defence is :(



Personally, I'm rather skeptical about claims of "I kept pushing the
brake but the car just accelerated". There is a long and inglorious
history of people stepping on the wrong pedal when in a panic, or drunk,
or distracted. I've even done it myself. (I expect *every* driver
has, at some point.) And a not-quite-as-long but even more inglorious
history of lawyers inventing nonsense links between the brake pedal and
the accelerator in order to extort money from car manufacturers. E.g. see
"Galileo's Revenge" by Peter W Huber and the case of the mythical, but
amazingly profitable for the lawyers involved, Audi Sudden Acceleration
Syndrome.

For me personally, perhaps the most despicable part of the whole sordid
story was the case of Wende Gatts, who ran over Darlene Norris, causing
$300,000 in damages. Not only did she got off scot-free, thanks to the
junk science invented by her "expert witness", but actual victim Norris
was ordered to pay Gatts' legal fees of $64K.

Of course, that was in the late 1980s, when even luxury cars still had
mechanical linkage between the user and the brakes. These days, when
nearly everything in the car is computer controlled, I wouldn't be
*quite* so skeptical. Nevertheless, chances are almost certain that by
far the majority of unexpected acceleration cases are PEBCAP errors.

http://www.caranddriver.com/features/its-all-your-fault-the-dot-renders-its-verdict-on-toyotas-unintended-acceleration-scare-feature

http://www.caranddriver.com/news/toyota-recall-scandal-media-circus-and-stupid-drivers-editorial



I hadn't heard about ASAS, another to add to my list of syndromes :)

--
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 malware because avast! Antivirus protection 
is active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


Re: Using threads for audio computing?

2014-05-12 Thread lgabiot

Le 12/05/14 10:14, lgabiot a écrit :

So if I follow you, if the Pyaudio part is "Non-blocking" there would be
a way to make it work without the two threads things. I'm back to the
Pyaudio doc, and try to get my head around the callback method, which
might be the good lead.


So far, if I understand correctly PyAudio, the callback method is a way 
to do some sort of computing on a Pyaudio stream, by declaring a 
function (the "callback" one) at stream opening time, the callback 
function being executed in a separate thread (as per the Pyaudio 
documentation)...

Still investigating.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Error while calling round() from future.builtins

2014-05-12 Thread Preethi
On Saturday, May 10, 2014 5:26:56 PM UTC+5:30, Steven D'Aprano wrote:
> On Sat, 10 May 2014 04:39:05 -0700, Preethi wrote:
> 
> 
> 
> > Hi,
> 
> > 
> 
> > I am new to python. I am getting an error "AttributeError: type object
> 
> > 'Decimal' has no attribute 'from_float'" when I run the following in
> 
> > python prompt:
> 
> > 
> 
>  from future.builtins import int, round 
> 
> 
> 
> I get an error when I try that:
> 
> 
> 
> 
> 
> py> from future.builtins import int, round
> 
> Traceback (most recent call last):
> 
>   File "", line 1, in 
> 
> ImportError: No module named future.builtins
> 
> 
> 
> 
> 
> Perhaps you are using the third-party library "future"? 
> 
> 
> 
> https://pypi.python.org/pypi/future
> 
> 
> 
> If so, then I believe the library is buggy and you should report it to 
> 
> the Centos package maintainer. You might also manually install a more 
> 
> recent version of future.
> 
> 
> 
> Decimal.from_float was only added in 2.7, it is not available in 2.6.
> 
> 
> 
> https://docs.python.org/2/library/decimal.html#decimal.Decimal.from_float
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Steven D'Aprano
> 
> http://import-that.dreamwidth.org/

Yes, I upgraded to 0.12.0 and it worked! Thanks a lot!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyPy updated

2014-05-12 Thread km
I tried compiling pandas on pypy 2.3 but it gave error as follows

numpy/core/src/multiarray/scalarapi.c:742:16: error: 'PyUnicodeObject' has
no member named 'str'

 uni->str[length] = 0;

^

numpy/core/src/multiarray/scalarapi.c:743:16: error: 'PyUnicodeObject' has
no member named 'length'

 uni->length = length;

Cleaning up...
Command /home/user/test101/bin/pypy-c -c "import setuptools,
tokenize;__file__='/home/user/test101/build/numpy/setup.py';exec(compile(getattr(tokenize,
'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))"
install --record /tmp/pip-d2Eg7e-record/install-record.txt
--single-version-externally-managed --compile --install-headers
/home/user/test101/include/site/python2.7 failed with error code 1 in
/home/user/test101/build/numpy
Storing debug log for failure in /home/user/.pip/pip.log

Regards,
Krishna



On Fri, May 9, 2014 at 7:18 PM, Mark Lawrence wrote:

> 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 malware because avast! Antivirus
> protection is active.
> http://www.avast.com
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is the difference between 32 and 64 bit Python on Windows 7 64 bit?

2014-05-12 Thread Sturla Molden

On 11/05/14 08:56, Ross Gayler wrote:


It looks to me as though 32 and 64 bit versions of Python on 64 bit
Windows are both really 32 bit Python, differing only in how they
interact with Windows.


No! Pointers are 64 bit, Python integers (on Python 2.x) are 32 bit. 
Microsoft decided to use a 32 bit long in MSVC for backwards 
compatiblity, but also because the AMD64 (x86-64) architecture was 
designed to use a 64 address with a 32 bit offset. (A 64 bit long was 
originally slightly less efficient.) You can see the value of 64 bit 
Python e.g. if you allocate a lot of objects or if you try to mmap a 
huge file. With 32 bit Python you are limited to only 2 GB of virtual 
memory. In 64 bit Python you can in practice mmap as much as you want.


The element size of what you try to index also matters. While a C long 
and a Python int is 32 bit on Windows, 64-bit Python will use a 64-bit 
offset internally (Py_ssize_t and Py_intptr_t) even on Windows. The 32 
bit Python int just limits how many objects you can index from Python 
space before Python roll over to using long instead of int. It does not 
limit the amount of memory a Python int can index. In is only when you 
index an array of bytes you will see the roll-over from Python int to 
Python long at the 2 GB limit. Typically, object will be much larger 
than one byte.


Here are two examples:

- A one-dimensional NumPy array with dtype np.float64 can keep 16 GB of 
data before a 32 bit index is too small and Python starts to use long. 
A two-dimensional NumPy array with dtype np.float64 can keep 256 GB of 
data before a 32 bit index is too small.


- A Python list stores internally an array of pointers, each of which is 
64 bit. So just indexing those goes up to 16 GB of pointer data before 
the int rolls over. Then each of these pointers point to a Python 
object. A Python float on my computer (not Windows) is 24 bytes, which I 
got from sys.getsizeof(1.) So 2**32 of those are another 383 GB. So if I 
indexed a list of Python floats on this computer, Python could handle an 
almost 400 GB data structure with a 32 bit int as indexer without 
rolling over to long.


This is obviously way beyond anything the 2 GB limit on 32 bit Python 
allows.





Sturla





--
https://mail.python.org/mailman/listinfo/python-list


Re: Fortran

2014-05-12 Thread Grant Edwards
On 2014-05-12, Steven D'Aprano  wrote:
> On Mon, 12 May 2014 00:51:01 +0100, MRAB wrote:
>> On 2014-05-12 00:15, Steven D'Aprano wrote:

>>> The F and J keys have "F" and "J" printed on them instead of "G" and
>>> "K". They're also in slightly different positions, offset one position
>>> to the left. Otherwise they are identical, to the limits of my vision
>>> and touch. (I haven't tried measuring them with a micrometer, or doing
>>> chemical analysis of the material they are made of.)

Really?  No rised dots or ridges?

>> Maybe keyboards are different where you are! :-)
>
> Certainly not. However they may be different where *you* are :-P
>
> I'm using an IBM keyboard, model SK-8820.
>
>> Mine have an little ridge on the keytop of those keys.
>
> I've seen keyboards with those, but not many. 

I would guess that at least 95% of the keyboards I've seen in the past
30 years have had them

-- 
Grant Edwards   grant.b.edwardsYow! One FISHWICH coming
  at   up!!
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fortran

2014-05-12 Thread alister
On Sun, 11 May 2014 20:14:14 -0400, Roy Smith wrote:

> In article ,
>  MRAB  wrote:
> 
>> On 2014-05-12 00:15, Steven D'Aprano wrote:
>> > On Sun, 11 May 2014 14:43:19 -0400, Roy Smith wrote:
>> >
>> >> In article ,
>> >>  Chris Angelico  wrote:
>> >>
>> >>> Some things are more standardized than others. A piano keyboard is
>> >>> incredibly standard, to make it possible to play without having to
>> >>> look at your fingers (even when jumping your hands around, which
>> >>> doesn't happen as much on a computer keyboard)
>> >>
>> >> Speaking of which, here's a trivia question.  Without looking at
>> >> your keyboard, describe how the "F" and "J" keys (assuming a
>> >> US-English key layout) differ from, say, the "G" and "K" keys.
>> >
>> > The F and J keys have "F" and "J" printed on them instead of "G" and
>> > "K".
>> > They're also in slightly different positions, offset one position to
>> > the left. Otherwise they are identical, to the limits of my vision
>> > and touch.
>> > (I haven't tried measuring them with a micrometer, or doing chemical
>> > analysis of the material they are made of.)
>> >
>> Maybe keyboards are different where you are! :-)
>> 
>> Mine have an little ridge on the keytop of those keys.
> 
> Yup.  Long before the days of computers, the F/J keys have had some sort
> of tactile feedback (a raised dot or whatever) so you can tell when you
> hands are in the home position by feel.  Pyjrteodr upi vsm rmf i[ yu[omh
> ;olr yjod/

I once used an Osborn one where each key-cap was individually sculptured 
to fit the finger depending on its position on the keyboard.




-- 
Bridge ahead.  Pay troll.
-- 
https://mail.python.org/mailman/listinfo/python-list


Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread Mark Lawrence
This was *NOT* written by our resident unicode expert 
http://lucumr.pocoo.org/2014/5/12/everything-about-unicode/


Posted as I thought it would make a rather pleasant change from 
interminable threads about names vs values vs variables vs objects.


--
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 malware because avast! Antivirus protection 
is active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


a better way to operate svn with python(better than pysvn)?

2014-05-12 Thread xs . nepaul

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.

2014-05-12 Thread Simon Evans
Hi Ian, thank you for your help. 
Yes that is the book by Vineeth J Nair.
At the top of page 12, at step 1 it says :

1.Download the latest tarball from 
https://pypi.python.org/packages/source/b/beautifulsoup4/.

So yes, the version the book is dealing with is beautiful soup 4. 
I am using Pyhon 2.7, I have removed Python 3.4.
Also on the bottom of page 10, Mr Nair states:

Pick the path variagble and add the following section to the Path variable:

;C:\PythonXY for example C:\Python27

Which tells me that the Python version cited in the book must be 2.7

I downloaded beautiful soup 4 last night. I unzipped it with 'Just unzip it' to 
a folder I called Beautiful Soup, the same as I did with the previous beautiful 
soup download. The console return is as below, showing that I am now facing the 
same conundrum as yesterday, before changing my version of Beautiful Soup. re:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Intel Atom>cd "c:\Beautiful Soup"

c:\Beautiful Soup>Beautiful Soup>c:\Python27\python setup.py install
'Beautiful' is not recognized as an internal or external command,
operable program or batch file.

c:\Beautiful Soup>


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.

2014-05-12 Thread Simon Evans
The version of Python the book seems to be referring to is 2.7, re: bottom of 
page 10-
'Pick the Path variable and add the following section to the Path variable: 
;C:\PythonXY for example C:\Python 27'

The version of Beautiful Soup seems to be Beautiful Soup 4 as at the top of 
page 12 it states:
'1.Download the latest tarball from 
https://pypi.python.org/packages/source/b/beautifulsoup4/.'

I have downloaded and unzipped to a folder called 'Beautiful Soup' on the C 
drive the Beautiful Soup 4 version. I am using the Python 2.7 console and IDLE, 
I have removed the 3.4 version. 

All the same I seem to be having difficulties again as console wont accept the 
code it did when it was the previous version of BS that I used yesterday. I 
realise I would not be having this problem if I proceeded to input the 'Hello 
World' code on the Python console, but as said, the text never specifically 
said 'change to Python 2.7 console'. I thought the problem was with the BS 
version and so changed it, but now can't even get as far as I had before 
changing it. Anyhow be that as it may, this is the console response to my input:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Intel Atom>cd "c:\Beautiful Soup"

c:\Beautiful Soup>Beautiful Soup>c:\Python27\python setup.py install
'Beautiful' is not recognized as an internal or external command,
operable program or batch file.

c:\Beautiful Soup>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.

2014-05-12 Thread Simon Evans
Thank you for your advice. I did buy a book on Python, 'Hello Python' but the 
code in it wouldn't run, so I returned it to the shop for a refund. I am going 
to visit the local library to see if they have any books on Python. I am 
familiar with Java and Pascal, and looking at a few You tubes on the subject, 
thought it was not much different, and shares many of the oop concepts 
(variables, initializing, expressions, methods, and so on, but I realize there 
is no point in walking backwards in new territory.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.

2014-05-12 Thread Simon Evans
Dear Ian, 
The book does recommend to use Python 2.7 (see bottom line of page 10).
The book also recommends to use Beautiful Soup 4. 
You are right that in that I have placed the unzipped BS4 folder within a 
folder, and I therefore removed the contents of the inner folder and 
transferred them to the outer folder. 
The console now can access the contents of the Beautiful Soup folder, but it is 
still having problems with it as the last output to my console demonstrates :


Microsoft Windows [Version 6.1.7601]

Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Intel Atom>cd "c:\Beautiful Soup"

c:\Beautiful Soup>c:\Python27\python setup.py install
running install
running build
running build_py
error: package directory 'bs4' does not exist

c:\Beautiful Soup>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: NumPy, SciPy, & Python 3X Installation/compatibility issues

2014-05-12 Thread Joseph Martinot-Lagarde

Le 10/05/2014 19:07, [email protected] a écrit :

Hi All--

Let me state at the start that I am new to Python. I am moving away from 
Fortran and Matlab to Python and I use all different types of numerical and 
statistical recipes in my work. I have been reading about NumPy and SciPy and 
could not find any definitive answers to my questions, below.  I had run into 
many mostly installation problems that I could never get NumPy or SciPy to work 
with Python 3.3 or newer.  I am using Windows7 64 bit OS.
A few questions:
1.  What are the latest versions of NumPy and SciPy that are compatible 
with Python 3.3 or newer and Windows7 64 bit?
2.  What is the best source to download and install them on my computer?
3.  Are they all installable on my OS w/o any major problems/addition?
4.  In the long run, would it be better to use UNIX instead of Windows, if 
I were to use Python for all of my research?
Thanks in advance. EK

Building the scientific libraries on windows is very tricky because you 
need a compatible C and Fortran compiler, as well as some libraries. The 
usual and recommended route is to use python distributions where the 
most used libraries are installed. You can still use pip to install 
additionnal packages. You have a list over here: 
http://www.scipy.org/install.html


---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce 
que la protection avast! Antivirus est active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


Re: How can this assert() ever trigger?

2014-05-12 Thread Joseph Martinot-Lagarde

Le 10/05/2014 17:24, Albert van der Horst a écrit :

I have the following code for calculating the determinant of
a matrix. It works inasfar that it gives the same result as an
octave program on a same matrix.

/ 

def determinant( mat ):
 ''' Return the determinant of the n by n matrix mat
 i row j column
 Destroys mat ! '''
 #print "getting determinat of", mat
 n=len(mat)
 nom = 1.
 if n == 1: return mat[0][0]
 lastr = mat.pop()
 jx=-1
 for j in xrange(n):
if lastr[j]:
jx=j
break
 if jx==-1: return 0.
 result = lastr[jx]
 assert(result<>0.)
 # Make column jx zero by subtracting a multiple of the last row.
 for i in xrange(n-1):
 pivot = mat[i][jx]
 if 0. == pivot: continue
 assert(result<>0.)
 nom *= result   # Compenstate for multiplying a row.
 for j in xrange(n):
 mat[i][j] *= result
 for j in xrange(n):
 mat[i][j] -= pivot*lastr[j]
 # Remove colunm jx
 for i in xrange(n-1):
x= mat[i].pop(jx)
assert( x==0 )

 if (n-1+jx)%2<>0: result = -result
 det = determinant( mat )
 assert(nom<>0.)
 return result*det/nom

/-

Now on some matrices the assert triggers, meaning that nom is zero.
How can that ever happen? mon start out as 1. and gets multiplied
with a number that is asserted to be not zero.

Any hints appreciated.

Groetjes Albert

I know it's not the question, but if you want a replacement for octave 
did you try numpy (and scipy) ? The determinant would be computer faster 
and with less memory than with your function.


---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce 
que la protection avast! Antivirus est active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


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

2014-05-12 Thread scottcabit
On Friday, May 9, 2014 8:12:57 PM UTC-4, Steven D'Aprano wrote:

> Good:
> 
> 
> 
> fStr = re.sub(b'‒', b'-', fStr)
> 

  Doesn't work...the document has been verified to contain endash and emdash 
characters, but this does NOT replace them.
> 
> 
> Better:
> 
> 
> 
> fStr = fStr.replace(b'‒', b'-')
> 
> 
   Still doesn't work
> 
> 
> 
> But having said that, you actually can make use of the nuclear-powered 
> 
> bulldozer, and do all the replacements in one go:
> 
> 
> 
> Best:
> 
> 
> 
> # Untested
> 
> fStr = re.sub(b'&#x(201[2-5])|(2E3[AB])|(00[2A]D)', b'-', fStr)

  Still doesn't work.

  Guess whatever the code is for endash and mdash are not the ones I am 
using

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread alister
On Mon, 12 May 2014 16:19:17 +0100, Mark Lawrence wrote:

> This was *NOT* written by our resident unicode expert
> http://lucumr.pocoo.org/2014/5/12/everything-about-unicode/
> 
> Posted as I thought it would make a rather pleasant change from
> interminable threads about names vs values vs variables vs objects.

Surely those example programs are not the pythonoic way to do things or 
am i missing something?

if those code samples are anything to go by this guy makes JMF look 
sensible.



-- 
The Heineken Uncertainty Principle:
You can never be sure how many beers you had last night.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread Ian Kelly
On Mon, May 12, 2014 at 11:47 AM, alister
 wrote:
> On Mon, 12 May 2014 16:19:17 +0100, Mark Lawrence wrote:
>
>> This was *NOT* written by our resident unicode expert
>> http://lucumr.pocoo.org/2014/5/12/everything-about-unicode/
>>
>> Posted as I thought it would make a rather pleasant change from
>> interminable threads about names vs values vs variables vs objects.
>
> Surely those example programs are not the pythonoic way to do things or
> am i missing something?

The _is_binary_reader and _is_binary_writer functions look like they
could be simplified by calling isinstance on the io object itself
against io.TextIOBase, io.BufferedIOBase or io.RawIOBase, rather than
doing those odd 0-length reads and writes.  And then perhaps those
exception-swallowing try-excepts wouldn't be necessary.  But perhaps
there's a non-obvious reason why it's written the way it is.

And there appears to be a bug where everything *except* the filename
'-' is treated as stdin, so the script probably hasn't been tested at
all.

> if those code samples are anything to go by this guy makes JMF look
> sensible.

This is an ad hominem.  Just because his code sucks doesn't mean he's
wrong about the state of Unicode and UNIX in Python 3.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.

2014-05-12 Thread Simon Evans
I did download the latest version of Beautiful Soup 4 from the download site, 
as the book suggested. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread MRAB

On 2014-05-12 19:31, Ian Kelly wrote:

On Mon, May 12, 2014 at 11:47 AM, alister
 wrote:

On Mon, 12 May 2014 16:19:17 +0100, Mark Lawrence wrote:


This was *NOT* written by our resident unicode expert
http://lucumr.pocoo.org/2014/5/12/everything-about-unicode/

Posted as I thought it would make a rather pleasant change from
interminable threads about names vs values vs variables vs objects.


Surely those example programs are not the pythonoic way to do things or
am i missing something?


The _is_binary_reader and _is_binary_writer functions look like they
could be simplified by calling isinstance on the io object itself
against io.TextIOBase, io.BufferedIOBase or io.RawIOBase, rather than
doing those odd 0-length reads and writes.  And then perhaps those
exception-swallowing try-excepts wouldn't be necessary.  But perhaps
there's a non-obvious reason why it's written the way it is.


How about checking sys.stdin.mode and sys.stdout.mode?


And there appears to be a bug where everything *except* the filename
'-' is treated as stdin, so the script probably hasn't been tested at
all.


if those code samples are anything to go by this guy makes JMF look
sensible.


This is an ad hominem.  Just because his code sucks doesn't mean he's
wrong about the state of Unicode and UNIX in Python 3.



--
https://mail.python.org/mailman/listinfo/python-list


Re: NumPy, SciPy, & Python 3X Installation/compatibility issues

2014-05-12 Thread Sturla Molden
 wrote:

> 4.In the long run, would it be better to use UNIX instead of Windows, if
> I were to use Python for all of my research?
> Thanks in advance. EK

For scientific computing, a UNIX or Linux system is clearly preferable.
Most of the scientific computing software is built around the UNIX
ecosystem.

This is the reason many scientists prefer to work on a Mac. I have a UNIX
system ready to use in the terminal, developer tools are free, and it
stills runs all the deskop apps I need (even Microsoft Office).  Apple even
provides us with highly optimized LAPACK, BLAS and FFT libraries as a part
of the operating system (Accelerate Framework). Even the free NumPy and
SciPy installers can link to Accelerate on a Mac. 

Matlab runs on Linux and Mac as well. That is not s reason to stay on
Windows.

An alternative to a Mac is to install Oracle Virtualbox and use it to run
Windows or Linux. Windows as host tends to work best on a laptop. On a
workstation it does not matter. 

If you are using Windows now and are happy with it, I would suggest you
just install Ubuntu into an VM with Virtualbox and forget about Windows
installers for Python, NumPy, SciPy, et al. Spend some money to buy an SSD
drive and more RAM if you need. The performance with Virtualbox is
excellent. Get a Python distro that uses MKL for faster linear algebra,
such as Enthought or Anaconda. Windows can be a great desktop OS because of
all the available applications. It sucks rocks for any coding or scientific
computing. But there is no law that says you need to use either. You can
have the best of both world's if you like.

Sturla

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Twisted-web] Twisted 14.0.0 Release Announcement

2014-05-12 Thread Glyph

On May 12, 2014, at 4:07 AM, HawkOwl  wrote:

> Twisted Agent can also now do HTTPS hostname verification.

I feel that it's important to note that Twisted Web's client Agent *does* do 
HTTPS hostname verification by default; you don't need to turn it on ;).

-glyph-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.

2014-05-12 Thread Ian Kelly
On Mon, May 12, 2014 at 10:35 AM, Simon Evans
 wrote:
> Dear Ian,
> The book does recommend to use Python 2.7 (see bottom line of page 10).
> The book also recommends to use Beautiful Soup 4.
> You are right that in that I have placed the unzipped BS4 folder within a 
> folder, and I therefore removed the contents of the inner folder and 
> transferred them to the outer folder.
> The console now can access the contents of the Beautiful Soup folder, but it 
> is still having problems with it as the last output to my console 
> demonstrates :
>
>
> Microsoft Windows [Version 6.1.7601]
>
> Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
>
> C:\Users\Intel Atom>cd "c:\Beautiful Soup"
>
> c:\Beautiful Soup>c:\Python27\python setup.py install
> running install
> running build
> running build_py
> error: package directory 'bs4' does not exist

In the same folder where setup.py is, there should be a bs4 folder.
You might want to just wipe your Beautiful Soup directory and do a
clean unzip.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread Ian Kelly
On Mon, May 12, 2014 at 1:42 PM, MRAB  wrote:
> How about checking sys.stdin.mode and sys.stdout.mode?

Seems to work, but I notice that the docs only define the mode
attribute for the FileIO class, which sys.stdin and sys.stdout are not
instances of.
-- 
https://mail.python.org/mailman/listinfo/python-list


SQLAlchemy - web framework ?

2014-05-12 Thread flebber
If I want to use SQLAlchemy as my ORM what would be the best option for a web 
framework?

It appears the general advice regarding Django is to do it the Django way and 
use the django ORM and change it out for SQLAlchemy.

That to me limited knowledge leaves flask, pyramid and turbogears 2. So if I 
wanted to not build it all myself as with flask then potentially pyramid, 
turbogears is the best option?

Is this true? I have completed the TG2 intro tutorial and have built several 
small things with flask although I feel offput by doing anything bigger in 
flask.

See what I have done is got my python knowledge to a fair point where I can do 
useful things, good knowledge of web HTML/CSS, built a few small projects in 
flask to get an idea for python web, completed django tutorials, turogears 
tutorials and now looking to design out a bigger project I want to set myself 
and i am trying to compile the parts so I can see what I will need to use and 
gather info to cover what othe things I will need to know.

Do I have a false fear of flask and doing bigger projects?

So at this point I know I want SQLAlchemy, will use postgres(although 
mysql/maria would work fine). 

Any pratical advice warmly welcomed, I think I am thining too much aimlessly 
maybe.

http://turbogears.org/
http://www.pylonsproject.org/
http://flask.pocoo.org/
https://www.djangoproject.com/
http://www.tornadoweb.org/en/stable/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is the difference between 32 and 64 bit Python on Windows 7 64 bit?

2014-05-12 Thread Sturla Molden

On 12/05/14 15:42, Sturla Molden wrote:


- A one-dimensional NumPy array with dtype np.float64 can keep 16 GB of
data before a 32 bit index is too small and Python starts to use long. A
two-dimensional NumPy array with dtype np.float64 can keep 256 GB of
data before a 32 bit index is too small.



Oops, the latter should be 34359738336 GB (that is, 32767 pentabytes) :)

Sturla





--
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread Chris Angelico
On Tue, May 13, 2014 at 4:31 AM, Ian Kelly  wrote:
> Just because his code sucks doesn't mean he's
> wrong about the state of Unicode and UNIX in Python 3.

Uhm... I think wrongness of code is generally fairly indicative of
wrongness of thinking :) If I write a rant about how Python's list
type sucks and it turns out my code is using it like a cons cell and
never putting more than two elements into a list, then you would
accurately conclude that I'm wrong about the state of data type
support in Python.

I don't have a problem with someone coming to the list here with
misconceptions. That's what discussions are for. But rants like that,
on blogs, I quickly get weary of reading. The tone is always "Look
what's so wrong", not inviting dialogue, and I can't be bothered
digging into the details to compose a full response. Chances are the
author's (a) not looking at what 3.4 and what's happened to improve
things (and certainly not 3.5 and what's going to happen), and (b) not
listening to responses anyway.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is the difference between 32 and 64 bit Python on Windows 7 64 bit?

2014-05-12 Thread Sturla Molden

On 11/05/14 08:56, Ross Gayler wrote:


Is that true?I have spent a couple of hours searching for a definitive
description of the difference between the 32 and 64 bit versions of
Python for Windows and haven't found anything.


Why do you care if a Python int object uses 32 or 64 bits internally? 
Python 2.x will automatically switch to long when needed. The size of 
the Python integer is an internal implementation detail you will not 
notice. Python knows when to use a long instead of an int. Python 3.x 
does not even have a fixed-size integer.


64 bit Python is 64 bit Python, even on Windows. The difference between 
32 bit and 64 bit Python is what you would expect: The size of a C 
pointer is 64 bits, and the virtual address space is much larger (in 
general not 2**63-1 bytes, but some OS dependent value).


Sturla



--
https://mail.python.org/mailman/listinfo/python-list


Re: What is the difference between 32 and 64 bit Python on Windows 7 64 bit?

2014-05-12 Thread MRAB

On 2014-05-13 00:41, Sturla Molden wrote:

On 12/05/14 15:42, Sturla Molden wrote:


- A one-dimensional NumPy array with dtype np.float64 can keep 16 GB of
data before a 32 bit index is too small and Python starts to use long. A
two-dimensional NumPy array with dtype np.float64 can keep 256 GB of
data before a 32 bit index is too small.



Oops, the latter should be 34359738336 GB (that is, 32767 pentabytes) :)


Double oops, Sturla, it's petabyte (well, pebibyte actually). :-)
--
https://mail.python.org/mailman/listinfo/python-list


Re: What is the difference between 32 and 64 bit Python on Windows 7 64 bit?

2014-05-12 Thread Chris Angelico
On Tue, May 13, 2014 at 10:05 AM, Sturla Molden  wrote:
> On 11/05/14 08:56, Ross Gayler wrote:
>
>> Is that true?I have spent a couple of hours searching for a definitive
>> description of the difference between the 32 and 64 bit versions of
>> Python for Windows and haven't found anything.
>
>
> Why do you care if a Python int object uses 32 or 64 bits internally? Python
> 2.x will automatically switch to long when needed. The size of the Python
> integer is an internal implementation detail you will not notice. Python
> knows when to use a long instead of an int. Python 3.x does not even have a
> fixed-size integer.

Sometimes you just want to confirm. :) Or maybe you want your program
to be able to detect which it's on. There are ways of doing both, but
sys.maxint isn't one of them, as it's specific to the int->long
promotion of Py2.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is the difference between 32 and 64 bit Python on Windows 7 64 bit?

2014-05-12 Thread Sturla Molden

On 13/05/14 02:09, Chris Angelico wrote:


Sometimes you just want to confirm. :) Or maybe you want your program
to be able to detect which it's on. There are ways of doing both, but
sys.maxint isn't one of them, as it's specific to the int->long
promotion of Py2.


The OPs main mistake, I guess, was to assume that sys.maxint is the 
biggest integer value Python 2.x can use.


Sturla


--
https://mail.python.org/mailman/listinfo/python-list


Re: SQLAlchemy - web framework ?

2014-05-12 Thread Iuri
I don't know what exactly you mean with "wanted to not build it all
myself", but Flask is great with SQLAlchemy. You have the Flask-SQLAlchemy
extension and it has a lot of other integrations, like Flask-Admin.

You don't have to fear flask to bigger projects. To be honest, I prefer it
instead of Django because I can grow the project the way I want, without
framework strings.




On Mon, May 12, 2014 at 8:34 PM, flebber  wrote:

> If I want to use SQLAlchemy as my ORM what would be the best option for a
> web framework?
>
> It appears the general advice regarding Django is to do it the Django way
> and use the django ORM and change it out for SQLAlchemy.
>
> That to me limited knowledge leaves flask, pyramid and turbogears 2. So if
> I wanted to not build it all myself as with flask then potentially pyramid,
> turbogears is the best option?
>
> Is this true? I have completed the TG2 intro tutorial and have built
> several small things with flask although I feel offput by doing anything
> bigger in flask.
>
> See what I have done is got my python knowledge to a fair point where I
> can do useful things, good knowledge of web HTML/CSS, built a few small
> projects in flask to get an idea for python web, completed django
> tutorials, turogears tutorials and now looking to design out a bigger
> project I want to set myself and i am trying to compile the parts so I can
> see what I will need to use and gather info to cover what othe things I
> will need to know.
>
> Do I have a false fear of flask and doing bigger projects?
>
> So at this point I know I want SQLAlchemy, will use postgres(although
> mysql/maria would work fine).
>
> Any pratical advice warmly welcomed, I think I am thining too much
> aimlessly maybe.
>
> http://turbogears.org/
> http://www.pylonsproject.org/
> http://flask.pocoo.org/
> https://www.djangoproject.com/
> http://www.tornadoweb.org/en/stable/
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SQLAlchemy - web framework ?

2014-05-12 Thread Ben Finney
flebber  writes:

> If I want to use SQLAlchemy as my ORM what would be the best option
> for a web framework?
>
> It appears the general advice regarding Django is to do it the Django
> way and use the django ORM and change it out for SQLAlchemy.

You don't say any more about this. Have you evaluated this option? What
leads you to believe it is not satisfactory (as implied by the rest of
your message)?

-- 
 \ “We are no more free to believe whatever we want about God than |
  `\ we are free to adopt unjustified beliefs about science or |
_o__)  history […].” —Sam Harris, _The End of Faith_, 2004 |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SQLAlchemy - web framework ?

2014-05-12 Thread Roy Smith
In article <[email protected]>,
 flebber  wrote:

> If I want to use SQLAlchemy as my ORM what would be the best option for a web 
> framework?
> 
> It appears the general advice regarding Django is to do it the Django way and 
> use the django ORM and change it out for SQLAlchemy.

I'm not quite sure how to parse that last sentence.  In any case, if 
you're afraid of using a third-party ORM with django, don't worry about 
that.  We make extensive use of django and do not use the supplied ORM 
layer.  In our case, we couldn't, because we're using MongoDB (we use 
mongoengine as our ORM).  Django is modular enough that there's really 
no problem swapping the ORM out for another component.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread Steven D'Aprano
On Mon, 12 May 2014 17:47:48 +, alister wrote:

> On Mon, 12 May 2014 16:19:17 +0100, Mark Lawrence wrote:
> 
>> This was *NOT* written by our resident unicode expert
>> http://lucumr.pocoo.org/2014/5/12/everything-about-unicode/
>> 
>> Posted as I thought it would make a rather pleasant change from
>> interminable threads about names vs values vs variables vs objects.
> 
> Surely those example programs are not the pythonoic way to do things or
> am i missing something?

Feel free to show us your version of "cat" for Python then. Feel free to 
target any version you like. Don't forget to test it against files with 
names and content that:

- aren't valid UTF-8;

- are valid UTF-8, but not valid in the local encoding.



> if those code samples are anything to go by this guy makes JMF look
> sensible.

Armin Ronacher is an extremely experienced and knowledgeable Python 
developer, and a Python core developer. He might be wrong, but he's not 
*obviously* wrong.

Unicode is hard, not because Unicode is hard, but because of legacy 
problems. I can create a file on a machine that uses ISO-8859-7 for the 
file name, put JShift-JIS encoded text inside it, transfer it to a 
machine that uses Windows-1251 as the file system encoding, then SSH into 
that machine from a system using Big5, and try to make sense of it. If 
everybody used UTF-8 any time data touched a disk or network, we'd be 
laughing. It would all be so simple.

Reading Armin's post, I think that all that is needed to simplify his 
Python 3 version is:

- have a bytes version of sys.argv (bargv? argvb?) and read 
  the file names from that;

- have a simple way to write bytes to stdout and stderr.

Most programs won't need either of those, but file system utilities will.



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SQLAlchemy - web framework ?

2014-05-12 Thread Sayth Renshaw
I am saying 'do it myself' in that with flask that provide a small base and
then all functionality is added by me directly, with the assistance of
community modules. Compared to Django whose developers have created an
integrated set of defaults with more functionality standard,  which is good
if you like the defaults.

Sayth
 On 13/05/2014 10:44 am, "Iuri"  wrote:

> I don't know what exactly you mean with "wanted to not build it all
> myself", but Flask is great with SQLAlchemy. You have the Flask-SQLAlchemy
> extension and it has a lot of other integrations, like Flask-Admin.
>
> You don't have to fear flask to bigger projects. To be honest, I prefer it
> instead of Django because I can grow the project the way I want, without
> framework strings.
>
>
>
>
> On Mon, May 12, 2014 at 8:34 PM, flebber  wrote:
>
>> If I want to use SQLAlchemy as my ORM what would be the best option for a
>> web framework?
>>
>> It appears the general advice regarding Django is to do it the Django way
>> and use the django ORM and change it out for SQLAlchemy.
>>
>> That to me limited knowledge leaves flask, pyramid and turbogears 2. So
>> if I wanted to not build it all myself as with flask then potentially
>> pyramid, turbogears is the best option?
>>
>> Is this true? I have completed the TG2 intro tutorial and have built
>> several small things with flask although I feel offput by doing anything
>> bigger in flask.
>>
>> See what I have done is got my python knowledge to a fair point where I
>> can do useful things, good knowledge of web HTML/CSS, built a few small
>> projects in flask to get an idea for python web, completed django
>> tutorials, turogears tutorials and now looking to design out a bigger
>> project I want to set myself and i am trying to compile the parts so I can
>> see what I will need to use and gather info to cover what othe things I
>> will need to know.
>>
>> Do I have a false fear of flask and doing bigger projects?
>>
>> So at this point I know I want SQLAlchemy, will use postgres(although
>> mysql/maria would work fine).
>>
>> Any pratical advice warmly welcomed, I think I am thining too much
>> aimlessly maybe.
>>
>> http://turbogears.org/
>> http://www.pylonsproject.org/
>> http://flask.pocoo.org/
>> https://www.djangoproject.com/
>> http://www.tornadoweb.org/en/stable/
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread Chris Angelico
On Tue, May 13, 2014 at 11:18 AM, Steven D'Aprano
 wrote:
> Reading Armin's post, I think that all that is needed to simplify his
> Python 3 version is:
>
> - have a bytes version of sys.argv (bargv? argvb?) and read
>   the file names from that;

argb? :)

> - have a simple way to write bytes to stdout and stderr.

I'm not sure how that goes with I/O redirection, but sure.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: a better way to operate svn with python(better than pysvn)?

2014-05-12 Thread alex23

On 13/05/2014 1:16 AM, [email protected] wrote:
> ...

Rather than just send an empty message, why not explain what you don't 
like about pysvn so that someone could provide more pertinant advice?


But since you didn't: 
https://pypi.python.org/pypi?%3Aaction=search&term=svn&submit=search

--
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread Mark H Harris

On 5/12/14 8:18 PM, Steven D'Aprano wrote:

Unicode is hard, not because Unicode is hard, but because of legacy
problems.


Yes.  To put a finer point on that, Unicode (which is only a 
specification constantly being improved upon) is harder to implement 
when it hasn't been on the design board from the ground up; Python in 
this case.


Julia has Unicode support from the ground up, and it was easier for 
those guys to implement (in beta release) than for the Python crew when 
they undertook the Unicode work that had to be done for Python3.x (just 
an observation).


Anytime there are legacy code issues, regression testing problems, and a 
host of domain issues that weren't thought through from the get-go there 
are going to be more problematic hurdles; not to mention bugs.


Having said that, I still think Unicode is somewhat harder than you're 
admitting.


marcus

--
https://mail.python.org/mailman/listinfo/python-list


Re: a better way to operate svn with python(better than pysvn)?

2014-05-12 Thread Mark H Harris

On 5/12/14 10:16 AM, [email protected] wrote:

> {nothing}

huh?
--
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread Mark Lawrence

On 13/05/2014 02:18, Steven D'Aprano wrote:

On Mon, 12 May 2014 17:47:48 +, alister wrote:


On Mon, 12 May 2014 16:19:17 +0100, Mark Lawrence wrote:


This was *NOT* written by our resident unicode expert
http://lucumr.pocoo.org/2014/5/12/everything-about-unicode/

Posted as I thought it would make a rather pleasant change from
interminable threads about names vs values vs variables vs objects.


Surely those example programs are not the pythonoic way to do things or
am i missing something?


Feel free to show us your version of "cat" for Python then. Feel free to
target any version you like. Don't forget to test it against files with
names and content that:

- aren't valid UTF-8;

- are valid UTF-8, but not valid in the local encoding.




if those code samples are anything to go by this guy makes JMF look
sensible.


Armin Ronacher is an extremely experienced and knowledgeable Python
developer, and a Python core developer. He might be wrong, but he's not
*obviously* wrong.

Unicode is hard, not because Unicode is hard, but because of legacy
problems. I can create a file on a machine that uses ISO-8859-7 for the
file name, put JShift-JIS encoded text inside it, transfer it to a
machine that uses Windows-1251 as the file system encoding, then SSH into
that machine from a system using Big5, and try to make sense of it. If
everybody used UTF-8 any time data touched a disk or network, we'd be
laughing. It would all be so simple.

Reading Armin's post, I think that all that is needed to simplify his
Python 3 version is:

- have a bytes version of sys.argv (bargv? argvb?) and read
   the file names from that;

- have a simple way to write bytes to stdout and stderr.

Most programs won't need either of those, but file system utilities will.



I think http://bugs.python.org/issue8776 and 
http://bugs.python.org/issue8775 are relevant but both were placed in 
the small round filing cabinet.


--
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 malware because avast! Antivirus protection 
is active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


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

2014-05-12 Thread Rustom Mody
On Monday, May 12, 2014 11:05:53 PM UTC+5:30, [email protected] wrote:
> On Friday, May 9, 2014 8:12:57 PM UTC-4, Steven D'Aprano wrote:
> > fStr = fStr.replace(b'‒', b'-')
> 
>Still doesn't work
> 
> 
> > Best:
> > 
> > 
> > # Untested
> > 
> > fStr = re.sub(b'&#x(201[2-5])|(2E3[AB])|(00[2A]D)', b'-', fStr)
> 
>   Still doesn't work.
> 
>   Guess whatever the code is for endash and mdash are not the ones I am 
> using

What happens if you divide two string?
>>> 'a' / 'b'
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported operand type(s) for /: 'str' and 'str'

Or multiply 2 lists?

>>> [1,2]*[3,3]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: can't multiply sequence by non-int of type 'list'

Trying to do a text operation like re.sub on a NON-text object like a doc-file
is the same.

Yes python may not be intelligent enough to give you such useful error messages
outside its territory ie on contents of random files, however logically its the
same -- an impossible operation.


The options you have:
1. Use doc-specific tools eg MS/Libre office to work on doc files ie dont use 
python
2. Follow Tim Golden's suggestion, ie use win32com which is a doc-talking
python API [BTW Thanks Tim for showing how easy it is]
3. Get out of the doc format to txt (export as plain txt) and then try what you 
are trying on the txt
-- 
https://mail.python.org/mailman/listinfo/python-list


Simple Function Decorator Sample Snippet

2014-05-12 Thread Mark H Harris
hi folks, I've come up with a simple snippet that intends to explain the 
concept of decorations without an article (for on app help), while being 
succinct and concise, while not being overly complicated.


Does this work?   I have another one coming for args, similar, if this 
works...  comments appreciated.  thanks.



# BEGIN FUNCTION DECORATOR SIMPLE 
#
# define the function decorator (wrapper function)
def enter_exit(f):
def new_f():
print("entering", f.__name__)
f()
print(f.__name__, "exited !", end="\n\n")
return new_f

# the above "function decoration" takes a 'callable' as an argument
#and returns a 'callable' new function that is used to
#replace the original function (function is decorated),  which
#adds functionality to the original function being decorated ...

# define the original function
def f1():
print("inside f1()")

# replace the original function (above) with the new decorated
#'wrapped' function using the function decoration 'enter_exit'...
f1 = enter_exit(f1)

# (OR) accomplish the same thing with decoration lines as below:

# functions wrapped with decoration lines syntax (annotations)
#as below, accomplish the same 'decoration' as above
#by using some 'syntactic sugar' to accomplish same ...

@enter_exit
def f2():
print("inside f2()")

@enter_exit
def f3():
print("inside f3()")

# demo the new 'decorated' functions
f1()
f2()
f3()

# END FUNCTION DECORATOR SIMPLE ##



--
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread Rustom Mody
On Tuesday, May 13, 2014 6:48:35 AM UTC+5:30, Steven D'Aprano wrote:
> On Mon, 12 May 2014 17:47:48 +, alister wrote:
> 
> > Surely those example programs are not the pythonoic way to do things or
> > am i missing something?
> 
> 
> 
> Feel free to show us your version of "cat" for Python then. Feel free to 
> target any version you like. Don't forget to test it against files with 
> names and content that:
> 
> 
> - aren't valid UTF-8;
> 
> 
> - are valid UTF-8, but not valid in the local encoding.

Thanks for a non-defensive appraisal!

> 
> 
> > if those code samples are anything to go by this guy makes JMF look
> > sensible.
> 
> 
> 
> Armin Ronacher is an extremely experienced and knowledgeable Python 
> developer, and a Python core developer. He might be wrong, but he's not 
> *obviously* wrong.
> 
> 
> 
> Unicode is hard, not because Unicode is hard, but because of legacy 
> problems. I can create a file on a machine that uses ISO-8859-7 for the 
> file name, put JShift-JIS encoded text inside it, transfer it to a 
> machine that uses Windows-1251 as the file system encoding, then SSH into 
> that machine from a system using Big5, and try to make sense of it. If 
> everybody used UTF-8 any time data touched a disk or network, we'd be 
> laughing. It would all be so simple.

I think the most helpful way forward is to accept two things:
a. Unicode is a headache
b. No-unicode is a non-option

> 
> 
> 
> Reading Armin's post, I think that all that is needed to simplify his 
> Python 3 version is:
> 
> 
> 
> - have a bytes version of sys.argv (bargv? argvb?) and read 
>   the file names from that;
> 
> - have a simple way to write bytes to stdout and stderr.
> 
> 
> Most programs won't need either of those, but file system utilities will.

About the technical merits of Armin's post and your suggestions, Ive 
nothing to say, since I am an ignoramus on (the mechanics of) unicode

[Consider me an eager, early, ignorant adopter :-) ]

Its however good to note that unicode is rather unique in the history
not just of IT/CS but of humanity, in the sense that no one (to the best
of my knowledge) has ever tried to come up with an all-encompassing umbrella
for all humanity's scripts/writing systems etc.

So hiccups and mistakes are only to be expected.  The absence of these would
be much more surprising!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SQLAlchemy - web framework ?

2014-05-12 Thread flebber
Roy.that is interesting that you can use mongoengine. 

Recent google results such as seem to assert there are a lot of inherent risk 
in swapping out components, though I may be misinterpreting it. 
http://www.slideshare.net/daikeren/tradeoffs-of-replacing-core-components

Sayth 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fortran (Was: The "does Python have variables?" debate)

2014-05-12 Thread Mark H Harris

On 5/12/14 3:44 AM, Alain Ketterlin wrote:

multiple-dispatch (i.e., dynamically testing types, converting to a
common type, and selecting the version of sqrt to use). That's probably
more than the time it takes to actually perform the computation, a bit
like what happens with x+y on integers with Python, where only a
fraction of time is spent on adding integers.

When you are doing scientific computation, this overhead is
unacceptable, because you'll have zillions of computations to perform.



I'm still trying to sort that out. I have not tested this yet, but 
it looks like Julia is fully dynamic (yes it has types too), and it does 
parallel processing at its core, so the zillions of computations are 
being handled all at once, depending on how many processors|cores you have.



Julia provides a way to make things fast: typing. If you provide
explicit types, the dynamic typing part obviously disappears, and
the overhead is removed.


Julia is dynamic (depending on how far you want to go with that) 
but what makes it fast is the JIT. It is almost accomplishing C/C++ and 
FORTRAN speeds (even though dynamic) because it is compiling on-the-fly.




But then, you're not too far from Fortran, or C/C++.


Right.  Again, this is really about the design goals and the JIT.


The following code will produce over 100,000 digits of π (pi) in less
than 2 seconds on a low-end processor, like my mac mini dual core
2Ghz:  {snip}


You seem to be discovering the power of the libraries that are behind
all this (MPFR in that case)...


Yes, and more+  Gnu GMP & MPFR are not new to me, but the wrapper 
and repl are !  I am just realizing the power behind the libraries in 
this context, but I am very impressed with the functionality wrapped 
around the Gnu stuff... the interface is quite nice.





But, like lisp, Julia's internal structures are lists, so, it can
create and modify its own code on-the-fly. [...]


Sorry, I was comparing to Fortran, and it's use in scientific computing.
Self modifying code is totally irrelevant there.


   no, no, no...  there has to be a value add for scientists to move 
away from R or Matlab, or from FORTRAN. Why go to the trouble?  FORTRAN 
works well (its fast too), and there are zillions of lines of code 
cranking away on huge linear arrays.  Enter Julia... over the next ten 
years; seriously. Because of the value adds!


   Why?, glad you asked.  Enter self modifying code for one. The 
influence of Lisp|Scheme is potentially huge here. For scientific 
computing the reason for making the switch is that the array functions 
being calculated now in FORTRAN can be calculated (as fast) but more 
elegantly with Julia; because the language has the ease of use of 
Python, the stats of R, the array capabilities of MatLab (on steroids) 
and the almost speed of C/C++ (all together in one package). There is 
enough of a value add in this language to make FORTRAN users (also NumPy 
SciPy) take notice.


   Yes, its on a development curve right now (very much beta); but very 
much out there with some serious capability --- right now. It will take 
some time to mature, but I really think this language has the potential 
to be around for a long long time. There needs to be some serious bench 
marking on the parallel processing model, and there needs to be some 
uptake on the user base to find out what 'they' really need from it, but 
I think this dev group is on the ball. (maybe a little too smart for 
their own good, we'll see)


   I noticed from the MIT videos 
http://julialang.org/blog/2013/03/julia-tutorial-MIT/  from a year ago 
that the project has grown with leaps and bounds... but, there is very 
much an intellectual edge here vs. a usability edge... um, the computer 
scientists are still very much in control.  It might be time for a 
larger user group to get involved with the development direction, and 
code base.


   I agree with D'Aprano that languages come and go. But I think Julia 
is different... like Python... for the scientific community; seriously. 
And, if they really are working together with certain Python group(s) to 
merge technologies, this could be big for years to come!


   I'm excited about it.


   Don't get me wrong anybody, I'm still a Pythonista!   :)


marcus

--
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread Mark H Harris

On 5/13/14 12:10 AM, Rustom Mody wrote:

I think the most helpful way forward is to accept two things:
a. Unicode is a headache
b. No-unicode is a non-option


QOTW(so far...)

--
https://mail.python.org/mailman/listinfo/python-list


Re: Fortran (Was: The "does Python have variables?" debate)

2014-05-12 Thread Steven D'Aprano
On Tue, 13 May 2014 00:33:47 -0500, Mark H Harris wrote:

> there has to be a value add for scientists to move away from R or
> Matlab, or from FORTRAN. Why go to the trouble?  FORTRAN works well (its
> fast too), and there are zillions of lines of code cranking away on huge
> linear arrays.  Enter Julia... over the next ten years; seriously.
> Because of the value adds!
> 
> Why?, glad you asked.  Enter self modifying code for one.

Self-modifying code is a nightmare inside the head of a Lovecraftian 
horror. There's a reason why almost the only people still using self-
modifying code are virus writers, and the viruses they create are 
notorious for being buggy.


-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread Gene Heskett
On Tuesday 13 May 2014 01:39:06 Mark H Harris did opine
And Gene did reply:
> On 5/13/14 12:10 AM, Rustom Mody wrote:
> > I think the most helpful way forward is to accept two things:
> > a. Unicode is a headache
> > b. No-unicode is a non-option
> 
> QOTW(so far...)

But its early yet, only Tuesday & its just barely started... :)

Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 
US V Castleman, SCOTUS, Mar 2014 is grounds for Impeaching SCOTUS
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple Function Decorator Sample Snippet

2014-05-12 Thread Steven D'Aprano
On Mon, 12 May 2014 23:41:18 -0500, Mark H Harris wrote:

> hi folks, I've come up with a simple snippet 

I don't think that this idea is original to you :-) I'm pretty sure many 
people have come up with the idea of a decorator that just announces when 
it runs and when it is called. I know I have  :-) 

People keep independently inventing this because it's an obvious, and 
easy to understand, example. Nicely done.


> that intends to explain the
> concept of decorations without an article (for on app help), while being
> succinct and concise, while not being overly complicated.
> 
> Does this work?   I have another one coming for args, similar, if this
> works...  comments appreciated.  thanks.

I tried to run your code, but every line is quoted with a > which causes 
a syntax error. Was there a reason you quoted the snippet?



-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fortran (Was: The "does Python have variables?" debate)

2014-05-12 Thread Chris Angelico
On Tue, May 13, 2014 at 3:48 PM, Steven D'Aprano  wrote:
> Self-modifying code is a nightmare inside the head of a Lovecraftian
> horror. There's a reason why almost the only people still using self-
> modifying code are virus writers, and the viruses they create are
> notorious for being buggy.

Hmm... what counts as self-modifying, though? When you decorate a
function to modify its behaviour (eg add caching around it), all the
modification happens at compile time, but it's still executing
something other than what you see as the bald code. What about a
microkernel that can load altered code from the disk, compile it into
memory, and replace portions of itself? I've done that a number of
times (not in Python as it has little support for it, but in Pike it's
easy); is that self-modifying code? Or a JIT compiler. As you run
something, it gets changed in form to be more streamlined. None of
these is as horrible as the loop that fiddles with its own code on the
fly, but any of them, if buggy, will have the same effect. And all are
useful.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fortran (Was: The "does Python have variables?" debate)

2014-05-12 Thread Mark H Harris

On 5/13/14 12:48 AM, Steven D'Aprano wrote:

On Tue, 13 May 2014 00:33:47 -0500, Mark H Harris wrote:


there has to be a value add for scientists to move away from R or
Matlab, or from FORTRAN. Why go to the trouble?  FORTRAN works well (its
fast too), and there are zillions of lines of code cranking away on huge
linear arrays.  Enter Julia... over the next ten years; seriously.
Because of the value adds!

 Why?, glad you asked.  Enter self modifying code for one.


Self-modifying code is a nightmare inside the head of a Lovecraftian
horror. There's a reason why almost the only people still using self-
modifying code are virus writers, and the viruses they create are
notorious for being buggy.


   no, no, no...  Steven don't think self-modifying (sorry I even used 
it) think meta-programming. Python accomplishes this kind of thing using 
Class and function decorations (sort-uv).


   Take a look at the video presentation of the concept before you turn 
it into a Friday the Thirteenth virus writing horror flick...  its going 
to be as powerful as lisp was supposed to be with the user friendliness 
of python-like code-ability but 'without' the forced indentation rule 
(Julia uses 'ends' and white-space means nothing).



marcus
--
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread Ben Finney
Gene Heskett  writes:

> On Tuesday 13 May 2014 01:39:06 Mark H Harris did opine

> > QOTW(so far...)
>
> But its early yet, only Tuesday & its just barely started... :)

Says who? For some of us, Tuesday is approaching sunset.

(It's always a good day to remind people that the rest of the world
exists.)

-- 
 \ “Reality must take precedence over public relations, for nature |
  `\   cannot be fooled.” —Richard P. Feynman, _Rogers' Commission |
_o__)   Report into the Challenger Crash_, 1986-06 |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple Function Decorator Sample Snippet

2014-05-12 Thread Mark H Harris

On 5/13/14 12:54 AM, Steven D'Aprano wrote:

I don't think that this idea is original to you :-) I'm pretty sure many
people have come up with the idea of a decorator that just announces when
it runs and when it is called. I know I have  :-)


   oh, absolutely... every piece of that thing comes from somebody 
(about six somebodies to be exact) what makes it unique is that its 
compressed, in the right order (I think), and 'without' extraneous 
gibberish that confuses the whole dang thing.




People keep independently inventing this because it's an obvious, and
easy to understand, example. Nicely done.


   Its obvious until you get to the @charater.  In fact its taken so 
obviously by *everyone* that no one actually gets it explained without 
eight pages or twelve steps of something until its all confused.




I tried to run your code, but every line is quoted with a > which causes
a syntax error. Was there a reason you quoted the snippet?


Yes, because depending on your interface the code can get mangled (the 
indentation thing breaks).  the quoted paste seems to avoid this mostly 
with the downside that the quote characters need to be striped from the 
py file.  by the way, any suggestions are welcome regarding 
that too...  there doesn't really seem to be a good way to share code on 
the group consistently.


marcus

--
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread Rustom Mody
On Tuesday, May 13, 2014 11:09:06 AM UTC+5:30, Mark H. Harris wrote:
> On 5/13/14 12:10 AM, Rustom Mody wrote:
> 
> > I think the most helpful way forward is to accept two things:
> > a. Unicode is a headache
> > b. No-unicode is a non-option
> 
> 
> QOTW(so far...)

I said that getting unicode right straight off is unrealistic.

I should have added this:
Armin makes a (sarcastic?) dig about the fact that python (3) goofs because
its mismatched with the assumptions of unix.

| UNIX is bytes, has been defined that way and will always be that way. To 

| Unicode on UNIX is only madness if you force it on everything. But that's not 
| how Unicode on UNIX works. UNIX does not have a distinction between unicode 
| and byte APIs. They are one and the same which makes them easy to deal with.]

| Python 3 takes a very difference stance on Unicode than UNIX does. Python 3 
| says: everything is Unicode ...

This may be right...
Or it may be the other way round as I claim at 
http://blog.languager.org/2014/04/unicode-and-unix-assumption.html

At this point I dont believe that anyone is very clear what is the
right way and and wrong way
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread Chris Angelico
On Tue, May 13, 2014 at 4:03 PM, Ben Finney  wrote:
> (It's always a good day to remind people that the rest of the world
> exists.)

Ironic that this should come up in a discussion on Unicode, given that
Unicode's fundamental purpose is to welcome that whole rest of the
world instead of yelling "LALALALALA America is everything" and
pretending that ASCII, or Latin-1, or something, is all you need.

ChrisA
Currently enjoying "Monday Night Flagging" on Threshold RPG... at 4pm
on Tuesday.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread alex23

On 13/05/2014 11:39 AM, Chris Angelico wrote:

On Tue, May 13, 2014 at 11:18 AM, Steven D'Aprano
 wrote:

- have a bytes version of sys.argv (bargv? argvb?) and read
   the file names from that;


argb? :)


I tried and failed to come up with an "argy bargy" joke here so decided 
to go for a meta-reference instead.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Fortran (Was: The "does Python have variables?" debate)

2014-05-12 Thread Gene Heskett
On Tuesday 13 May 2014 01:48:43 Steven D'Aprano did opine
And Gene did reply:
> On Tue, 13 May 2014 00:33:47 -0500, Mark H Harris wrote:
> > there has to be a value add for scientists to move away from R or
> > Matlab, or from FORTRAN. Why go to the trouble?  FORTRAN works well
> > (its fast too), and there are zillions of lines of code cranking
> > away on huge linear arrays.  Enter Julia... over the next ten years;
> > seriously. Because of the value adds!
> > 
> > Why?, glad you asked.  Enter self modifying code for one.
> 
> Self-modifying code is a nightmare inside the head of a Lovecraftian
> horror. There's a reason why almost the only people still using self-
> modifying code are virus writers, and the viruses they create are
> notorious for being buggy.

People who write buggy self-modifying code aren't paying attention. And 
you don't want those people anywhere near your code in 107% of the cases.

Stable, dead reliable self modifying code CAN be written, I have done it.  
And that code was still in use at the tv station that I wrote it for 15 
years later.  The only time it crashed was when there was a power failure, 
and the backup generator, which had to be started by hand, didn't get 
started soon enough to keep the battery backup, an old fried & dried 6 
volt gel-cell from running down.  An RCA 1802 device without an assembler 
even, just a hex monitor for code entry, and memory in those days (1980) 
was $400 for 4k of static ram when I built it.  By using self modifying 
code, I was able to do about 10k worth of code, using about 2.5k of that 
4k of ram.  Its all in how you reset each location that is modified on 
your way back to the top of the program to await the next command.

IMO, people who bad-mouth self-modifying code are folks who don't have the 
patience to do it right, because stable self-modifying code CAN most 
certainly be done.

Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 
US V Castleman, SCOTUS, Mar 2014 is grounds for Impeaching SCOTUS
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread Chris Angelico
On Tue, May 13, 2014 at 4:25 PM, alex23  wrote:
> On 13/05/2014 11:39 AM, Chris Angelico wrote:
>>
>> On Tue, May 13, 2014 at 11:18 AM, Steven D'Aprano
>>  wrote:
>>>
>>> - have a bytes version of sys.argv (bargv? argvb?) and read
>>>the file names from that;
>>
>>
>> argb? :)
>
>
> I tried and failed to come up with an "argy bargy" joke here so decided to
> go for a meta-reference instead.

I'm just waiting for someone to have need for arguments in both
network byte order and host byte order. The latter, of course, would
be "argh".

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Everything you did not want to know about Unicode in Python 3

2014-05-12 Thread Mark H Harris

On 5/13/14 1:18 AM, Chris Angelico wrote:

instead of yelling "LALALALALA America is everything" and
pretending that ASCII, or Latin-1, or something, is all you need.



... it isn't?



LALALALALALALALALA   :))

--
https://mail.python.org/mailman/listinfo/python-list