Re: [Tutor] Array slices in python with negative step

2010-01-11 Thread spir
On Mon, 11 Jan 2010 21:50:10 +0530 vishwajeet singh wrote: > Hello All, > > I am bit confuse how the slice works in case a negative step is supplied > a = 'abcde' > a[::-1] gives me edcba > > but [4:0:-1] gives me edcb > > while searching net I came accross something which said the following:

Re: [Tutor] Searching in a file

2010-01-14 Thread spir
On Wed, 13 Jan 2010 23:05:11 - "Alan Gauld" wrote: > But a third option is to use a split and apply it to the whole file as > a string thereby breaking the file into as many chunks as start with > a line containing 'NEW'... Why not simply a regex pattern starting with "NEW" and ending with '

Re: [Tutor] Keeping a list of attributes of a certain type

2010-01-14 Thread spir
On Wed, 13 Jan 2010 20:15:21 -0800 "Guilherme P. de Freitas" wrote: > Ok, I got something that seems to work for me. Any comments are welcome. > > > class Member(object): > def __init__(self): > pass > > > class Body(object): > def __init__(self): > self.members = [] >

Re: [Tutor] Html entities, beautiful soup and unicode

2010-01-19 Thread spir
On Tue, 19 Jan 2010 08:49:27 +0100 andy wrote: > Hi people > > I'm using beautiful soup to rip the uk headlines from the uk bbc page. > This works rather well but there is the problem of html entities which > appear in the xml feed. > Is there an elegant/simple way to convert them into the "stan

Re: [Tutor] combinatorics problem: assembling array

2010-01-21 Thread spir
On Thu, 21 Jan 2010 10:06:40 +0100 markus kossner wrote: > Dear Pythonics, > I have a rather algorithmic problem that obviously made a knot in my brain: > > Assume we have to build up all the arrays that are possible if we have a > nested array > containing an array of integers that are allowed

Re: [Tutor] Is it pythonesque

2010-01-25 Thread spir
On Sun, 24 Jan 2010 11:13:37 -0500 "Robert Berman" wrote: > Good morning, > > > > Given the following code snippets: > > > > def getuserinput(): > > while True: > > s1 = raw_input('Enter fraction as N,D or 0,0 to exit>>') > > delim = s1.find(',') > > if del

Re: [Tutor] The magic parentheses

2010-01-25 Thread spir
On Mon, 25 Jan 2010 01:06:45 - "Alan Gauld" wrote: > > "Lie Ryan" wrote > > >> and used print, I thought they would be considered the same whether as > >> a variable, or as a direct line, guess not. > > what is equivalent: > > print (a, b, c) > > > > and > > x = a, b, c > > print x > >

[Tutor] get (x)range borders

2010-01-28 Thread spir
Hello, Is there a way to retrieve an (x)range's borders? (Eg if I want to print out "m..n" instead of "xrange(m, n)".) Denis la vita e estrany http://spir.wikidot.com/ ___ Tutor maillist - Tutor@python.org To unsubsc

Re: [Tutor] get (x)range borders

2010-01-28 Thread spir
On Thu, 28 Jan 2010 13:37:28 +0100 Alan Plum wrote: > You mean like this? > > >>> m = 20 > >>> n = 30 > >>> a = xrange(m, n) > >>> a > xrange(20, 30) > >>> a[0] > 20 > >>> a[-1] > 29 !!! Did not even think at that (looked for attributes of xrange instances). Thank you. Denis

[Tutor] hash value input

2010-01-29 Thread spir
Hello, What actually is hashed when a data item is used a dict key? If possible, I would also like some clues on the method used to produce the hash value. (Maybe a pointer to the the relevant part of the python source, if clear and/or commented.) The reason why I ask is the well known limitat

Re: [Tutor] hash value input

2010-01-30 Thread spir
On Fri, 29 Jan 2010 08:23:37 -0800 Emile van Sebille wrote: > > So, how does python do this? > > > > Start here... > > http://effbot.org/zone/python-hash.htm Great, thank you! From the above pointed page: === For ordinary integers, the hash value is simply the integer itself (unless it’

Re: [Tutor] Problem creating a search

2010-01-31 Thread spir
On Sat, 30 Jan 2010 19:45:04 -0600 Luke Paireepinart wrote: > The key here is the "for line in infile" will not keep the whole file in > memory ... provided the file is structured in lines. (Also, the searched term should not be nore hold a newline). Denis la

Re: [Tutor] parse text file

2010-02-01 Thread spir
On Mon, 1 Feb 2010 00:43:59 +0100 Norman Khine wrote: > but this does not take into account of data which has negative values just add \-? in front of \d+ Denis la vita e estrany http://spir.wikidot.com/ ___ Tutor ma

Re: [Tutor] parse text file

2010-02-02 Thread spir
On Mon, 1 Feb 2010 16:30:02 +0100 Norman Khine wrote: > On Mon, Feb 1, 2010 at 1:19 PM, Kent Johnson wrote: > > On Mon, Feb 1, 2010 at 6:29 AM, Norman Khine wrote: > > > >> thanks, what about the whitespace problem? > > > > \s* will match any amount of whitespace includin newlines. > > thank y

Re: [Tutor] parse text file

2010-02-03 Thread spir
On Tue, 2 Feb 2010 22:56:22 +0100 Norman Khine wrote: > i am no expert, but there seems to be a bigger difference. > > with repr(), i get: > Sat\\xe9re Maw\\xe9 > > where as you get > > Sat\xc3\xa9re Maw\xc3\xa9 > > repr()'s > é == \\xe9 > whereas on your version > é == \xc3\xa9 This is a ra

Re: [Tutor] help with random.randint

2010-02-03 Thread spir
On Wed, 03 Feb 2010 11:21:56 +0800 David wrote: > Hello list, > > I thought this was easy even for me, but I was wrong, I guess. > Here is what I want to do: take two random numbers between 1 and 99, and > put them into a list. > > import random > terms = [] > for i in range(2): > terms

Re: [Tutor] help with random.randint (cont. -- now: pseudo code)

2010-02-03 Thread spir
On Wed, 03 Feb 2010 14:12:42 +0800 David wrote: > Hello Benno, list, > > thanks for those clarifications, which, well, clarify things ;-) > > This is my latest creation: > > import random > > def createTerms(): > terms = [] > for i in range(2): > terms.append(random.randin

Re: [Tutor] language aid

2010-02-04 Thread spir
On Thu, 4 Feb 2010 07:39:29 -0800 (PST) Albert-Jan Roskam wrote: > Hi, >   > A dictionary (associative array of keys and values) seems a good datatype to > use. > vocab = {} > vocab[frenchword] = englishword >   > For instance: > >>> vocab = {"aimer": "love"} > >>> vocab > {'aimer': 'love'} > >>

Re: [Tutor] language aid

2010-02-04 Thread spir
On Thu, 04 Feb 2010 16:11:33 + Owain Clarke wrote: > But if one word has different meanings in the other language, you may need to > use a list of words as the values. ? You can have a more sophisticated structure for you dict. For instance, "love" is both a noun and a verb, and each has

Re: [Tutor] correcting an Active State Recipe for conversion to ordinal

2010-02-04 Thread spir
On Thu, 4 Feb 2010 12:11:24 -0500 Serdar Tumgoren wrote: > Hi folks, > > A few months back I posted my first (and only) "recipe" to > ActiveState. It was just a little function to convert an integer or > its string representation to an ordinal value: 1 to 1st, 2 to 2nd, > etc. > > Not sure if t

Re: [Tutor] language aid

2010-02-04 Thread spir
On Thu, 04 Feb 2010 16:11:33 + Owain Clarke wrote: > But if one word has different meanings in the other language, you may need to > use a list of words as the values. ? You can have a more sophisticated structure for you dict. For instance, "love" is both a noun and a verb, and each has

Re: [Tutor] language aid (various)

2010-02-06 Thread spir
On Fri, 05 Feb 2010 11:29:30 + Owain Clarke wrote: > On Thu, Feb 4, 2010 at 5:43 AM, Owain Clarke wrote: > > > >> My question is, that if I proceed like this I will end up with a single > >> list > >> of potentially several hundred strings of the form "frword:engword". In > >> terms of p

Re: [Tutor] "else:" triggering a Syntax Error

2010-02-06 Thread spir
On Sat, 6 Feb 2010 20:18:53 +0900 Benno Lang wrote: > > if ((self.start_dot.x > self.end_dot.x) and (self.start_dot.y != > > self.end_dot.y)): > (1) Are you sure you want all those superfluous parentheses? @ Benno: I do not find the _inner_ ones superfluous at all... @ Stijn: When you ask abo

[Tutor] why inline-only string literals?

2010-02-07 Thread spir
Hello, I recently wrote a parser for a (game scripting) language in which ordinary strings inside quotes can hold (literal) newlines: s = "Hello, how do you do?" So, I wonder why most languages do not allow that from scratch; and some, like python, need a special syntax for multi-line strings.

Re: [Tutor] Variable: From input and output

2010-02-07 Thread spir
On Fri, 5 Feb 2010 14:14:49 -0800 (PST) ssiverling wrote: > > Greetings, > > Thanks, and I will try and not to toppost. You just did it right now ;-) Also, a good practice is to cut out irrelevant parts of previous massage(s) in thread. Both work together to make threads fast/easy/pleasant t

Re: [Tutor] why inline-only string literals?

2010-02-08 Thread spir
[sorry, Steve, first replied to sender instead of list] On Sun, 7 Feb 2010 09:54:12 -0800 Steve Willoughby wrote: > I believe it's a deliberate design decision, [...] > So by making you explicitly state when you wanted multi-line strings, > it makes it easier to spot this common mistake as well

Re: [Tutor] string to list

2010-02-10 Thread spir
On Wed, 10 Feb 2010 11:26:25 + Owain Clarke wrote: > Please excuse the obviousness of my question (if it is), but I have > searched the documentation for how to generate a list e.g. [(1,2), > (3,4)] from a string "[(1,2), (3,4)]". I wonder if someone could point > me in the right direction

Re: [Tutor] Simple Stats on Apache Logs

2010-02-11 Thread spir
On Thu, 11 Feb 2010 09:56:51 + Lao Mao wrote: > Hi, > > I have 3 servers which generate about 2G of webserver logfiles in a day. > These are available on my machine over NFS. > > I would like to draw up some stats which shows, for a given keyword, how > many times it appears in the logs, pe

tutor@python.org

2010-02-13 Thread spir
On Sat, 13 Feb 2010 13:58:34 -0500 David Abbott wrote: > I am attempting to understand this little program that converts a > network byte order 32-bit integer to a dotted quad ip address. > > #!/usr/bin/python > # Filename : int2ip.py > > MAX_IP = 0xL > ip = 2130706433 > > def int2ip(l

tutor@python.org

2010-02-13 Thread spir
On Sat, 13 Feb 2010 23:17:27 +0100 spir wrote: > On Sat, 13 Feb 2010 13:58:34 -0500 > David Abbott wrote: > > > I am attempting to understand this little program that converts a > > network byte order 32-bit integer to a dotted quad ip address. > > > >

Re: [Tutor] file exception & behaviour (was: Getting caller name...)

2010-02-14 Thread spir
On Sun, 14 Feb 2010 12:33:09 +0100 patrice laporte wrote: > 2010/2/13 Luke Paireepinart > > > > > > > On Sat, Feb 13, 2010 at 9:56 AM, patrice laporte > > wrote: > > > >> > >> Hi, > >> > >> Being in an exeption of my own, I want to print the name of the caller, > >> and I'm looking for a way t

tutor@python.org

2010-02-14 Thread spir
Just reviewed this post and wonder whether the explanation is clear for anyone else as myself ;-) Denis On Sat, 13 Feb 2010 23:17:27 +0100 spir wrote: > On Sat, 13 Feb 2010 13:58:34 -0500 > David Abbott wrote: > > > I am attempting to understand this little program

tutor@python.org

2010-02-14 Thread spir
On Sun, 14 Feb 2010 09:16:18 - "Alan Gauld" wrote: > In the case in point the & 255 keeps the coding style consistent > and provides an extra measure of protection against unexpected > oddities so I would keep it in there. You're right on that, Kent. My comment was rather wrong. Especially

[Tutor] pure symbol -- __subtype__

2010-02-18 Thread spir
Hello, I was lately implementing a kind of "pure symbol" type. What I call pure symbols is these kinds of constants that refer to pure "idea", so that they have no real obvious value. We usually _arbitrarily_ give them as value an int, a string, a boolean, an empty object: BLACK, WHITE = Fal

Re: [Tutor] pure symbol -- __subtype__

2010-02-18 Thread spir
PS: see also on the topic: http://en.wikipedia.org/wiki/Enumerated_type On Thu, 18 Feb 2010 10:13:33 +0100 spir wrote: > Hello, > > I was lately implementing a kind of "pure symbol" type. What I call pure > symbols is these kinds of constants that refer to pure "ide

Re: [Tutor] Python and algorithms

2010-02-19 Thread spir
On Thu, 18 Feb 2010 09:11:22 -0500 Kent Johnson wrote: > It's true that solving a problem often involves creating an algorithm > in a broad sense. The formal study of algorithms studies specific > techniques and algorithms that have proven to be useful to solve many > hard problems. In my experie

Re: [Tutor] Replacing part of a URL

2010-02-20 Thread spir
On Sun, 21 Feb 2010 11:25:31 +1100 Steven D'Aprano wrote: > "Some people, when confronted with a problem, think 'I know, I'll use > regular expressions.' Now they have two problems." -- Jamie Zawinski ;-) la vita e estrany http://spir.wikidot.com/ ___

Re: [Tutor] Python file escaping issue?

2010-02-21 Thread spir
Just a little complement to Steven's excellent explanation: On Mon, 22 Feb 2010 10:01:06 +1100 Steven D'Aprano wrote: [...] > So if you write a pathname like this: > > >>> path = 'C:\datafile.txt' > >>> print path > C:\datafile.txt > >>> len(path) > 15 > > It *seems* to work, because \d i

Re: [Tutor] What Editori?

2010-02-23 Thread spir
On Tue, 23 Feb 2010 17:46:24 +0100 Giorgio wrote: > Definitely i just use pyscripter because it has the py idle integrated in > the window. > > It's very useful! Most editors have an integreated console that allow typing commands, launching the interactice interpreter, and running progs all wi

[Tutor] common (sub)attributes

2010-02-24 Thread spir
Hello, Just a really basic note: Classes are often used to hold common or default attribute. Then, some of these attrs may get custom values for individual objects of a given type. Simply by overriding the attr on this object (see code below). But this will not only if the attr is a top-level o

Re: [Tutor] Cannot open SQLite database

2010-02-24 Thread spir
On Wed, 24 Feb 2010 09:38:56 +0100 Timo wrote: > Hello all, my program uses SQLite as database and everything worked fine > until now. > I have over 3000 downloads of my program, but I got 2 mails this week > from people who get this error: > > OperationalError: unable to open database file >

Re: [Tutor] Top posters for 2009

2010-02-26 Thread spir
On Thu, 25 Feb 2010 21:53:24 -0500 Kent Johnson wrote: > 2009 (7730 posts, 709 posters) > > Alan Gauld 969 (12.5%) > Kent Johnson 804 (10.4%) > Dave Angel 254 (3.3%) > spir 254 (3.3%) > Wayne Watson 222 (2.9%) I hope Dave is as thin as I am (*). Denis (*) for us t

Re: [Tutor] Top posters for 2009

2010-02-26 Thread spir
On Fri, 26 Feb 2010 09:27:04 +0530 Shashwat Anand wrote: > @Kent: thanks for the script. It is kool. > > Here is 2010 list of Top-20 (as of now): > > 2010 (1155 posts, 204 posters) > > Alan Gauld 127 (11.0%) > Kent Johnson 108 (9.4%) > spir 52 (4.5%) >

Re: [Tutor] parsing a "chunked" text file

2010-03-02 Thread spir
On Mon, 1 Mar 2010 22:22:43 -0800 Andrew Fithian wrote: > Hi tutor, > > I have a large text file that has chunks of data like this: > > headerA n1 > line 1 > line 2 > ... > line n1 > headerB n2 > line 1 > line 2 > ... > line n2 > > Where each chunk is a header and the lines that follow it (up

Re: [Tutor] Why is the max size so low in this mail list?

2010-03-03 Thread spir
On Wed, 03 Mar 2010 02:38:57 +1100 Lie Ryan wrote: > On 03/02/2010 04:13 AM, Wayne Watson wrote: > > See Subject. 40K here, but other Python lists allow for larger (total) > > sizes. > > I don't know, I've never realized it; that's an indication that the 40K > limit is reasonable, at least to me

Re: [Tutor] Encoding

2010-03-03 Thread spir
On Wed, 3 Mar 2010 16:32:01 +0100 Giorgio wrote: > Uff, encoding is a very painful thing in programming. For sure, but it's true for any kind of data, not only text :-) Think at music or images *formats*. The issue is a bit obscured for text but the use of the mysterious, _cryptic_ (!), word "

Re: [Tutor] Encoding

2010-03-03 Thread spir
On Wed, 3 Mar 2010 20:44:51 +0100 Giorgio wrote: > Please let me post the third update O_o. You can forgot other 2, i'll put > them into this email. > > --- > >>> s = "ciao è ciao" > >>> print s > ciao è ciao > >>> s.encode('utf-8') > > Traceback (most recent call last): > File "", line 1, in

[Tutor] object representation

2010-03-03 Thread spir
Hello, In python like in most languages, I guess, objects (at least composite ones -- I don't know about ints, for instance -- someone knows?) are internally represented as associative arrays. Python associative arrays are dicts, which in turn are implemented as hash tables. Correct? Does this

Re: [Tutor] lazy? vs not lazy? and yielding

2010-03-04 Thread spir
On Wed, 03 Mar 2010 15:41:34 -0500 Dave Angel wrote: > John wrote: > > Hi, > > > > I just read a few pages of tutorial on list comprehenion and generator > > expression. From what I gather the difference is "[ ]" and "( )" at the > > ends, better memory usage and the something the tutorial lab

Re: [Tutor] Encoding

2010-03-04 Thread spir
On Thu, 4 Mar 2010 15:13:44 +0100 Giorgio wrote: > Thankyou. > > You have clarificated many things in those emails. Due to high numbers of > messages i won't quote everything. > > So, as i can clearly understand reading last spir's post, python gets > strings encoded by my editor and to convert

Re: [Tutor] lazy? vs not lazy? and yielding

2010-03-04 Thread spir
On Thu, 4 Mar 2010 21:57:18 +0100 Andreas Kostyrka wrote: I would rather write it: > x_it = iter(x) # get an iterator for x > try: > while True: >i = x_it.next() >print i > except StopIteration: > pass x_it = iter(x) # get an iterator for x while True: try:

Re: [Tutor] Instantiating a list of strings into a list of classes

2010-03-06 Thread spir
On Fri, 5 Mar 2010 17:38:08 -0800 Daryl V wrote: > I have a csv list of data, of the form: > plot, utmN83_X, utmN83_Y, plot_radius_m > Spring1,348545,3589235,13.2 > etc. [...] > What I want to do is use the first entry in that row (row[0]) as the > variable name for the instantiated class. Ther

[Tutor] recursive generator

2010-03-07 Thread spir
Hello, Is it possible at all to have a recursive generator? I think at a iterator for a recursive data structure (here, a trie). The following code does not work: it only yields a single value. Like if child.__iter__() were never called. def __iter__(self): ''' Iteration on (key,val

Re: [Tutor] Encoding

2010-03-07 Thread spir
On Sun, 7 Mar 2010 13:23:12 +0100 Giorgio wrote: > One more question: Amazon SimpleDB only accepts UTF8. [...] > filestream = file.read() > filetoput = filestream.encode('utf-8') No! What is the content of the file? Do you think it can be a pure python representation of a unicode text? uConten

[Tutor] __iter__: one obvious way to do it

2010-03-07 Thread spir
Hello, Below 6 working way to implement __iter__ for a container here simulated with a plain inner list. Sure, the example is a bit artificial ;-) 1. __iter__ returns a generator _expression_ 2. __iter__ *is* a generator 3. __iter__ returns a generator (this one is a bit weird, i guess) 4. __

[Tutor] __iter__: one obvious way to do it

2010-03-07 Thread spir
[sorry, forgot the code] Hello, Below 6 working way to implement __iter__ for a container here simulated with a plain inner list. Sure, the example is a bit artificial ;-) 1. __iter__ returns a generator _expression_ 2. __iter__ *is* a generator 3. __iter__ returns a generator (this one is a

Re: [Tutor] recursive generator

2010-03-07 Thread spir
On Sun, 7 Mar 2010 17:20:07 +0100 Hugo Arts wrote: > On Sun, Mar 7, 2010 at 1:58 PM, spir wrote: > > Hello, > > > > Is it possible at all to have a recursive generator? I think at a iterator > > for a recursive data structure (here, a trie). The following code

Re: [Tutor] Passing nested structures to fcntl.ioctl

2010-03-08 Thread spir
On Mon, 8 Mar 2010 11:57:35 +0530 (IST) "Noufal Ibrahim" wrote: > Hello everyone, > I have some code that's calling fcntl.ioctl. I need to pass a nested > structure as the 3rd argument of the function. Something like this > > typedef struct coordinates{ > int x; > int y; > } coordinates;

Re: [Tutor] Printing time without "if" statement

2010-03-08 Thread spir
On Mon, 8 Mar 2010 18:03:12 +1100 Steven D'Aprano wrote: > On Mon, 8 Mar 2010 03:38:49 pm Elisha Rosensweig wrote: > > Hi, > > > > I have an event-based simulator written in Python (of course). It > > takes a while to run, and I want to have messages printed every so > > often to the screen, indi

[Tutor] variable inheritance

2010-03-08 Thread spir
Hello, Say I have a Tree type that may be based on 2 kinds of Node-s. Both conceptually and practically, a tree itself is a node, namely the top/root one. But a tree also has some additional tree-level behaviour, which is independant of the kind of node. Say, the node type performs all the unde

Re: [Tutor] matching words from a text to keys in a dictionary

2010-03-08 Thread spir
On Mon, 8 Mar 2010 08:05:54 -0800 (PST) Karjer Jdfjdf wrote: > I want to compare words in a text to a dictionary with values attached to the > words. > > The dictionary  looks like: > { word1: [1,2,3] word2: [2,3,4,a,b ] ... } And how does your source text look like? (we have half of the data)

Re: [Tutor] Making Regular Expressions readable

2010-03-08 Thread spir
On Mon, 8 Mar 2010 16:12:35 + Stephen Nelson-Smith wrote: > Hi, > > I've written this today: > > #!/usr/bin/env python > import re > > pattern = > r'(?P^(-|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(, > [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})*){1}) > (?P(\S*)) (?P(\S*)) > (?P(

Re: [Tutor] for _ in

2010-03-09 Thread spir
On Tue, 9 Mar 2010 11:25:19 +0800 Joson wrote: > if labels is None: labels = [OrderedSet() for _ in xrange(ndim)] > .. > > It's a library named "divisi". "OrderedSet" is a string set defined in this > lib. "ndim" is integer. What's the meaning of "for _ in" ? > > Joson

[Tutor] use of __new__

2010-03-11 Thread spir
Hello, I need a custom unicode subtype (with additional methods). This will not be directly used by the user, instead it is just for internal purpose. I would like the type to be able to cope with either a byte str or a unicode str as argument. In the first case, it needs to be first decoded. I

Re: [Tutor] Problem with turtle

2010-03-11 Thread spir
On Thu, 11 Mar 2010 10:11:28 -0500 Marco Rompré wrote: > Hi! I am relatively new to python and turtle and I really need your help. > > Here what I wanted turtle to do: I created a function named carré which > would draw a square with 3 different parameters (color, size, angle). >

Re: [Tutor] use of __new__

2010-03-12 Thread spir
On Fri, 12 Mar 2010 12:27:02 +1100 Steven D'Aprano wrote: > On Fri, 12 Mar 2010 11:53:16 am Steven D'Aprano wrote: > > > I have tried to match the behaviour of the built-in unicode as close > > as I am able. See here: > > http://docs.python.org/library/functions.html#unicode > > And by doing so

[Tutor] %s %r with cutom type

2010-03-12 Thread spir
Hello again, A different issue. On the custom Unicode type discussed in another thread, I have overloaded __str__ and __repr__ to get encoded byte strings (here with debug prints & special formats to distinguish from builtin forms): class Unicode(unicode): ENCODING = "utf8" def __new__(

Re: [Tutor] Visual Python programming and decompilers?

2010-03-12 Thread spir
On Fri, 12 Mar 2010 10:19:39 +0200 Ludolph wrote: > Hi Guys > > I posted the following message on my local pug mailing list and > someone recommended I post it here. > > At work I have been exposed to a Agile Platform called OutSystems. It > allows you to visually program your web applications

Re: [Tutor] use of __new__

2010-03-12 Thread spir
On Fri, 12 Mar 2010 22:56:37 +1100 Steven D'Aprano wrote: > You might be tempted to change the first reference to Unicode to cls as > well, but sadly that does not work. The reason is complicated, and to > be honest I don't remember it, but you will probably find it by > googling for "python s

Re: [Tutor] %s %r with cutom type

2010-03-13 Thread spir
On Sat, 13 Mar 2010 13:50:55 +1100 Steven D'Aprano wrote: > On Fri, 12 Mar 2010 10:29:17 pm spir wrote: > > Hello again, > > > > A different issue. On the custom Unicode type discussed in another > > thread, I have overloaded __str__ and __repr__ to get encoded b

Re: [Tutor] Proper way to use **kwargs?

2010-03-15 Thread spir
On Mon, 15 Mar 2010 05:38:43 -0700 (PDT) Karjer Jdfjdf wrote: > I want to use **kwargs to check a list of conditions (if true do this, if > false do nothing) besides required parameters ( in sample a and b).  > Sometimes I want to add a Python object (in example a dictionary and a list). > Bel

Re: [Tutor] module.class.method in logging.debug

2010-03-15 Thread spir
On Mon, 15 Mar 2010 13:26:27 -0400 Brian Jones wrote: > I tried a couple of things I could think of, and successfully got the module > and class without issue, but the one missing piece was the method name. All methods and funcs (and types) have a __name__ attr. from types import FunctionType a

Re: [Tutor] Self-intro and two short newbie questions

2010-03-18 Thread spir
On Thu, 18 Mar 2010 22:42:05 +1100 Kevin Kirton wrote: > My questions are: how long would you estimate it to take and how > complicated would it be to create the following as Python programs? (I > know it varies depending on the person, but for example, how long > would it take _you_?) My opinio

Re: [Tutor] Misc question about scoping

2010-06-03 Thread spir
On Thu, 3 Jun 2010 11:50:42 -0400 Tino Dai wrote: > Hi All, > > Is there a way to express this: > isThumbnail = False > if size == "thumbnail": > isThumbnail = True > > like this: > [ isThumbnail = True if size == "thumbnail" isThumbnail = False ] > and the sc

Re: [Tutor] sockets, servers, clients, broadcasts...?

2010-06-04 Thread spir
On Thu, 3 Jun 2010 18:03:34 -0400 Alex Hall wrote: > Hi all, > I am a CS major, so I have had the required networking class. I get > the principles of networking, sockets, and packets, but I have never > had to actually implement any such principles in any program. Now I > have this Battleship ga

Re: [Tutor] Misc question about scoping

2010-06-04 Thread spir
On Fri, 4 Jun 2010 12:26:20 -0400 Tino Dai wrote: > Also could you give me some instances > where a generator > would be used in a real situation? I have already read the stuff on > doc.python.org about > generators. Sure, generally speaking in the programming world, documentation misses the fi

Re: [Tutor] treeTraversal, nested return?

2010-06-04 Thread spir
On Fri, 4 Jun 2010 10:15:26 -0700 (PDT) jjcr...@uw.edu wrote: > All, > > any observations might be helpful. For the display of database contents I > have the following problem: > > Database querys will return data to me in tuples of the following sort: > each tuple has a unique id, a parent id,

[Tutor] Lisphon

2010-06-04 Thread spir
On Fri, 4 Jun 2010 22:33:19 +0200 Hugo Arts wrote: > On Fri, Jun 4, 2010 at 6:26 PM, Tino Dai wrote: > > > > LOL, it's actually on the list of things to do. And hear that one will > > become a > > better programmer once they learn LISP. > > > > I most certainly did. There are very few language

Re: [Tutor] Simple PassGen

2009-02-10 Thread spir
Le Tue, 10 Feb 2009 10:26:54 -0500, pyt...@bdurham.com a écrit : > IDLE 2.6.1 > >>> from __future__ import print_function > >>> print( 3, 4 ) > 3 4 lol! -- la vida e estranya ___ Tutor maillist - Tutor@python.org http://mail.python.org/ma

Re: [Tutor] Inserting special characters into urlencoded string

2009-02-10 Thread spir
Le Tue, 10 Feb 2009 18:08:26 +0100, pa yo a écrit : > Novice programmer here. > > I am using urllib.urlencode to post content to a web page: > > ... > >>Title = "First Steps" > >>Text = "Hello World." > >>Username = "Payo2000" > >>Content = Text + "From: " + Username > >>SubmitText = urllib.url

Re: [Tutor] Reply All Dilemma of This List

2009-02-10 Thread spir
Le Tue, 10 Feb 2009 12:20:51 -0500, Brian Mathis a écrit : > This war has been raging since the dawn of mailing lists, and you're > not likely to get a resolution now either. Newer mail user agents have a "to list" reply button. End of war? -- la vida e estranya

Re: [Tutor] Keeping Dictonary Entries Ordered

2009-02-12 Thread spir
Le Thu, 12 Feb 2009 09:25:22 -, "Alan Gauld" a écrit : > > config_names = {"start_time : '18:00:00', 'gray_scale' : True, > > "long": 120.00} > > > > If I iterate over it, the entries will appear in any order, as > > opposed to > > what I see above. However, in the config file, I'd like to

Re: [Tutor] Keeping Dictonary Entries Ordered

2009-02-13 Thread spir
Le Fri, 13 Feb 2009 15:41:01 +1300, John Fouhy a écrit : > 2009/2/13 Eric Dorsey : > > Alan, can you give a short snippet of what that would look like? I was > > trying to code out some idea of how you'd retain insertion order using > > another dict or a list and didn't get anywhere. > > Here's

Re: [Tutor] exec "self.abc=22" ?

2009-02-16 Thread spir
Le Mon, 16 Feb 2009 12:01:24 -0800, Marc Tompkins a écrit : > On Mon, Feb 16, 2009 at 11:58 AM, Wayne Watson > wrote: > > > Python doesn't like the code in the Subject (unqualified exec not allowed > > in function). but easily likes self.abc="22". However, I'd like to assemble > > the assignme

Re: [Tutor] Add readline capabilities to a Python build 2.6 on Ubuntu

2009-02-17 Thread spir
Le Mon, 16 Feb 2009 22:34:23 -0700, Eric Dorsey a écrit : > Greetings Tutor: > I've managed to install Python 2.6 on my Ubuntu VM from source, however, it > looks as though I missed something important along the way. My 2.6 > interpreter does not have readline support (example: I cant hit up arr

Re: [Tutor] Proxies/Interceptors for file-like objects

2009-02-19 Thread spir
Le Wed, 18 Feb 2009 22:01:34 -0500, Kent Johnson s'exprima ainsi: > Hmm. I guess this is Python 3? In 2.6, open is a function and trying > to subclass it gives an error: > > In [10]: open > Out[10]: > > In [11]: class myopen(open): pass > >: > > TypeError: Error when calling the meta

Re: [Tutor] Standardizing on Unicode and utf8

2009-02-20 Thread spir
Le Fri, 20 Feb 2009 02:52:27 -0800, "Dinesh B Vadhia" s'exprima ainsi: > We want to standardize on unicode and utf8 and would like to clarify and > verify their use to minimize encode()/decode()'ing: > > 1. Python source files > Use the header: # -*- coding: utf8 -*- You don't even need fancy

Re: [Tutor] Default list arguments in __init__

2009-02-21 Thread spir
Le Sat, 21 Feb 2009 11:38:49 -0800, Moos Heintzen s'exprima ainsi: > Hi, > > This behavior was totally unexpected. I only caught it because it was > the only thing I changed. > > >>> class foo: > ... def __init__(self, lst=[]): > ... self.items = lst > ... > >>> f1 = foo() >

Re: [Tutor] calling user defined function

2009-02-22 Thread spir
Le Sun, 22 Feb 2009 22:21:22 +0100, roberto s'exprima ainsi: > hello > i have a question which i didn't solved yet: > i can define a function using the text editor provided by IDLE 3.0; > then i'd like to call this function from the python prompt > > but when i try to do it, python warns me that

Re: [Tutor] regex help

2009-02-23 Thread spir
Le Mon, 23 Feb 2009 06:45:23 -0500, Kent Johnson s'exprima ainsi: > On Sun, Feb 22, 2009 at 10:49 PM, ish_ling wrote: > > I have a string: > > > >'a b c h' > > > > I would like a regex to recursively match all alpha letters that are > > between . That is, I would like the following list of >

Re: [Tutor] create dictionary from csv data

2009-02-23 Thread spir
Le Mon, 23 Feb 2009 14:41:10 +0100, Norman Khine s'exprima ainsi: > Hello, > > I have this csv file: > > $ cat licences.csv > "1","Air Travel Organisation Licence (ATOL)\n Operates Inclusive Tours (IT)" > "2","Air Travel Organisation Licence (ATOL)\n Appointed Agents of IATA > (IATA)" > "3", "

Re: [Tutor] using re to build dictionary

2009-02-24 Thread spir
Le Tue, 24 Feb 2009 12:48:51 +0100, Norman Khine s'exprima ainsi: > Hello, > From my previous post on create dictionary from csv, i have broken the > problem further and wanted the lists feedback if it could be done better: > > >>> s = 'Association of British Travel Agents (ABTA) No. 56542\nA

Re: [Tutor] Accessing callers context from callee method

2009-02-24 Thread spir
Le Tue, 24 Feb 2009 10:53:29 -0800, mobiledream...@gmail.com s'exprima ainsi: > when i call a method foo from another method func. can i access func context > variables or locals() from foo > so > def func(): > i=10 > foo() > > in foo, can i access func's local variables on in this case i > T

Re: [Tutor] Passing perimeters in dictionary values?

2009-02-24 Thread spir
Le Tue, 24 Feb 2009 14:03:09 -0500, nathan virgil s'exprima ainsi: > I'm experimenting with OOP using the Critter Caretaker script from Python > Programming for the Absolute Beginner as my basis. I've noticed that a > dictionary/function combo is a great way to handle menus, and so I've > adapted

Re: [Tutor] Passing perimeters in dictionary values?

2009-02-25 Thread spir
Le Wed, 25 Feb 2009 00:01:49 -, "Alan Gauld" s'exprima ainsi: > > "nathan virgil" wrote > > > I'm not familiar with lambdas yet, and I don't think this book will > > introduce me to them; they aren't listed in the index, anyway. > > lambda is just a fancy mathematical name for a simple

Re: [Tutor] how to instantiate a class

2009-02-26 Thread spir
Le Thu, 26 Feb 2009 12:38:27 +0530, Abhishek Kumar s'exprima ainsi: > hello list, > > Below is the sample code of a class. > > > import > > Class ABC: > def __init__(self,a,b,c): > statement 1 > statement 2 >

Re: [Tutor] learning new features of python

2009-02-26 Thread spir
Le Thu, 26 Feb 2009 18:16:59 + (GMT), ALAN GAULD s'exprima ainsi: > > > >> Similaraly in Alan Guald Learn to program link, he has given > > >> information on opening a file with file() and open() functions. > > > > > > And in V3 they took that back out again :-( > > > > ?? open() is in V3.

Re: [Tutor] Class instance understanding = None

2009-02-26 Thread spir
Le Fri, 27 Feb 2009 00:06:59 -0500, David s'exprima ainsi: > Hi Everyone, > I go through the archived [Tutor] mail list to find programs others have > tried to do. I found one that would keep track of a petty cash fund. > please point out my misunderstanding. > Here is what I started with; > [

Re: [Tutor] Class instance understanding = None

2009-02-26 Thread spir
Le Fri, 27 Feb 2009 00:06:59 -0500, David s'exprima ainsi: > Hi Everyone, > I go through the archived [Tutor] mail list to find programs others have > tried to do. I found one that would keep track of a petty cash fund. > please point out my misunderstanding. > Here is what I started with; > >

Re: [Tutor] Extract strings from a text file

2009-02-26 Thread spir
Le Thu, 26 Feb 2009 21:53:43 -0800, Mohamed Hassan s'exprima ainsi: > Hi all, > > I am new to Python and still trying to figure out some things. Here is the > situation: > > There is a text file that looks like this: > > text text text Joseph > text text text text text text text text text text

  1   2   3   4   5   6   7   >