Re: Negative array indicies and slice()

2012-10-29 Thread Andrew Robinson
On 10/29/2012 04:01 PM, Ian Kelly wrote: On Mon, Oct 29, 2012 at 9:20 AM, Andrew Robinson wrote: FYI: I was asking for a reason why Python's present implementation is desirable... I wonder, for example: Given an arbitrary list: a=[1,2,3,4,5,6,7,8,9,10,11,12] Why would someone *want* to do:

Re: Negative array indicies and slice()

2012-10-29 Thread Ian Kelly
On Mon, Oct 29, 2012 at 4:39 PM, Andrew Robinson wrote: > In addition to those items you mention, of which the reference count is not > even *inside* the struct -- there is additional debugging information not > mentioned. Built in objects contain a "line number", a "column number", and > a "cont

Re: Negative array indicies and slice()

2012-10-29 Thread Andrew Robinson
Hi Ian, There are several interesting/thoughtful things you have written. I like the way you consider a problem before knee jerk answering. The copying you mention (or realloc) doesn't re-copy the objects on the list. It merely re-copies the pointer list to those objects. So lets see what it w

Re: date and time comparison how to

2012-10-29 Thread Chris Angelico
On Tue, Oct 30, 2012 at 3:20 PM, noydb wrote: > But for the user supplied date... I'm not sure of the format just yet... > testing with a string for now (actual date-date might be possible, tbd > later), so like '10292012213000' (oct 29, 2012 9:30pm). How would you get > that input into a form

Re: Negative array indicies and slice()

2012-10-29 Thread Ian Kelly
On Mon, Oct 29, 2012 at 12:00 PM, Andrew Robinson wrote: > I downloaded the source code for python 3.3.0, as the tbz; > In the directory "Python-3.3.0/Python", look at Python-ast.c, line 2089 & > ff. Python-ast.c is part of the compiler code. That's not the struct used to represent the object at

Re: Negative array indicies and slice()

2012-10-29 Thread Michael Torrie
On 10/29/2012 01:34 PM, Andrew Robinson wrote: > No, I don't think it big and complicated. I do think it has timing > implications which are undesirable because of how *much* slices are used. > In an embedded target -- I have to optimize; and I will have to reject > certain parts of Python to ma

Re: Negative array indicies and slice()

2012-10-29 Thread Andrew Robinson
On 10/29/2012 06:49 PM, Chris Kaynor wrote: Every Python object requires two pieces of data, both of which are pointer-sized (one is a pointer, one is an int the size of a pointer). These are: a pointer to the object's type, and the object's reference count. A tuple actually does not need a hea

Re: date and time comparison how to

2012-10-29 Thread noydb
On Monday, October 29, 2012 11:11:55 PM UTC-4, Dave Angel wrote: > On 10/29/2012 10:13 PM, noydb wrote: > > > I guess I get there eventually! > > > This seems to work > > > > > > pdf_timeStamp = > > time.strftime("%m%d%y%H%M%S",time.localtime(os.path.getmtime(pdf))) > > > intermedia

Re: date and time comparison how to

2012-10-29 Thread MRAB
On 2012-10-30 03:11, Dave Angel wrote: On 10/29/2012 10:13 PM, noydb wrote: I guess I get there eventually! This seems to work pdf_timeStamp = time.strftime("%m%d%y%H%M%S",time.localtime(os.path.getmtime(pdf))) intermediateTime = time.strptime(pdf_timeStamp, "%m%d%y%H%M%S") pdfFile

Re: date and time comparison how to

2012-10-29 Thread Dave Angel
On 10/29/2012 10:13 PM, noydb wrote: > I guess I get there eventually! > This seems to work > > pdf_timeStamp = > time.strftime("%m%d%y%H%M%S",time.localtime(os.path.getmtime(pdf))) > intermediateTime = time.strptime(pdf_timeStamp, "%m%d%y%H%M%S") > pdfFile_compareTime = time.mktime(

Re: Negative array indicies and slice()

2012-10-29 Thread Andrew Robinson
On 10/29/2012 05:02 PM, Steven D'Aprano wrote: On Mon, 29 Oct 2012 08:42:39 -0700, Andrew Robinson wrote: But, why can't I just overload the existing __getitem__ for lists and not bother writing an entire class? You say that as if writing "an entire class" was a big complicated effort. It isn'

Re: date and time comparison how to

2012-10-29 Thread noydb
I guess I get there eventually! This seems to work pdf_timeStamp = time.strftime("%m%d%y%H%M%S",time.localtime(os.path.getmtime(pdf))) intermediateTime = time.strptime(pdf_timeStamp, "%m%d%y%H%M%S") pdfFile_compareTime = time.mktime(intermediateTime) (and I'll do the same to the us

Re: date and time comparison how to

2012-10-29 Thread noydb
if I do time.time() I get 1351562187.757, do it again I get 1351562212.2650001 --- so I can compare those, the latter is later then the former. Good. SO how do I turn pdf_timeStamp (a string) above into time in this (as from time.time()) format? Am I on the right track -- is that the way to d

Re: Negative array indicies and slice()

2012-10-29 Thread Chris Kaynor
On Mon, Oct 29, 2012 at 11:00 AM, Andrew Robinson wrote: > > Let's look at the source code rather than the web notes -- the source must > be the true answer anyhow. > > I downloaded the source code for python 3.3.0, as the tbz; > In the directory "Python-3.3.0/Python", look at Python-ast.c, line 2

Re: date and time comparison how to

2012-10-29 Thread noydb
Thanks, I did find this... pdf_timeStamp = time.strftime("%m%d%y%H%M%S",time.localtime(os.path.getmtime(pdf))) >> pdf_timestamp >> '102909133000' ... but now how to do the comparison? Cannot just do a raw string comparison, gotta declare it a date -- http://mail.python.org/mailman/listinfo/p

Re: Nice solution wanted: Hide internal interfaces

2012-10-29 Thread alex23
On Oct 30, 2:33 am, Johannes Bauer wrote: > I'm currently looking for a good solution to the following problem: I > have two classes A and B, which interact with each other and which > interact with the user. Instances of B are always created by A. > > Now I want A to call some private methods of

Re: Negative array indicies and slice()

2012-10-29 Thread Andrew Robinson
On 10/29/2012 06:53 AM, Chris Angelico wrote: Can you provide links to these notes? I'm looking at cpython/Include/sliceobject.h that has this comment: /* A slice object containing start, stop, and step data members (the names are from range). After much talk with Guido, it was decided to let

Re: date and time comparison how to

2012-10-29 Thread MRAB
On 2012-10-30 00:04, Gary Herron wrote: On 10/29/2012 04:13 PM, noydb wrote: All, I need help with a date and time comparison. Say a user enters a date-n-time and a file on disk. I want to compare the date and time of the file to the entered date-n-time; if the file is newer than the entere

Re: Negative array indicies and slice()

2012-10-29 Thread Roy Smith
In article , Ian Kelly wrote: > On Mon, Oct 29, 2012 at 5:24 PM, Roy Smith wrote: > > I think you're missing the point of "amortized constant time". Yes, the > > first item appended to the list will be copied lg(20,000,000) ~= 25 > > times, because the list will be resized that many times(*).

Re: date and time comparison how to

2012-10-29 Thread Gary Herron
On 10/29/2012 04:13 PM, noydb wrote: All, I need help with a date and time comparison. Say a user enters a date-n-time and a file on disk. I want to compare the date and time of the file to the entered date-n-time; if the file is newer than the entered date-n-time, add the file to a list to

Re: Negative array indicies and slice()

2012-10-29 Thread Steven D'Aprano
On Mon, 29 Oct 2012 08:42:39 -0700, Andrew Robinson wrote: >>> But, why can't I just overload the existing __getitem__ for lists and >>> not bother writing an entire class? You say that as if writing "an entire class" was a big complicated effort. It isn't. It is trivially simple, a single line:

Re: Negative array indicies and slice()

2012-10-29 Thread Ian Kelly
On Mon, Oct 29, 2012 at 5:43 PM, Ian Kelly wrote: > The growth factor is approximately 1.125. "Approximately" because > there is also a small constant term. The average number of copies per > item converges on 8. Of course, that is the *maximum* number of copies. The actual number could be muc

Re: Negative array indicies and slice()

2012-10-29 Thread Oscar Benjamin
On 29 October 2012 23:01, Ian Kelly wrote: > On Mon, Oct 29, 2012 at 9:20 AM, Andrew Robinson > wrote: >> FYI: I was asking for a reason why Python's present implementation is >> desirable... >> >> I wonder, for example: >> >> Given an arbitrary list: >> a=[1,2,3,4,5,6,7,8,9,10,11,12] >> >> Why w

Re: Negative array indicies and slice()

2012-10-29 Thread Ian Kelly
On Mon, Oct 29, 2012 at 5:24 PM, Roy Smith wrote: > I think you're missing the point of "amortized constant time". Yes, the > first item appended to the list will be copied lg(20,000,000) ~= 25 > times, because the list will be resized that many times(*). But, on > average (I'm not sure if "aver

Re: Negative array indicies and slice()

2012-10-29 Thread Roy Smith
In article , Ian Kelly wrote: > On Mon, Oct 29, 2012 at 9:42 AM, Andrew Robinson > wrote: > > The list was generated in a single pass by many .append() 's, and then > > copied once -- the original was left in place; and then I attempted to slice > > it. > > Note that if the list was generated

Re: Immutability and Python

2012-10-29 Thread Steven D'Aprano
On Mon, 29 Oct 2012 15:45:59 -0700, Chris Kaynor wrote: > On Mon, Oct 29, 2012 at 3:30 PM, Steven D'Aprano > wrote: >> On Mon, 29 Oct 2012 17:05:07 +, andrea crotti wrote: >> >>> I meant how do I create new immutables classes myself, I guess that's >>> possible writing C extensions but I don'

date and time comparison how to

2012-10-29 Thread noydb
All, I need help with a date and time comparison. Say a user enters a date-n-time and a file on disk. I want to compare the date and time of the file to the entered date-n-time; if the file is newer than the entered date-n-time, add the file to a list to process. How best to do? I have looke

Re: Negative array indicies and slice()

2012-10-29 Thread Ian Kelly
On Mon, Oct 29, 2012 at 9:42 AM, Andrew Robinson wrote: > The list was generated in a single pass by many .append() 's, and then > copied once -- the original was left in place; and then I attempted to slice > it. Note that if the list was generated by .appends, then it was copied more than once.

Re: Immutability and Python

2012-10-29 Thread Steven D'Aprano
On Mon, 29 Oct 2012 15:20:02 +, andrea crotti wrote: > I have a philosofical doubt about immutability, that arised while doing > the SCALA functional programming course. "Philosophical". Like most words derived from the ancient Greeks, the "F" sound uses "ph" rather than "f". > Now suppose

Re: Negative array indicies and slice()

2012-10-29 Thread Ian Kelly
On Mon, Oct 29, 2012 at 9:20 AM, Andrew Robinson wrote: > FYI: I was asking for a reason why Python's present implementation is > desirable... > > I wonder, for example: > > Given an arbitrary list: > a=[1,2,3,4,5,6,7,8,9,10,11,12] > > Why would someone *want* to do: > a[-7,10] > Instead of saying

Re: Negative array indicies and slice()

2012-10-29 Thread Chris Angelico
On Tue, Oct 30, 2012 at 2:42 AM, Andrew Robinson wrote: > No, there was no error at all. Pthon just crashed & exited; not even an > exception that I can recall. It was if it exited normally! Can you create a reproducible test case? There's usually a cause to these sorts of things. ChrisA --

Re: problems with xml parsing (python 3.3)

2012-10-29 Thread jannidis
Am Sonntag, 28. Oktober 2012 03:27:14 UTC+1 schrieb jann...@gmail.com: > Hello all, > > > > I am new to Python and have a problem with the behaviour of the xml parser. > Assume we have this xml document: > > > > > > > > > > Title of the first book. > > > >

Re: Negative array indicies and slice()

2012-10-29 Thread Andrew Robinson
On 10/29/2012 10:09 AM, Ian Kelly wrote: On Oct 29, 2012 7:10 AM, "Andrew Robinson" wrote: I will be porting Python 3.xx to a super low power embedded processor (MSP430), both space and speed are at a premium. Running Python on top of Java would be a *SERIOUS* mistake. .NET won't even run on

Re: Immutability and Python

2012-10-29 Thread Chris Kaynor
On Mon, Oct 29, 2012 at 3:30 PM, Steven D'Aprano wrote: > On Mon, 29 Oct 2012 17:05:07 +, andrea crotti wrote: > >> I meant how do I create new immutables classes myself, I guess that's >> possible writing C extensions but I don't see in pure Python.. > > Well, you can't *quite* make a truly i

Re: Nice solution wanted: Hide internal interfaces

2012-10-29 Thread Steven D'Aprano
On Mon, 29 Oct 2012 17:33:24 +0100, Johannes Bauer wrote: > Hi there, > > I'm currently looking for a good solution to the following problem: I > have two classes A and B, which interact with each other and which > interact with the user. Instances of B are always created by A. > > Now I want A

Re: Immutability and Python

2012-10-29 Thread Steven D'Aprano
On Tue, 30 Oct 2012 06:36:52 +1100, Chris Angelico wrote: > On Tue, Oct 30, 2012 at 6:23 AM, Ian Kelly > wrote: >> _MyImmutableClass = namedtuple('MyImmutableClass', 'field1 field2 >> field3 field4') >> >> class MyImmutableClass(_MyImmutableClass): > > Question: Is it clearer to take advantage o

Re: Immutability and Python

2012-10-29 Thread Steven D'Aprano
On Mon, 29 Oct 2012 17:05:07 +, andrea crotti wrote: > I meant how do I create new immutables classes myself, I guess that's > possible writing C extensions but I don't see in pure Python.. Well, you can't *quite* make a truly immutable class in pure-Python, because if *your* Python code can

RE: better way for ' '.join(args) + '\n'?

2012-10-29 Thread Prasad, Ramit
Thomas Rachel wrote: > Am 26.10.2012 09:49 schrieb Ulrich Eckhardt: > > Hi! > > > > General advise when assembling strings is to not concatenate them > > repeatedly but instead use string's join() function, because it avoids > > repeated reallocations and is at least as expressive as any alternativ

Re: Negative array indicies and slice()

2012-10-29 Thread Andrew Robinson
On 10/29/2012 06:52 AM, Roy Smith wrote: Show me an example where someone would write a slice with a negative and a positive index (both in the same slice); and have that slice grab a contiguous slice in the *middle* of the list with orientation of lower index to greater index. It's possible in b

Re: Negative array indicies and slice()

2012-10-29 Thread Steven D'Aprano
On Mon, 29 Oct 2012 11:19:38 +, Steven D'Aprano wrote: > Because xrange represents a concrete sequence of numbers, all three of > start, end and stride must be concrete, known, integers: > > py> xrange(4, None, 2) > Traceback (most recent call last): > File "", line 1, in > TypeError: an i

Re: SSH Connection with Python

2012-10-29 Thread Roy Smith
In article , Gelonida N wrote: > On 10/29/2012 02:10 PM, Roy Smith wrote: > > In article , > > Gelonida N wrote: > > > >> The sh module looks intersting, but it's not supported for Windows > >> platforms. > > > > "The X module looks interesting but it's not supported for Windows" is > > true

Re: Negative array indicies and slice()

2012-10-29 Thread Steven D'Aprano
On Mon, 29 Oct 2012 23:40:53 +1100, Chris Angelico wrote: > On Mon, Oct 29, 2012 at 3:52 PM, Andrew Robinson > wrote: >> I am curious as to how quickly it constructs the result compared to a >> slice operation. >> >> Eg: >> a[1:5] >> vs. >> [ a[i] for i in xrange[1:5] ] > > For the most part, do

Re: I need help installing pypng in Python 3.3

2012-10-29 Thread Andrew Robinson
On 10/29/2012 06:39 AM, ic...@tagyourself.com wrote: That's very kind of you but I don't think it would be particularly fitted to my needs. The program I'm trying to code creates an image as an 2D array of "pixels" which is defined by RGBA value. My program needs to access and modifies every co

Re: SSH Connection with Python

2012-10-29 Thread Gelonida N
On 10/29/2012 02:10 PM, Roy Smith wrote: In article , Gelonida N wrote: The sh module looks intersting, but it's not supported for Windows platforms. "The X module looks interesting but it's not supported for Windows" is true for many values of X. It's all part of the TCO of using a brain

Re: SSH Connection with Python

2012-10-29 Thread Gelonida N
On 10/29/2012 04:18 PM, David Robinow wrote: On Sun, Oct 28, 2012 at 4:09 PM, Gelonida N wrote: The only thing I'm concerned about paramiko is, that I don't see any activity on the paramiko site and that one library it depends on is not available is windows binary package for newer versions of

Python Bug Day this Saturday in Montreal and on IRC

2012-10-29 Thread Éric Araujo
This Saturday, you have the opportunity of participating in the Python Bug Day. How would you like to be one of the contributors of Python? If you have ideas for improving parts of the official documentation, the standard library, the language itself, or if you have a patch waiting for a review t

Re: Immutability and Python

2012-10-29 Thread Ian Kelly
On Mon, Oct 29, 2012 at 1:36 PM, Chris Angelico wrote: > Question: Is it clearer to take advantage of the fact that the base > class can be an arbitrary expression? > > class MyImmutableClass(namedtuple('MyImmutableClass', 'field1 field2 > field3 field4')): > > You lose the unnecessary temporary a

Re: Immutability and Python

2012-10-29 Thread Chris Angelico
On Tue, Oct 30, 2012 at 6:23 AM, Ian Kelly wrote: > _MyImmutableClass = namedtuple('MyImmutableClass', 'field1 field2 > field3 field4') > > class MyImmutableClass(_MyImmutableClass): Question: Is it clearer to take advantage of the fact that the base class can be an arbitrary expression? class M

Re: Immutability and Python

2012-10-29 Thread Ian Kelly
On Mon, Oct 29, 2012 at 10:12 AM, andrea crotti wrote: > Also because how doi I make an immutable object in pure Python? I sometimes use namedtuples for this. from collections import namedtuple MyImmutableClass = namedtuple('MyImmutableClass', 'field1 field2 field3 field4') If you want default

Re: Nice solution wanted: Hide internal interfaces

2012-10-29 Thread Ian Kelly
On Mon, Oct 29, 2012 at 10:58 AM, Johannes Bauer wrote: > Ah, that's nice. I didn't know that nested classes could access their > private members naturally (i.e. without using any magic, just with plain > old attribute access). There is nothing at all special about nested classes that is differen

Re: OrderedDict / DIctComprehension

2012-10-29 Thread Christian
Too bad that's not (using python2.7) 'ordered_dict_generator' ((), {}) 1.089588 sec Anyway thanks for your hint! > Hi, > > > > is there a way building an OrderedDict faster? > > > > Thanks in advance > > Christian > > > > @timeit > > def ordered(n=10): > > d = OrderedDict() >

Re: Immutability and Python

2012-10-29 Thread Devin Jeanpierre
On Mon, Oct 29, 2012 at 12:46 PM, Paul Rubin wrote: > andrea crotti writes: >> Also because how doi I make an immutable object in pure Python? > > Numbers in Python are already immutable. What you're really looking for > is a programming style where you don't bind any variable more than once. N

Re: I need help installing pypng in Python 3.3

2012-10-29 Thread icgwh
> > Do you have the file c:\Python33\Lib\site-packages\pypng-0.0.13-py3.3.egg ? > > If not, you have not successfully installed pypng. Please try one of > > the methods I gave above. Yes I do have the egg. I'm gonna try to summarize: I don't have installations problems anymore but it seems

Re: Nice solution wanted: Hide internal interfaces

2012-10-29 Thread Grant Edwards
On 2012-10-29, Johannes Bauer wrote: > On 29.10.2012 17:47, Chris Angelico wrote: > >> The usual convention for private methods is a leading underscore on the name: > > Yup, that's what I'm using. > >> It's only a convention, though; it doesn't make it "hard" to call >> them, it just sends the mes

Re: Immutability and Python

2012-10-29 Thread Terry Reedy
On 10/29/2012 1:05 PM, andrea crotti wrote: I meant how do I create new immutables classes myself, I guess that's possible writing C extensions but I don't see in pure Python.. If you mean class with immutable instances, mutate new instances in __new__ instead of __init__ and write a custom .

Re: Re: Immutability and Python

2012-10-29 Thread Evan Driscoll
On 10/29/2012 12:05 PM, andrea crotti wrote: > I meant how do I create new immutables classes myself, I guess that's > possible writing C extensions but I don't see in pure Python.. The short answer is: you don't, not really, except by using NamedTuple if that gives you what you want. The longer

Re: Immutability and Python

2012-10-29 Thread Terry Reedy
On 10/29/2012 11:20 AM, andrea crotti wrote: I have a philosofical doubt about immutability, that arised while doing the SCALA functional programming course. In real life, the physical world, things have mutable state, at least down to the atomic level. Do you only want to model mathematical w

Re: Negative array indicies and slice()

2012-10-29 Thread Ian Kelly
On Mon, Oct 29, 2012 at 1:54 AM, Andrew wrote: > My intended inferences about the iterator vs. slice question was perhaps not > obvious to you; Notice: an iterator is not *allowed* in __getitem__(). Yes, I misconstrued your question. I thought you wanted to change the behavior of slicing to wra

Re: OrderedDict / DIctComprehension

2012-10-29 Thread Terry Reedy
On 10/29/2012 8:36 AM, Christian wrote: Hi, is there a way building an OrderedDict faster? Thanks in advance Christian @timeit def ordered(n=10): d = OrderedDict() for i in xrange(n): d['key'+str(i)] = i return d try d = OrderedDict(['key'+str(i),i for i in xrange

Re: Negative array indicies and slice()

2012-10-29 Thread Ian Kelly
On Oct 29, 2012 7:10 AM, "Andrew Robinson" wrote: > I will be porting Python 3.xx to a super low power embedded processor > (MSP430), both space and speed are at a premium. > Running Python on top of Java would be a *SERIOUS* mistake. .NET won't even > run on this system. etc. If that's the ca

Re: Nice solution wanted: Hide internal interfaces

2012-10-29 Thread Peter Otten
Johannes Bauer wrote: > On 29.10.2012 17:52, Grant Edwards wrote: > >> By "decleare them privide" do you mean using __ASDF__ name-munging? >> >> It sounds to me like you're just making life hard on yourself. > > Gaah, you are right. I just noticed that using the single underscore > (as I do

Re: Nice solution wanted: Hide internal interfaces

2012-10-29 Thread Paul Rubin
Johannes Bauer writes: > This makes the source files largish however (they're currently split up > in different files). Can I use the nested class advantage and somehow > include the inner class from another file? You could possibly duck-punch class A: import B class A: ... A.B = B.B

Re: Nice solution wanted: Hide internal interfaces

2012-10-29 Thread Peter Otten
Johannes Bauer wrote: > Now I want A to call some private methods of B and vice versa (i.e. what > C++ "friends" are), but I want to make it hard for the user to call > these private methods. > > Currently my ugly approach is this: I delare the internal methods > private (hide from user). Then I

Re: Nice solution wanted: Hide internal interfaces

2012-10-29 Thread Johannes Bauer
On 29.10.2012 17:52, Grant Edwards wrote: > By "decleare them privide" do you mean using __ASDF__ name-munging? > > It sounds to me like you're just making life hard on yourself. Gaah, you are right. I just noticed that using the single underscore (as I do) does not restrict usage in any "no

Re: Nice solution wanted: Hide internal interfaces

2012-10-29 Thread Johannes Bauer
On 29.10.2012 17:47, Chris Angelico wrote: > The usual convention for private methods is a leading underscore on the name: Yup, that's what I'm using. > It's only a convention, though; it doesn't make it "hard" to call > them, it just sends the message "this is private, I don't promise that > it

Re: Nice solution wanted: Hide internal interfaces

2012-10-29 Thread Grant Edwards
On 2012-10-29, Johannes Bauer wrote: > I'm currently looking for a good solution to the following problem: I > have two classes A and B, which interact with each other and which > interact with the user. Instances of B are always created by A. > > Now I want A to call some private methods of B an

Re: Immutability and Python

2012-10-29 Thread Paul Rubin
andrea crotti writes: > Also because how doi I make an immutable object in pure Python? Numbers in Python are already immutable. What you're really looking for is a programming style where you don't bind any variable more than once. This gives rise to a programming style that Python can support

Re: Nice solution wanted: Hide internal interfaces

2012-10-29 Thread Chris Angelico
On Tue, Oct 30, 2012 at 3:33 AM, Johannes Bauer wrote: > Hi there, > > I'm currently looking for a good solution to the following problem: I > have two classes A and B, which interact with each other and which > interact with the user. Instances of B are always created by A. > > Now I want A to ca

Re: Numpy module

2012-10-29 Thread Benjamin Kaplan
On Sun, Oct 28, 2012 at 10:40 PM, wrote: > Hello to the group! > > I've learned a lot about Ubuntu just trying to install numpy for Python > 3.2.3. I've finally managed to put it in the Python3.2 directory but when I > try to import it, I still get there's "no module named numpy." There are >

Re: Nice solution wanted: Hide internal interfaces

2012-10-29 Thread Benjamin Kaplan
On Mon, Oct 29, 2012 at 9:33 AM, Johannes Bauer wrote: > Hi there, > > I'm currently looking for a good solution to the following problem: I > have two classes A and B, which interact with each other and which > interact with the user. Instances of B are always created by A. > > Now I want A to ca

Re: Nice solution wanted: Hide internal interfaces

2012-10-29 Thread andrea crotti
2012/10/29 Johannes Bauer : > Hi there, > > I'm currently looking for a good solution to the following problem: I > have two classes A and B, which interact with each other and which > interact with the user. Instances of B are always created by A. > > Now I want A to call some private methods of B

Nice solution wanted: Hide internal interfaces

2012-10-29 Thread Johannes Bauer
Hi there, I'm currently looking for a good solution to the following problem: I have two classes A and B, which interact with each other and which interact with the user. Instances of B are always created by A. Now I want A to call some private methods of B and vice versa (i.e. what C++ "friends"

Re: Immutability and Python

2012-10-29 Thread andrea crotti
2012/10/29 Chris Angelico : > On Tue, Oct 30, 2012 at 2:55 AM, Paul Rubin wrote: >> andrea crotti writes: >>> and we want to change its state incrementing the number ... >>> the immutability purists would instead suggest to do this: >>> def increment(self): >>> return NumWrapper(self

Re: Immutability and Python

2012-10-29 Thread andrea crotti
2012/10/29 Jean-Michel Pichavant : > > > In an OOP language num.increment() is expected to modify the object in place. > So I think you're right when you say that functional languages technics do > not necessarily apply to Python, because they don't. > > I would add that what you're trying to sugg

Re: Immutability and Python

2012-10-29 Thread Chris Angelico
On Tue, Oct 30, 2012 at 2:55 AM, Paul Rubin wrote: > andrea crotti writes: >> and we want to change its state incrementing the number ... >> the immutability purists would instead suggest to do this: >> def increment(self): >> return NumWrapper(self.number + 1) > > Immutability puris

Re: Immutability and Python

2012-10-29 Thread Jean-Michel Pichavant
- Original Message - > 2012/10/29 Jean-Michel Pichavant : > > > > "return NumWrapper(self.number + 1) " > > > > still returns a(nother) mutable object. > > > > So what's the point of all this ? > > > > JM > > > > Well sure but it doesn't modify the first object, just creates a new > one.

Re: Immutability and Python

2012-10-29 Thread Paul Rubin
andrea crotti writes: > and we want to change its state incrementing the number ... > the immutability purists would instead suggest to do this: > def increment(self): > return NumWrapper(self.number + 1) Immutability purists would say that numbers don't have "state" and if you're tr

Re: Immutability and Python

2012-10-29 Thread Mark Lawrence
On 29/10/2012 15:20, andrea crotti wrote: I have a philosofical doubt about immutability, that arised while doing the SCALA functional programming course. Now suppose I have a simple NumWrapper class, that very stupidly does: class NumWrapper(object): def __init__(self, number): s

Re: Immutability and Python

2012-10-29 Thread andrea crotti
2012/10/29 andrea crotti : >> > > Well sure but it doesn't modify the first object, just creates a new > one. There are in general good reasons to do that, for example I can > then compose things nicely: > > num.increment().increment() > > or I can parallelize operations safely not caring about th

Re: Immutability and Python

2012-10-29 Thread andrea crotti
2012/10/29 Jean-Michel Pichavant : > > "return NumWrapper(self.number + 1) " > > still returns a(nother) mutable object. > > So what's the point of all this ? > > JM > Well sure but it doesn't modify the first object, just creates a new one. There are in general good reasons to do that, for examp

Re: Immutability and Python

2012-10-29 Thread Jean-Michel Pichavant
- Original Message - > I have a philosofical doubt about immutability, that arised while > doing > the SCALA functional programming course. > > Now suppose I have a simple NumWrapper class, that very stupidly > does: > > class NumWrapper(object): > def __init__(self, number): >

Re: SSH Connection with Python

2012-10-29 Thread David Robinow
On Sun, Oct 28, 2012 at 4:09 PM, Gelonida N wrote: > The only thing I'm concerned about paramiko is, that I don't see any > activity on the paramiko site and that one library it depends on is not > available is windows binary package for newer versions of python. > I don't understand why this is

Re: I need help installing pypng in Python 3.3

2012-10-29 Thread David Robinow
On Mon, Oct 29, 2012 at 8:23 AM, wrote: > Hello all, > > I am very new to python. I am currently porting a little project of mine from > java to python and I need to be able to construct and write png images. I > naturally turned myself toward pypng to accomplish this. > > I learned from the ne

[ANN] 2 new articles in The Python Papers

2012-10-29 Thread mauricel...@acm.org
Hi all I'm pleased to announce 2 newly published articles in The Python Papers (ojs.pythonpapers.org). FUSE’ing Python for Development of Storage Efficient Filesystem (http://ojs.pythonpapers.org/index.php/tpp/article/view/244) Abstract: Filesystem is a core component of a functional operating

Re: Negative array indicies and slice()

2012-10-29 Thread Roy Smith
In article , Andrew Robinson wrote: > Show me an example where someone would write a slice with a negative and > a positive index (both in the same slice); > and have that slice grab a contiguous slice in the *middle* of the list > with orientation of lower index to greater index. It's possib

Re: Negative array indicies and slice()

2012-10-29 Thread Chris Angelico
On Mon, Oct 29, 2012 at 5:01 PM, Andrew Robinson wrote: > Looking at some of the online programming notes -- a slice apparently > doesn't use an integer storage variable that is capable of arbitrary > expansion. =-O -- and hence, won't work for very large sized lists. That > actually explains so

Re: Where are documentation for Gnome

2012-10-29 Thread Gene Heskett
On Sunday 28 October 2012 16:45:12 GangGreene did opine: > On Sun, 28 Oct 2012 16:29:07 +, Mark Lawrence wrote: > > On 13/10/2012 18:49, Santosh Kumar wrote: > > > > > > Try your local garden centre. > > I inquired at the local garden centre, Just got strange looks > > Are you sure tha

Re: OT Questions

2012-10-29 Thread Ian Kelly
On Sun, Oct 28, 2012 at 10:15 AM, Joshua Landau wrote: > I feel necessity to argue against this point. > > It is a common thing to stereotype teens in this way - but, being teen > myself, I feel one should try to avoid it. It's painful to watch every time > someone claims "he can't be a teenager

Re: I need help installing pypng in Python 3.3

2012-10-29 Thread icgwh
That's very kind of you but I don't think it would be particularly fitted to my needs. The program I'm trying to code creates an image as an 2D array of "pixels" which is defined by RGBA value. My program needs to access and modifies every component of every pixels in the image following a set o

Re: I need help installing pypng in Python 3.3

2012-10-29 Thread icgwh
I probably should have mentioned that I'm under W7 ultimate x64, I'm using eclipse Juno (latest) and pydev 2.7.1 -- http://mail.python.org/mailman/listinfo/python-list

Re: I need help installing pypng in Python 3.3

2012-10-29 Thread Andrew Robinson
On 10/29/2012 05:23 AM, icgwh wrote: Hello all, I am very new to python. I am currently porting a little project of mine from java to python and I need to be able to construct and write png images. I naturally turned myself toward pypng to accomplish this. I don't know if this will help, but:

Re: SSH Connection with Python

2012-10-29 Thread Roy Smith
In article , Gelonida N wrote: > The sh module looks intersting, but it's not supported for Windows > platforms. "The X module looks interesting but it's not supported for Windows" is true for many values of X. It's all part of the TCO of using a brain-dead operating system. -- http://mail

Re: Negative array indicies and slice()

2012-10-29 Thread Andrew Robinson
On 10/29/2012 04:19 AM, Steven D'Aprano wrote: On Mon, 29 Oct 2012 00:54:29 -0700, Andrew wrote: Slices and iterators have different purposes and therefore have not been made interchangeable. Yes, there are certain similarities between a slice and xrange, but there are also significant differenc

Re: SSH Connection with Python

2012-10-29 Thread Christian
Am Donnerstag, 25. Oktober 2012 12:31:46 UTC+2 schrieb Schneider: > Hi Folkz, > > how can i create a SSH-Connection with python? I have to send some > > commands to the remote host and parse their answers. > > greatz Johannes There is a module in chilkat. http://www.example-code.com/python/ssh

Re: SSH Connection with Python

2012-10-29 Thread Schneider
thank you guys for the huge list of answers, In my setting I have to access some routers and firewall from a linux-client. I think I'll try Fabric. On 26.10.2012 06:20, Rodrick Brown wrote: On Oct 25, 2012, at 6:34 AM, Schneider wrote: Hi Folkz, how can i create a SSH-Connection with pyth

Re: Negative array indicies and slice()

2012-10-29 Thread Chris Angelico
On Mon, Oct 29, 2012 at 3:52 PM, Andrew Robinson wrote: > I am curious as to how quickly it constructs the result compared to a slice > operation. > > Eg: > a[1:5] > vs. > [ a[i] for i in xrange[1:5] ] For the most part, don't concern yourself with performance. Go with functionality and readabili

OrderedDict / DIctComprehension

2012-10-29 Thread Christian
Hi, is there a way building an OrderedDict faster? Thanks in advance Christian @timeit def ordered(n=10): d = OrderedDict() for i in xrange(n): d['key'+str(i)] = i return d @timeit def comprehension(n=10): d = { 'key'+str(i):i for i in xrange(n) } return d

I need help installing pypng in Python 3.3

2012-10-29 Thread icgwh
Hello all, I am very new to python. I am currently porting a little project of mine from java to python and I need to be able to construct and write png images. I naturally turned myself toward pypng to accomplish this. I learned from the net that pypng 0.0.13 is supposed to work in Python 3.x

Re: attaching names to subexpressions

2012-10-29 Thread Neil Cerutti
On 2012-10-28, Devin Jeanpierre wrote: >>> The 'canonical way' >>> while True: >>> line = complex_expression >>> if not line: >>> break >>> do_something_with(line) >>> >>> avoids this problem, but I was never really convinced about the beauty / >>> readbility of this constr

Re: Negative array indicies and slice()

2012-10-29 Thread Andrew Robinson
On 10/29/2012 04:32 AM, Chris Angelico wrote: I wonder if what the OP is looking for is not slicing, but something more akin to map. Start with a large object and an iterator that produces keys, and create an iterator/list of their corresponding values. Something like: a=[1,2,3,4,5,6,7,8,9,10]

  1   2   >