Re: DOS or not? [was Re: How to tell Script to use pythonw.exe ?]

2013-07-04 Thread Andrew Berg
On 2013.07.04 09:08, Wayne Werner wrote: > powershell -ExecutionPolicy Bypass -File ... > > > \o/ > > Microsoft "security" at it again! (reminds me a bit of just pushing > "Cancel" to log into windows 98, I think it was) From an MSDN page linked in one of the answers: > Now, why is > > Pow

Re: Help with 'self' and 'set_usage'

2013-07-09 Thread Andrew Berg
On 2013.07.09 12:03, L O'Shea wrote: > Could anyone shed some light on this? I can't find mention of this anywhere > in any Python documentation or anywhere else in the code where usage_str > might be defined. In Python, you don't declare or initialize variables before using them. In the example

Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-17 Thread Andrew Berg
On 2013.07.18 01:36, Aseem Bansal wrote: > I learnt Python myself and everyone told me that Python 2 is status quo so I > learned Python 2 and have been working with it. I am just 1.5 months in > Python programming so should I consider switching to Python 3 if it helps > with new things or shoul

Re: None shown in output

2012-06-21 Thread Andrew Berg
On 6/21/2012 10:42 PM, Xander Solis wrote: > Hello Python list, > > Noob here with a newbie question. I'm reading and working on the > exercise of the book, Learn Python the Hard way 2.0. When I use this > code, I get "None" on the output. My question is why does this happen? Your function prints

Re: Why is python source code not available on github?

2012-06-23 Thread Andrew Berg
On 6/23/2012 7:16 PM, gmspro wrote: > Why is python source code not available on github? If you mean CPython, it's because the devs use Mercurial and have their own hosting on python.org. hg clone http://hg.python.org/cpython http://docs.python.org/devguide/setup.html github is far from the only

Re: exception problem

2012-06-24 Thread Andrew Berg
On 6/25/2012 12:27 AM, Charles Hixson wrote: > The documentation section covering the except statement could stand to > be a *LOT* clearer. I read the sections on the except statement and > exception handlers several times and couldn't figure out was the "as" > argument of the except statement

Re: Why has python3 been created as a seperate language where there is still python2.7 ?

2012-06-25 Thread Andrew Berg
On 6/23/2012 10:46 PM, gmspro wrote: > What's wrong editing/customizing/changin python2.7 instead of making a > seperate language? py3k is not a separate language. In fact, it is possible to maintain a codebase that supports 2.2 (maybe even older), 3.3, and every version in between. > What's wrong

Re: The Quran on Human Embryonic Development

2012-06-25 Thread Andrew D'Angelo
*Rimshot* wrote in message news:[email protected]... > Well, I use wxFormBuilder for my embryonic GUIs, but I have no qualms (or > is that quorans) about changing the generated code to make it more > efficient. -- http://mail.python.org/mailman/listinfo/

vBulletin scraper -- feasible?

2012-06-25 Thread Andrew D'Angelo
Taking a look through vBulletin's HTML, I was wondering whether it would be overly difficult to parse it into nice, manipulatible data. I'd suppose my ultimate goal would be to dynamically parse a vBulletin and feed it into a locally hosted NNTP server. -- http://mail.python.org/mailman/listi

Re: vBulletin scraper -- feasible?

2012-06-26 Thread Andrew D'Angelo
Thanks, this seems to be just what I need. -- http://mail.python.org/mailman/listinfo/python-list

Re: Following syntax error in Mac OX10.7 Terminal

2012-06-28 Thread Andrew Berg
On 6/28/2012 12:11 PM, David Thomas wrote: > Hi, > I have the following error regarding a loop tutorial found on > http://www.sthurlow.com/python/lesson04/ > a=0 while a<10: > ... a=a+1 > File "", line 2 > a=a+1 > ^ > IndentationError: expected an indented block You indented

Re: Re Following syntax error in Mac OX10.7 Terminal

2012-06-29 Thread Andrew Berg
On 6/29/2012 10:58 AM, David Thomas wrote: > Just discovered this in the tutorial further down. I'm currently learning > Python 2 because there seems to be a lot of tutorials out there covering > Python 2 rather than 3. The latest edition (3rd?) of Programming Python by Mark Lutz covers py3k (it

Re: when "normal" parallel computations in CPython will be implemented at last?

2012-07-01 Thread Andrew Berg
On 7/1/2012 1:53 PM, Thomas Jollans wrote: > As far as I can tell, there are no concrete plans to integrate > concurrency better, or get rid of the GIL, at the moment. To quote > http://wiki.python.org/moin/GlobalInterpreterLock > > """Getting rid of the GIL is an occasional topic on the python-

Re: helping with unicode

2012-07-02 Thread Andrew Berg
On 7/2/2012 7:49 PM, self.python wrote: > > Traceback (most recent call last): > File "C:wrong.py", line 8, in > print rf.read().decode('utf-8') > UnicodeEncodeError: 'cp949' codec can't encode character u'u1368' in position >

Re: 2 + 2 = 5

2012-07-05 Thread Andrew Cooper
y for new math, new-hoo-hoo math" :-) > > Evan It wont do you a bit of good to read new math! (My mind was on exactly the same track) ~Andrew -- http://mail.python.org/mailman/listinfo/python-list

Socket code not executing properly in a thread (Windows)

2012-07-07 Thread Andrew D'Angelo
Hi, I've been writing an IRC chatbot that an relay messages it recieves as an SMS. As it stands, I can retrieve and parse SMSs from Google Voice perfectly, and print them to the console. The problem lies in actually posting the message to the IRC channel. Since the SMS checker runs in a thread apar

Re: Socket code not executing properly in a thread (Windows)

2012-07-07 Thread Andrew D'Angelo
"Thomas Jollans" wrote in message news:[email protected]... > On 07/08/2012 12:55 PM, Andrew D'Angelo wrote: > > Please set your clock to the correct date and time. My BIOS battery has died and I haven't gotten a chance to rep

Re: Socket code not executing properly in a thread (Windows)

2012-07-08 Thread Andrew D'Angelo
"John Nagle" wrote in message news:[email protected]... >We have no idea what IRC module you're using. I am sending plain text to the socket, sorry for not mentioning it before. At the simplest level, it appears that when the code runs in Windows, data is not sent to a socket

Implicit conversion to boolean in if and while statements

2012-07-15 Thread Andrew Berg
This has probably been discussed before, but why is there an implicit conversion to a boolean in if and while statements? if not None: print('hi') prints 'hi' since bool(None) is False. If this was discussed in a PEP, I would like a link to it. There are so many PEPs, and I wouldn't know

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Andrew Berg
On 7/15/2012 5:56 AM, Steven D'Aprano wrote: > 3) Rather than distinguishing "true" from "false", a more useful > dichotomy is between "something" and "nothing". Python includes a number > of ways of spelling "nothing" of various types, such as: > > None, 0, 0.0, '', [], {}, set() > > and n

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Andrew Berg
On 7/15/2012 11:19 AM, Ian Kelly wrote: > Ugh, that's irritating. I can't think of any scenario where I would > ever want the semantics "if timeval (is not midnight):". It's not implemented with such a test, but logging.handlers.TimedRotatingFileHandler has an option to rollover at midnight. -- C

Re: Implicit conversion to boolean in if and while statements

2012-07-16 Thread Andrew Berg
On 7/15/2012 9:38 PM, Steven D'Aprano wrote: >> I would expect None to mean "doesn't exist" or "unknown" or >> something like that - e.g., a value of 0 means 0 jelly beans in the jar >> and None means there isn't a jar. > > How you interpret some_variable = None depends on what some_variable > re

Re: Diagramming code

2012-07-16 Thread Andrew Cooper
ats $STATS | dot -T$TYPE -o $OUT > > doxygen is more useful for C++ but it's also able to infer a few things > (without running) from a python project.. +1 for doxygen. Combined with http://code.foosel.org/doxypy , it is a fully featured solution. I use it for all my projects, python and otherwise. ~Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Implicit conversion to boolean in if and while statements

2012-07-16 Thread Andrew Berg
On 7/15/2012 3:28 PM, Terry Reedy wrote: > Because everything does (or should). I can see how truth testing for empty values is convenient, but perhaps objects should only have a truth value if explicitly given one - particularly in cases where such a value wouldn't be obvious or the obvious value

Re: Implicit conversion to boolean in if and while statements

2012-07-16 Thread Andrew Berg
On 7/16/2012 7:43 PM, Steven D'Aprano wrote: > The existence of a jar or no jar is irrelevant to the question of how > many jellybeans there are. They are two different things, and therefore > need two different values. There are many ways to implement this. I have a better real example, but I op

Re: Implicit conversion to boolean in if and while statements

2012-07-16 Thread Andrew Berg
On 7/16/2012 11:11 PM, Steven D'Aprano wrote: > If you are right that SimpleNamespace should be treated as a container, > then it should implement container semantics. Since it doesn't, that is > either: > > 1) a bug; or > 2) a triumph of laziness over correctness > > I imagine though that the

Re: Implicit conversion to boolean in if and while statements

2012-07-16 Thread Andrew Berg
On 7/16/2012 11:39 PM, Steven D'Aprano wrote: > If you need three (or four, or fifty) > distinguishable states, then obviously boolean context will not solve > your problem. I never said it would. That is the impression I got from this statement: > How you interpret some_variable = None depends

Re: Implicit conversion to boolean in if and while statements

2012-07-17 Thread Andrew Berg
On 7/17/2012 2:08 AM, Steven D'Aprano wrote: > The default behaviour is that every object is something, hence true-like, > unless explicitly coded to be treated as false-like. Since both loggers > and functions are objects, they are true-like unless the default is > overridden. I am aware of the

Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Andrew Berg
On 7/17/2012 6:01 AM, Lipska the Kat wrote: > Anyway, I'm looking at Python as a rapid prototyping language. > I have an idea and just want to get it down in basic outline code as > quickly as possible before it departs my aging brain... I'm not used to > using variables without declaring their t

Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Andrew Berg
On 7/17/2012 6:44 AM, Lipska the Kat wrote: > I'll check it out, thanks. I forgot to add this: http://wiki.python.org/moin/Python2orPython3 It's a little outdated (there is more progress toward py3k by 3rd-party libraries every day), but still quite helpful. -- CPython 3.3.0b1 | Windows NT 6.1.76

Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Andrew Berg
On 7/17/2012 9:01 AM, Lipska the Kat wrote: > Wow, that was a blast from the past > Just downloaded, unzipped, untarred, configured, made and installed > python 3.2.3 ... it's YEARS since I've done this, makes me feel young again. Most Linux distributions should have a premade package for stable P

Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Andrew Berg
On 7/17/2012 12:30 PM, Terry Reedy wrote: > (In some ways, it is already better than 3.2.3.) I certainly make heavy use of some of the new features. I'm not sure we can have enough separate exceptions for OS errors without exhausting every possibility and I might start looking for excuses to use th

Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Andrew Cooper
ake for example a Linux system call handler. The general form looks a little like (substituting C for python style pseudocode) if not (you are permitted to do this): return -EPERM if not (you've given me some valid data): return -EFAULT if not (you've given me some sensible data): return -EINVAL return actually_try_to_do_something_with(data) How would you program this sort of logic with a single return statement? This is very common logic for all routines for which there is even the remotest possibility that some data has come from an untrusted source. ~Andrew P.S. like the sig. -- http://mail.python.org/mailman/listinfo/python-list

Re: Encapsulation, inheritance and polymorphism

2012-07-18 Thread Andrew Berg
On 7/18/2012 9:34 AM, Grant Edwards wrote: > people who us tabs are wrong Don't make me get my flamethrower! > and people who mix spaces and tabs -- well, we don't > talk about them in polite company. Mixing can make sense, but not in Python. *hides* -- CPython 3.3.0b1 | Windows NT 6.1.7601.1780

Re: Basic question about speed/coding style/memory

2012-07-21 Thread Andrew Berg
On 7/21/2012 2:33 AM, Jan Riechers wrote: > Block > ... > versus this block: > ... > Now, very briefly, what is the better way to proceed in terms of > execution speed, readability, coding style? Using if/else is the most readable in the general sense. Using return (or break or continue as applica

Re: Basic question about speed/coding style/memory

2012-07-21 Thread Andrew Berg
On 7/21/2012 3:13 AM, Jan Riechers wrote: > Cause, as I understand the interpreter chooses either the "else" (1st > block) or just proceeds with following code outside the if. If none of the if/elif statements evaluate to something true, the else block is executed. > So if there is some overhead

Re: Sudden doubling of nearly all messages

2012-07-21 Thread Andrew Berg
On 7/21/2012 5:48 AM, Dave Angel wrote: > Has anybody else noticed the sudden double-posting of nearly all > messages in the python mailing list? I am also using the mailing list, but I haven't experienced this. -- CPython 3.3.0b1 | Windows NT 6.1.7601.17803 -- http://mail.python.org/mailman/list

Re: My first ever Python program, comments welcome

2012-07-22 Thread Andrew Berg
On 7/22/2012 3:37 AM, Lipska the Kat wrote: > Many in > the Linux world seem to use git. Seeing as I've been using Linux at home > since the early days of slackware I suppose I'd better look into it. There are Mercurial (aka Hg) and Bazaar as well for DVCS. AFAIK, git, Mercurial, and Bazaar are a

Re: What's wrong with this code?

2012-07-23 Thread Andrew Cooper
bsequently changed x) Python is a statically scoped language, whereas the functionality you are expecting would be an example of dynamically scoped. Care to reveal your programming background? ~Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: catch UnicodeDecodeError

2012-07-25 Thread Andrew Berg
On 7/25/2012 6:05 AM, [email protected] wrote: > What I really want to do is use something like > > try: > # open file, read line, or do something else, I don't care > except UnicodeDecodeError: > sys.exit("Found a bad char in file " + file + " line " + str(line_number) > > Yet, n

Re: OT: Text editors (was Re: Search and replace text in XML file?)

2012-07-29 Thread Andrew Cooper
ws, various *NIXes, GUIs and terminals, having a common text editor across all is fantastically useful. ~Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python a commercial proposition ?

2012-07-29 Thread Andrew Cooper
der version" to "set up a pool of 4 servers, kill the master server (by removing its power), and verify that the remaining 3 fail over and one gets promoted to master" ~Andrew > > I hope this is an acceptable question for this group > > Many thanks > > Lipska > -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python a commercial proposition ?

2012-07-29 Thread Andrew Berg
On 7/29/2012 7:12 PM, Rodrick Brown wrote: > Python is a glue language much like Perl was 10 years ago. Until the > GIL is fixed I doubt anyone will seriously look at Python as an option > for large enterprise standalone application development. The GIL is neither a bug to be fixed nor an inherent

Firefox 3.6 [OT] (was: Re: [ANN] pyknon: Simple Python library to generate music in a hacker friendly way.)

2012-07-31 Thread Andrew Berg
On 7/30/2012 9:25 PM, Steven D'Aprano wrote: > I don't. But in my experience, the risk of security breaches is *much* > less than the chance that the new version will break functionality, > introduce bugs, have a worse user interface, and generally be a step > backwards rather than forward. 4.0

Re: Intermediate Python user needed help

2012-08-05 Thread Andrew Berg
On 8/5/2012 2:51 PM, John Mordecai Dildy wrote: > print "We'd have %d beans, %d jars, and %d crabapples." % > secret_formula(start_pont > sentence = "All good things come to those who wait." You are missing a parenthesis at the end of the previous line. > .print_first_word(sorted_words) That dot

Re: Is there a clever way to pass arguments

2012-08-08 Thread Andrew Cooper
uments in a single statement knowing that > each argument is a sequential index from a list? > I cannot change the function definition. > > Thanks, > Bruce > testData(*z) assuming that there are exactly 8 entries in z see http://docs.python.org/dev/tutorial/controlflow.html

Re: save dictionary to a file without brackets.

2012-08-09 Thread Andrew Cooper
. > Sligtly off topic, but looking up a value in a dictionary is actually O(n) for all other entries in the dict which suffer a hash collision with the searched entry. True, a sensible choice of hash function will reduce n to 1 in common cases, but it becomes an important consideration for large

Re: save dictionary to a file without brackets.

2012-08-09 Thread Andrew Cooper
On 09/08/2012 23:26, Dave Angel wrote: > On 08/09/2012 06:03 PM, Andrew Cooper wrote: >> On 09/08/2012 22:34, Roman Vashkevich wrote: >>> Actually, they are different. >>> Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred >>> thousand entri

Re: OT: Monty Python in Syria

2012-08-15 Thread Andrew Cooper
post > > agreed. > >> and what gives you the right >> to determine what is or is not on topic here? > > The same right as anyone. > >> The subject is also >> clearly marked OT or did that escape your attention? > > But it has nothing to do with M

Re: OT: Monty Python in Syria

2012-08-15 Thread Andrew Cooper
On 16/08/2012 01:52, Andrew Cooper wrote: > On 16/08/2012 01:01, Terry Reedy wrote: >> On 8/15/2012 6:07 PM, Mark Lawrence wrote: >>> On 15/08/2012 20:15, Tamer Higazi wrote: >>>> Exactly! >>>> NOT PROGRAMMING related has NOTHING TODO HERE! >>>

Re: How to tell people to ask questions the smart way

2012-09-05 Thread Andrew Artajos
Stack Overflow has a nice guideline on how to ask a question. http://stackoverflow.com/questions/ask/advice? -- -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing strings from the back?

2012-09-05 Thread Andrew Artajos
a random idea: you could compare strings by their hashes.. print hash("randomstring") == hash("randomstring") print hash("randomstring") == hash("randoMstring") -- -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for an IPC solution

2012-09-09 Thread Andrew Cooper
>> >> >> -- >> >> >> >> DaveA > > From my OS development experience, there are two sizes of pages - 4K and 1 > byte > No - pages are always 4k (or bigger given superpage support). You are probably thinking about the granularity bit in descriptor entries, which is relevant for segmentation. The granularity bit changes the limit between 1 byte or 4K chunks, as there are only 20 bits of limit space in a 32bit {L,G}DT entry. However, in the modern days of paging, segmentation support is only for legacy compatibility. ~Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Which Version of Python?

2012-09-11 Thread Andrew Berg
On 2012.09.11 19:17, Peter wrote: > If your desire is to "learn" Python then I would stick to 2.7 > > My reasoning would be that there are still a significant number of packages > that have not been ported to 3.x (and may never be ported). This is true, but the /potential/ for the need for one of

Re: portable way of locating an executable (like which)

2012-09-20 Thread Andrew Berg
On 2012.09.20 21:31, Dave Angel wrote: > I don't have a Windows machine set up right now, but I believe there are > two more directories to search, besides the ones described in the PATH > variable. > > One is the current directory, and the other is the Windows directory > (maybe also the xxx/syst

Re: Functional way to compare things inside a list

2012-09-22 Thread Andrew Berg
On 2012.09.22 02:08, Jamie Paul Griffin wrote: > I find this intriguing, I had no idea bots existed to post to mailing > lists in this way. What's the point of them? To amuse their owners is my guess. -- CPython 3.3.0rc2 | Windows NT 6.1.7601.17835 -- http://mail.python.org/mailman/listinfo/pyth

Re: EOL for Python 3.2?

2012-09-29 Thread Andrew Berg
On 2012.09.29 15:03, David Dillard wrote: > With the release of Python 3.3.0 does that mean the 3.2.x line is now end of > life? No. Old releases get security fixes for years. > I've looked for some sort of end of life policy on python.org, but was unable > to find one. http://www.python.org/dow

Re: Coexistence of Python 2.x and 3.x on same OS

2012-09-30 Thread Andrew Berg
On 2012.09.30 14:14, Edward Diener wrote: > The situation is so confusing on Windows, where the file associations, > registry entries, and other internal software which allows a given > Python release to work properly when invoking Python is so complicated, > that I have given up on trying to in

Re: Coexistence of Python 2.x and 3.x on same OS

2012-09-30 Thread Andrew Berg
On 2012.09.30 22:06, Edward Diener wrote: > The problem with that is that one has to already being using 3.3 to use > this facility. I was hoping for a solution which was backwards > compatible with Python 2.x. It's a separate tool that comes with 3.3. You can install 3.3 and never use the actual

Re: How to execute commands on a windows machine from a Linux machine

2012-10-03 Thread Andrew Berg
On 2012.10.04 00:13, Shambhu Rajak wrote: > Here i have two questions, > > 1. I want to write a framework for Linux machine that can execute > commands on windows machine: > > How to create a persistent shell between Linux and Windows machine. > > 2. I require to extract windows dis

Re: Is there a way to create kernel log messages via Python?

2012-10-16 Thread Andrew Cooper
he kernel log is the only form of logging, and the serial console is the only useful method of communication.) ~Andrew -- http://mail.python.org/mailman/listinfo/python-list

Interest in seeing sh.py in the stdlib

2012-10-20 Thread Andrew Moffat
ebian-main-i386/python-pbs_0.95-1_all.deb.html I'm interested in making sh.py more accessible to help bring Python forward in the area of shell scripting, so I'm interested in seeing if sh would be suitable for the standard library. Is there any other interest in something like this?

Re: Negative array indicies and slice()

2012-10-29 Thread Andrew Robinson
wrapper class that must be explicitly called. I'm thinking something like, PyListObject.__getitem__= lambda self, slice: --Andrew. -- http://mail.python.org/mailman/listinfo/python-list

Re: Negative array indicies and slice()

2012-10-29 Thread Andrew Robinson
quickly it constructs the result compared to a slice operation. Eg: a[1:5] vs. [ a[i] for i in xrange[1:5] ] But, unless it were grossly slower -- so that if/then logic and slices were generally faster -- I will use it. Thanks. --Andrew. -- http://mail.python.org/mailman/listinfo/python-list

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 signif

Re: I need help installing pypng in Python 3.3

2012-10-29 Thread Andrew Robinson
cript to do the same or better. If this interests you, I will see if I can post the py script; or email it to you. --Andrew. -- 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 06:39 AM, [email protected] 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: 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 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&#

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: 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 co

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: 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: 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*

Re: Negative array indicies and slice()

2012-10-30 Thread Andrew Robinson
On 10/29/2012 10:53 PM, Michael Torrie wrote: 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

Re: Negative array indicies and slice()

2012-10-30 Thread Andrew Robinson
On 10/29/2012 11:51 PM, Ian Kelly wrote: On Mon, Oct 29, 2012 at 4:39 PM, Andrew Robinson As above, you're looking at the compiler code, which is why you're finding things like "line" and "column". The tuple struct is defined in tupleobject.h and stores tuple e

Float to String "%.7e" - diff between Python-2.6 and Python-2.7

2012-10-30 Thread andrew . mackeith
e+02,2.096732151e+02,2.096732160+02] >>> for a in x: ... print ' %.9e%.7e'%(a,a) ... 2.096732130e+022.0967321e+02 2.096732140e+022.0967321e+02 2.096732150e+022.0967321e+02 <<<<<<<< 2.096732151e+022.0967322e+02 4.096732160e+004.

Re: Negative array indicies and slice()

2012-10-30 Thread Andrew Robinson
On 10/30/2012 11:02 AM, Ian Kelly wrote: On Tue, Oct 30, 2012 at 10:14 AM, Ethan Furman wrote: File a bug report? Looks like it's already been wontfixed back in 2006: http://bugs.python.org/issue1501180 Thanks, IAN, you've answered the first of my questions and have been a great help. (And y

Re: Negative array indicies and slice()

2012-10-30 Thread Andrew Robinson
On 10/30/2012 01:17 AM, Steven D'Aprano wrote: By the way Andrew, the timestamps on your emails appear to be off, or possibly the time zone. Your posts are allegedly arriving before the posts you reply to, at least according to my news client. :D -- yes, I know about that problem. Every t

Re: Negative array indicies and slice()

2012-10-30 Thread Andrew Robinson
On 10/30/2012 04:48 PM, Mark Lawrence wrote: On 30/10/2012 15:47, Andrew Robinson wrote: I would refer you to a book written by Steve Maguire, Writing Solid Code; Chapter 5; Candy machine interfaces. The book that took a right hammering here http://accu.org/index.php?module=bookreviews

RE: Negative array indicies and slice()

2012-10-30 Thread Andrew Robinson
s a __str__ issue vs. __repr__. >>> print( a[1:2] ) # Boy, I have to get used to the print's parenthesis range(3, 5, 2) So, the answer is *NOPE*. I guess I need to read the doc's all over again... it's ... well, quite different. --Andrew. -- http://mail.python.org/mailman/listinfo/python-list

Re: Negative array indicies and slice()

2012-10-31 Thread Andrew Robinson
On 10/30/2012 10:29 PM, Michael Torrie wrote: As this is the case, why this long discussion? If you are arguing for a change in Python to make it compatible with what this fork you are going to create will do, this has already been fairly thoroughly addressed earl on, and reasons why the semant

Re: Negative array indicies and slice()

2012-10-31 Thread Andrew Robinson
On 10/31/2012 02:20 PM, Ian Kelly wrote: On Wed, Oct 31, 2012 at 7:42 AM, Andrew Robinson wrote: Then; I'd note: The non-goofy purpose of slice is to hold three data values; They are either numbers or None. These *normally* encountered values can't create a memory lo

Re: Negative array indicies and slice()

2012-11-01 Thread Andrew Robinson
On 11/01/2012 07:12 AM, Ethan Furman wrote: Andrew Robinson wrote: On 10/31/2012 02:20 PM, Ian Kelly wrote: On Wed, Oct 31, 2012 at 7:42 AM, Andrew Robinson wrote: Then; I'd note: The non-goofy purpose of slice is to hold three data values; They are either numbers or None.

Re: Negative array indicies and slice()

2012-11-01 Thread Andrew Robinson
On 11/01/2012 12:07 PM, Ian Kelly wrote: On Thu, Nov 1, 2012 at 5:32 AM, Andrew Robinson wrote: H was that PEP the active state of Python, when Tim rejected the bug report? Yes. The PEP was accepted and committed in March 2006 for release in Python 2.5. The bug report is from June

Re: Negative array indicies and slice()

2012-11-02 Thread Andrew Robinson
Hi Ian, I apologize for trying your patience with the badly written code example. All objects were meant to be ThirdParty(), the demo was only to show how a slice() filter could have been applied for the reasons PEP357 made index() to exist. eg: because numpy items passed to __getitems__ via

Memory profiling: Python 3.2

2012-11-02 Thread Andrew Robinson
When Python3.2 is running, is there an easy way within Python to capture the *total* amount of heap space the program is actually using (eg:real memory)? And how much of that heap space is allocated to variables ( including re-capturable data not yet GC'd ) ? -- http://mail.python.org/mail

Fwd: Re: Negative array indicies and slice()

2012-11-03 Thread Andrew Robinson
Forwarded to python list: Original Message Subject:Re: Negative array indicies and slice() Date: Sat, 03 Nov 2012 15:32:04 -0700 From: Andrew Robinson Reply-To: [email protected] To: Ian Kelly <> On 11/01/2012 05:32 PM, Ian Kelly wrote:

Re: Multi-dimensional list initialization

2012-11-04 Thread Andrew Robinson
On 11/04/2012 10:27 PM, Demian Brecht wrote: So, here I was thinking "oh, this is a nice, easy way to initialize a 4D matrix" (running 2.7.3, non-core libs not allowed): m = [[None] * 4] * 4 The way to get what I was after was: m = [[None] * 4, [None] * 4, [None] * 4, [None * 4]] FYI: The b

Re: Multi-dimensional list initialization

2012-11-04 Thread Andrew Robinson
On 11/04/2012 11:27 PM, Chris Angelico wrote: On Mon, Nov 5, 2012 at 6:07 PM, Chris Rebert wrote: x = None x.a = 42 Traceback (most recent call last): File "", line 1, in AttributeError: 'NoneType' object has no attribute 'a' Python needs a YouGottaBeKiddingMeError for times when you do so

Re: Multi-dimensional list initialization

2012-11-05 Thread Andrew Robinson
On 11/05/2012 06:30 PM, Oscar Benjamin wrote: On 6 November 2012 02:01, Chris Angelico wrote: On Tue, Nov 6, 2012 at 12:32 PM, Oscar Benjamin wrote: I was just thinking to myself that it would be a hard thing to change because the list would need to know how to instantiate copies of all the

Re: Multi-dimensional list initialization

2012-11-06 Thread Andrew Robinson
On 11/05/2012 10:07 PM, Chris Angelico wrote: On Tue, Nov 6, 2012 at 4:51 PM, Andrew Robinson wrote: I really don't think doing a shallow copy of lists would break anyone's program. Well, it's a change, a semantic change. It's almost certainly going to break _something_.

Re: Multi-dimensional list initialization

2012-11-06 Thread Andrew Robinson
On 11/06/2012 06:35 AM, Oscar Benjamin wrote: > In general, people don't use element multiplication (that I have *ever* seen) to make lists where all elements of the outer most list point to the same sub-*list* by reference. The most common use of the multiplication is to fill an array with

Re: Multi-dimensional list initialization

2012-11-06 Thread Andrew Robinson
On 11/06/2012 09:32 AM, Prasad, Ramit wrote: Ian Kelly wrote: On Tue, Nov 6, 2012 at 1:21 AM, Andrew Robinson [snip] See if you can find *any* python program where people desired the multiplication to have the die effect that changing an object in one of the sub lists -- changes all the

Re: Multi-dimensional list initialization

2012-11-06 Thread Andrew Robinson
On 11/06/2012 01:19 AM, Ian Kelly wrote: On Tue, Nov 6, 2012 at 1:21 AM, Andrew Robinson If you nest it another time; [[[None]]]*4, the same would happen; all lists would be independent -- but the objects which aren't lists would be refrenced-- not copied. a=[[["alpha","be

Re: Multi-dimensional list initialization

2012-11-06 Thread Andrew Robinson
On 11/06/2012 01:04 AM, Steven D'Aprano wrote: On Mon, 05 Nov 2012 21:51:24 -0800, Andrew Robinson wrote: The most compact notation in programming really ought to reflect the most *commonly* desired operation. Otherwise, we're really just making people do extra typing for no reas

Re: Multi-dimensional list initialization

2012-11-07 Thread Andrew Robinson
Hi IAN! On 11/06/2012 03:52 PM, Ian Kelly wrote: On Tue, Nov 6, 2012 at 3:41 PM, Andrew Robinson The objection is not nonsense; you've merely misconstrued it. If [[1,2,3]] * 4 is expected to create a mutable matrix of 1s, 2s, and 3s, then one would expect [[{}]] * 4 to create a mutable m

Re: Multi-dimensional list initialization

2012-11-07 Thread Andrew Robinson
On 11/06/2012 05:55 PM, Steven D'Aprano wrote: On Tue, 06 Nov 2012 14:41:24 -0800, Andrew Robinson wrote: Yes. But this isn't going to cost any more time than figuring out whether or not the list multiplication is going to cause quirks, itself. Human psychology *tends* (it&#x

Re: Multi-dimensional list initialization

2012-11-07 Thread Andrew Robinson
On 11/06/2012 10:56 PM, Demian Brecht wrote: My question was *not* based on what I perceive to be intuitive (although most of this thread has now seemed to devolve into that and become more of a philosophical debate), but was based on what I thought may have been inconsistent behaviour (which w

Re: Right solution to unicode error?

2012-11-07 Thread Andrew Berg
On 2012.11.07 17:27, Oscar Benjamin wrote: > Are you using cmd.exe (standard Windows terminal)? If so, it does not > support unicode Actually, it does. Code page 65001 is UTF-8. I know that doesn't help the OP since Python versions below 3.3 don't support cp65001, but I think it's important to poin

<    1   2   3   4   5   6   7   8   9   10   >