[Tutor] nul file in Windows

2009-11-15 Thread Timo List
For my program I disable the py2exe log feature by routing output to the nul-file. Code: if win32 and py2exe: sys.stdout = open("nul", "w") sys.stderr = open("nul", "w") This always worked fine. Today, I received an email from a user with the following error: IOEr

[Tutor] Generating unique ID

2009-10-28 Thread Timo List
Hello, I'm writing an application which will hold a database of people. Ofcourse, people can have the same name, so I want to stock them with an unique ID. I've searched and found some things: - uuid.uuid4() - id(name) - os.urandom(n) But they seem overkill to me. Well, maybe not id(). What sho

[Tutor] reading and processing xml files with python

2009-06-20 Thread python . list
p;xml=') >>> opener = urllib2.build_opener() >>> firstdatastream = opener.open(request) >>> firstdata = firstdatastream.read() >>> print firstdata 134388 Milford Plaza at Times Square 700 8th Avenue New York NY US 10036 ..

[Tutor] Python and SQL recommendation

2009-06-19 Thread Timo List
Hello all, At the moment I'm using 3 files as datastorage for my program. One file using ConfigParser and two use the Pickle module. File one contains for example: [ID] option1 = string1 option2 = string2 option3 = string3 And is connected to one of the Pickle files which is like this: {ID : [{k

Re: [Tutor] Using new style classes and __slots__

2005-09-24 Thread mailing list
l a wee bit. I was almost considering writing setters/getters to get around the magic methods, but I grew to dislike them after having used Java, I got annoyed at having to write setters/getters for every public variable. Of course, I was using Notepad to write the Java programmes, and then Ecl

[Tutor] Using new style classes and __slots__

2005-09-23 Thread mailing list
Hi all, I'm just looking for a quick runthrough on the differences between new style classes and the old ones, and how to use the new ones. Also, how exactly do you use __slots__? I've got a 6000 object collection, and apparently using __slots__ will save memory, but only those attributes specifi

[Tutor] How do you organize code snippets?

2005-09-18 Thread List
The subject pretty much says it. I tend to clip and save snippets from various lists for later reference. I save each in a separate text file more or less named appropriately (or so I think at the time), but I've ended up with a mess of files in a snippets directory and I can't always remember what

Re: [Tutor] How do fix this error?

2005-09-16 Thread mailing list
raw_input takes one argument. While >>> x = 5 >>> b = 10 >>> print x, "+", b, "=", x+b will print 5 + 10 = 15, you could also have written it - >>>print str(x) + " + " + str(b) + " = " + str(x+b) Now, if I have a function - def divByTen(number): return number/10 I can call it like s

Re: [Tutor] making a table

2005-09-09 Thread mailing list
ver. i.e. to create a list from 5 to 50 in increments of 5 - zeroToFifty = range(start = 5, stop = 55, step = 5) Remember, it'll count up to but not including stop, so if you tell it to count to two hundred in steps of 10, it'll count to 190, counting to 16 by steps of 2 will count

[Tutor] OT - email & imaplib modules

2005-09-07 Thread mailing list
of the opinion that simple things should be. I'm not sure what's being worked on for Py3K, but I really hope imaplib and email are. Would adding a layer over each to simplify things be bad or good? For instance, instead of IMAP using and returning IMAP specific strings, why not do stuff lik

Re: [Tutor] UTf-8 to Entity

2005-08-19 Thread mailing list
ant to make a python program which opens an XML (UTF-8 encoding) and do a > search & replace. It will search the Unicode and replace them with their > equivalent entity name. The program will read a look-up table (a tab > delimited text file) which list the unicodes that needs to be repl

Re: [Tutor] Sorting a list of lists aka nested lists

2005-08-19 Thread mailing list
No-one's mentioned a Schwartzian Transform yet ; ) On 8/15/05, Kent Johnson <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Note that in Python2.4+, you can use key= instead: > > > > def sortKey(lst): > > return lst[2] > > Quant.sort(key=sortKey) > > > > This is more effient than spe

[Tutor] Declaring encoding question

2005-08-19 Thread mailing list
Hi all, I've got some source code which will be handling non-ASCII chars like umlauts and what not, and I've got a testing portion stored in the code. I get this deprecation warning when I run my code - __main__:1: DeprecationWarning: Non-ASCII character '\xfc' in file C:\Python24\testit.py on

Re: [Tutor] Silly loop question

2005-08-19 Thread mailing list
Hehe, Yah, I should've read the tutorial again, I do apologise, it was a 3 in the morning-coffee not working question. Regards, Liam Clarke On 8/17/05, Alan G <[EMAIL PROTECTED]> wrote: > > changeIndex = None > > al = len(line) > > for i in range(al): > > And theres the problem. > Pythonpro

[Tutor] Silly loop question

2005-08-16 Thread mailing list
Hi all, I should know this, but it seems to elude me at present. I have a loop which is looping through a line of chars by index. So, one of these - for i in range(len(line)): Now, question is, is there a simple way to 'fast forward' index i? At the moment, I'm doing it like this - c

Re: [Tutor] Question on classes/instances

2005-08-10 Thread mailing list
Erk, I of course meant - path = os.path.join('categories', self.name) On 8/10/05, mailing list <[EMAIL PROTECTED]> wrote: > Hi Negroup, > > First off, you may want to use os.path.join to create paths - > > path = 'categories/%s' % self.name > >

Re: [Tutor] Question on classes/instances

2005-08-10 Thread mailing list
, and IMAO, tidier code is easier to maintain. As for what you're wanting to do with the list comprehension, once again I'd use os.path.join, but otherwise your comprehension looks workable. On 8/10/05, Negroup - <[EMAIL PROTECTED]> wrote: > Hi, Sorry for the subject a bit generi

Re: [Tutor] help

2005-08-10 Thread mailing list
Also, you may want to consider something like easygui - http://www.ferg.org/easygui/ if all you need is simple dialogs. You may also want to consider Pythoncard - pythoncard.sourceforge.net, it's quite capable of more elaborate GUI stuff, but it's built on wxPython, which can be a little intimidat

[Tutor] references and popping, caveats?

2005-08-07 Thread mailing list
#Only other value in test data is "}", so close group ... ref.pop(-1) Fairly unreadable huh. Basically, I'm using the list to store dictionary references, so as to create a bunch of nested dictionaries, working on the principle of last in, first off. I guess