Re: First python program, syntax error in while loop

2013-05-06 Thread rusi
On May 6, 6:08 pm, Roy Smith  wrote:

> BTW, in C, I used to write:
>
> return (foo)
>
> for years until somebody pointed out to me that
>
> return foo
>
> works.  I just assumed that if I had to write:
>
> if (foo)
> while (foo)
> for (foo; bar; baz)
>
> then
>
> return (foo)
>
> made sense too.

I guess its because K&R always show their examples with
return (expr);
and so we all assume its the propah way
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-08 Thread rusi
On May 8, 6:11 am, Benjamin Kaplan  wrote:
> On May 7, 2013 5:42 PM, "Neil Hodgson"  wrote:

> > jmfauth:
>
> >> 2) More critical, Py 3.3, just becomes non unicode compliant,
> >> (eg European languages or "ascii" typographers !)
> >> ...
>
> >    This is not demonstrating non-compliance. It is comparing performance,
> not compliance.
>
> >    Please show an example where Python 3.3 is not compliant with Unicode.
>
> >    Neil
>
> It's violating page 1+1j of the Unicode spec, where it says precisely how
> long each operation is allowed to take. Only wise people can see that page.

Ha Ha! -- I infer some Harry Potter here!
[Boarding train at platform 7.3 ]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Message passing syntax for objects | OOPv2

2013-05-08 Thread rusi
On May 9, 7:35 am, Mark Janssen  wrote:
> On Fri, Apr 12, 2013 at 11:28 PM, Mark Janssen
>
>  wrote:
> >> Mark, this proposal is out of place on a Python list, because it proposes 
> >> an
> >> object methodology radically different from any that is implemented in
> >> Python now, or is even remotely likely to be implemented in Python in the
> >> future.
>
> > Wow, you guys are a bunch of ninnies.  I'm going to find some
> > theoretical folks
>
> Okay, to anyone who might be listening, I found the core of the problem.
>
> This issue is/was much deeper than OOP (which would be roughly a 20
> year refactoring) -- that was my mistake.  The issue goes right to the
> core to models of computation and the historical factions within
> theoretical CS itself (a 50+ year refactoring).
>
> The field needs re-invented and re-centered.  Mark my words.  There
> has been a half-century of confusion between two entirely separate
> domains and they've been using the same lexicon.  Long story short:
> the lambda calculus folks have to split from the Turing machine folks.
>  These models of computation should not use the same language.  Their
> computation models are too radically different.  Lisp will remain a
> pinnacle of the lambda calculus, but should be remanded to philosophy.
>  The logic of the binary/boolean arithmetic is simply not compatible,
> but forms the basis of any sensible computer science here in the West.
>
> Here pronouncith the whatever
>
> --
> MarkJ
> Tacoma, Washington

"Lisp will remain the pinnacle of lambda calculus" ???  : Surreal
feeling of falling into a 25-year time-warp

Read this http://www.cs.kent.ac.uk/people/staff/dat/miranda/wadler87.pdf

Just for historical context:
When this was written in the 80s:
- The FP languages of the time -- KRC, SASL, Miranda, Orwell -- were
elegant and academic
- Lisp was quasi-industrial-strength but as Wadler argues above, was
not doing good service to functional programming
-- 
http://mail.python.org/mailman/listinfo/python-list


Alternate computational models can be harmonious (was Message passing syntax for objects | OOPv2)

2013-05-09 Thread rusi
On May 9, 10:39 am, Steven D'Aprano  wrote:
> On Wed, 08 May 2013 19:35:58 -0700, Mark Janssen wrote:
> > Long story short: the lambda
> > calculus folks have to split from the Turing machine folks.
> >  These models of computation should not use the same language.  Their
> > computation models are too radically different.
>
> Their computation models are exactly equivalent.
>
> This is like saying that Cartesian coordinates and polar coordinates are
> so radically different that they cannot possibly both describe the same
> space.

Spot on Steven -- thanks.

And further we do know that from a pragmatic POV the two can be quite
different.
For example cartesian are easier for add/subtract, whereas polar are
easier for multiply/divide.
And so on occasion the best way of doing an operation is to -- if
necessary -- convert to the more appropriate format.

I feel that the case of alternate computation models is analogous --
for some purposes one model works well and sometimes another.

Python embeds the functional model almost as natively as it does the
imperative/OO model.  This is an aspect of python that is powerful but
can also make it hard for some people. In short, python's multi-
paradigm possibilities could do with some good publicity.

My own attempts at bringing functional thinking to classical
imperative languages and Python in particular, will be up at:
https://moocfellowship.org/submissions/the-dance-of-functional-programming-languaging-with-haskell-and-python

It is also an attempt at bringing the lightness and freedom of Python
to the Haskell community and answer divisive judgements of
computational models/paradigms such as the OP's.

More details at 
http://blog.languager.org/2013/05/dance-of-functional-programming.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unicode humor

2013-05-10 Thread rusi
On May 10, 8:32 pm, Chris Angelico  wrote:
> On Sat, May 11, 2013 at 1:24 AM, Ned Batchelder  
> wrote:
> > On 5/10/2013 11:06 AM, jmfauth wrote:
>
> >> On 8 mai, 15:19, Roy Smith  wrote:
>
> >>> Apropos to any of the myriad unicode threads that have been going on
> >>> recently:
>
> >>>http://xkcd.com/1209/
>
> >> --
>
> >> This reflects a lack of understanding of Unicode.
>
> >> jmf
>
> > And this reflects a lack of a sense of humor.  :)
>
> Isn't that a crime in the UK?
>
> ChrisA

The problem with English humour (as against standard humor) is that
its not unicode compliant
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-11 Thread rusi
On May 12, 3:16 am, alex23  wrote:
> On 12 May, 06:10, Mark Janssen  wrote:
>
> > Wow.  You must be from another planet.  Find Socrates if you wish to
> > know these things.  He's from there also.
>
> Now now, there's no need for a turf war, there's plenty of room on
> this list for crazies.

I'm reminded of this:

Conversation between inmate and attendant in an asylum

Inmate: I am Napoleon
Attendant: Yes of course. But how did you know that?
Inmate: God himself told me s…
[Loud voice from another corner] I told you no such thing!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-11 Thread rusi
On May 12, 9:22 am, rusi  wrote:
> On May 12, 3:16 am, alex23  wrote:
>
> > On 12 May, 06:10, Mark Janssen  wrote:
>
> > > Wow.  You must be from another planet.  Find Socrates if you wish to
> > > know these things.  He's from there also.
>
> > Now now, there's no need for a turf war, there's plenty of room on
> > this list for crazies.
>
> I'm reminded of this:
>
> Conversation between inmate and attendant in an asylum
>
> Inmate: I am Napoleon
> Attendant: Yes of course. But how did you know that?
> Inmate: God himself told me s…
> [Loud voice from another corner] I told you no such thing!

I have on occasion expressed that newcomers to this list should be
treated with more gentleness than others.
And since my own joking may be taken amiss, let me hasten to add (to
the OP -- Citizen Kant)

What you are looking for is more in line with what is called
'rewriting systems'
And the shortening you talk of is usually called 'canonical form' or
'normal form'

Python is closer to such than traditional imperative/OO languages like
C/C++/Java, though other languages -- usually called 'functional
language' are generally closer to this ideal.

The most mainstream of these today is probably 'Haskell'
For your purposes however you may want to look at functional languages
that are more explicitly based on rewriting such as 'Pure' (earlier
'Q')

For last http://en.wikipedia.org/wiki/Pure_%28programming_language%29

For rest: Ive tried to put into quotes things that could he helpful
starting points for search engine research
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-12 Thread rusi
On May 12, 7:17 pm, Citizen Kant  wrote:
> Maybe It'd be good if I explain myself a bit more. What I'm trying here is
> to grasp Python from the game's abstraction point of view, as if it were,
> for example, chess. That's why I need a real_player to point me to: (so to
> speak, I wish I could express the ideas according to the python's syntax
> but that's out of my scope by now)

On seeing the interest in games, I can only reiterate the suggestion
to look at rewrite systems
Here is on of the classics on rewrite systems

http://rewriting.loria.fr/documents/survey-draft.ps.gz

whose starting example is a game.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-13 Thread rusi
On May 13, 7:41 am, Steven D'Aprano  wrote:
> Python is not well-modelled as a Finite State Machine. Python is
> equivalent in computing power to a Turing Machine, while Finite State
> Machines are much weaker, so there are things that Python can do that a
> FSM cannot.

Consider the following.

Python is turing-equivalent; so is C and scheme.
I now write a recursive factorial function in all 3.
[To level the pitch all three are written tail-recursively]

Python--
def fact(n,acc=1):
return acc if not n else fact(n-1,n*acc)
C-
#include 
main(int argc, char **argv)
{
  printf("fact %d is %d\n", atoi(argv[1]), fact(atoi(argv[1],1)));
}

int fact(int n, int acc)
{
  return !n? acc : fact(n-1,acc*n);
}
-
When I run these, the C happily keeps giving answers until a million

The python crashes around a thousand.

However examined closely we find that though the C is giving answers
its giving junk after around 12
fact 17 is -288522240
And 35 onwards its 0 (!!)

So finally we do it in scheme:
(define (fact n ac)
  (if (zero? n) ac (fact (1- n) (* ac n


This program neither crashes (because of tail recursion) nor gives
wrong answers

However around 9 my entire machine becomes completely unusable
with top showing guile (scheme) taking all the memory and kswapd next
in line.

So whats the moral?

The Turing model is essentially infinite.
[A TM to compute factorial would never crash because it can never be
built]

The machines we use are finite.
As a first approx we may say that languages like C,Python,Scheme are
Turing-complete.

However in fact when we have to stuff these (conceptually beautiful)
infinite objects into messy finite objects such as Intel hardware,
some corners have to be cut.

And these 3 -- C, Python, Scheme -- CUT THE CORNERS DIFFERENTLY

So when these corners dont matter -- Turing-equivalence is fine
When they do, we must make do living in a more messy finite world
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-13 Thread rusi
On May 13, 9:24 pm, Chris Angelico  wrote:
>
> Your final conclusion is of course correct; nothing we build can be
> truly infinite. But we can certainly give some very good
> approximations, if we're prepared to pay for them. The reality is,
> though, that we usually do not want to pay for approximations to
> infinity; why is IEEE 754 floating point so much more used than, say,
> arbitrary-precision rational? Most of the time, we'd rather have good
> performance and adequate accuracy than abysmal performance and perfect
> accuracy. But hey, if you want to render a Mandelbrot set and zoom in
> to infinity, the option IS there.

Lets look at the costs of locomotion (which I am rounding to neat
figures for an easy discussion)

It costs $10K for a car which goes at around 80 kmph

Now if I want to move at 800 kmph I need to switch from car to plane
and that will cost me in millions

And if I want to move at 8000 kmph I need to be in a rocket in outer
space. Cost perhaps in billions

And maybe if I spend in trillions (leaving aside the question where I
got the trillions) maybe my rocket can go at 80,000 kmph

So what will it cost me to have a rocket that will go at 300,000 m/sec
(186,000 miles per second may be more familiar)?

So what am I driving at?

Some limitations are technological. Some are fundamental.

Earlier I talked of the fact that C, python and scheme hit the
finiteness wall in different ways/places.
machine word size is C's casualty
stack size is python's
memory is scheme's

The details are technological; the fact of finiteness is fundamental
just like the speed-of-light bar is fundamental.

The example of numbers is another such case.

The set of real numbers is in general not computable
Even if we restrict ourselves to the so-called computable real
numbers...
[interestingly Turing's original paper was on computable (real)
numbers]
we get into a soup because:
One can (somewhat simplistically) think of a real number as a
(potentially) infinite list of digits.
Now comparing two finite lists for equality is a trivial operation

However comparing two infinite lists gets us into trouble because both
lists may go on and on... and be same and same... for ever and ever...
In short equality for infinite lists (and therefore real numbers) is
undecidable.
[Well technically semidecidable because if they are different we get a
'not-equal' answer]

Sorry if this all sounds abstruse...
The other day I was reading someone saying that java -- which is after
all such an 'enterprisey' language -- had goofed by not providing a
half-decent money-type.

If you think about it, this is saying the opposite of your:
> But we can certainly give some very good  approximations, if we're prepared 
> to pay for them.

He cannot use int and have a billionaire (or more correctly a
2147483648-aire) add a dollar and get to zero
Nor is it a great idea to use floating point and have some clever
programmer skim off the sub-penny round-off errors into his personal
account.

tl;dr
Computers are hopelessly finite
Much harder to deal with this finitude than to hand-wave the problem
away
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's sad, unimaginative Enum

2013-05-14 Thread rusi
On May 14, 2:24 pm, Jean-Michel Pichavant 
wrote:
> - Original Message -
> > On Mon, 13 May 2013 13:00:36 +0200, Jean-Michel Pichavant wrote:
>
> > > - Original Message -
> > >> That's the title of this little beast
> > >>http://www.acooke.org/cute/Pythonssad0.htmlif anybody's
> > >> interested.
>
> > >> --
> > >> If you're using GoogleCrap™ please read this
> > >>http://wiki.python.org/moin/GoogleGroupsPython.
>
> > >> Mark Lawrence
>
> > >> --
> > >>http://mail.python.org/mailman/listinfo/python-list
>
> > > python 2.5
>
> > > class Enum:
> > >   class __metaclass__(type):
> > >     def __iter__(self):
> > >       for attr in sorted(dir(self)):
> > >         if not attr.startswith("__"):
> > >           yield getattr(self, attr)
>
> > > class Colours(Enum):
> > >   RED = "red"
> > >   GREEN = "green"
>
> > py> class Experience(Enum):
> > ...     NOVICE = 'novice'
> > ...     GREEN = 'green'
> > ...     EXPERIENCED = 'experienced'
> > ...     MASTER = 'master'
> > ...
> > py>
> > py> Colours.GREEN == Experience.GREEN
> > True
>
> > Oops.
>
> > It's very easy to make something which does a few things that enums
> > should do, and call it an Enum. It's much harder to do a lot of
> > things
> > that enums should do.
>
> > --
> > Steven
>
> I was just proposing a solution I've been using and found quite satisfactory. 
> As for the perfect "enumness" of that solution, I don't know. To be honest, 
> I'm not sure I know the exact definition of an enum, and whether or not the C 
> enum fits 100% that definition. It does the job in python. Some people may 
> find it useful, others may just ignore it.
> Additionally, the "bug" you mentioned can be written in C as well, casts 
> allow to compare apples and oranges:
>
> (Colours::GREEN == (enum Coulours::Colour)Experiences::GREEN)


Enums are like names.
And like names are impossible to do right:
http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Software epigrams

2013-05-15 Thread rusi
On May 14, 8:08 am, Dan Sommers  wrote:
> On Tue, 14 May 2013 04:12:53 +1000, Chris Angelico wrote:
> > On Tue, May 14, 2013 at 4:02 AM, Skip Montanaro  wrote:
> >>> 8. A programming language is low level when its programs require
> >>> attention to the irrelevant.
> >> I think "irrelevant" in this context means stuff like memory
> >> management.
> > Sure. That one's pretty clear (if you care about memory management,
> > you want a low level language) ...
>
> http://www.memorymanagement.org/articles/lang.htmlsays:
>
>     C programmers think memory management is too important to be
>     left to the computer. Lisp programmers think memory management
>     is too important to be left to the user.
>
>     (from Ellis and Stroustrup's The Annotated C++ Reference Manual)

Notable physicist David Bohm wrote that the difficulty in
understanding quantum physics is largely a result of the limitation of
the subject-predicate format of Indo-European languages.

He suggested some experiments in languaging called rheomode that makes
English more process-oriented and less (abstract)noun oriented.

One part of this project is to learn to use the word 'relevate' --
which is 'relevant' verbified with an element of 'elevate' as in 'lift
into relief'

I guess the Ellis and Stroupstrup quote above just shows that C++
programmers relevate in one direction whereas Lisp programmers
relevate in another.

More http://www.mindstructures.com/2010/04/meaning-and-context/

Twenty two years ago I wrote about this 
http://www.the-magus.in/Publications/chor.pdf

Suddenly I am finding glowing references to this
http://dieswaytoofast.blogspot.in/2013/01/why-i-grown-to-loathe-c.html

And I am uneasy because these questions are far less rhetorical/
tautological than I imagines in 1990!

So here's a (rather incomplete/preliminary) rebuttal to myself
http://blog.languager.org/2013/02/c-in-education-and-software-engineering.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-15 Thread rusi
On May 16, 6:17 am, Tim Daneliuk  wrote:
> On 05/15/2013 08:01 PM, Ned Batchelder wrote:
>
> > On 5/11/2013 4:03 PM, Citizen Kant wrote:
> >> Don't get me wrong. I can see the big picture and the amazing things that 
> >> programmers write on Python, it's just that my question points to the 
> >> lowest level of it's existence.
>
> > Sometimes a cigar is just a cigar.  Python is a tool, it does what you tell 
> > it.  To make an analogy, or maybe to clarify your philosophical view of the 
> > world, consider a hammer.  What is the "lowest level of its existence"?
>
> > --Ned.
>
> All You People are making this way too hard.  To understand how
> questions like the OPs ought be resolved, please read:
>
>    http://pvspade.com/Sartre/cookbook.html

Ha Ha! Very funny!
Also a serious reminder of what philosophy tends to become.
[Robert Pirsig wrote about the diff between philosophy and
philosophology]

>
> --
> 
> Tim Daneliuk     tun...@tundraware.com
> PGP Key:        http://www.tundraware.com/PGP/

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


Re: Fwd: Fwd: Fwd: Python for philosophers

2013-05-16 Thread rusi
On May 16, 5:28 pm, Citizen Kant  wrote:
>
> I'm just an honest and polite guy asking you guys a couple of simple out of
> the box questions that are important for me. Everyone here has the freedom
> to keep on with their own assumptions and beliefs. If someone's interested
> on thinking outside the box with me for the sake of helping me, that would
> be great and highly appreciated. Thinking outside the box isn't just a
> cheap thing since it's highly creative. Take note that being able to think
> and write in English doesn't make you writers as, put, Faulkner. Same
> happens with any other language, same happens with Python.

Let me quote your first post (OP):


> I roughly came to the idea that Python could be considered as an *economic
> mirror for data*, one that mainly *mirrors* the data the programmer types
> on its black surface, not exactly as the programmer originally typed it,
> but expressed in the most economic way possible.

And let me suggest that you follow your own advise -- Can you say what
you have to say in 1/10th the number of words? Ok if not 1/10th then
1/5th? 1-third?

If you can, you are on the way to appreciating something which you
almost came to and then lost in interminable prolixity, to wit:
> The starting question I make to myself about Python is:
> which is the single and most basic use of Python as the entity it is?

IOW a programmer is one who quickly and easily comes to the nub/core/
kernel/essence of a problem and as easily and adroitly shaves off the
irrelevant.

Else: (you cant /wont reduce your prolixity)
You are bullshitting us and we are being trolled by you
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Software epigrams

2013-05-16 Thread rusi
On May 16, 7:37 pm, Chris Angelico  wrote:
> On Fri, May 17, 2013 at 12:23 AM, Neil Cerutti  wrote:
> > On 2013-05-16, F?bio Santos  wrote:
> >> And in Java we have factories, builders and builderfactories.
> >> What's so relevant about them? Java is high level, no?
>
> > When I tried to pin down what an irrelevant detail in a computer
> > program could be, I couldn't do it. I guess comment decorations,
> > maybe? But those would have no bearing on the level of problem
> > for which a programming language is most appropriate.
>
> Let me give you a real example.
>
> One of the programs I wrote at work is a simple daemon that runs on
> every node in a network. It periodically sends out a heartbeat signal
> that the other nodes hear, and if any node hasn't been heard from in X
> seconds, it is deemed "down". (It might technically not be down, if
> there's a network problem, but the point is that we don't care about
> the difference. It's down.) There's also some incidental statussy data
> included, for convenience. This is implemented using UDP.
>
> Do I care about how a UDP packet is structured? No.
>
> Do I care about the mechanics of IP routing? No.
>
> Do I care about MAC addresses? No. They might feature in our IPv6
> addresses, but I still don't care - the IP addresses (v4 or v6) of the
> nodes are treated as opaque tokens.
>
> All I care about is that I call a function with a string of data and a
> corresponding function gets called in the other program with that same
> string. All the details of how that happens in between aren't
> important to my program. They're somewhat of note in the design phase,
> but not to the program itself. They are, in fact, irrelevant.
>
> ChrisA

You are just saying (in specific detail) what I said, viz that the
programmer is one who 'relevates' ie sifts the relevant from the
irrelevant and a good programming language is one that gives good
relevating tools:
http://blog.languager.org/2013/02/c-in-education-and-software-engineering.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Python for philosophers

2013-05-19 Thread rusi
On May 17, 1:06 am, Citizen Kant  wrote:
> rusi said:
>
> > And let me suggest that you follow your own advise -- Can you say what
> > you have to say in 1/10th the number of words? Ok if not 1/10th then
> > 1/5th? 1-third?
>
> Thanks for the suggestion. I apologize for being that expansive; maybe you
> are right about this. In my world less use to be less. I'll try to review
> my doubts in order to express them in a much more concise format.
>
> Of course this is not trolling at all, and I'm intrigued by how fast
> someone can fall into that kind of conclusions...
>
> I'm pretty much interested in the topic, so I'll review the stuff.

You are doing well -- Glad to see that.
Except for the subject line. What's with the Fwd-loop?
Anyway I have attempted to correct it
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Utility to locate errors in regular expressions

2013-05-24 Thread rusi
On May 24, 5:58 pm, Malte Forkel  wrote:
> Finding out why a regular expression does not match a given string can
> very tedious. I would like to write a utility that identifies the
> sub-expression causing the non-match. My idea is to use a parser to
> create a tree representing the complete regular expression. Then I could
> simplify the expression by dropping sub-expressions one by one from
> right to left and from bottom to top until the remaining regex matches.
> The last sub-expression dropped should be (part of) the problem.
>
> As a first step, I am looking for a parser for Python regular
> expressions, or a Python regex grammar to create a parser from.
>
> But may be my idea is flawed? Or a similar (or better) tools already
> exists? Any advice will be highly appreciated!
>
> Malte



python-specific:  http://kodos.sourceforge.net/
Online: http://gskinner.com/RegExr/
emacs-specific: re-builder and regex-tool http://bc.tech.coop/blog/071103.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-24 Thread rusi
On May 25, 10:15 am, lokeshkopp...@gmail.com wrote:
> On Friday, May 24, 2013 1:34:51 PM UTC+5:30, lokesh...@gmail.com wrote:
> > i need to write a code which can sort the list in order of 'n' without use 
> > builtin functions
>
> > can anyone help me how to do?
>
>  Note:
> the list only contains 0's,1's,2's
> need to sort them in order of 'n'

Its a classic problem
http://en.wikipedia.org/wiki/Dutch_national_flag_problem
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Text-to-Sound or Vice Versa (Method NOT the source code)

2013-05-25 Thread rusi
On May 25, 3:52 pm, Rakshith Nayak  wrote:
> Always wondered how sound is generated from text. Googling couldn't help. 
> Devs having knowledge about this could provide, the information, Links, URLs 
> or anything that could help.
>
> 

look for speech synthesis

http://en.wikipedia.org/wiki/Speech_synthesis
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Short-circuit Logic

2013-05-26 Thread rusi
On May 27, 5:40 am, Steven D'Aprano  wrote:
> On Sun, 26 May 2013 16:22:26 -0400, Roy Smith wrote:
> > In article ,
> >  Terry Jan Reedy  wrote:
>
> >> On 5/26/2013 7:11 AM, Ahmed Abdulshafy wrote:
>
> >> >       if not allow_zero and abs(x) < sys.float_info.epsilon:
> >> >                  print("zero is not allowed")
>
> >> The reason for the order is to do the easy calculation first and the
> >> harder one only if the first passes.
>
> > This is a particularly egregious case of premature optimization.  You're
> > worried about how long it takes to execute abs(x)?  That's silly.
>
> I don't think it's a matter of premature optimization so much as the
> general principle "run code only if it needs to run". Hence, first you
> check the flag to decide whether or not you care whether x is near zero,
> and *only if you care* do you then check whether x is near zero.
>
> # This is silly:
> if x is near zero:
>     if we care:
>         handle near zero condition()
>
> # This is better:
> if we care:
>     if x is near zero
>         handle near zero condition()
>
> Not only is this easier to understand because it matches how we do things
> in the real life, but it has the benefit that if the "near zero"
> condition ever changes to become much more expensive, you don't have to
> worry about reordering the tests because they're already in the right
> order.
>
> --
> Steven

Three points:

3. These arguments are based on a certain assumption: that the inputs
are evenly distributed statistically.
If however that is not so, ie say:
"We-care" is mostly true
and
"x-is-near-zero" is more often false
then doing the near-zero test first would be advantageous

Well thats the 3rd point...

2. Nikalus Wirth deliberately did not use short-circuit boolean
operators in his languages because he found these kind of distinctions
to deteriorate into irrelevance and miss out the more crucial
questions of correctness

1. As Roy pointed out in his initial response to the OP:
"I dont understand your confusion... None of  applies to
your example"
its not at all clear to me that anything being said has anything to do
with what the OP asked!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to compare two json file line by line using python?

2013-05-26 Thread rusi
On May 27, 9:32 am, Avnesh Shakya  wrote:
> hi,
>    how to compare two json file line by line using python? Actually I am 
> doing it in this way..
>
> import simplejson as json
> def compare():
>     newJsonFile= open('newData.json')
>     lastJsonFile= open('version1.json')
>     newLines = newJsonFile.readlines()
>     print newLines
>     sortedNew = sorted([repr(x) for x in newJsonFile])
>     sortedLast = sorted([repr(x) for x in lastJsonFile])
>     print(sortedNew == sortedLast)
>
> compare()
>
> But I want to compare line by line and value by value. but i found that json 
> data is unordered data, so how can i compare them without sorting it. please 
> give me some idea about it. I am new for it.
> I want to check every value line by line.
>
> Thanks

It really depends on what is your notion that the two files are same
or not.

For example does extra/deleted non-significant white-space matter?

By and large there are two approaches:
1. Treat json as serialized python data-structures, (and so) read in
the data-structures into python and compare there

2. Ignore the fact that the json file is a json file; just treat it as
text and use string compare operations

Naturally there could be other considerations: the files could be huge
and so you might want some hybrid of json and text approaches
etc etc
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to: Setuptools

2013-05-27 Thread rusi
On May 28, 6:45 am, Carlos Nepomuceno 
wrote:
> curl -Ohttp://peak.telecommunity.com/dist/ez_setup.py
> python ez_setup.py

Curl comes built into windows??
Does not seem so...
http://serverfault.com/questions/483754/is-there-a-built-in-command-line-tool-under-windows-like-wget-curl

Also given that the question clearly says 'I dont know what it means
to "run it" '
I think your two lines could be too cryptic :-)

To the OP: Sorry I am not being very helpful to you -- I am not on
windows now and dont know these commands offhand

I am sure someone else will chime in..
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to: Setuptools

2013-05-27 Thread rusi
On May 28, 8:06 am, Carlos Nepomuceno 
wrote:
> 
>
> > Date: Mon, 27 May 2013 19:57:47 -0700
> > Subject: Re: How to: Setuptools
> > From: rustompm...@gmail.com
> > To: python-l...@python.org
>
> > On May 28, 6:45 am, Carlos Nepomuceno 
> > wrote:
> >> curl -Ohttp://peak.telecommunity.com/dist/ez_setup.py
> >> python ez_setup.py
>
> > Curl comes built into windows??
>
> No, but you can get it fromhttp://curl.haxx.se/download.html

Oooff! Talk of using sledgehammers to crack nuts...

All that is needed is to visit http://peak.telecommunity.com/dist/ez_setup.py
with the browser and to save the file!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to: Setuptools

2013-05-27 Thread rusi
On May 28, 9:09 am, Carlos Nepomuceno 
wrote:
> 
>
> > Date: Mon, 27 May 2013 20:54:53 -0700
> > Subject: Re: How to: Setuptools
> > From: rustompm...@gmail.com
> [...]
>
> > Oooff! Talk of using sledgehammers to crack nuts...
>
> > All that is needed is to visithttp://peak.telecommunity.com/dist/ez_setup.py
> > with the browser and to save the file!!
>
> Can you show me how to do that from a batch file? Please...

What in the OP's question translates into a need for a batch-file?

And you are proposing that he downloads curl just to write that batch-
file?!?!

How come that proposal is not subject to the same requirement, viz. I
dont see in your recipe any:
"Here-is-a-batchfile-to-download-curl-without-curl?"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encodign issue in Python 3.3.1 (once again)

2013-05-28 Thread rusi
On May 28, 10:55 am, Νίκος Γκρ33κ  wrote:
> Ôç Ôñßôç, 28 ÌáÀïõ 2013 1:18:06 ð.ì. UTC+3, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:
>
> > You're effectively asking people to put in a few minutes' work,
> > sometimes quite a few minutes, to help you. Is it too much to hope
> > that you'll spend one more minute on your posts?
>
> No it is not, you are right, i should be more careful when typing and spend 
> some time to correct before i send my responses. I promise i will not 
> overlook this as well as the blank line google imposes.
>
> As fo my initial question any comments-remarks?

You say you should be more careful to correct your typing and
'promise' to not overlook this.
Your next line has a 'fo' instead of a 'for'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to: Setuptools

2013-05-28 Thread rusi
On May 28, 6:32 am, ray  wrote:
> I would like to use easy_install, but can't figure out how to install it.
>
> I have 64-bit Python 2.7.5 on Windows 7.
>
> Following the instructions onhttps://pypi.python.org/pypi/setuptools, it says:
> Download ez_setup.py and run it; it will download the appropriate .egg file 
> and install it for you. (Currently, the provided .exe installer does not 
> support 64-bit versions of Python for Windows, due to a distutils installer 
> compatibility issue
>
> Being new to Python, I don't know what it means to "run it".  I am not sure 
> what I am looking at when I open it as the first line is "#!python".
>
> Looking down into the content of ez_setup.py, I find:
> 'setuptools-0.6c10-py2.6.egg':
> but there is no entry
> 'setuptools-0.6c10-py2.7.egg':
>
> Searching for it, I found a version 
> at:https://pypi.python.org/packages/2.7/s/setuptools/
>
> This appeared to be a linux version, the first line is:
> #!/bin/sh
> and the content seems to be encoded.
>
> There is an exe athttps://pypi.python.org/pypi/setuptools, but the
> instructions on the page state the .exe won't work for 64-bit installs.
>
> Ray

Since there seems to be no response to this, let me try (even though I
am not on windows)
Just point your browser at the link
http://peak.telecommunity.com/dist/ez_setup.py
And save the file ez_setup.py

The more windows-y way of running this is to right-click this and edit
the run-with in some way that I dont have at my finger-tips.

The more old-fashioned way is to start a dos-box (run cmd.exe)
navigate to the directory where the ez_setup.py is saved
from there run the command:
python ez_setup.py

Do that and report back on what happened

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


Re: How to: Setuptools

2013-05-28 Thread rusi
On May 28, 6:05 pm, ray  wrote:
> On May 28, 7:26 am, Mark Lawrence  wrote:
>
>
>
>
>
>
>
>
>
> > On 28/05/2013 13:03, rusi wrote:
>
> > > On May 28, 6:32 am, ray  wrote:
> > >> I would like to use easy_install, but can't figure out how to install it.
>
> > >> I have 64-bit Python 2.7.5 on Windows 7.
>
> > >> Following the instructions onhttps://pypi.python.org/pypi/setuptools, it 
> > >> says:
> > >> Download ez_setup.py and run it; it will download the appropriate .egg 
> > >> file and install it for you. (Currently, the provided .exe installer 
> > >> does not support 64-bit versions of Python for Windows, due to a 
> > >> distutils installer compatibility issue
>
> > >> Being new to Python, I don't know what it means to "run it".  I am not 
> > >> sure what I am looking at when I open it as the first line is "#!python".
>
> > >> Looking down into the content of ez_setup.py, I find:
> > >> 'setuptools-0.6c10-py2.6.egg':
> > >> but there is no entry
> > >> 'setuptools-0.6c10-py2.7.egg':
>
> > >> Searching for it, I found a version 
> > >> at:https://pypi.python.org/packages/2.7/s/setuptools/
>
> > >> This appeared to be a linux version, the first line is:
> > >> #!/bin/sh
> > >> and the content seems to be encoded.
>
> > >> There is an exe athttps://pypi.python.org/pypi/setuptools, but the
> > >> instructions on the page state the .exe won't work for 64-bit installs.
>
> > >> Ray
>
> > > Since there seems to be no response to this, let me try (even though I
> > > am not on windows)
> > > Just point your browser at the link
> > >http://peak.telecommunity.com/dist/ez_setup.py
> > > And save the file ez_setup.py
>
> > > The more windows-y way of running this is to right-click this and edit
> > > the run-with in some way that I dont have at my finger-tips.
>
> > Do this, something goes wrong, no output to see.
>
> > > The more old-fashioned way is to start a dos-box (run cmd.exe)
> > > navigate to the directory where the ez_setup.py is saved
> > > from there run the command:
> > > python ez_setup.py
>
> > Do this, something goes wrong, output in front of you.
>
> > > Do that and report back on what happened
>
> > --
> > If you're using GoogleCrap� please read 
> > thishttp://wiki.python.org/moin/GoogleGroupsPython.
>
> > Mark Lawrence
>
> The installation fails.  The report stated it could not find the file.
> Per:
> Looking down into the content of ez_setup.py, I find:
> 'setuptools-0.6c10-py2.6.egg':
> but there is no entry
> 'setuptools-0.6c10-py2.7.egg':
>
> Since I am trying to install this for Python 2.7, it fails.
>
> Any suggestions?
>
> Ray

Mysterious...

If you are in hack mode you could try patching that file with the 2.7
egg name and md5
Both of them here https://pypi.python.org/pypi/setuptools

ie after this line
'setuptools-0.6c11-py2.6.egg': 'bfa92100bd772d5a213eedd356d64086',

add this line
'setuptools-0.6c11-py2.7.egg': 'fe1f997bc722265116870bc7919059ea',

However it maybe a better idea to ask on the distutils mailing list
http://mail.python.org/pipermail/distutils-sig/

[And let us know how/what happened!]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to: Setuptools

2013-05-28 Thread rusi
On May 28, 6:40 pm, Mark Lawrence  wrote:
> On 28/05/2013 14:05, ray wrote:
>
>
>
> > The installation fails.  The report stated it could not find the file.
> > Per:
> > Looking down into the content of ez_setup.py, I find:
> > 'setuptools-0.6c10-py2.6.egg':
> > but there is no entry
> > 'setuptools-0.6c10-py2.7.egg':
>
> > Since I am trying to install this for Python 2.7, it fails.
>
> > Any suggestions?
>
> > Ray
>
> Try reading 
> thishttp://stackoverflow.com/questions/3652625/installing-setuptools-on-6...
> which refers to thishttp://www.lfd.uci.edu/~gohlke/pythonlibs/where
> you can get pip which is an easy_install replacement.  You pays your
> money, you takes your choice :)

Hmm...
Something new (for me)
Last I knew, pip was the supposed replacement for setuptools and you
had to install setuptools to install pip!!!
Maybe this has changed?? Or its different on windows??
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Text-to-Sound or Vice Versa (Method NOT the source code)

2013-05-29 Thread rusi
On May 29, 4:30 am, Dennis Lee Bieber  wrote:
> On Tue, 28 May 2013 15:10:03 + (UTC), Grant Edwards
>  declaimed the following in
> gmane.comp.python.general:
>
> > On 2013-05-25, Rakshith Nayak  wrote:
>
> > > Always wondered how sound is generated from text. Googling couldn't
> > > help. Devs having knowledge about this could provide, the
> > > information, Links, URLs or anything that could help.
>
> > >
>
> >http://www.cstr.ed.ac.uk/projects/festival/
> >http://code.google.com/p/pyfestival/
> >http://machakux.appspot.com/blog/44003/making_speech_with_python
>
>         I suppose one could go for archaic and complex...
>
>         Obtain a working Amiga computer, install whatever the last Python
> version was available pre-built. Then write a server application which
> would take text over the net, and feed it to the appropriate Amiga
> libraries -- translator and narrator as I recall (one converted plain
> text to phoneme codings, the other then converted phonemes to sound, and
> could return values for "mouth shape" to sync animation) [history: the
> Amiga had text to speech in the late 80s -- it even allowed for
> adjusting some formant parameters so one could create pseudo accents].

If venerable history is wanted, there is (always?!) emacs:
http://emacspeak.sourceforge.net/
This seems to go back to version 19 of emacs which is (c) mid-
nineties
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Output is not coming with defined color

2013-05-29 Thread rusi
On May 29, 5:11 pm, Fábio Santos  wrote:
> On 29 May 2013 12:25, "Avnesh Shakya"  wrote:
>
>
>
>
>
>
>
>
>
> > hi,
> >    I am trying to display my output with different colour on terminal,
> but it's
> > coming with that colour code.
> > Please help me how is it possible?
>
> > my code is -
> > from fabric.colors import green, red, blue
> > def colorr():
> >     a = red('This is red')
> >     b = green('This is green')
> >     c = blue('This is blue')
> >     d = {a, b, c}
> >     print d
> > colorr()
>
> > output -
> > set(['\x1b[32mThis is green\x1b[0m', '\x1b[34mThis is blue\x1b[0m',
>
> '\x1b[31mThis is red\x1b[0m'])
>
>
>
> > Thanks
>
> You are printing the {a, b, c} set. That ends up printing the repr of all
> of its contents. The repr breaks the desired output. Try to just
>
> print a, b, c

Or

for x in d: print x
should work
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Short-circuit Logic

2013-05-29 Thread rusi
On May 29, 7:27 pm, Ahmed Abdulshafy  wrote:
> On Tuesday, May 28, 2013 3:48:17 PM UTC+2, Steven D'Aprano wrote:
> > On Mon, 27 May 2013 13:11:28 -0700, Ahmed Abdulshafy wrote:
>
> > > That may be true for integers, but for floats, testing for equality is
>
> > > not always precise
>
> > Incorrect. Testing for equality is always precise, and exact. The problem
>
> > is not the *equality test*, but that you don't always have the number
>
> > that you think you have. The problem lies elsewhere, not equality!
>
> > Steven
>
> Well, this is taken from my python shell>
>
> >>> 0.33455857352426283 == 0.33455857352426282
>
> True
>
> Anyway, man, those were not my words anyway, most programming books I've read 
> state so. Here's an excerpt from the Python book, I'm currently reading>
>
> ">>> 0.0, 5.4, -2.5, 8.9e-4
> (0.0, 5.4004, -2.5, 0.00088995)
>
> The inexactness is not a problem specific to Python—all programming languages 
> have this problem with floating-point numbers."

0.0 == 0.0 implies 5.4 == 5.4
is not a true statement is what (I think) Steven is saying.
0 (or if you prefer 0.0) is special and is treated specially.

Naturally if you reach (nearabout) 0.0 by some numerical process thats
another matter...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: detect key conflict in a JSON file

2013-05-29 Thread rusi
On May 29, 6:41 pm, Jabba Laci  wrote:
> > The real answer here is that JSON is probably not the best choice for
> > large files that get hand-edited.  For data that you intend to hand-edit
> > a lot, YAML might be a better choice.
>
> >> Currently the value of the second key silently overwrites the value of
> >> the first.
>
> Thanks but how would it be different with YAML? Can YAML check duplicate keys?
>
> How to process (read) YAML files in Python? Can you give me some hints
> how to get started? All I need is read it in and create a dictionary
> of it.
>
> Thanks,
>
> Laszlo

There seems to be a suggested patch for duplicate-detection here
http://pyyaml.org/ticket/128
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fatal Python error

2013-05-29 Thread rusi
On May 29, 5:43 pm, Joshua Landau  wrote:
> On 29 May 2013 13:25, Dave Angel  wrote:
>
> > On 05/29/2013 07:48 AM, Joshua Landau wrote:
>
> >> Hello all, again. Instead of revising like I'm meant to be, I've been
> >> delving into a bit of Python and I've come up with this code:
>
> > To start with, please post in text mode.  By using html, you've completely
> > messed up any indentation you presumably had.
>
> Appologies, I use GMail and I don't know how to force text-only

In gmail
New interface:
There should be a down arrow next to the trash-can right bottom of
posting-screen
Click the down-arrow. YOu should see a 'choose text-only' option

Old interface:
When posting a new message, right at the top next to all the
formatting icons is a text-only link
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How clean/elegant is Python's syntax?

2013-05-29 Thread rusi
On May 30, 6:14 am, Ma Xiaojun  wrote:
> What interest me is a one liner:
> print '\n'.join(['\t'.join(['%d*%d=%d' % (j,i,i*j) for i in
> range(1,10)]) for j in range(1,10)])

Ha,Ha! The join method is one of the (for me) ugly features of python.
You can sweep it under the carpet with a one-line join function and
then write clean and pretty code:

#joinwith
def joinw(l,sep): return sep.join(l)

def mktable(m,n):
return [[(j,i,i*j) for i in range(1,m+1)] for j in range(1,n+1)]

def prettyrow(r):
return joinw(['%d*%d=%d' % ele for ele in r],'\t')

def prettytable(t):
return joinw([prettyrow(r) for r in t],'\n')

> I don't like code like this. But Python at least allow such practise.

Are you saying VB etc disallow dirty code??  Dirty code is always
possible in all languages. Of course the shape and size and smell of
the dirt will differ
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Short-circuit Logic

2013-05-30 Thread rusi
On May 30, 5:58 pm, Chris Angelico  wrote:
> The alternative would be an infinite number of iterations, which is far far 
> worse.

There was one heavyweight among programming teachers -- E.W. Dijkstra
-- who had some rather extreme views on this.

He taught that when writing a loop of the form

i = 0
while i < n:
  some code
  i += 1

one should write the loop test as i != n rather than i < n, precisely
because if i got erroneously initialized to some value greater than n,
(and thereby broke the loop invariant), it would loop infinitely
rather than stop with a wrong result.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How clean/elegant is Python's syntax?

2013-05-30 Thread rusi
On Thu, May 30, 2013 at 9:34 AM, Ma Xiaojun 
wrote:
>
> On Thu, May 30, 2013 at 10:49 AM, rusi  wrote:
> > Ha,Ha! The join method is one of the (for me) ugly features of python.
> > You can sweep it under the carpet with a one-line join function and
> > then write clean and pretty code:
> >
> > #joinwith
> > def joinw(l,sep): return sep.join(l)
> >
> > def mktable(m,n):
> > return [[(j,i,i*j) for i in range(1,m+1)] for j in range(1,n+1)]
> >
> > def prettyrow(r):
> > return joinw(['%d*%d=%d' % ele for ele in r],'\t')
> >
> > def prettytable(t):
> > return joinw([prettyrow(r) for r in t],'\n')
>
> Wait a minute! Isn't the most nature way of doing/thinking "generating
> 9x9 multiplication table" two nested loop?

Thats like saying that the most natur(al) way of using a car is to
attach a horse to it.
Sure if all you've seen are horse-carriages then a horseless carriage
will seem nonsensical.  Once you get used to horseless carriages the
horsed ones would seem quite a nuisance [global warming aside!!]

The only problem with this analogy is that you have to imagine the
world of horse/horseless 'cars' in 1900 and not 2013.

Likewise in the world of programming, 90% of programmers think
imperative/OO programming is natural while functional programming is
strange.  Just wait 10 years and see if things are not drastically
different!

>
> I understand that using "join", we don't need to worry about "one
> element doesn't need white space" issue. And that's it.

More evidence of the above!
join like list-comprehensions are tools for functional programming and
not merely ways of writing loops in short.

The key difference between the two is seen not in the code you write
but in the natural language (English) you use to describe it:

> Wait a minute! Isn't the most nature way of doing/thinking "generating
> 9x9 multiplication table" two nested loop?

You associate the primal (f)act of thinking about programming with
*doing* the generating.
By contrast the functional programmer thinks about what *is* the
result.

Please also note the difference in emphasis in your code and mine.
Rewriting to make it more obvious:

# The main multiplication table building function
def multtable(m,n):
return [[(j,i,i*j) for i in range(1,m+1)] for j in range(1,n+1)]

# The 'icing' to get it into the shape you want
def joinw(l,sep): return sep.join(l)
def prettytable(t):
return joinw([joinw(['%d*%d=%d' % ele for ele in r],'\t') for r in
t],'\n')

The call that puts them together:
>>> print prettytable(multtable(6,7))

The nice thing about the last is that it separates three things:
1. Computing the actual table
2. The string form of that table that looks the way we want
3. Printing that string

And I can see each of these separately:

In [2]: multtable(2,3)
Out[2]: [[(1, 1, 1), (1, 2, 2)], [(2, 1, 2), (2, 2, 4)], [(3, 1, 3),
(3, 2, 6)]]

In [3]: prettytable(_)
Out[3]: '1*1=1\t1*2=2\n2*1=2\t2*2=4\n3*1=3\t3*2=6'

In [4]: print _
1*1=1   1*2=2
2*1=2   2*2=4
3*1=3   3*2=6

---
I would be pleasantly surprised if the double nested loop you think
natural, allowed for such a modular separation!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How clean/elegant is Python's syntax?

2013-05-30 Thread rusi
On May 30, 10:28 pm, Chris Angelico  wrote:
> On Fri, May 31, 2013 at 3:12 AM, rusi  wrote:
> > You associate the primal (f)act of thinking about programming with
> > *doing* the generating.
> > By contrast the functional programmer thinks about what *is* the
> > result.
>
> I wish you'd explain that to my boss :) He often has trouble
> understanding why sometimes I put two syntactic statements on one
> line, such as:
>
> for (int i=0;i {
>     //do something with foo[i]
>
> }
>
> In Python, that would probably be done with a list comprehension or
> some other form of filtered iteration, and is to my mind a single
> operation - "iterate over all the marked foo" is just as much a valid
> loop header as "iterate over all the foo". This is a simple example,
> and what you say about thinking about what *is* the result doesn't
> really translate well into a C++ example, but the broader concept
> applies: there's a difference between code as the compiler/interpreter
> sees it and code as the programmer sees it, and there is not always a
> 1:1 correspondence of statements.
>
> ChrisA

I had a blog post about line-length in programs
http://blog.languager.org/2012/10/layout-imperative-in-functional.html

followed by an interesting discussion on the haskell mailing list
http://groups.google.com/group/haskell-cafe/browse_thread/thread/f146ec7753c5db56/09eb73b1efe79fec

The comment by Alexander Solla was insightful and is probably what you
are saying.

[Probably!! I am not sure what you are saying!]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How clean/elegant is Python's syntax?

2013-05-30 Thread rusi
On May 30, 11:36 pm, Ian Kelly  wrote:
> On Wed, May 29, 2013 at 8:49 PM, rusi  wrote:
> > On May 30, 6:14 am, Ma Xiaojun  wrote:
> >> What interest me is a one liner:
> >> print '\n'.join(['\t'.join(['%d*%d=%d' % (j,i,i*j) for i in
> >> range(1,10)]) for j in range(1,10)])
>
> > Ha,Ha! The join method is one of the (for me) ugly features of python.
> > You can sweep it under the carpet with a one-line join function and
> > then write clean and pretty code:
>
> > #joinwith
> > def joinw(l,sep): return sep.join(l)
>
> I don't object to changing the join method (one of the more
> shoe-horned string methods) back into a function, but to my eyes
> you've got the arguments backward.  It should be:
>
> def join(sep, iterable): return sep.join(iterable)
>
> Putting the separator first feels more natural to me because I expect
> the separator to usually be short as compared to the iterable, which
> is often a longer expression (as is the case in both of your
> subsequent usages).  Placing the separator first also preserves
> consistency of interface with the str.join and bytes.join functions,
> as well as the older string.join function.

This is a subjective view of course...
My problem is not method vs function but the order.
Ive seen/used join dozens of times. Yet I find
"".join(["apple","bear","cat"])
backkwards as compared to
["apple","bear","cat"].join("")

The consistency is a separate question -- not arguing about that. Just
that I dont like the look
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How clean/elegant is Python's syntax?

2013-05-30 Thread rusi
On May 31, 12:36 am, Steven D'Aprano  wrote:
>
> But even if only a minority of programmers can master languages like
> Lisp, Haskell, or Scheme, doesn't mean that *all* programmers can't learn
> something from them. Functional programming is at least 50% a philosophy:
>
> * pass arguments to functions, and return results, rather than getting
> and setting state from a variable.

Yes that's the sense in which I am using the term.
More such ideas of FP that can be used by all sorts of programmers
across the board (not just FPers) is here:
http://blog.languager.org/2012/10/functional-programming-lost-booty.html

> On Thu, 30 May 2013 10:12:22 -0700, rusi wrote:
> > On Thu, May 30, 2013 at 9:34 AM, Ma Xiaojun 
> > wrote:
> >> Wait a minute! Isn't the most nature way of doing/thinking "generating
> >> 9x9 multiplication table" two nested loop?
>
> > Thats like saying that the most natur(al) way of using a car is to
> > attach a horse to it.
> >[...]
> > Likewise in the world of programming, 90% of programmers think
> > imperative/OO programming is natural while functional programming is
> > strange.  Just wait 10 years and see if things are not drastically
> > different!
>
> It won't be. Functional programming goes back to Lisp, which is nearly as
> old as Fortran and older than Cobol. There have been many decades for
> functional languages to become mainstream, but they've never quite done
> it. There's no reason to think that the next decade will see a change to
> this.

Depends on how you define your terms.

Comprehensions and lambdas have come into python. From where? [Lambdas
have even got into C++ !!]
Also LINQ in C# is inspired by comprehensions
Generics were not there in C# and Java early editions.  Now they've
been retrofitted -- Origin SML.
Almost every modern language supports garbage collection. Origin Lisp
Numpy is a rip-off of APL. [Ripping off is a tribute. Non-
acknowledgement is sad...]
TAOCP -Vol 1 is a gigantic exercise on how to do lisp without lisp.
Also called Greenspun's 10th law: 
http://c2.com/cgi/wiki?GreenspunsTenthRuleOfProgramming

> Some modern Functional languages are really neat, like Haskell, but I
> think the sad truth is that to really master them (and not just make do
> with a small percentage of their functionality) is beyond 90% of
> programmers. I'm not ashamed to admit that I struggle with advanced FP
> concepts.

Yes Haskell is HARD. Gets harder with each new major addition.

Which is why I suggest using Haskell core (ie minus most fancy
features) as an *ideology* rather than as a *technology*.
Which is what I am suggesting in my course proposal
https://moocfellowship.org/submissions/the-dance-of-functional-programming-languaging-with-haskell-and-python

"Think with Haskell --- Code into Python"
Want to contribute ?

Well actually the last applies to anyone who is interested --
suggestions welcome!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How clean/elegant is Python's syntax?

2013-05-31 Thread rusi
On May 31, 2:08 pm, Alister  wrote:
> On Thu, 30 May 2013 20:38:40 +0100, MRAB wrote:
> > And additional argument (pun not intended) for putting sep second is
> > that you can give it a default value:
>
> >     def join(iterable, sep=""): return sep.join(iterable)
>
> I think that is the winning argument.

Yes

> Next question is what should be the default ("", " " or',')?

Hmm... Never thought there was any choice here except "".  Yes can see
the case for each.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Create a file in /etc/ as a non-root user

2013-05-31 Thread rusi
On May 31, 7:42 pm, Chris Angelico  wrote:
> On Sat, Jun 1, 2013 at 12:02 AM, Alister  wrote:
> > /etc is used to store configuration files for the operating system & if
> > you inadvertently corrupt the wrong one then you could kill the system.
>
> Expanding on this:
>
> http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
>
> The FHS applies to Linux, but you'll find it close to what other
> Unix-like OSes use too.

Yes the FHS is a good center for such discussions.  Let me expand on
this a bit.

I am going to use debian/ubuntu+apt because I know it a bit. You can
substitute RH/Centos+yum or whatever...

Modern linuxes are SOAs (service oriented architectures) or cloud
architectures even if we dont like the buzzwords.

This means that when I install debian/ubuntu on my personal computer
there is some kind of contract-ing that goes on between me and
debian.  Some of it legal, some semi-legal some entirely informal/
conventional but still very important.

Legal:
For example it may be 'my very own computer' but if I take sources
under a certain license and use them in violation of that license I
could get into legal trouble.

Semi-legal:
Free and not-free software can coexist in ways that are at least
legally nebulous

Conventional:
Debian must not use the machine (and file-system in particular) in
ways that disrespect me.
Note I am not talking of obvious legal gaffes like stealing my private
data but of more 'conventional' problems like strewing my home
directory with meaningless temporary files.

Likewise:
I MUST RESPECT Debian's AREA.
For example I cant go messing about in /usr/bin [the name 'usr' is
misleading and unfortunate] and expect support from debian.
So
$ sudo rm /usr/bin/foo
is improper whereas
$ sudo apt-get purge foo
is proper.

And its improper because you are not to mess around in debian's area
-- except for officially approved channels like 'apt-get purge…' --
just as debian is not to mess around in yours.

And writing into /etc constitutes messing with debian (or whatever is
your distro).

So yes, as Chris suggested read the FHS.

And consider using a 'public-messable' area like /usr/local instead
of /etc.

Actually the situation is more complicated: the deal is not between
just ordinary users like you/me and the distro. There's
- ordinary users like you/me
- packagers
- the distro
- upstream

each with their own rights and responsibilities.
What these are and how to navigate them is best discussed in your
distro's fora eg
http://forums.debian.net/
http://ubuntuforums.org/forum.php
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can anyone please help me in understanding the following python code

2013-06-01 Thread rusi
On May 30, 2:48 pm, bhk...@gmail.com wrote:
> Code :
> -
> def mergeSort(alist):
>     print("Splitting ",alist)
>     if len(alist)>1:
>         mid = len(alist)//2
>         lefthalf = alist[:mid]
>         righthalf = alist[mid:]
>
>         mergeSort(lefthalf)
>         mergeSort(righthalf)
>
>         i=0
>         j=0
>         k=0
>         while i             if lefthalf[i]                 alist[k]=lefthalf[i]
>                 i=i+1
>             else:
>                 alist[k]=righthalf[j]
>                 j=j+1
>             k=k+1
>
>         while i             alist[k]=lefthalf[i]
>             i=i+1
>             k=k+1
>
>         while j             alist[k]=righthalf[j]
>             j=j+1
>             k=k+1
>     print("Merging ",alist)
>
> alist = [54,26,93,17,77,31,44,55,20]
> mergeSort(alist)
> print(alist)
>
> Output:
> ---
> ('Splitting ', [54, 26, 93, 17, 77, 31, 44, 55, 20])
> ('Splitting ', [54, 26, 93, 17])
> ('Splitting ', [54, 26])
> ('Splitting ', [54])
> ('Merging ', [54])
> ('Splitting ', [26])
> ('Merging ', [26])
> ('Merging ', [26, 54])
> ('Splitting ', [93, 17])
> ('Splitting ', [93])
> ('Merging ', [93])
> ('Splitting ', [17])
> ('Merging ', [17])
> ('Merging ', [17, 93])
> ('Merging ', [17, 26, 54, 93])
> ('Splitting ', [77, 31, 44, 55, 20])
> ('Splitting ', [77, 31])
> ('Splitting ', [77])
> ('Merging ', [77])
> ('Splitting ', [31])
> ('Merging ', [31])
> ('Merging ', [31, 77])
> ('Splitting ', [44, 55, 20])
> ('Splitting ', [44])
> ('Merging ', [44])
> ('Splitting ', [55, 20])
> ('Splitting ', [55])
> ('Merging ', [55])
> ('Splitting ', [20])
> ('Merging ', [20])
> ('Merging ', [20, 55])
> ('Merging ', [20, 44, 55])
> ('Merging ', [20, 31, 44, 55, 77])
> ('Merging ', [17, 20, 26, 31, 44, 54, 55, 77, 93])
> [17, 20, 26, 31, 44, 54, 55, 77, 93]
>
> Question:
> -
> Function mergeSort is called only once, but it is getting recursively 
> executed after the printing the last statement "print("Merging ",alist)". But 
> don't recursion taking place except at these places "mergeSort(lefthalf), 
> mergeSort(righthalf)"
>
> Sometimes the function execution directly starts from i=0,j=0,k=0 . Not sure 
> how.
>
> Can anyone please help me out here?

Not in direct answer to your question... Still see if this helps you
to understand mergesorting better.

I generally find that mixing recursion along with imperative
programming makes recursion look difficult.
Imperative programming goes scot-free and recursion gets a bad name!!

So here is a pure recursive/functional solution.  Tell me if you
understand it better (or worse!!)
Its written to demonstrate the IDEA of mergesort. Its actual
efficiency is sub-par for various reasons.

-
# merging two lists, both assumed sorted
def merge(a,b):
if a == []: return b
elif b== []: return a
elif a[0] < b[0]:
return [a[0]] + merge(a[1:],b)
else:
return [b[0]] + merge(a,b[1:])

# The same as merge above written in pure functional style
def merge1(a,b):
return (b if a == [] else
a if b == [] else
[a[0]] + merge(a[1:],b) if a[0] < b[0] else
[b[0]] + merge(a,b[1:])
   )

def mergeSort(alist):
if len(alist)>1:
mid = len(alist)//2
lefthalf = alist[:mid]
righthalf = alist[mid:]
return merge1(mergeSort(lefthalf),mergeSort(righthalf) )
else:
return alist

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


Re: Create a file in /etc/ as a non-root user

2013-06-01 Thread rusi
On Jun 2, 2:19 am, Denis McMahon  wrote:
> On Fri, 31 May 2013 02:12:58 -0700, BIBHU DAS wrote:
> > Any Idea how to create a file in /etc as non-root user?Can i use umask
> > or chmod...confused
>
> If you don't have root access, you probably shouldn't be trying to write
> in /etc. If you need to write in /etc, explain to the sysadmin why you
> need root access.

The OP is evidently working on a macbook pro.
>From which I infer its his own personal notebook.
So 'explain to the sysadmin' amounts to explain to oneself!!

40 years ago, on the first Unices, with machines millions of times
weaker and costlier than today, 'sysadmin' and 'normal user' were
usually different. Today they are usually the same.

So we old Unix-heads need to change our explanations from 'explain to
the sysadmin' to 'change hat from normal-user to superuser'.  And then
why simplifying life by having only one hat --
$ sudo bash # and do everything there
is not such a good idea!

To the OP:
One thing that has not changed in 40 (or rather 60) years is the
concept of binding times.
eg C programmers cannot get off the ground if they do not distinguish
compile-time from run-time.

In the current context, it is probably good to distinguish system-
admining time from system-use time.
So as sysadmin, you can pretty much do as you please (though remember
my comments earlier on respecting your distro's space), make a
directory under /etc, chmod, chown, chgrp it to your taste, so that
the (group of) ordinary users can write to it.

And then in normal user mode you should be able to write to it.

However... as I said above it may be preferable to use /usr/local (for
programs) or /var (for data) rather than mess in /etc. [Think of /etc
as windows' registry]  Study the FHS to make the right choice.

And finally, if you are the only guy involved, why are you not doing
everything under $HOME?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-03 Thread rusi
On Jun 3, 2:12 pm, Νικόλαος Κούρας  wrote:
> You are right Steven, i just renames the file 'Euxi tou Ihsou.mp3' => 'Eõ÷Þ 
> ôïõ Éçóïý.mp3' and…

Is that how you renamed your file?
In any case thats what I see!!

[Dont whether to say: Its greek to me or its not greek to me!!]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-03 Thread rusi
On Jun 4, 3:37 am, Steven D'Aprano  wrote:
> (Note: this post is sent using UTF-8. If anyone reading this sees
> mojibake, please make sure your email or news client is set to use UTF-8.)
>
> On Mon, 03 Jun 2013 05:54:30 -0700, rusi wrote:
> > On Jun 3, 2:12 pm, Νικόλαος Κούρας  wrote:
> >> You are right Steven, i just renames the file 'Euxi tou Ihsou.mp3' =>
> >> 'Eõ÷Þ ôïõ Éçóïý.mp3' and…
>
> > Is that how you renamed your file?
> > In any case thats what I see!!
>
> rusi, whatever program you are using to read these posts is buggy.

When you go to the python mailing list archive and look at Nikos mail
http://mail.python.org/pipermail/python-list/2013-June/648301.html
I see


[Not claiming to understand all this unicode stuff...]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyWart: The problem with "print"

2013-06-04 Thread rusi
On Jun 4, 5:23 pm, jmfauth  wrote:
> On 2 juin, 20:09, Rick Johnson  wrote:
>
>
>
> > I never purposely inject ANY superfluous cycles in my code except in
> > the case of testing or development. To me it's about professionalism.
> > Let's consider a thought exercise shall we?
>
> 
>
> The flexible string representation is the perfect example
> of this lack of professionalism.
> Wrong by design, a non understanding of the mathematical logic,
> of the coding of characters, of Unicode and of the usage of
> characters (everything is tight together).
>
> How is is possible to arrive to such a situation ?
> The answer if far beyond my understanding (although
> I have my opinion on the subject).
>
> jmf

The Clash of the Titans

Lé jmf chârgeth with mightƴ might
And le Mond underneath trembleth
Now RR mounts his sturdy steed
And the windmill yonder turneth
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: create new python file

2013-06-04 Thread rusi
On Jun 4, 11:09 pm, kakararunachalserv...@gmail.com wrote:
> Thank you so much! Why didn't i thought about that. So, can i program within 
> just by the print
> statement? Or do i have to do something else. I'm sorry, i just learning 
> python. Thanks again!

If you are just learning python, you almost certainly dont want to do
what you are asking for.
So take some time, think through what you want, tell us, without
worrying too much about the python angle -- we'll handle that side.

And yes, please spell-n-grammar check your question, if necessary with
a friend who knows English a bit.  An odd English error here and there
we can get on with. However with

> So, can i program within just by the print statement? Or do i have to do 
> something else.

it is completely indecipherable (to me at least) what you are saying,
leave aside any issues with python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Source code to identify user through browser?

2013-06-05 Thread rusi
On Jun 5, 8:10 pm, Carlos Nepomuceno 
wrote:
> > From: nos...@nospam.com
> > Subject: Source code to identify user through browser?
> > Date: Wed, 5 Jun 2013 15:08:54 +0200
> > To: python-l...@python.org
>
> > Hello
>
> > I was wondering if some Python module were available to identify a
> > user through their browser, like it's done on the Panopticlick site:
>
> What do you mean by user?

Ha! Nice question.  Not in direct answer but here's E.W Dijkstra
defining 'user':

[from http://www.cs.utexas.edu/~EWD/transcriptions/EWD06xx/EWD618.html
]

The computer “user” isn’t a real person of flesh and blood, with
passions and brains. No, he is a mythical figure, and not a very
pleasant one either. A kind of mongrel with money but without taste,
an ugly caricature that is very uninspiring to work for. He is, as a
matter of fact, such an uninspiring idiot that his stupidity alone is
a sufficient explanation for the ugliness of most computer systems.
And oh! Is he uneducated! That is perhaps his most depressing
characteristic. He is equally education-resistant as another equally
mythical bore, “the average programmer”, whose solid stupidity is the
greatest barrier to progress in programming. It is a sad thought that
large sections of computing science are effectively paralyzed by the
narrow-mindedness and other grotesque limitations with which a poor
literature has endowed these influential mythical figures. (Computing
science is not unique in inventing such paralyzing caricatures:
universities all over the world are threatened by the invention of
“the average student”, scientific publishing is severely hampered by
the invention of “the innocent reader” and even “the poor reader”!)





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


Re: Source code to identify user through browser?

2013-06-05 Thread rusi
On Jun 5, 8:31 pm, Mark Lawrence  wrote:
> On 05/06/2013 16:18, rusi wrote:
>
>
>
>
>
>
>
>
>
> > On Jun 5, 8:10 pm, Carlos Nepomuceno 
> > wrote:
> >>> From: nos...@nospam.com
> >>> Subject: Source code to identify user through browser?
> >>> Date: Wed, 5 Jun 2013 15:08:54 +0200
> >>> To: python-l...@python.org
>
> >>> Hello
>
> >>> I was wondering if some Python module were available to identify a
> >>> user through their browser, like it's done on the Panopticlick site:
>
> >> What do you mean by user?
>
> > Ha! Nice question.  Not in direct answer but here's E.W Dijkstra
> > defining 'user':
>
> > [fromhttp://www.cs.utexas.edu/~EWD/transcriptions/EWD06xx/EWD618.html
> > ]
> > 
> > The computer �user� isn�t a real person of flesh and blood, with
> > passions and brains. No, he is a mythical figure, and not a very
> > pleasant one either. A kind of mongrel with money but without taste,
> > an ugly caricature that is very uninspiring to work for. He is, as a
> > matter of fact, such an uninspiring idiot that his stupidity alone is
> > a sufficient explanation for the ugliness of most computer systems.
> > And oh! Is he uneducated! That is perhaps his most depressing
> > characteristic. He is equally education-resistant as another equally
> > mythical bore, �the average programmer�, whose solid stupidity is the
> > greatest barrier to progress in programming. It is a sad thought that
> > large sections of computing science are effectively paralyzed by the
> > narrow-mindedness and other grotesque limitations with which a poor
> > literature has endowed these influential mythical figures. (Computing
> > science is not unique in inventing such paralyzing caricatures:
> > universities all over the world are threatened by the invention of
> > �the average student�, scientific publishing is severely hampered by
> > the invention of �the innocent reader� and even �the poor reader�!)
>
> Where does the Bastard Operator From Hell fit in this? :)

:-)
Yes Dijkstra is quite a devil.
Always thought-provoking and entertaining -- never to be taken too
seriously!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Apache and suexec issue that wont let me run my python script

2013-06-05 Thread rusi
On Jun 5, 11:34 pm, Νικόλαος Κούρας  wrote:
> Here is the mails you sent to my customers for the other members to see.


In the normal run of things, I would say Chris has done a horrible
thing.
In this case however, let us remember:
Many people -- hardly exclusively Chris -- tried to educate you
  1. on technical matters
  2. on methodological matters (eg how to debug)
  3. on matters of minimum etiquette -- eg spellchecking
  4. on basic security

For the most part, you simply have not listened.
Finally Chris warned you what he can do.
Instead of listening, you whined: "I trust you!!" (Heres a kiss!) and
gave him your password.
He gently tapped you on your rather hard and impervious 'Ferrous
Cranus' to let you understand the implications.

Even now, instead of understanding that you were wrong throughout, you
are still blaming Chris -- Good Grief!

And you expect us to sympathize with you?!?!  I dont know whether to
laugh or cry...

Please note Nikos:
If you obdurately, obstinately, insistently, incessantly behave like
an asshole, you leave no-one the choice but to treat you like an
asshole.

So... Are you an asshole??  One can only hope that you prove me wrong...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-06 Thread rusi
On Jun 6, 6:45 am, Chris Angelico  wrote:
> On Thu, Jun 6, 2013 at 11:37 AM, Steven D'Aprano
>
>  wrote:
> > What prevents bugs is the skill of the people writing the code, not the
> > compiler.
>
> +1 QOTW.

In many Indian languages there is a saying: A poor dancer blames the
crooked floor. [Yeah… sounds tame in English]  -- which is probably
what Steven is saying.

However in defence of the crooked floor… 

When I taught C at the university in the early 90s[1], every third/
fourth compile+run of the kids would result in 'segmentation fault' if
they were lucky enough to be on unix, and OS crashes if they were on
DOS.
At first I would rail at the kids for not doing due diligence.  Over
time I came to the conclusion that if a system is designed in such a
way that everyone is wrong, then its the system that is wrong and not
everyone.

When we switched from to python (via Scheme and a haskell-
predecessor), I dont remember ever getting a segmentation fault.

[Well once RR gave some Wx code that I tried and python core dumped.
Whether this speaks for RR or Wx or a dangerous combo...]

So yes, elegant programming languages are not proof against inelegant
programmers.
Nevertheless, programming languages can be made in a way that makes
certain class of errors harder/easier to make.

Joel Spolsky moans that:
Java is not, generally, a hard enough programming language that it can
be used to discriminate between great programmers and mediocre
programmers.
http://www.joelonsoftware.com/articles/ThePerilsofJavaSchools.html

And Paul Graham is even more provocative:
Java programmers are not as smart as python programmers
http://www.paulgraham.com/gh.html

[1] Prompted a paper in the 90s, with some modernizing modifications
http://blog.languager.org/2013/02/c-in-education-and-software-engineering.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-06 Thread rusi
On Jun 6, 8:26 pm, Chris Angelico  wrote:
> On Fri, Jun 7, 2013 at 12:09 AM, rusi  wrote:
> > When we switched from to python (via Scheme and a haskell-
> > predecessor), I dont remember ever getting a segmentation fault.
>
> Oh, it's easy to segfault Python.
>
> import sys
> sys.setrecursionlimit(9)
> def foo(): foo()
> foo()
>
> :)
>
> ChrisA

And so you are hereby anointed into the august company of RR!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-06 Thread rusi
On Jun 6, 9:08 pm, Robert Kern  wrote:
> On 2013-06-06 16:41, Chris Angelico wrote:
>
> > Anyway, regardless of your language, there's always some criteria that
> > can't be coded. Suppose the valid input for a function were "integers
> > whose square roots are integers but whose cube roots are not". You
> > won't easily get compile-time checking of that.
>
> Say that on a Haskell list, and they'll take it as a challenge. :-)

Yes, all programming communities have blind-spots.  The Haskell
community's is that Haskell is safe and safe means that errors are
caught at compile-time.

Unfortunately* the halting problem stands.  When generalized to Rice
theorem it says that only trivial properties of programs are
algorithmically decidable:
http://mathworld.wolfram.com/RicesTheorem.html

And so the semantic correctness of a program -- a non-trivial property
-- is not decidable.

In short the Haskell dream is a pipe-dream**.

Discussed in more detail here: 
http://blog.languager.org/2012/08/functional-programming-philosophical.html.

Nevertheless I need to say: If a programmers comes to python from
Haskell, he will end up being a better programmer than one coming from
C or Java or…


* actually fortunately considering that for most of us programming is
our job :-)

** Haskellers would point out that there is agda which grows out of
Haskell and in agda one can encode arbitrary properties of types.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-06 Thread rusi
On Jun 6, 11:44 pm, Devin Jeanpierre  wrote:
>
> > Unfortunately* the halting problem stands.  When generalized to Rice
> > theorem it says that only trivial properties of programs are
> > algorithmically decidable:
> >http://mathworld.wolfram.com/RicesTheorem.html
>
> > And so the semantic correctness of a program -- a non-trivial property
> > -- is not decidable.
>
> Just because a problem is NP-complete or undecidable, doesn't mean
> there aren't techniques that give the benefits you want (decidability,
> poly-time) for a related problem. Programmers often only or mostly
> care about that related problem, so it isn't the end of the line just
> when we hit this stumbling block.
>
> As far as undecidability goes, one possibility is to accept a subset
> of desired programs. For example, restrict the language to not be
> turing complete, and there is no problem.
>
> Another resolution to the problem of undecidability is to accept a
> _superset_ of the collection you want. This permits some programs
> without the property we want, but it's often acceptable anyway.
>
> A third approach is to attach proofs, and only accept a program with
> an attached and correct proof of said property. This is a huge
> concept, vital to understanding complexity theory. It may be
> undecidable to find a proof, but once it is found, it is decidable to
> check the proof against the program.
>
> Haskell takes something akin to the second approach, and allows errors
> to exist which would require "too much work" to eliminate at compile
> time. (Although the type system is a literal case of the first
> resolution). Python, by contrast, often values flexibility over
> correctness, regardless of how easy it might be to check an error at
> compile time. The two languages have different philosophies, and that
> is something to respect. The reduction to Rice's theorem does not
> respect the trade-off that Haskell is making, it ignores it. It may be
> a "pipe dream" to get everything ever, but that's not to say that the
> entire approach is invalid and that we should ignore how Haskell
> informs the PL discourse.
>

Nice 3-point summary. Could serve as a good antidote to some of the
cargo-culting that goes on under Haskell.
To make it very clear: In any science, when there are few people they
probably understand the science. When the numbers explode, cargo-cult
science happens.  This does not change the fact that a few do still
understand.  Haskell is not exception.  See below

>
> On Thu, Jun 6, 2013 at 1:27 PM, rusi  wrote:
> > Yes, all programming communities have blind-spots.  The Haskell
> > community's is that Haskell is safe and safe means that errors are
> > caught at compile-time.
>
> I don't think Haskell people believe this with the thoroughness you
> describe. There are certainly haskell programmers that are aware of
> basic theory of computation.

Of course!  Here's cmccann from Haskell weekly news of May 31: [On
reimplementing cryptography in pure Haskell] writing in Haskell lets
you use type safety to ensure that all the security holes you create
are subtle instead of obvious.

Which is showing as parody exactly what I am talking of: All errors
cannot be removed algorithmically/mechanically.

And here's Bob Harper -- father of SML -- pointing out well-known and
less well-known safety problems with Haskell:
http://existentialtype.wordpress.com/2012/08/14/haskell-is-exceptionally-unsafe/


--
> Super OT divergence because I am a loser nerd:

Uh? Not sure I understand…
OT: OK: How can you do programming if you dont understand it?
I guess in a world where majority do it without understanding, someone
who understands (more) will be called 'nerd'?

> For some reason both the Python and Haskell communities feel the other
> is foolish and ignorant, dismissing their opinions as unimportant
> babbling. I wish that would stop.

Dunno whether you are addressing me specifically or python folks
generally.
If me, please remember my post ended with
> If a programmer comes to python from Haskell, he will end up being a better 
> programmer than one
> coming from C or Java or…

If addressed generally, I heartily agree. My proposed course:
https://moocfellowship.org/submissions/the-dance-of-functional-programming-languaging-with-haskell-and-python
is in this direction. That is it attempts to create a new generation
of programmers who will be able to use Haskell's theory-power to pack
an extra punch into batteries-included python.

More details:  
http://blog.languager.org/2013/05/dance-of-functional-programming.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-06 Thread rusi
On Jun 7, 12:03 am, Lele Gaifax  wrote:

> You should *read* and *understand* the error message!

When you *shout* at the deaf, the non-deaf get deaf .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-06 Thread rusi
On Jun 7, 8:14 am, Mark Janssen  wrote:
> >> I am aware of what it means, but Python doesn't really have it (although
> >> it may evolve to it with annotations).
>
> > No polymorphism huh?
>
> > py> len([1, 2, 3])  # len works on lists
> > 3
> > py> len((1, 2))  # and on tuples
> > 2
> > py> len({})  # and on dicts
> > 0
> > py> len('I pity the fool')  # and on strings
> > 15
> > py> len(b'\x23')  # and on bytes
> > 1
> > py> len(set(range(2)))  # and on sets
> > 2
> > py> len(frozenset(range(4)))  # and on frozensets
> > 4
> > py> len(range(1000))  # and on range objects
> > 1000
>
> Okay, wow, it looks like we need to define some new computer science
> terms here.

Fairly definitive terms have existed since 1985:
http://lucacardelli.name/Papers/OnUnderstanding.A4.pdf

>
> You are making an "outside view of a function" (until a better term is
> found).  So that give you one possible view of polymorphism.  However,
> *within* a class that I would write, you would not see polymorphism
> like you have in C++,  where it is within the *function closure*
> itself.   Instead you would see many if/then combinations to define
> the behavior given several input types.  I would call this simulated
> polymorphism.

Cardelli and Wegner cited above call this ad-hoc polymorphism.
What you are calling polymorphism, they call universal polymorphism.

See sect 1.3 for a summary diagram

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


Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-06 Thread rusi
On Jun 7, 8:24 am, rusi  wrote:
> On Jun 7, 8:14 am, Mark Janssen  wrote:
>
>
>
>
>
>
>
>
>
> > >> I am aware of what it means, but Python doesn't really have it (although
> > >> it may evolve to it with annotations).
>
> > > No polymorphism huh?
>
> > > py> len([1, 2, 3])  # len works on lists
> > > 3
> > > py> len((1, 2))  # and on tuples
> > > 2
> > > py> len({})  # and on dicts
> > > 0
> > > py> len('I pity the fool')  # and on strings
> > > 15
> > > py> len(b'\x23')  # and on bytes
> > > 1
> > > py> len(set(range(2)))  # and on sets
> > > 2
> > > py> len(frozenset(range(4)))  # and on frozensets
> > > 4
> > > py> len(range(1000))  # and on range objects
> > > 1000
>
> > Okay, wow, it looks like we need to define some new computer science
> > terms here.
>
> Fairly definitive terms have existed since 
> 1985:http://lucacardelli.name/Papers/OnUnderstanding.A4.pdf
>
>
>
> > You are making an "outside view of a function" (until a better term is
> > found).  So that give you one possible view of polymorphism.  However,
> > *within* a class that I would write, you would not see polymorphism
> > like you have in C++,  where it is within the *function closure*
> > itself.   Instead you would see many if/then combinations to define
> > the behavior given several input types.  I would call this simulated
> > polymorphism.
>
> Cardelli and Wegner cited above call this ad-hoc polymorphism.
> What you are calling polymorphism, they call universal polymorphism.
>
> See sect 1.3 for a summary diagram

I should have added that python has the universal polymorphism that
you want:

$ python
Python 2.7.5 (default, May 20 2013, 13:49:25)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> len([1,2])
2
>>> len([[1,2]])
1
>>> len([[[1,2]],[[3]],[[4,5]]])
3
>>>

The main thing to note about universal -> parametric polymorphism is
that one definition works for an infinite set of types, without any
extra code(ing)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Don't rebind built-in names*" - it confuses readers

2013-06-10 Thread rusi
On Jun 11, 5:53 am, Mark Janssen  wrote:
> > There's a subtle difference between a keyword and a built-in.  Good
> > Python style generally avoids masking built-ins but allows it:
>
> Right, thank you for reminding me.  My C-mind put them in the same category.
> --
> MarkJ
> Tacoma, Washington

Dont know what you mean.  This is working C:
-
#include 
int getpid = 4;
main()
{
  printf("pid is %d\n", getpid);
}
-
As is this
-
#include 
main()
{
  printf("pid is %d\n", getpid());
}
-

The first prints 4; the second prints the pid.
gcc 4.7
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Don't rebind built-in names*" - it confuses readers

2013-06-10 Thread rusi
On Jun 11, 5:14 am, Terry Jan Reedy  wrote:
> Many long-time posters have advised "Don't rebind built-in names*.
>
> * Unless you really mean to mask it, or more likely wrap it, such as
> wrapping print to modify some aspect of its operation than one cannot do
> with its keyword parameters. The point for this post is that such
> wrapping modify or extend the basic meaning of the builtin, but do not
> abolish it.
>
> Reasons have been given in various related forms: 'my long experience
> tells me its bad', 'you may need the builtin later', 'you may forget
> that you rebound the builtin, 'it can lead to subtle bugs, etc.
>
> Leaving aside the code writer and code operation, I recently discovered
> that it is not nice for readers, whether humans or programs.
>
> For instance, open Lib/idlelib/GrepDialog.py in an editor that colorizes
> Python syntax, such as Idle's editor, jump down to the bottom and read
> up, and (until it is patched) find
>                      list.append(fn)
> with 'list' colored as a builtin. Stop. That looks wrong. List.append
> needs two arguments: a list instance and an object to append to the
> list. The 'solution' is in a previous line
>          list = []
> Reading further, one sees that the function works with two lists, a list
> of file names, unfortunately called 'list', and a list of
> subdirectories, more sensibly call 'subdirs'. I was initially confused
> and reading the code still takes a small bit of extra mental energy.
> Idle stays confused and will wrongly color the list instance name until
> it is changed. Calling the file list 'fnames' or 'filenames' would have
> been clearer to both me and Idle.
>
> --
> Terry Jan Reedy

Pascal introduced the idea of block structure -- introduce a name at
one level, override it at a lower level. [Ok ALgol introduced, Pascal
popularized].
This has caused more trouble than it has solved. And so languages
nowadays tend to 'protect' against this feature.

Here is Erlang's 'sticky' feature
http://books.google.co.in/books?id=Qr_WuvfTSpEC&pg=PA181&lpg=PA181&dq=erlang+sticky+directory&source=bl&ots=aLZCjwzUFb&sig=DQiiQgzHCt5EtE5H3WY3bCWh4eM&hl=en&sa=X&ei=gYu2UbD6DMOMrQeNh4HYDA&ved=0CEAQ6AEwAw#v=onepage&q=erlang%20sticky%20directory&f=false
that prevents a programmer from overriding a builtin module unless he
explicitly asks for that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Don't rebind built-in names*" - it confuses readers

2013-06-10 Thread rusi
On Jun 11, 8:02 am, Steven D'Aprano  wrote:
> On Mon, 10 Jun 2013 19:36:44 -0700, rusi wrote:
> > Pascal introduced the idea of block structure -- introduce a name at one
> > level, override it at a lower level. [Ok ALgol introduced, Pascal
> > popularized].
> > This has caused more trouble than it has solved.
>
> > And so languages nowadays tend to 'protect' against this feature.
>
> Apart from Erlang, got any other examples? Because it seems to me that in
> languages with nested scopes or namespaces, shadowing higher levels is
> exactly the right thing to do.

This is just opening up the definition of block-structure and saying
its a good thing.

> Certainly it would be a PITA, and defeat
> the purpose of having nested scopes, if inner names had to be globally
> unique. Wouldn't it be absolutely horrible if adding a global variable
> "foo"[1] suddenly meant that all your functions that used "foo" as a
> local variable stopped working?
>
> [1] For some value of "foo".

Your opinion.

Not so convincing if the sequence of composing the program was the
other-way-round:
if I have a global variable, say errno, and 'lose' it by introducing a
local variable errno.

And in fact for a reader of a program, the order of its writing should
not matter.
Which brings us pat into Terry's example.  [Also notice that changing
from a 'parametric-semantic' name like foo to a more 'fixed-semantic'
name like 'errno' or 'list' changes the desirability of this feature.

>
> I take it you have never programmed in a programming language with a
> single, flat, global namespace? :-)

Well Ive used Basic and Assembler -- which are fun in the way that
childhood and mountaineering respectively are fun.

What it seems you are not getting about Erlang's outlook about block-
structure is this: There are two separable aspects to it:
1. Names can be created in local scopes which dont leak into (more)
global scopes -- a desirable feature

2. Names in local scopes can override names in global scope -- a
dangerous feature [BTW which is what this thread is about].  And
Erlang's approach seems to be the most nuanced -- you can do it if you
go out of your way to say: "unstick the global namespace".

This is somewhat analogous to gotos in Pascal. For Pascal goto was a
sufficiently undesirable feature that using it was not completely
easy.  However if you did surely want it, you had to declare the goto
label.

Or by example:

def foo(x)...
def bar(x,y)...
there is no reason to confuse the two xes.

Whereas

x = ...
def foo(x)...
Now there is!

The first should be encouraged, the second discouraged.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Don't rebind built-in names*" - it confuses readers

2013-06-11 Thread rusi
On Jun 11, 12:09 pm, Peter Otten <__pete...@web.de> wrote:
> Terry Jan Reedy wrote:
> > Many long-time posters have advised "Don't rebind built-in names*.
>
> I'm in that camp, but I think this old post by Guido van Rossum is worth
> reading to put the matter into perspective:

Not sure what you are saying Peter… If it is this (taken without
context):

> (Not that it isn't a good idea to avoid obvious clashes --
> 'str' for string variables and 'type' for type variables being the
> most obvious stumbling blocks.)

then I guess we are saying the same thing??

If however we consider the context of that message:
First there was only open, then there came file, and file was
considered better than open, now again file seems to have disappeared
from python3… and this message is written in the context of making the
'kosherness' of one python generation become the *different*
kosherness of the next…

then what the message of the Guido-quote is, is not clear (at least to
me).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Build Python 2.7.5 - Modules missing

2013-06-11 Thread rusi
On Jun 10, 10:51 pm, Walter Hurry  wrote:
> On building Python 2.7.5 I got the following message:
>
> Python build finished, but the necessary bits to build these modules
>  were not found:
> dl                 imageop            linuxaudiodev
> spwd               sunaudiodev
> To find the necessary bits, look in setup.py in detect_modules()
>  for the module's name.
>
> It carried on with the installation OK, but I don't understand the last
> sentence in the message. How can I find out exactly what modules are
> missing, and what I need to do to make sure they are built next time?

On a debian box (which includes ubuntu etc), doing:
# aptitude build-dep python
will get you all the packages you need to build python. You can use
apt-get instead of aptitude.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Split a list into two parts based on a filter?

2013-06-11 Thread rusi
On Jun 11, 6:48 pm, Fábio Santos  wrote:
>
> What I like so much about it is the .. if .. else .. Within the parenthesis
> and the append() call outside these parenthesis.

You can do this -- which does not mix up functional and imperative
styles badly and is as much a 2-liner as Roy's original.

new_songs, old_songs = [], []
for s in songs: (new_songs if s.is_new() else old_songs).append(s)

[Of course I would prefer a 3-liner where the body of the for is
indented :-) ]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHONPATH: dev and prod

2013-06-11 Thread rusi
On Jun 11, 9:28 pm, jacopo  wrote:
> I am developing my code in the path:
> /py/myscripts
> /py/mylib
> In order to "import mylib", I need to add /py/mylib to PYTHONPATH.
>
> Now I want to save a snapshot of the current code in the production 
> directory, I will copy all in:
> /prod/myscripts
> /prod/mylib
>
> The problem now is that when I execute /prod/myscripts/any_script.py, every 
> "import" will look at PYTHONPATH and therefore it will load the modules from 
> /py/mylib. On the contrary I want to load it from /prod/mylib.
>
> Is there an elegant way to cope with this?
>
> thanks, Jacopo


Use explicit (dot-based) relative imports
http://docs.python.org/release/2.5/whatsnew/pep-328.html
Avoid using PYTHONPATH

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


Re: Split a list into two parts based on a filter?

2013-06-11 Thread rusi
On Jun 11, 10:05 pm, Fábio Santos  wrote:
> On 11 Jun 2013 17:47, "rusi"  wrote:
>
> > [Of course I would prefer a 3-liner where the body of the for is
> > indented :-) ]
>
> Is this an aside comprehension?

Eh?

Its a for-loop. Same as:
for s in songs:
   (new_songs if s.is_new() else old_songs).append(s)

Maybe you are unfamiliar with the line
... A suite can be one or more semicolon-separated simple statements
on the same line as the header,
??

from http://docs.python.org/2/reference/compound_stmts.html

Or you are joking??

What with the offside rule (indentation rule in Haskell) becoming the
'aside rule' causing (in)comprehension in reading comprehensions??

Ok... Jokes aside... Dunno what you are asking.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Split a list into two parts based on a filter?

2013-06-11 Thread rusi
On Jun 11, 10:37 pm, Chris Angelico  wrote:
> On Wed, Jun 12, 2013 at 3:23 AM, rusi  wrote:
> > On Jun 11, 10:05 pm, Fábio Santos  wrote:
> >> On 11 Jun 2013 17:47, "rusi"  wrote:
>
> >> > [Of course I would prefer a 3-liner where the body of the for is
> >> > indented :-) ]
>
> >> Is this an aside comprehension?
>
> > Eh?
>
> I know they always say "don't explain the joke", but I'll have a shot
> at it. It's somewhat like an autopsy though - you find out why it
> ticks, but in the process, you prove that it's no longer ticking...

Ok :-)

Missed that my aside looked like a comprehension. Or rather did not
comprehend!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHONPATH: dev and prod

2013-06-12 Thread rusi
On Jun 12, 4:10 pm, jacopo  wrote:
> this idea seemed perfect but it turned out that you have to execute the 
> module as a package
> (python -m py.myscripts.any_script) otherwise I get an error on the relative 
> import.
> Unfortunately I am working in a team and I do not have control on how the 
> module is launched.

You need to give more data:

1. How you run -- 'launch' -- the code -- from py and from prod
2. What error you get
3. Did you try bundling your modules into a package? What problem
happened?

If PYTHONPATH does not work for you you can look at path-configuration-
files (.pth) files
http://docs.python.org/2/library/site.html [Ive not used them myself]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHONPATH: dev and prod

2013-06-12 Thread rusi
On Jun 12, 6:29 pm, jacopo  wrote:
> > 1. How you run -- 'launch' -- the code -- from py and from prod
>
> when I have to test I use "python any_script.py"  but in production there is 
> a c++ program that is able to wrap and run python code (the technical details 
> are a bit beyond my knowledge)
>
> > 2. What error you get
>
> when I run as "python any_script.py" I get
> "ValueError: Attempted relative import in non-package"
> I have found this 
> explanation:http://stackoverflow.com/questions/11536764/attempted-relative-import...
> So I have added at the top of my module:
>
> if __name__=="__main__" and __package__ is None:
>      __package__="myscripts"
> from ..mylib import MyClass
>
> and I get the error:
> SystemError: Parent module 'mylib' not loaded, canno perform relative import
>
> > 3. Did you try bundling your modules into a package? What problem
> > happened?
>
> What does it mean? what does build mean in this contest? I am not compiling, 
> I just write the .py files.

I mean use a python package to wrap the modules.
Roughly that means have a file named __init__.py in the root of your
modules directory.
For the details see http://docs.python.org/2/tutorial/modules.html#packages

More intricacies I dont know. Hopefully someone who knows better can
answer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Turnign greek-iso filenames => utf-8 iso

2013-06-12 Thread rusi
On Jun 12, 7:42 pm, Mark Lawrence  wrote:
> On 12/06/2013 13:42, Νικόλαος Κούρας wrote:
>
>
>
> > Something you want me to try?
>
> I'd suggest suicide but that would no doubt start another stream of
> questions along the lines of "How do I do it?".

There's a saying in some Indian languages (unfortunately sounds tame
when I translate it):
Counterfeit coin refuses to be lost…
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Version Control Software

2013-06-12 Thread rusi
On Jun 13, 11:00 am, cutems93  wrote:
> Thank you everyone for such helpful responses! Actually, I have one more 
> question. Does anybody have experience with closed source version control 
> software? If so, why did you buy it instead of downloading open source 
> software? Does closed source vcs have some benefits over open source in some 
> part?
>
> Thanks!
> MinS

Not too many people who buy expensive software use it.
Those who use it, have usually not been party to buying it.

The first are usually called 'boss'.
The second, 'programmer' or some euphemism for that like 'software-
engineer.'

As to your question about vcs, there is also fossil:
http://www.fossil-scm.org/xfer/doc/trunk/www/fossil-v-git.wiki
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Version Control Software

2013-06-13 Thread rusi
On Jun 13, 4:26 pm, MRAB  wrote:
> On 13/06/2013 07:00, cutems93 wrote:> Thank you everyone for such helpful 
> responses! Actually, I have one
> > more question. Does anybody have experience with closed source
> > version control software? If so, why did you buy it instead of
> > downloading open source software? Does closed source vcs have some
> > benefits over open source in some part?
>
> I've used Microsoft SourceSafe. I didn't like it (does anyone? :-)).

It seems to me that even MS is realizing that SourceSafe's time is
over:

http://techcrunch.com/2013/01/30/microsoft-announces-git-support-for-visual-studio-team-foundation-server-and-service/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Version Control Software

2013-06-13 Thread rusi
On Jun 13, 7:30 am, Ben Finney  wrote:
>
> You should be wary of GitHub, a very popular Git hosting site. It uses
> what amount to proprietary protocols, which encourage using GitHub's
> specific interface instead of native Git for your operations and hide a
> lot of the needless complexity; but this results in a VCS repository
> that is difficult to use *without* being tied to that specific site,
> killing one of the best reasons to use a DVCS in the first place.

bitbucket -- originally only Hg based -- now supports Hg or git.
And for small private (non open source) repos its more affordable
http://tilomitra.com/bitbucket-vs-github/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A certainl part of an if() structure never gets executed.

2013-06-13 Thread rusi
On Jun 12, 8:20 pm, Zero Piraeus  wrote:
> :
>
> On 12 June 2013 10:55, Neil Cerutti  wrote:
>
>
>
> > He's definitely trolling. I can't think of any other reason to
> > make it so hard to kill-file himself.
>
> He's not a troll, he's a help vampire:
>
>  http://slash7.com/2006/12/22/vampires/
>
> ... a particularly extreme example, I'll admit

Thanks for that term.

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


Re: My son wants me to teach him Python

2013-06-13 Thread rusi
On Jun 13, 12:46 am, John Ladasky  wrote:
> Hi folks,
>
> My son is 17 years old.  He just took a one-year course in web page design at 
> his high school.  HTML is worth knowing, I suppose, and I think he has also 
> done a little Javascript.  He has expressed an interest in eventually wanting 
> to program 3D video games.
>
> For that purpose, HTML and Javascript are too limited.  I hardly consider 
> either one to be a real programming language.  I want to get him started with 
> a real applications programming language -- Python, of course.  And he's 
> ready to learn.  OK, so it's not necessarily a fast enough language for the 
> epic video games he envisions, but it's a darn good start.  I'll tax his 
> brain with a compiled language like C at some other time.
>
> He's a smart kid, but prefers to be shown, to be tutored, rather than having 
> the patience to sit down and RTFM.  Have any of you been down this road 
> before?  I would appreciate it if you would share your experiences, or 
> provide resource material.
>
> Thanks!

Some views of mine (controversial!).

Python is at least two things, a language and a culture.
As a language its exceptionally dogma-neutral.
You can do OO or FP, throwaway one-off scripts or long-term system
building etc

However as a culture it seems to prefer the OO style to the FP style.
This is unfortunate given that OO is on the down and FP is on a rise.
Some thoughts re OOP: 
http://blog.languager.org/2012/07/we-dont-need-no-o-orientation-4.html

So my suggestion is use some rigorous FPL like Haskell to learn/teach
programming.
After that you can switch to python or some other realistic language.

Note: I have some serious reservations regarding Haskell
http://blog.languager.org/2012/08/functional-programming-philosophical.html
Nevertheless it seems to be the best there is at the moment.

tl;dr: Haskell is in 2013 what Pascal was in 1970 -- good for
programming pedagogy.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My son wants me to teach him Python

2013-06-13 Thread rusi
On Jun 13, 6:07 pm, Roy Smith  wrote:
> In article
> <545a441b-0c2d-4b1e-82ae-024b011a4...@e1g2000pbo.googlegroups.com>,
>
>  rusi  wrote:
> > Python is at least two things, a language and a culture.
>
> This is true of all languages.  Hang out on the PHP, Ruby, Python, etc,
> forums and you quickly learn that the cultures are as different (or more
> so) than the languages.

Umm... Of course. I dont know though how that relates to the OP's
question.
So let me try state my point differently:

Python-the-language has strengths that are undermined by the biases in
the culture of Python.
A father wanting to give his son the best may want to apply correcting
anti-biases.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wrong website loaded when other requested

2013-06-13 Thread rusi
On Jun 13, 7:28 pm, Chris Angelico  wrote:
> On Fri, Jun 14, 2013 at 12:23 AM, Íéêüëáïò Êïýñáò  
> wrote:
> > Please suggest something of why this happnes.
>
> You remind me of George.
>
> http://www.chroniclesofgeorge.com/
>
> ChrisA

HA!
You are evil -- Chris!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My son wants me to teach him Python

2013-06-13 Thread rusi
On Jun 13, 9:50 pm, Tomasz Rola  wrote:
> I've reposted on another list and got this reply. At first I was sceptic
> a bit, but for the sake of completeness, here goes. Processing language
> seems to be interesting in its own right. Examples are Java-flavoured,
> images are ok.
>
> Regards,
> Tomasz Rola
>
> --
> ** A C programmer asked whether computer had Buddha's nature.      **
> ** As the answer, master did "rm -rif" on the programmer's home    **
> ** directory. And then the C programmer became enlightened...      **
> **                                                                 **
> ** Tomasz Rola          mailto:tomasz_r...@bigfoot.com             **
>
> -- Forwarded message --
> Date: Thu, 13 Jun 2013 16:55:11 +0200
> From: Eugen Leitl 
> To:  
> Subject: Re: [info] (comp.lang.python) Re: My son wants me to teach him Python
>
> On Thu, Jun 13, 2013 at 04:48:52PM +0200, Tomasz Rola wrote:
>
> > No. Definitely not. Programming does NOT begin with a GUI. It begins with
> > something *simple*, so you're not stuck fiddling around with the
> > unnecessary. On today's computers, that usually means console I/O
> > (actually console output, with console input coming along much later).
>
> Of course kids are more interesting in things painted on
> screen, especially if they are colorful, move and make
> sounds at that. The next step would be a simple,
> interactive game.
>
> Which is why I would synthesize something neat yet
> simple fromhttp://processing.org/tutorials/
>
> Python is overkill for a kid. Ugh. Some people have just
> no common sense at all.

All kids can be fit into the stereotype -- 'kid'??

I can tell you after 25 years teaching programming --
Some kids will take to FP, others will not
Some will take to C, some wont
Some will take to C AND C++, some will take to only one
The majority are ok with python, some hate it

One of my long term projects is to take a type classification like
http://en.wikipedia.org/wiki/Myers-Briggs_Type_Indicator
and see how it maps to a person's potential as a programmer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python biases [was Re: My son wants me to teach him Python]

2013-06-13 Thread rusi
On Jun 14, 5:44 am, Steven D'Aprano  wrote:
> On Thu, 13 Jun 2013 06:37:34 -0700, rusi wrote:
> > Python-the-language has strengths that are undermined by the biases in
> > the culture of Python.
>
> This implies that there are strengths in Python-the-language which are
> not just missed or ignored by Python programmers immersed in the culture,
> but actively (if unconsciously) fought against.
>
> As someone immersed in that culture, and therefore at risk of being
> unaware of my biases, I am *very* curious as to what you think they are,
> and what strengths of Python you think I might be missing.

[This is more of an example than a full answer]
Lets say I have a 'kid' -- son, niece, student, whatever -- and for
some reason, we, both me and 'kid', feel its important to master
regular expressions.

Now regular expressions are there everywhere -- vi, emacs, perl,
python, awk, egrep, lex, ragel ... -- and so *technically* they are
quite orthogonal to the programming language issue.
Let us also assume that as a programming language, I definitely prefer
python over perl, in particular, REs in perl and python are more or
less equipotent.

However once we go beyond the technical basics of REs to a cultural
question -- asking more intricate questions on a forum -- I expect the
following to happen.

If (s)he asks an RE question on a perl forum I expect answers that are
cute, one-liner, zany etc but in a SE sense promote bad programming.
As a (cultural) rebound from that, when the same is asked on a python
forum, (s)he may get the hi-power RE answer. He is more more likely to
get a lecture on why REs are bad.

Now from a programming/SE angle, this is fine -- certainly writing an
ugly, buggy, inefficient RE where a few lines of beautiful soup (say)
would do better is poor practice. However lets remember that mastering
RE for its own sake is our agenda in addition to mastering
programming.

In short, I am not interested in perl for its own sake, yet the path
to RE-mastery in perl-culture is shorter.

So as guardian to my ward I have a simple evaluation to make:
"learn perl + python, learn REs in both, learn to translate REs across
the two"
is more or less work than
"Do everything in python"

Common sense suggests that the second is the less-work option.
Experience (may) suggest otherwise.

So much for my toy example. Now to more directly answer your question.

Here's Richard O'Keefe on the Erlang mailing list. Note particularly
the COBOL-Scheme reference.

-
Once upon a time (about 1992ish) in a land where the moles
have beaks and swim and the deer jump on their hind legs
(Australia), a certain computer science department (RMIT)
decided that Pascal had reached its use-by date.  What shall
we do?  What shall we replace it with?  Set up a committee!
I was on the committee.  We set up a short list.
 (1) Scheme.
 Tiny language, amazingly capable, REPL so you can try
 things out, implementations for all the machines we
 cared about.  And Rob Hagan at Monash had shown that
 you could teach students more COBOL with one semester
 of Scheme and one semester of COBOL than you could
 with three semesters of COBOL.
 (2) Miranda.
 The commercial precursor of Haskell.
 Melbourne University were also looking at this (or had
 already switched to it) which would make it easier to
 pick up some of their students.
 (3) Ada.
 Close enough to Pascal that our staff were comfortable with
 it and our material would not need major revision.
 A better Pascal than Pascal.
 Handled concurrency about as nicely as an imperative language
can.

Personal Note:
For years Ive taught programming using two languages, one FPL, one
imperative language.
FPL  one of {Miranda, Gofer, Scheme, Haskell}
Imp. Lang one of {Pascal, C, Python}
If I had to do it again (and had the choice!) I would evaluate the
sets again. I would not go from 2 to 1.

--
tl;dr:

The shortest route to mastery of programming in some chosen language,
say python, may be to learn a bunch of contrasting, competing
languages.  Which others and how much, needs care and experience to
decide.

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


Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program

2013-06-13 Thread rusi
On Jun 14, 12:28 am, buford.lum...@gmail.com wrote:
> Hi, I'm new to Python. Would someone be able to write me and/or to show me 
> how to write a simple program that:
>
> 1-follows a hyperlink from MS Excel to the internet (one of many links like 
> this,http://www.zipdatamaps.com/76180, for e.g.) and then,
>
> 2-copies some data (a population number, e.g. 54195) and then,
>
> 3-pastes that data back into the same MS Excel spreadsheet, into the adjacent 
> cell.
>
> ... and that’s it... row after row of hyperlinks all in one column...
>
1> will probably be best done inside excel. Simple export as Dave
suggests or something more programmer-ish like an excel macro to
export a specific column of links as a text-file

2> I am not clear about -- looked at the page and there were a number
of hits for 'population'
If the format is fixed -- same site different cities -- use beautiful
soup (in python) with urls from 1>

> Please, please help me my wrist is starting to hurt a lot. You would have my 
> greatest appreciation for your help!
>
> thank you, Buford

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


Re: Don't feed the troll... (was: Re: A few questiosn about encoding)

2013-06-14 Thread rusi
On Jun 14, 3:20 pm, Fábio Santos  wrote:
> > Come on now, this is _so_ obviously trolling, it's not even remotely
>
> funny anymore. Why doesn't killfiling work with the mailing list version of
> the python list? :-(
>
> I have skimmed the archives for this month, and I estimate that a third of
> this month's activity on this list was helping this person. About 80% of
> that is wasted in explaining basic concepts he refuses to read in links
> given to him. A depressingly large number of replies to his posts are
> seemingly ignored.
>
> Since this is a lot of spam, I feel like leaving the list, but I also
> honestly want to help people use python and the replies to questions of
> others often give me much insight on several matters.

Adding my +1 to this sentiment.

In older saner and more politically incorrect times, when there was a
student who was as idiotic as Nikos, he would be made to:
-- run five rounds of the field
-- stay after school
-- write pages of "I shall not talk in class"

In the age of cut-n-paste the last has lost its sting. Likewise the
first two are hard to administer across the internet.
Still if we are genuinely interested in solving this problem, ways may
be found, for example:

Any question from Nikos that has any English error, should be returned
with:
Correct your English before we look at your python.

If he is brazen enough to correct one error and leave the other 35,
then we put in a 24-hour delay for each reply.

I am sure others can come up with better solutions if we wish.

The alternative is that this disease has an unfavorable prognosis:
[Yes Nikos is an infectious disease: I believe I can pull out mails
from Steven and Grant Edwards whic hare begng tolook sspcicious ly
like Nikos [Sorry Im not much good at imitation!] ]

And that unfavorable prognosis is what Fabio is suggesting -- people
will start leaving the list/group.

Nikos:
This is not against you personally.  Just your current mode of conduct
towards this list.
And that mode quite simply is this: You have no interest in python,
you are only interested in the immediate questions of your web-hosting.
-- 
http://mail.python.org/mailman/listinfo/python-list



Re: Don't feed the help-vampire

2013-06-14 Thread rusi
On Jun 14, 4:51 pm, rusi  wrote:
> On Jun 14, 3:20 pm, Fábio Santos  wrote:
>
> > > Come on now, this is _so_ obviously trolling, it's not even remotely
>
> > funny anymore. Why doesn't killfiling work with the mailing list version of
> > the python list? :-(
>
> > I have skimmed the archives for this month, and I estimate that a third of
> > this month's activity on this list was helping this person. About 80% of
> > that is wasted in explaining basic concepts he refuses to read in links
> > given to him. A depressingly large number of replies to his posts are
> > seemingly ignored.
>
> > Since this is a lot of spam, I feel like leaving the list, but I also
> > honestly want to help people use python and the replies to questions of
> > others often give me much insight on several matters.
>
> Adding my +1 to this sentiment.

Since identifying a disease by the right name is key to finding a
cure:
Nikos is not trolling or spamming; he is help-vampiring.

Lets call it that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Debugging memory leaks

2013-06-14 Thread rusi
On Jun 13, 6:24 am, writeson  wrote:
> Anyway, my real question is how to go about debugging memory leak problems in 
> Python, particularly for a long running
> server process written with Twisted. I'm not sure how to use heapy or guppy, 
> and objgraph doesn't tell me enough to
> locate the problem. If anyone as any suggestions or pointers it would be very 
> much appreciated!

Can you explain in more detail what you get stuck with using heapy/
guppy?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Debugging memory leaks

2013-06-14 Thread rusi
On Jun 14, 1:15 am, Giorgos Tzampanakis
 wrote:
> Am I the only one who thinks this is terrible advice?

I would expect a typical desktop app to run for a couple of hours --
maybe a couple of days.
Living with a small (enough) leak there may be ok.
[In particular I believe that most commercial apps will leak a bit if
run long enough]

The case of something server-ish is quite different.
A server in principle runs forever.
And so if it leaks its not working.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread rusi
On Jun 14, 6:48 pm, Zero Piraeus  wrote:
> :
>
> On 14 June 2013 09:07, Nick the Gr33k  wrote:
>
>
>
> > Thanks for explaining this but i cannot follow its logic at all.
> > My mind is stuck trying to interpret it as an English sentence:
>
> > if ('Parker' and 'May' and '2001')
>
> > if ('Parker' or 'May' or '2001')
>
> > i just don't get it and i feel silly about it.
>
> You've been advised many times to experiment in the Python
> interpreter. I may be mistaken, but I don't recall seeing any evidence
> at all that you've ever done so.
>
> Try the following in a Python interpreter:
>
> >>> "vic" and "bob"
> >>> "bob" and "vic"
> >>> "vic" or "bob"
> >>> "bob" or "vic"
> >>> "vic" and ""
> >>> "" and "bob"
> >>> "bob" or ""
> >>> "" or "vic"
>
> Carefully study the results you get. This is simple, basic stuff;
> don't come back here asking for explanations of it. If you get stuck,
> *carefully* read this article:
>
>  http://en.wikipedia.org/wiki/Short-circuit_evaluation
>
> Repeat the steps above until you do understand. If all else fails,
> google "short circuit logic" or "short circuit evaluation python" or
> similar search terms, until you find a resource which you do follow.
>
>  -[]z.

You get my prize 'Zero' for best answer!

[You've also given me a nice example for my next python class -- I
usually spend time showing how to play in the interpreter.  And the
examples I usually give are numeric/string/list based. Short-circuit
evaluation is good to show. So thanks]

Incidentally, you have also proved right Nicolas' claim that this is
helpful to all :-)  All that is needed is that other charitable-to-
Nick souls on this list should exercise some restraint and provide the
answers that they *know* he *needs* rather than what he *claims* to
*want*.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wrong website loaded when other requested

2013-06-14 Thread rusi
On Jun 14, 8:37 pm, Nick the Gr33k  wrote:
>
> PLEASE SUGGEST SOMETHING!

A lollipop maybe?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Eval of expr with 'or' and 'and' within

2013-06-14 Thread rusi
On Jun 14, 9:09 pm, Steven D'Aprano  wrote:
> On Fri, 14 Jun 2013 11:14:16 +0100, Robert Kern wrote:
> > On 2013-06-14 10:50, Nick the Gr33k wrote:
> [snip question]
> >> This is all iw ant to know.
>
> > This is all you need to read:
>
> >    http://docs.python.org/2/reference/expressions.html#boolean-
>
> operations
>
> Thank you Robert for contributing a helpful response.
>
> To everyone else... I know that Nikos' posts are draining. Sometimes he
> brings me to the brink of despair too. But if you aren't part of the
> solution, you are part of the problem: writing short-tempered, insulting
> posts after short-tempered, insulting post doesn't teach him, it just
> adds to EVERYBODY'S frustration with this never-ending serious of threads.

Notice your spelling of series Steven?

>From which I suggest you seriously(!) consider my earlier suggestion
that Nikos is an infectious disease.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Eval of expr with 'or' and 'and' within

2013-06-14 Thread rusi
On Jun 14, 11:03 pm, Antoon Pardon 
wrote:
> Op 14-06-13 18:09, Steven D'Aprano schreef:
>
>
>
>
>
>
>
>
>
> > On Fri, 14 Jun 2013 11:14:16 +0100, Robert Kern wrote:
>
> >> On 2013-06-14 10:50, Nick the Gr33k wrote:
> > [snip question]
> >>> This is all iw ant to know.
>
> >> This is all you need to read:
>
> >>    http://docs.python.org/2/reference/expressions.html#boolean-
> > operations
>
> > Thank you Robert for contributing a helpful response.
>
> > To everyone else... I know that Nikos' posts are draining. Sometimes he
> > brings me to the brink of despair too. But if you aren't part of the
> > solution, you are part of the problem: writing short-tempered, insulting
> > posts after short-tempered, insulting post doesn't teach him, it just
> > adds to EVERYBODY'S frustration with this never-ending serious of threads.
>
> That depends on your view. Maybe there are people who view you as part
> of the problem because you keep giving Nikos hope other people will
> solve his problems without him having to do anything significant himself.
>
> > Please keep the snarky comments offlist. Contribute something helpful if
> > you like, mute the thread or killfile Nikos if you must, but adding to
> > the volume of unproductive junk doesn't do anyone any favour.
>
> In my opinion the only really helpful thing would be to ignore nikos. He
> has been given plenty or links, to read through in order to better his
> understanding and i think it is about time people made it clear they
> would no longer spoon feed him. Since that is probably not going to
> happen and you will probably continue contributing to the annoyance
> of other list members by continuing "helping" nikos, I don'y see why
> other can't continue to the annoyance in a away that they themselves may
> find somewhat amusing.
>
> --
> Antoon Pardon.

Thanks Antoon.
You are echoing the sentiments of probably hundreds of list
subscribers.

That said I would like to add a few points.
1. Beginning teachers (and young parents) are taught that one never
should say: "You are a bad boy!" but rather "THIS behavior wont do"
That nikos behavior is unacceptable has been reiterated by dozens of
members in 100s of posts.  That does not mean Nikos the person is
unacceptable.  We should always give him the room to change if/when he
chooses to.

2. The recent responses from Robert Kern are in my view the ideal. In
summary it runs thus:
Stupid question no. 6457 from Nikos: ...
Robert : Look this up 
Nikos: I dont understand
Robert:  explains
Nikos: I DONTU NDERSTND
Robert:  explains (repeated as often as needed)

When (if) finally Nikos actually reads the link and asks a more
specific/intelligent question,  can be replaced by more specific

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


Re: Debugging memory leaks

2013-06-14 Thread rusi
On Jun 15, 5:16 am, Ben Finney  wrote:
> rusi  writes:
> > On Jun 14, 1:15 am, Giorgos Tzampanakis
> >  wrote:
> > > Am I the only one who thinks this is terrible advice?
>
> > I would expect a typical desktop app to run for a couple of hours --
> > maybe a couple of days.
>
> Is a web browser a “typical desktop app”? A filesystem browser? An
> instant messenger? A file transfer application? A podcatcher? All of
> those typically run for months at a time on my desktop.
>
> Any memory leak in any of those is going to cause trouble, please hunt
> them all down with fire and exterminate with prejudice.

Oh well -- I guess I am an old geezer who shuts my machine when I am
done!
Yeah I know -- not so good for the disk though its good for the
planet!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pattern Search Regular Expression

2013-06-15 Thread rusi
On Jun 15, 3:55 pm, Mark Lawrence  wrote:
> On 15/06/2013 11:24, Denis McMahon wrote:
>
>
>
>
>
>
>
>
>
> > On Sat, 15 Jun 2013 10:05:01 +, Steven D'Aprano wrote:
>
> >> On Sat, 15 Jun 2013 02:42:55 -0700, subhabangalore wrote:
>
> >>> Dear Group,
>
> >>> I am trying to search the following pattern in Python.
>
> >>> I have following strings:
>
> >>>   (i)"In the ocean" (ii)"On the ocean" (iii) "By the ocean" (iv) "In
> >>>   this group" (v) "In this group" (vi) "By the new group"
> >>>         .
>
> >>> I want to extract from the first word to the last word, where first
> >>> word and last word are varying.
>
> >>> I am looking to extract out:
> >>>    (i) the (ii) the (iii) the (iv) this (v) this (vi) the new
> >>>        .
>
> >>> The problem may be handled by converting the string to list and then
> >>> index of list.
>
> >> No need for a regular expression.
>
> >> py> sentence = "By the new group"
> >> py> words = sentence.split()
> >> py> words[1:-1]
> >> ['the', 'new']
>
> >> Does that help?
>
> > I thought OP wanted:
>
> > words[words[0],words[-1]]
>
> > But that might be just my caffeine deprived misinterpretation of his
> > terminology.
>
>  >>> sentence = "By the new group"
>  >>> words = sentence.split()
>  >>> words[words[0],words[-1]]
> Traceback (most recent call last):
>    File "", line 1, in 
> TypeError: list indices must be integers, not tuple
>
> So why would the OP want a TypeError?  Or has caffeine deprivation
> affected your typing skills? :)

:-)

I guess Denis meant (words[0], words[-1])

To the OP:
You have the identity:
words == [words[0]] + words[1:-1] + [words[-1]]

So take your pick of what parts of the expression you want (and
discard what you dont want).
[The way you've used 'extract' is a bit ambiguous]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Debugging memory leaks

2013-06-15 Thread rusi
On Jun 15, 4:23 pm, Ben Finney  wrote:
> rusi  writes:
> > On Jun 15, 5:16 am, Ben Finney  wrote:
> > > Is a web browser a “typical desktop app”? A filesystem browser? An
> > > instant messenger? A file transfer application? A podcatcher? All of
> > > those typically run for months at a time on my desktop.
>
> > > Any memory leak in any of those is going to cause trouble, please
> > > hunt them all down with fire and exterminate with prejudice.
>
> > Oh well -- I guess I am an old geezer who shuts my machine when I am
> > done!
>
> As do I. And when I power on the machine, it resumes exactly where it
> left off: with the exact same contents of memory as when I pressed the
> Suspend button.
>
> That is, the memory leak will continue to accumulate as the run time of
> the process continues.
>
> > Yeah I know -- not so good for the disk though its good for the
> > planet!
>
> You can have both: a continuous session, and stop consuming power while
> not using your machine.

Suspend is low-power, hibernate is 0-power
http://www.unixmen.com/suspend-vs-hibernate-in-linux-what-is-the-difference/

And I keep having some issues with hibernate
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Don't feed the troll...

2013-06-15 Thread rusi
On Jun 15, 10:30 pm, Nick the Gr33k  wrote:
>
> You are spamming my thread.

With you as our spamming-guru, Onward! Sky is the limit!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: RFD: rename comp.lang.python to comp.support.superhost

2013-06-15 Thread rusi
On Jun 15, 10:29 pm, Nick the Gr33k  wrote:
> On 15/6/2013 8:11 μμ, Chris “Kwpolska” Warrick wrote:
>
>
>
>
>
>
>
>
>
> > On Fri, Jun 14, 2013 at 5:25 AM, alex23  wrote:
> >> On Jun 14, 2:24 am, Νικόλαος Κούρας  wrote:
> >>> iam researchign a solution to this as we speak.
>
> >> Spamming endless "ZOMG HELP ME I'M INCOMPETENT" posts isn't "research".
> >> --
> >>http://mail.python.org/mailman/listinfo/python-list
>
> > BTW: Do we have a Greek around that is not Nikos, who is willing to
> > report him to the Police for publishing personal data of his clients?
> >http://superhost.gr/?page=pelatologio.pyhas PHONE NUMBERS of people
> > according to Google Translate.  And that doesn’t seem to be legal.  I
> > have already thrown an e-mail address to the domain registrar.
>
> > --
> > Kwpolska  | GPG KEY: 5EAAEA16
> > stop html mail                | always bottom-post
> >http://asciiribbon.org       |http://caliburn.nl/topposting.html
>
> How much of a bastard can you be?

So bastard is an uncountable noun?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Don't feed the troll...

2013-06-15 Thread rusi
On Jun 15, 10:52 pm, Steven D'Aprano  wrote:
> On Sat, 15 Jun 2013 10:36:00 -0700, rusi wrote:
> > With you as our spamming-guru, Onward! Sky is the limit!
>
> If you're going to continue making unproductive, off-topic, inflammatory
> posts that prolong these already excessively large threads, Nikos won't
> be the only one kill-filed.

At least two people -- Alex and Antoon -- have told you that by
supporting Nikos, when everyone else wants him off list, you are part
of the problem.

Others -- Fabio -- have indicated their wish to leave the list due to
everything becoming Nikos-tainted.

Everyone is exasperated and talking of kill-filing him.

Let me remind you of your post: 
http://mail.python.org/pipermail/python-list/2013-June/649581.html

In this post you have imputed masturbation to first-time poster for a
quite valid question.
[I am assuming that google is correct in informing me that choking the
chicken means that].
This is way beyond being rude uncalled-for and generally unacceptable.

I suggest it is because of something else you said -- viz that Nikos
mails are draining you.

In short because you are unable to restrain your charitable behavior
towards Nikos -- note that this is charity at public (the group)
expense -- you are behaving abominably in other contexts, including
towards first time posters.

If you must help Nikos, please do it in private.
He is not wanted here.
[This is not specifically addressed to you Steven alone but to all who
are feeling charitable at public expense]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Version Control Software

2013-06-15 Thread rusi
On Jun 16, 4:14 am, Chris Angelico  wrote:
> On Sun, Jun 16, 2013 at 12:16 AM, Roy Smith  wrote:
> > The advantage of DVCS is that everybody has a full copy of the repo.
> > The disadvantage of the DVCS is that every MUST have a full copy of the
> > repo.  When a repo gets big, you may not want to pull all of that data
> > just to get the subtree you need.
>
> Yeah, and depending on size, that can be a major problem. While git
> _will_ let you make a shallow clone, it won't let you push from that,
> so it's good only for read-only repositories (we use git to manage
> software deployments at work - shallow clones are perfect) or for
> working with patch files.
>
> Hmm. ~/cpython/.hg is 200MB+, but ~/pike/.git is only 86MB. Does
> Mercurial compress its content? A tar.gz of each comes down, but only
> to ~170MB and ~75MB respectively, so I'm guessing the bulk of it is
> already compressed. But 200MB for cpython seems like a lot.

[I am assuming that you have run  "git gc --aggressive" before giving
those figures]

Your data would tell me that python is about twice as large a project
as pike in terms of number of commits. Isn't this a natural conclusion?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: on git gc --aggressive [was Re: Version Control Software]

2013-06-16 Thread rusi
On Jun 16, 7:09 pm, Jason Swails  wrote:
> On Sat, Jun 15, 2013 at 11:55 PM, rusi  wrote:
> > On Jun 16, 4:14 am, Chris Angelico  wrote:
> > > On Sun, Jun 16, 2013 at 12:16 AM, Roy Smith  wrote:
> > > > The advantage of DVCS is that everybody has a full copy of the repo.
> > > > The disadvantage of the DVCS is that every MUST have a full copy of the
> > > > repo.  When a repo gets big, you may not want to pull all of that data
> > > > just to get the subtree you need.
>
> > > Yeah, and depending on size, that can be a major problem. While git
> > > _will_ let you make a shallow clone, it won't let you push from that,
> > > so it's good only for read-only repositories (we use git to manage
> > > software deployments at work - shallow clones are perfect) or for
> > > working with patch files.
>
> > > Hmm. ~/cpython/.hg is 200MB+, but ~/pike/.git is only 86MB. Does
> > > Mercurial compress its content? A tar.gz of each comes down, but only
> > > to ~170MB and ~75MB respectively, so I'm guessing the bulk of it is
> > > already compressed. But 200MB for cpython seems like a lot.
>
> > [I am assuming that you have run  "git gc --aggressive" before giving
> > those figures]
>
> Off-topic, but this is a bad idea in most cases.  This is a post including
> an email from Torvalds proclaiming how and why git gc --aggressive is dumb
> in 99% of cases and should rarely be used:
>
> http://metalinguist.wordpress.com/2007/12/06/the-woes-of-git-gc-aggre...

Yeah... Thanks for that link.
I knew there's something about gc and something about pack. Too much
of a git noob to know which is which!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Don't feed the troll...

2013-06-16 Thread rusi
On Jun 16, 12:54 am, ru...@yahoo.com wrote:
>
> ... killfile him and shut the fuck up.

Ok. Advice taken. Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python API

2013-06-16 Thread rusi
On Jun 17, 11:38 am, Ganesh Pandi  wrote:
> Hi
>         What are all the python api, u used in your python programming, we 
> used more api but may we forgot those, so i just want to list down the api we 
> familiar aboutplease add your replies...

Maybe you are referring to this??
http://docs.python.org/2/extending/

If not, please explain more clearly what you mean by API
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: weird behavior. bug perhaps?

2013-06-18 Thread rusi
On Jun 18, 7:23 pm, zoom  wrote:
> Hi, I have a strange problem here. Perhaps someone would care to help me.
>
> In the file test.py I have the following code:
>
> from scipy import matrix, tile, mean, shape
> import unittest
>
> class TestSequenceFunctions(unittest.TestCase):
>
>      def setUp(self):
>          self.m = [[1,2],[3,4],[3,4],[3,4]]
>
>      def test_simplify(self):
>          m = matrix(self.m)
>          print shape(m)
>          print [shape(m)[1],1]
>          print shape(tile(mean(m,1),[shape(m)[1],1]).T)
>
> if __name__ == '__main__':
>      unittest.main()
>
> (Note that test.py, is just a simplification of my testing file,
> sufficient to reproduce the weird behavior that I'm  about to describe.)
>
> If i run it in terminal via "python test.py" command I get the following
> output:
>
> (4, 2)
> [2, 1]
> (1, 8)
> .
> --
> Ran 1 test in 0.000s
>
> OK
>
> Now comes the funny part.
> Let's try to run the following code in python interpreter:
>
>  >>> m = [[1,2],[3,4],[3,4],[3,4]]
>  >>>
>  >>> from scipy import matrix, tile, mean, shape
>  >>> print shape(m)
> (4, 2)
>  >>> print [shape(m)[1],1]
> [2, 1]
>  >>> print shape(tile(mean(m,1),[shape(m)[1],1]).T)
> (4, 2)
>
> Note the difference between outputs of:
> print shape(tile(mean(m,1),[shape(m)[1],1]).T)
>
> I mean, WTF?
> This is definitely not the expected behavior.
> Anybody knows what just happened here?

[Never used scipy so pls excuse if I am off...]

Given list m, in the class you are doing m -> matrix(m)
which you dont seem to be doing in the interpreter.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: weird behavior. bug perhaps?

2013-06-19 Thread rusi
On Jun 18, 8:31 pm, zoom  wrote:
>
> yes, that's the hing.
>
> thanks a lot
>
> FYI this happens because
>  >>> shape(mean(m,1))
> (4, 1)
>  >>> shape(mean(array(m),1))
> (4,)
>
> thanks again

And thank you for the 'Thank you'  !!
Given the noob-questions the list is currently dealing with, your
question was a relief and a pleasure.
You have (unwittingly maybe??) followed http://sscce.org/ Thats great.
Also the 'Thanks' at end helps not just to tickle the ego of the
responder but also to confirm the answer which is often not sure.

The only small suggestion I would make is next time please spend a
minute on choosing a pointed subject line.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing Extensions for Python 3 in C

2013-06-19 Thread rusi
On Jun 18, 3:24 pm, Aditya Avinash  wrote:
> Hi. This is the last place where I want to ask a question. I have searched
> for lots of tutorials and documentation on the web but, didn't find a
> decent one to develop extensions for Python 3 using a custom compiler
> (mingw32, nvcc). Please help me.
> PS: Don't point me to Python Documentation. It is not good for beginners.
> It doesn't elaborate about calls and implementation.

You need to tell what youve read, what youve tried, where stuck.
Yes the extending and embedding stuff http://docs.python.org/2/extending/
and
http://docs.python.org/2/c-api/index.html is more difficult than much
other than other python docs.

That is intrinsic to the problem -- you are not in the python world
but the C world and C is a much harder and headachey-er than python.
And building the python infrastructure on top of that is still harder.

If you have to use it, you really need to get the data-structure
invariants right: eg 
http://docs.python.org/2/c-api/intro.html#objects-types-and-reference-counts.

However as Terry suggests, using something like Cython to avoid this
should always be first explored.  Heres a list

1. 'Classic' extending/embedding
2. SCXX
3. PyCXX
4. Boost
5. Ctypes
6. Swig
7. Sip
8. cython

Explore in reverse order!
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   7   8   9   10   >