is pathlib Path.resolve working as intended?

2014-12-23 Thread Chris Cioffi
Ok, I'm guessing I'm doing something wrong, but I can't see what.

I'm playing around with pathlib (Python 3.4.2) on Mac OSX, Yosemite.

In the past I've used os.path.expanduser() to expand paths with ~.  Based on 
the description, I would have expected .resolve to do that automatically, but 
it doesn't seem to work.

Is this a bug, oversight or design choice?

Here's my example of what I was doing:

>>> p = Path('~/.profile')
>>> p
PosixPath('~/.profile')
>>> p.resolve

>>> 
>>> p.resolve()
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/pathlib.py",
 line 1031, in resolve
s = self._flavour.resolve(self)
  File 
"/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/pathlib.py",
 line 297, in resolve
return _resolve(base, str(path)) or sep
  File 
"/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/pathlib.py",
 line 282, in _resolve
target = accessor.readlink(newpath)
  File 
"/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/pathlib.py",
 line 374, in readlink
return os.readlink(path)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/chris/~'
>>> 


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


Re: OFF TOPIC Snow Crash [was Re: Hello World]

2014-12-23 Thread Steven D'Aprano
Grant Edwards wrote:

> On 2014-12-23, Steven D'Aprano 
> wrote:
>> Chris Angelico wrote:
>>
>>> On Tue, Dec 23, 2014 at 12:15 AM, Roy Smith  wrote:
 If I really didn't trust something, I'd go to AWS and spin up one of
 their free-tier micro instances and run it there :-)
>>> 
>>> How do you know it won't create console output that stroboscopically
>>> infects you with a virus through your eyes? Because that's *totally*
>>> what would be done in the town of Eureka.
>>
>> Anybody in IT who hasn't read Neal Stephenson's "Snow Crash" needs to
>> hand in their Geek Card immediately.
> 
> I tried, but I got so tired of the author doing stuff like pointing
> out that there were 65536 of something or other (and that it's a power
> of TWO, kids!) that I gave up.  The annoying thing was that there was
> no real technical reason why the quantity _needed_ to be a power of
> two.


Neal Stephenson's technical chops, and his limits, are well established. He
is a writer first and foremost and it is quite obvious that he's often
showing off his technical knowledge even when it's not strictly relevant.

Remember to that Snow Crash became a cult classic among hackers, but it was
written for a science fiction and cyberpunk audience. To them, 2^16 is a
strange and exotic concept: 1, or 5, or 10 would be a round
number, not 65536.


> And even _with_ all the technical jibber-jabber, none of it explained
> or justified the whole "writing a virus to infect the brain through
> the optic nerve" thing which might just have well been magick and
> witches.  

Any sufficiently advanced technology.

I disagree. I think he did a good job of making such a thing seem plausible
without getting bogged down with inventing a detailed mechanism which could
only ever be wrong.

But then I was easily convinced, because I already knew of various related
facts and concepts which probably primed me to accept the concept of the
Snow Crash virus:

- Zombie ant fungus and various other parasites which manipulate the 
  brains of organisms, including human beings (Toxoplasmosis, syphillis
  and others).

- The optic nerve is technically not a nerve, but part of the brain, 
  and there are deep and subtle connections between it and the rest 
  of the brain, e.g. blind-sight.

- The theory of memes, or perhaps I should say the meme of memes, 
  since memetics has never been quite vigorous enough to count 
  as an actual theory.

- Super-stimuli.

- The human brain considered as an information processor.

- Julian Jaynes' book "The Origin Of Consciousness In The Breakdown
  Of The Bicameral Mind", a hypothesis so wonderful that it needs to
  be true (alas, it's probably rubbish).


Personally, I don't believe that in this day and age of Java programming,
anyone could be programmed by looking at a black and white animated bitmap,
but back in the 1990s it was probably a bit more plausible that hackers
would spend their time learning to read machine code. But there's always
the chance that somebody will find a way a stimulus that crashes the human
brain and lets them run the arbitrary code of their choice...



-- 
Steven

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


Re: very weird pandas behavior

2014-12-23 Thread Steven D'Aprano
Rick Johnson wrote:

> On Tuesday, December 23, 2014 3:35:20 AM UTC-6, wxjm...@gmail.com wrote:
>>
>> [...]
>>
>> Wait for ther 3.5 release. I will still show
>> you how to make Idle, tkinter, Python crashing
>> in 10 seconds.
>> 
>> Discussing with (some) core devs is simply impossible,
>> they do not whish to discuss!
>> 
>> All this can be explained with a sheet of paper,
>> a pencil and some basic mathematical knowledge.
>> 
>> jmf
> 
> Hello "Jmf". I'm confused by your interjection. Are you the OP? Or are you
> speaking on behalf of the OP? Or did you forget to switch accounts -- gawd
> that can be so embarrassing! (Urm, not that i have any experience in the
> area).


JMF is our resident Unicode crackpot, he is obsessed with the idea that a
minor performance regression on some artificial and simplistic string
operations which nobody would ever actually use in real life is categorical
proof that Python's Unicode implementation is fundamentally and
mathematically broken.

I don't think he is trolling, I think he really is obsessed with this idea,
like the circle-squarers, pi-is-a-rational-number cranks, "Queen Elizabeth
and the Pope are space-aliens" nutters, Einstein-was-wrong maniacs and all
the rest.



-- 
Steven

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


Re: Sending plain text messages (was: what is wrong with d.clear()?)

2014-12-23 Thread Steven D'Aprano
alister wrote:

> for the same reason a pet hate of mine is a memo sent as an attached
> document when it could simply have been the body of the text.

And then the attached document (a Word doc, naturally) simply says "Please
see ", which opens to a page which links to a PDF file which
contains a one sentence message.


-- 
Steven

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


Re: OFF TOPIC Snow Crash [was Re: Hello World]

2014-12-23 Thread Steven D'Aprano
Rustom Mody wrote:

> On Tuesday, December 23, 2014 9:50:22 PM UTC+5:30, Grant Edwards wrote:
>> 
>> And even _with_ all the technical jibber-jabber, none of it explained
>> or justified the whole "writing a virus to infect the brain through
>> the optic nerve" thing which might just have well been magick and
>> witches.
> 
> You find that far-fetched?
> I would have thought it commoner than common-cold -- basis for the
> trillion dollar industry called advertising


[controversial and perhaps annoying]

To say nothing of religion, both the supernatural/mystical kind and the "my
editor/programming language/brand of car/gaming console/etc is better than
yours" kind... 



-- 
Steven

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


Re: object has no attribute 'ecrire'

2014-12-23 Thread Chris Angelico
On Wed, Dec 24, 2014 at 11:42 AM,   wrote:
> I wrote this code (it was on a book)
>
> class TableauNoir:
> def __init__(self):
> self.surface=""
> def ecrire(self, message_a_ecrire):
> if self.surface != "":
> self.surface += "\n"
> self.surface+=message_a_ecrire
> it does not run on the shell and tells (object TableauNoir has no attribute 
> 'ecrire'

My crystal ball tells me that there's a lot more code going on here
than you've shared with us, and suggests that maybe you had a few
tries at this. If you instantiate an object from a "class TableauNoir"
and then redefine that class, the object is still of the old class,
even though the classes have the same name. You'd need to construct a
new object of the new class.

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


Re: object has no attribute 'ecrire'

2014-12-23 Thread MRAB

On 2014-12-24 00:42, fulga...@gmail.com wrote:

Hello,
I wrote this code (it was on a book)

class TableauNoir:
def __init__(self):
self.surface=""
def ecrire(self, message_a_ecrire):
if self.surface != "":
self.surface += "\n"
self.surface+=message_a_ecrire
it does not run on the shell and tells (object TableauNoir has no attribute 
'ecrire'
could you tell me why it does not work. in the book ecrire should be a method 
from the class not an attribute
thanks


It works for me:

Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:16:31) [MSC v.1600 64 
bit (AM

D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> class TableauNoir:
... def __init__(self):
... self.surface=""
... def ecrire(self, message_a_ecrire):
... if self.surface != "":
... self.surface += "\n"
... self.surface+=message_a_ecrire
...
>>> TableauNoir().ecrire("foo")
>>>
--
https://mail.python.org/mailman/listinfo/python-list


object has no attribute 'ecrire'

2014-12-23 Thread fulgar36
Hello,
I wrote this code (it was on a book)

class TableauNoir:
def __init__(self):
self.surface=""
def ecrire(self, message_a_ecrire):
if self.surface != "": 
self.surface += "\n"
self.surface+=message_a_ecrire
it does not run on the shell and tells (object TableauNoir has no attribute 
'ecrire'
could you tell me why it does not work. in the book ecrire should be a method 
from the class not an attribute
thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: learning to use iterators

2014-12-23 Thread Terry Reedy

On 12/23/2014 4:25 PM, Ben Finney wrote:

Ian Kelly  writes:


On Tue, Dec 23, 2014 at 11:55 AM, Seb  wrote:

Particulary, what do the parentheses do there?


The parentheses enclose a generator expression, which is similar to a
list comprehension [1] but produce a generator, which is a type of
iterator, rather than a list.


To be clear: there's nothing about parentheses that produce a generator
expression.


Incorrect; parentheses *are* as a part of 'generator expression'.  From 
the doc:

generator_expression ::=  "(" expression comp_for ")"


The generator expression is produced by the syntax used, such as
‘frob(spam) for spam in collection_of_spam if spam > 0’.


This is (intentionally) not a generator expression.

a = i for i in range(39)

is a syntax error, whereas

t = a, 3, '3'

binds 't' to the tuple a, 3, '3'.

The parentheses that are part of a generator expression may only be 
omitted in a call with one argument.  See my other response.


--
Terry Jan Reedy


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


Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?

2014-12-23 Thread Rick Johnson
On Tuesday, August 26, 2014 7:01:22 PM UTC-5, Steven D'Aprano wrote:
> I think it is a serious design flaw that the standard
> library and user code co-exist in a single namespace.


I'm not sure if your wording is just clumsily and you meant: 

  """
  I think it is a serious design flaw that the standard
  library modules and user defined modules co-exist like
  filthy, naked, flip-flop over white sock wearing hippies
  in same import namespace(sys.modules).
  """
  
If so than i agree whole heartily. However, in the past when
i mentioned that all std-lib modules should have been
hidden behind a homogeneous symbol you were quick to play
Devil's Advocate against me.

Well it was you or the "Angelic One", heck, i can't tell you
two apart most times. It seems as though your both
weakref'ing the same "over-cooked noodle", and that Chris's
stdin is prematurely attached to your stdout! Seriously, you
two need to get a room.


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


Re: what is wrong with d.clear()?

2014-12-23 Thread Chris Angelico
On Wed, Dec 24, 2014 at 9:38 AM, alister
 wrote:
> On Wed, 24 Dec 2014 09:31:12 +1100, Chris Angelico wrote:
>
>> On Wed, Dec 24, 2014 at 8:08 AM, alister
>>  wrote:
>>> Sometime I have to switch to HTML @ work but even then only when I want
>>> to send someone a screen shot
>>
>> Attachments don't work?
>>
>> ChrisA
>
> not with some of the people I have to work with :-(

It's not the *attachment* that isn't working, then...

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


Re: what is wrong with d.clear()?

2014-12-23 Thread alister
On Wed, 24 Dec 2014 09:31:12 +1100, Chris Angelico wrote:

> On Wed, Dec 24, 2014 at 8:08 AM, alister
>  wrote:
>> Sometime I have to switch to HTML @ work but even then only when I want
>> to send someone a screen shot
> 
> Attachments don't work?
> 
> ChrisA

not with some of the people I have to work with :-(



-- 
"Linux poses a real challenge for those with a taste for late-night
hacking (and/or conversations with God)."
(By Matt Welsh)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: very weird pandas behavior

2014-12-23 Thread Rick Johnson
On Tuesday, December 23, 2014 3:35:20 AM UTC-6, wxjm...@gmail.com wrote:
>
> [...]
>
> Wait for ther 3.5 release. I will still show
> you how to make Idle, tkinter, Python crashing
> in 10 seconds.
> 
> Discussing with (some) core devs is simply impossible,
> they do not whish to discuss!
> 
> All this can be explained with a sheet of paper,
> a pencil and some basic mathematical knowledge.
> 
> jmf

Hello "Jmf". I'm confused by your interjection. Are you the OP? Or are you 
speaking on behalf of the OP? Or did you forget to switch accounts -- gawd that 
can be so embarrassing! (Urm, not that i have any experience in the area).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: what is wrong with d.clear()?

2014-12-23 Thread Chris Angelico
On Wed, Dec 24, 2014 at 8:08 AM, alister
 wrote:
> Sometime I have to switch to HTML @ work but even then only when I want
> to send someone a screen shot

Attachments don't work?

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


Re: Sending plain text messages (was: what is wrong with d.clear()?)

2014-12-23 Thread alister
On Wed, 24 Dec 2014 08:31:44 +1100, Ben Finney wrote:

> alister  writes:
> 
>> Sometime I have to switch to HTML @ work but even then only when I want
>> to send someone a screen shot
> 
> I've been able to attach images to plain text messages without any
> trouble. Why would HTML be needed? MIME attachments work just fine.

Indeed although sometimes it is better to have the image "in Line" rather 
than forcing the recipient to open it in another application.

for the same reason a pet hate of mine is a memo sent as an attached 
document when it could simply have been the body of the text.

I try to use the right format & the right time (& I do not claim to be 
perfect at this) & limit my HTML emails to when they will benefit the 
intended recipient ( A knowledge of the intended recipient helps in 
making this choice).

a news group is not the place for HTML


-- 
A private sin is not so prejudicial in the world as a public indecency.
-- Miguel de Cervantes
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why my ; continuator idea is better for debugging too.

2014-12-23 Thread Skybuck Flying

A:=B:=C:=D:=0;

With the continuator idea this coding would look as follows:

Good single line code:

A:=B:=C:=D:=0

Bad multi line code:

A:=
B:=
C:=
D:=
0

^This would not be allowed and lead to error messages.

Good multi line code:

A:=;
B:=;
C:=;
D:=;
0

^ This would lead to a good compile.

Bye,
 Skybuck :)


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


Sending plain text messages (was: what is wrong with d.clear()?)

2014-12-23 Thread Ben Finney
alister  writes:

> Sometime I have to switch to HTML @ work but even then only when I want 
> to send someone a screen shot

I've been able to attach images to plain text messages without any
trouble. Why would HTML be needed? MIME attachments work just fine.

-- 
 \   “In the long run nothing can withstand reason and experience, |
  `\and the contradiction which religion offers to both is all too |
_o__)palpable.” —Sigmund Freud |
Ben Finney

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


Re: learning to use iterators

2014-12-23 Thread Ben Finney
Ian Kelly  writes:

> On Tue, Dec 23, 2014 at 11:55 AM, Seb  wrote:
> > Particulary, what do the parentheses do there?
>
> The parentheses enclose a generator expression, which is similar to a
> list comprehension [1] but produce a generator, which is a type of
> iterator, rather than a list.

To be clear: there's nothing about parentheses that produce a generator
expression. Rather, parentheses are just performing their typical role
of enclosing an expression.

The generator expression is produced by the syntax used, such as
‘frob(spam) for spam in collection_of_spam if spam > 0’. The surrounding
parentheses don't affect that; they are not part of the generator
syntax. They *do* enclose it so the Python parser knows it is an
expression distinct from what surrounds it.

For this reason, if you already have some syntax where it will be clear
what is a distinct expression, additional parentheses are not needed. In
other words, parentheses are only needed to *separate* a generator
expression from its surrounds.

# Syntax would be ambiguous without parentheses.
foo = (frob(spam) for spam in collection_of_spams if spam > 0)

# Syntax already dictates the parameter is an expression;
# no additional parens needed.
twiddle(frob(spam) for spam in collection_of_spams if spam > 0)

Parens are used in a lot of places, but they are commonly not *part of*
the expression; rather, they enclose the expression to be unambiguous.

-- 
 \  “Any sufficiently advanced bug is indistinguishable from a |
  `\  feature.” —Rich Kulawiec |
_o__)  |
Ben Finney

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


Re: what is wrong with d.clear()?

2014-12-23 Thread alister
On Tue, 23 Dec 2014 15:15:03 -0500, Dave Angel wrote:

> On 12/23/2014 07:59 AM, shawool wrote:
>> Thank you for answering my query.
>>
>> Fonts and colors are reset to defaults now. Sorry for the inconvenience
>> caused.
>>
>> Regards,
>> Shawool
> 
> The following is a piece of your message:
> 
> Thank you for answering my
> query. div>Fonts and colors are reset to defaults now. Sorry for the
> inconvenience=
>   caused.Regards,Shawool class=3D"gmai=
> l_extra">On Tue, Dec 23, 2014 at 3:55 PM,
> St=
> eve Hayes  ta=
> rget=3D"_blank">hayes...@telkomsa.net>
> wrote: class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc
> solid=
> ;padding-left:1ex">On Tue, 23 Dec 2014 13:33:53 +1100,
> Ste=
> ven D'Aprano
> 
> Still looks like html to me.  Sooner or later you'll mess somebody up
> doing that.  My current email program can ignore that part, and for a
> simple message I have no problem, but many of us have had trouble
> before, and will again.
> 
> As Steven says, it's probably hopeless, but if I can just convince a few
> more people -- tell your email program to just use text.  Help stamp
> out html mail, except when it actually helps.  And not on a text forum,
> where some gateways don't even handle the html correctly.

+1 
Sometime I have to switch to HTML @ work but even then only when I want 
to send someone a screen shot
HTML mail when not required breaks the 1st rule of all engineering 
(including software engineering) KISS - Keep It Simple Stupid.
 



-- 
Who are you?
-- 
https://mail.python.org/mailman/listinfo/python-list


Sending plain text messages (was: what is wrong with d.clear()?)

2014-12-23 Thread Ben Finney
shawool  writes:

> Fonts and colors are reset to defaults now. Sorry for the inconvenience
> caused.

Thank you for working to resolve this.

The problem isn't the stting of your fonts or colours; those should be
irrelevant to us and should affect only you (if you send plain text).

Rather, you should compose the message as plain text (and ideally
without any HTML-formatted message at all).

Instead, configure your mail composition program – whatever that is,
online or on your computer – to compose messages in “plain text” format.
http://email.about.com/od/netiquettetips/qt/When-In-Doubt-Send-Plain-Text-Email-Not-Fancy-Html.htm>

-- 
 \  “I tell you the truth: this generation will certainly not pass |
  `\   away until all these things [the end of the world] have |
_o__)  happened.” —Jesus, c. 30 CE, as quoted in Matthew 24:34 |
Ben Finney

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


Re: learning to use iterators

2014-12-23 Thread Terry Reedy

On 12/23/2014 1:55 PM, Seb wrote:


def n_grams(a, n):

... z = (islice(a, i, None) for i in range(n))
... return zip(*z)



I'm impressed at how succinctly this islice helps to build a list of
tuples with indices for all the required windows.  However, I'm not
quite following what goes on in the first line of the function.
Particulary, what do the parentheses do there?


The parenthesized expression is a generator expression.  The ()s are 
part of the syntax and may only be omitted when the expression is the 
argument of a function call, as in


>>> list((i for i in range(0, 7, 2)))
[0, 2, 4, 6]
>>> list(i for i in range(0, 7, 2))
[0, 2, 4, 6]

--
Terry Jan Reedy

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


Re: what is wrong with d.clear()?

2014-12-23 Thread Dave Angel

On 12/23/2014 07:59 AM, shawool wrote:

Thank you for answering my query.

Fonts and colors are reset to defaults now. Sorry for the inconvenience
caused.

Regards,
Shawool


The following is a piece of your message:

Thank you for answering my query.Fonts and colors are reset to defaults now. Sorry for the inconvenience=
 caused.Regards,Shawoolclass=3D"gmai=

l_extra">On Tue, Dec 23, 2014 at 3:55 PM, St=
eve Hayes hayes...@telkomsa.net> wrote:On Tue, 23 Dec 2014 13:33:53 +1100, Ste=
ven D'Aprano

Still looks like html to me.  Sooner or later you'll mess somebody up 
doing that.  My current email program can ignore that part, and for a 
simple message I have no problem, but many of us have had trouble 
before, and will again.


As Steven says, it's probably hopeless, but if I can just convince a few 
more people -- tell your email program to just use text.  Help stamp 
out html mail, except when it actually helps.  And not on a text forum, 
where some gateways don't even handle the html correctly.



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


Re: Old newbie needs help.

2014-12-23 Thread Ian Kelly
On Sat, Dec 20, 2014 at 9:34 AM, John Culleton 
wrote:
>
> This week I wrote my first Python program, a script callable from
Scribus, a DTP program. It ran! Now I want to spread my wings a little. How
do I call a C language executable subprogram from Python and pass
information back and forth?

When you say "subprogram", do you mean that you want to start and
communicate with a whole new process, or do you merely want to invoke some
dynamically loaded entry point within the same process? For the former, use
the subprocess module. For the latter, use the ctypes module (or consider
using Cython instead of pure Python if Scribus will support it).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: learning to use iterators

2014-12-23 Thread Seb
On Tue, 23 Dec 2014 12:23:45 -0700,
Ian Kelly  wrote:

> The parentheses enclose a generator expression, which is similar to a
> list comprehension [1] but produce a generator, which is a type of
> iterator, rather than a list.

> In much the same way that a list comprehension can be expanded out to
> a for loop building a list, another way to specify a generator is by
> defining a function using the yield keyword. For example, this
> generator function is equivalent to the generator expression above:

[...]

Thank you, this exactly what I was missing.

Happy holidays,

-- 
Seb

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


Re: [Distutils] Release: pip 6.0 and virtualenv 12.0

2014-12-23 Thread Terry Reedy

On 12/23/2014 12:27 PM, Mark Lawrence wrote:

I chanced upon this
https://mail.python.org/pipermail/distutils-sig/2014-December/025450.html via
twitter and thought it would be of interest here.

I'll assume that by the time I hit 'Send' it'll have arrived on the
announcements mailing list :)


Donald Stufft also patched CPython so that future installers that 
install pip (Windows, OSX) will install pip 6+.


--
Terry Jan Reedy

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


Re: learning to use iterators

2014-12-23 Thread Ian Kelly
On Tue, Dec 23, 2014 at 11:55 AM, Seb  wrote:
>
> Hi,
>
> I'm fairly new to Python, and while trying to implement a custom sliding
> window operation for a pandas Series, I came across a great piece of
> code¹:
>
> >>> def n_grams(a, n):
> ... z = (islice(a, i, None) for i in range(n))
> ... return zip(*z)
> ...
>
> I'm impressed at how succinctly this islice helps to build a list of
> tuples with indices for all the required windows.  However, I'm not
> quite following what goes on in the first line of the function.
> Particulary, what do the parentheses do there?

The parentheses enclose a generator expression, which is similar to a list
comprehension [1] but produce a generator, which is a type of iterator,
rather than a list.

In much the same way that a list comprehension can be expanded out to a for
loop building a list, another way to specify a generator is by defining a
function using the yield keyword. For example, this generator function is
equivalent to the generator expression above:

def n_gram_generator(a, n):
for i in range(n):
yield islice(a, i, None)

[1]
https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions
-- 
https://mail.python.org/mailman/listinfo/python-list


Configuring code editors (was Re: IDLE ...)

2014-12-23 Thread Terry Reedy

On 12/23/2014 10:24 AM, pypythotho wrote:

In Command Prompt, 'python -m idlelib' helped me to dicover the
problem source. An explicit message told that an indentation was
insconsistant in the file ntpath.py I modified previously with
notepad++. I replaced a tab by 4 spaces and IDLE run again like a
charm.


[It was python, not Idle, that had a problem with the tab.]

The stdlib .py files (should all) use the PEP8 standard 4 space indents. 
 Idle comes configured to convert tabs to 4 spaces.


Notepad++ does not.  Settings -> Language Menu/Tab Settings lets one set 
a default tab handling setting and langauge-specific tab settings. 
Python should be configured for tabsize 4 and [X] replace tab with 
space.  Unless, of course, one uses tabs.  But then one should either 
not edit stdlib files or make sure to switch every time one edits one. 
I have had settings disappear after upgrading (ugh).


Similar comments apply to other code editors.

--
Terry Jan Reedy

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


learning to use iterators

2014-12-23 Thread Seb
Hi,

I'm fairly new to Python, and while trying to implement a custom sliding
window operation for a pandas Series, I came across a great piece of
code¹:

>>> def n_grams(a, n):
... z = (islice(a, i, None) for i in range(n))
... return zip(*z)
...

I'm impressed at how succinctly this islice helps to build a list of
tuples with indices for all the required windows.  However, I'm not
quite following what goes on in the first line of the function.
Particulary, what do the parentheses do there?

Thanks,


+--- Footnotes ---+
¹ 
http://sahandsaba.com/thirty-python-language-features-and-tricks-you-may-not-know.html#sliding-windows-n-grams-using-zip-and-iterators

-- 
Seb

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


[OT]ORM Is an Offensive Anti-Pattern

2014-12-23 Thread Mark Lawrence

http://java.dzone.com/articles/orm-offensive-anti-pattern

Please don't shoot the messenger.  More importantly please don't make 
him write Java :)


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


[Distutils] Release: pip 6.0 and virtualenv 12.0

2014-12-23 Thread Mark Lawrence
I chanced upon this 
https://mail.python.org/pipermail/distutils-sig/2014-December/025450.html via 
twitter and thought it would be of interest here.


I'll assume that by the time I hit 'Send' it'll have arrived on the 
announcements mailing list :)


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: OFF TOPIC Snow Crash [was Re: Hello World]

2014-12-23 Thread Rustom Mody
On Tuesday, December 23, 2014 9:50:22 PM UTC+5:30, Grant Edwards wrote:
> 
> And even _with_ all the technical jibber-jabber, none of it explained
> or justified the whole "writing a virus to infect the brain through
> the optic nerve" thing which might just have well been magick and
> witches.

You find that far-fetched?
I would have thought it commoner than common-cold -- basis for the trillion 
dollar
industry called advertising
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OFF TOPIC Snow Crash [was Re: Hello World]

2014-12-23 Thread Grant Edwards
On 2014-12-23, Steven D'Aprano  wrote:
> Chris Angelico wrote:
>
>> On Tue, Dec 23, 2014 at 12:15 AM, Roy Smith  wrote:
>>> If I really didn't trust something, I'd go to AWS and spin up one of
>>> their free-tier micro instances and run it there :-)
>> 
>> How do you know it won't create console output that stroboscopically
>> infects you with a virus through your eyes? Because that's *totally*
>> what would be done in the town of Eureka.
>
> Anybody in IT who hasn't read Neal Stephenson's "Snow Crash" needs to hand
> in their Geek Card immediately.

I tried, but I got so tired of the author doing stuff like pointing
out that there were 65536 of something or other (and that it's a power
of TWO, kids!) that I gave up.  The annoying thing was that there was
no real technical reason why the quantity _needed_ to be a power of
two.  Too many of the technical details that you got constantly beat
over the head with were 

  1) not even remotely relevent to the story

  2) mostly an effort by the author to demonstrate that he had a
 junior-high level understanding of a 68K based Macintosh and knew
 lots of cool grown up tech-sounding words -- and even if had only
 a vague idea of what they meant, he could still impress the other
 13-year olds.

  3) just plain wrong

And even _with_ all the technical jibber-jabber, none of it explained
or justified the whole "writing a virus to infect the brain through
the optic nerve" thing which might just have well been magick and
witches.
  
-- 
Grant

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


Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?

2014-12-23 Thread pypythotho
'python -m idlelib' gave me information about a file, ntpath.py, that I've 
edited before with notepad++. This file has been rewritten with a tab instead 
of 4 paces. The command suggested by Terry displayed an explicit message about 
wrong indentation. This error fixed, IDLE run again like a charm.


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


Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what?

2014-12-23 Thread pypythotho
In Command Prompt, 'python -m idlelib' helped me to dicover the problem source. 
An explicit message told that an indentation was insconsistant in the file 
ntpath.py I modified previously with notepad++. I replaced a tab by 4 spaces 
and IDLE run again like a charm.


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


Re: Why my ; continuator idea is better for debugging too.

2014-12-23 Thread Maynard A. Philbrook Jr.
In article <85795$54978fe1$5419aafe$2...@news.ziggo.nl>, skybuck2000
@hotmail.com says...
> 
> Hello,
> 
> In the past I wrote about pascal's ; mistake.
> 
> ; should be used as a continuator.
> 
> I just made a programming mistake which solidifies/merits my idea:
> 
> The programming mistake was this:
> 
> vBattlefieldLosingWarrior :=
> 
> // modified warrior and brain
> vSimulatorWinningWarrior := vBattlefieldBattle.Warrior[0];
> 
> Code should look like this:
> 
> vBattlefieldLosingWarrior := 
> TBattlefieldWarrior(vBattlefieldBattle.Warrior[2].Association);
> 
> // modified warrior and brain
> vSimulatorWinningWarrior := vBattlefieldBattle.Warrior[0];
> 
> Fortunately there was a type mistmatch which hinted me at the programming 
> mistake.
> 
> The code is a bit messy above so let's make a simpler example to understand, 
> the in my oppinion, dangerous programming mistake:
> 
> A :=
> 
> B := C;
> 
> The above statements "A :=" is valid in Delphi's current design.
> 
> The danger is that B is assigned to A which is not what I wanted, the 
> problem was missing code at A.
> 
> So the danger is that some day, somebody will write B in such a way that it 
> will accidently be assigned to A.
> 
> By using ";" as a continuator instead of a "seperator" the code would look 
> as follows:
> 
> A :=
> 
> B := C
> 
> Since there was no continuator specified, "future-Delphi" would have been 

 That is perfectly valid and a good idea too.

 You can have a string of variables you need to initiate to short cut 
the coding, plus I also think it compacts the generated code because you 
only need to load a single register with the initial value.

A:=B:=C:=D:=0;

 All get set the zero..

Jamie

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


Following Up

2014-12-23 Thread Sean Brady


Hi Marky,

 

Hope all is well! Just wanted to check in and see if you were able to read my 
last email. I think you would be a fantastic fit for some of our roles. We have 
placed 90% of our candidates in the past 5 months closer to their homes with a 
higher salary, that's just how hot the market is right now. I would love to 
help you out, but if you are not interested, let me know if you have anyone in 
mind who may be, I would love to help them out as well! 
 

Best,

Sean







 


 


 


 


 

Sean Brady 
| Sales Executive, Recruiter | Highview Partners, LLC | 



| Phone: 781.353.6429 ext. 206| Fax: 781.794.3489 | 
sbr...@highview-partners.com 
|





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


Re: what is wrong with d.clear()?

2014-12-23 Thread shawool
Thank you for answering my query.

Fonts and colors are reset to defaults now. Sorry for the inconvenience
caused.

Regards,
Shawool

On Tue, Dec 23, 2014 at 3:55 PM, Steve Hayes  wrote:

> On Tue, 23 Dec 2014 13:33:53 +1100, Steven D'Aprano
>  wrote:
>
> >Dave Angel wrote:
> >
> >> Or even better:  Don't use html email for forum messages.  It frequently
> >> messes up the colors, the font, the formatting (like indentation), or
> >> even prevents some people from even seeing and/or replying to the
> >> message.  Put the email program in text mode, and just send what you
> >> want people to see.
> >
> >
> >I agree, but alas the horse has bolted and the idiots have taken over.
> >
> >We cannot stop the great mass of people sending HTML mail, but there is no
> >reason why we have to *read* HTML email. Even today, most mail clients
> will
> >send a plain text part that contains the same content as the HTML part,
> and
> >any decent mail client can be set to prefer the plain text part in
> >preference to rendering the HTML.
> >
> >For those few cases where there is no plain text part[1], the better mail
> >clients (such as mutt) will include an option to dump the raw HTML to
> plain
> >text, minus all the tags.
> >
> >Last but not least, for the *vanishingly small* number of cases that has
> no
> >plain text part, and the formatting of the text dump is unreadable, or
> >where the formatting of the HTML is actually essential to understanding
> the
> >post, then you have a choice of pressing Delete on the message or
> rendering
> >the HTML. But rendering HTML should never be the default.
>
> I had a message, discussed in another NG, inviting me to look at someone's
> family tree on the web. It had no plain text version, and when I clicked on
> the relevant link, it crashed my mail reader.
>
> When I right-clicked on the link and tried to copy the URL to paste ibnto
> the
> address line of my web browser, it led to a "file not found" page.
>
> The HTML was enormously complex, and all they were supposed to be sending
> was
> a simple link.
>
> >[1] Or worse, one of those shitty messages that include a plain text part
> >that says "Your mail program cannot read this email. Please upgrade to a
> >better mail program."
>
> I usually reply to those saying "So why did you send it to me?"
>
> I suspect that in most cases the senders do not know that that is what
> their
> mail program is sending, and do it to let them know that their mesdsage
> could
> not be read.
>
>
> --
> Steve Hayes from Tshwane, South Africa
> Web:  http://www.khanya.org.za/stevesig.htm
> Blog: http://khanya.wordpress.com
> E-mail - see web page, or parse: shayes at dunelm full stop org full stop
> uk
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Select method of Range class failed

2014-12-23 Thread Dave Angel

On 12/23/2014 06:04 AM, Jaydeep Patil wrote:

Hi all,

I have developed python code which copy & paste data from one excel sheet to 
another excel sheet. I have compiled code both for 32 bit & 64 bit. It is working 
fine on 64 bit machine. But on 32 bit, it is giving below error.

rng.Select()
"Select method of Range class failed"

Just to know you, I am continuously copying data from one excel sheet to 
another sheet.



There are a larg number of posts on the internet where people have the 
same error message in VBA.  it's probably a fundamental problem in the 
Excel logic.  One solution frequently posted is to avoid doing a select; 
 apparently it's seldom actually necessary:


http://www.mrexcel.com/forum/excel-questions/585856-runtime-error-1004-select-method-range-class-failed.html


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


Select method of Range class failed

2014-12-23 Thread Jaydeep Patil
Hi all,

I have developed python code which copy & paste data from one excel sheet to 
another excel sheet. I have compiled code both for 32 bit & 64 bit. It is 
working fine on 64 bit machine. But on 32 bit, it is giving below error.

rng.Select()
"Select method of Range class failed"

Just to know you, I am continuously copying data from one excel sheet to 
another sheet.


Regards
Jaydeep M Patil
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: what is wrong with d.clear()?

2014-12-23 Thread Steve Hayes
On Tue, 23 Dec 2014 13:33:53 +1100, Steven D'Aprano
 wrote:

>Dave Angel wrote:
>
>> Or even better:  Don't use html email for forum messages.  It frequently
>> messes up the colors, the font, the formatting (like indentation), or
>> even prevents some people from even seeing and/or replying to the
>> message.  Put the email program in text mode, and just send what you
>> want people to see.
>
>
>I agree, but alas the horse has bolted and the idiots have taken over.
>
>We cannot stop the great mass of people sending HTML mail, but there is no
>reason why we have to *read* HTML email. Even today, most mail clients will
>send a plain text part that contains the same content as the HTML part, and
>any decent mail client can be set to prefer the plain text part in
>preference to rendering the HTML.
>
>For those few cases where there is no plain text part[1], the better mail
>clients (such as mutt) will include an option to dump the raw HTML to plain
>text, minus all the tags.
>
>Last but not least, for the *vanishingly small* number of cases that has no
>plain text part, and the formatting of the text dump is unreadable, or
>where the formatting of the HTML is actually essential to understanding the
>post, then you have a choice of pressing Delete on the message or rendering
>the HTML. But rendering HTML should never be the default.

I had a message, discussed in another NG, inviting me to look at someone's
family tree on the web. It had no plain text version, and when I clicked on
the relevant link, it crashed my mail reader. 

When I right-clicked on the link and tried to copy the URL to paste ibnto the
address line of my web browser, it led to a "file not found" page. 

The HTML was enormously complex, and all they were supposed to be sending was
a simple link. 

>[1] Or worse, one of those shitty messages that include a plain text part
>that says "Your mail program cannot read this email. Please upgrade to a
>better mail program."

I usually reply to those saying "So why did you send it to me?" 

I suspect that in most cases the senders do not know that that is what their
mail program is sending, and do it to let them know that their mesdsage could
not be read. 


-- 
Steve Hayes from Tshwane, South Africa
Web:  http://www.khanya.org.za/stevesig.htm
Blog: http://khanya.wordpress.com
E-mail - see web page, or parse: shayes at dunelm full stop org full stop uk
-- 
https://mail.python.org/mailman/listinfo/python-list


New github source

2014-12-23 Thread chris . hinsley
Hellow, just letting people know I've put up some github repo's of my Pthon 
projects:

https://github.com/vygr/Python-PCB
https://github.com/vygr/Python-Chess

Regards

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