Re: [Tutor] python list, right! but concretely?

2010-05-02 Thread spir
On Mon, 3 May 2010 00:50:40 +1000 Steven D'Aprano wrote: > On Sun, 2 May 2010 07:44:22 pm Lie Ryan wrote: > > > Python's 'list' is an array of pointers to `PyObject` ('object' in > > Python) and the resizing algorithm keeps the list size such that > > "allocated / 2 <= actual <= allocated". When

Re: [Tutor] python list, right! but concretely?

2010-05-03 Thread spir
On Mon, 3 May 2010 00:58:14 +0100 "Alan Gauld" wrote: > > "spir ☣" wrote > > > ...When writing "size = size + new_allocated" instead of > > "size = new_allocated", It get a growth pattern of: > >0 3 6 9 16 24 33 43 5

Re: [Tutor] Iterating through a list of strings

2010-05-03 Thread spir
On Mon, 03 May 2010 10:55:11 +0200 Stefan Behnel wrote: > Luke Paireepinart, 03.05.2010 10:27: > > On Mon, May 3, 2010 at 1:49 AM, Stefan Behnel wrote: > >> line = line.split('%', 1)[0] > > > > lines = [line[:line.index('%')] for line in ... > > Agreed that > > line = line[

Re: [Tutor] Iterating through a list of strings

2010-05-03 Thread spir
On Mon, 03 May 2010 13:08:18 +0200 Stefan Behnel wrote: > > Why aren't strings mutable, or lists immutable? > > What would be the use case of an immutable list, as opposed to a tuple? How > would you use mutable strings in a dictionary? [I'm not totally sure of the following, take it with so

Re: [Tutor] List comprehension + lambdas - strange behaviour

2010-05-06 Thread spir
On Thu, 06 May 2010 16:53:07 -0300 Ricardo Aráoz wrote: > So you see, your functions just return the value of x. That's because > the lambda have no parameter, so x refers to the global name x. In other words, the "upvalue" (the variable captured in the closure) is referenced. Meaning if you la

Re: [Tutor] List comprehension + lambdas - strange behaviour

2010-05-07 Thread spir
On Thu, 6 May 2010 22:15:34 +0100 "Alan Gauld" wrote: > As others have pointed out you are returning a reference not a value. Yes. (I have said that, too.) But still there is a mystery for me. Better explained byt the following: x = 0 ; print id(x) # an address def f() : print x # 0

Re: [Tutor] An interesting situation befalls me

2010-05-09 Thread spir
On Sun, 9 May 2010 13:43:50 +1000 Steven D'Aprano wrote: > http://inventwithpython.com Yep, this one is great! (I gave it a nickname: "play programming!" Is this correct english?) Denis vit esse estrany ☣ spir.wikidot.com __

Re: [Tutor] reading binary file on windows and linux

2010-05-09 Thread spir
On Sun, 9 May 2010 19:33:51 +0200 Jan Jansen wrote: > Hello, > > I've got some trouble reading binary files with struct.unpack on windows. > According to the documentation of the binary file's content, at the > beginning there're some simple bytes (labeled as 'UChar: 8-bit unsigned > byte'). Wit

Re: [Tutor] An interesting situation befalls me

2010-05-09 Thread spir
On Sun, 9 May 2010 13:43:50 +1000 Steven D'Aprano wrote: > Here's a counter-opinion: > > Dive Into Python must die! > http://oppugn.us/posts/1272050135.html I 100% share the article author's opinion. This "book" was surely crafted with the only intention to disgust anybody of programming. A sh

Re: [Tutor] Help required to count no of lines that are until 1000 characters

2010-05-11 Thread spir
On Tue, 11 May 2010 11:00:20 -0700 ramya natarajan wrote: > Hello, > > I am very beginner to programming, I got task to Write a loop that reads > each line of a file and counts the number of lines that are read until the > total length of the lines is 1,000 characters. I have to read lines fro

Re: [Tutor] (no subject)

2010-05-11 Thread spir
On Wed, 12 May 2010 00:35:27 -0500 Luke Paireepinart wrote: > I'd have rather you top-posted, then I wouldn't have wasted 30 seconds > scrolling past a bunch of irrelevant crap that I just gloss over > anyway. > If I want context I'll read the previous messages in the thread. > but that's just MH

Re: [Tutor] (no subject)

2010-05-12 Thread spir
On Wed, 12 May 2010 20:12:29 +1000 Steven D'Aprano wrote: > On Wed, 12 May 2010 03:35:27 pm Luke Paireepinart wrote: > > I'd have rather you top-posted, then I wouldn't have wasted 30 > > seconds scrolling past a bunch of irrelevant crap that I just gloss > > over anyway. > > If I want context I'

Re: [Tutor] First steps for C++/Qt developers

2010-05-12 Thread spir
On Wed, 12 May 2010 13:09:05 +0200 "M. Bashir Al-Noimi" wrote: > Hi All, > > This is my first post and I want to set a plan for learning python > syntax within 2 weeks. > > I'm C++/Qt desktop developer and I want to learn python for creating > rapid web applications so I read some articles ab

[Tutor] object structure

2010-05-12 Thread spir
Hello, Python objects are supposed to be mainly a structure composed of a (pointer to a) type and a (pointer to a) value; and to be more or less implemented that way in the C version. When an object is of a standard type like a number, the value field would then point to a C value, or rather

Re: [Tutor] First steps for C++/Qt developers

2010-05-12 Thread spir
On Wed, 12 May 2010 15:01:09 +0200 "M. Bashir Al-Noimi" wrote: > humm, you confused me I'm still a newbie and I don't know anything about > differences between C++ & python even I couldn't understand you. How C++ > is a static language !??!! Have a look at: http://en.wikipedia.org/wiki/Dynamic

Re: [Tutor] First steps for C++/Qt developers

2010-05-12 Thread spir
On Wed, 12 May 2010 16:12:55 +0200 "M. Bashir Al-Noimi" wrote: > Hi > > On 12/05/2010 02:52 م, spir ☣ wrote: > > On Wed, 12 May 2010 15:01:09 +0200 > > "M. Bashir Al-Noimi" wrote: > > > > > >> humm, you confused me I'm stil

Re: [Tutor] Character creator program

2010-05-12 Thread spir
On Wed, 12 May 2010 13:33:46 +0100 "Ben Millane" wrote: > Ok first off here is a link to my code > > http://pastie.org/956909 > > My problem is, that although I have the program working how I want it to work > in general. I still have an issue with the user input section. If my user > inputs

Re: [Tutor] raw_input a directory path

2010-05-12 Thread spir
On Wed, 12 May 2010 13:44:30 -0600 Spencer Parker wrote: > I have a search and replace script that I am having the user put in the > directory path as raw_input. The problem lies when I run the script it > doesn't pick that up for some reason. Is there an appropriate way to take a > directory p

Re: [Tutor] Design Question: File Object used everywhere

2010-05-14 Thread spir
On Fri, 14 May 2010 06:49:59 +0200 Jan Jansen wrote: > Hi there, > > I'm working on a code to read and write large amounts of binary data > according to a given specification. In the specification there are a lot > of "segments" defined. The segments in turn have defintions of datatypes > and

Re: [Tutor] PYTHON 3.1

2010-05-18 Thread spir
On Tue, 18 May 2010 14:53:45 +0100 Dipo Elegbede wrote: > I AM CURRENTLY LEARNING WITH PYTHON 3.0 > just about now, you are all blowing my minds. > this is great. Please don't write your replies on top. Write them instead just after the part(s) of the message you're replying to; and delete the

Re: [Tutor] what is wrong with this syntax?

2010-05-18 Thread spir
On Wed, 19 May 2010 01:23:55 +1000 Steven D'Aprano wrote: > On Tue, 18 May 2010 11:36:02 pm Dipo Elegbede wrote: > > ples help me figure out what is wrong with this syntax? > > > > > > print('Here are the numbers from 0 to 9') > > for i in the range(10): > > print(i) > > > > thank you. > > O

Re: [Tutor] 2d list index inverting?

2010-05-26 Thread spir
On Tue, 25 May 2010 21:47:19 -0400 Alex Hall wrote: > I thought so, but I was hoping you would not say that as this means a > logic bug deep in my code, and those are the hardest to track down... No, they're not. On the contrary. Logical bugs are easily diagnosed by printing out relevant values

Re: [Tutor] class methods: using class vars as args?

2010-05-27 Thread spir
On Sun, 23 May 2010 15:40:13 -0400 Alex Hall wrote: > Hello all, > I know Python reasonably well, but I still run into basic questions > which those over on the other python list request I post here instead. > I figure this would be one of them: > Why would this not work: > > class c(object): >

Re: [Tutor] list of dicts <-> dict of lists?

2010-05-28 Thread spir
On Thu, 27 May 2010 20:00:46 -0600 Matthew Wood wrote: > I THOUGHT the guaranteed same-ordering of dict.keys and dict.values started > in python 2.6. That was a simple mistake. > > It turns out, that's not the case. But in general, access to dicts and sets > is unordered, so you can't/don't/sh

Re: [Tutor] Homework Problem

2010-05-29 Thread spir
On Fri, 28 May 2010 19:11:13 -0400 "Shawn Blazer" wrote: > > This problem told me to use map and filter, so how would I use that to > solve it? [some piece of interactive session] > Thanks! So, where's the problem? Denis vit esse estrany ☣ spir.wikidot.com

[Tutor] SENTINEL, & more

2010-05-29 Thread spir
Hello, from the thread: "class methods: using class vars as args?" On Sat, 29 May 2010 11:01:10 +1000 Steven D'Aprano wrote: > On Fri, 28 May 2010 07:42:30 am Alex Hall wrote: > > Thanks for all the explanations, everyone. This does make sense, and > > I am now using the > > if(arg==None): arg

Re: [Tutor] SENTINEL, & more

2010-05-30 Thread spir
On Sun, 30 May 2010 00:36:24 +0200 Eike Welk wrote: > Hey Denis! > > I waited for a thread like this to appear, because I have a quirky, but IMHO > elegant, solution for those kinds of variables: > > class EnumMeta(type): > def __repr__(self): > return self.__name__ > > class

<    2   3   4   5   6   7