How to find difference in years between two dates?

2006-07-26 Thread thebjorn
For the purpose of finding someone's age I was looking for a way to find how the difference in years between two dates, so I could do something like: age = (date.today() - born).year but that didn't work (the timedelta class doesn't have a year accessor). I looked in the docs and the cookbook,

Re: How to find difference in years between two dates?

2006-07-26 Thread thebjorn
Roy Smith wrote: > "thebjorn" <[EMAIL PROTECTED]> wrote: > > > def age(born): > > now = date.today() > > birthday = date(now.year, born.month, born.day) > > return now.year - born.year - (birthday > now and 1 or 0) >

Re: How to find difference in years between two dates?

2006-07-26 Thread thebjorn
John Machin wrote: > thebjorn wrote: [...] > > > > def age(born): > > now = date.today() > > birthday = date(now.year, born.month, born.day) > > Bad luck if the punter was born on 29 Feb and the current year is not a > leap year. Good catch! Tha

Re: How to find difference in years between two dates?

2006-07-26 Thread thebjorn
Bruno Desthuilliers wrote: [...] > Possible solution: > > import mx.DateTime as dt > def age(date): > return dt.Age(dt.today(), date).years > born = dt.Date(1967, 5, 1) > assert age(born) == 39 dealbreaker: >>> age(datetime.date(1970,5,2)) Traceback (most recent call last): File "", line 1,

Re: How to find difference in years between two dates?

2006-07-27 Thread thebjorn
John Machin wrote: > thebjorn wrote: > > John Machin wrote: > > > thebjorn wrote: [...] > > > Holy code bloat, Batman! Try this: > > > > > > return now.year - born.year - (birthday > now) > > > > yuck :-) > > But this: >

Re: How to find difference in years between two dates?

2006-07-27 Thread thebjorn
John Machin wrote: > thebjorn wrote: [...] > > You give a good argument that the concept of a month is fuzzy > > Sorry, I can't imagine where you got "fuzzy" from. Perhaps you mean > some other word. The concept is capable of being expressed precisely. and the se

Re: How to find difference in years between two dates?

2006-07-27 Thread thebjorn
Bruno Desthuilliers wrote: > Which conversion ? How do you get the data ? as a datetime object ? as a > (y,m,d) tuple ? as a "y-m-d" string ? Else ? All input routines, whether they're from a web-form, database, command line, or anywhere else, only produce objects from the datetime module for cale

Re: How to find difference in years between two dates?

2006-07-28 Thread thebjorn
John Machin wrote: > Jan 31 to Feb 27: 27d (ex) 28d (in) > Jan 31 to Feb 28: 28d (ex) 1m 1d (in) > Jan 31 to Mar 01: 1m 1d (ex) 1m 2d (in) > So 1 day short of 1m 1d is not 1m 0 d??? Exactly. Just as a person born on 1999-3-1 isn't a year old on 2000-2-29. Perfectly regular, consistent and reasonab

Re: How to find difference in years between two dates?

2006-07-29 Thread thebjorn
John Machin wrote: > I don't understand. The examples that I showed went from the last day > of a month to the last day of another month. [...] Q1: is ((date-4days)+4days) == date? Q2: is (((date-4days)+1month)+4days) == date+1month? Ok, let's use Python'ish syntax (including numbering the days f

Unicode/utf-8 data in SQL Server

2006-08-08 Thread thebjorn
I'm working with a MS SQL Server database created by a program from a fine US company who seems to have gotten run over by the Unicode truck. In their infinite wisdom they've decided to store Unicode data directly in regular varchar fields, utf-8 encoded! (on the bright side, it is properly utf-8 e

Re: newb question: file searching

2006-08-08 Thread thebjorn
[EMAIL PROTECTED] wrote: [...] > that? And also, I'm still not sure I know exactly how os.walk() works. > And, finally, the python docs all note that symbols like . and .. > don't work with these commands. How can I grab the directory that my > script is residing in? os.getcwd() will get you th

Is there a way to get utf-8 out of a Unicode string?

2006-10-29 Thread thebjorn
I've got a database (ms sqlserver) that's (way) out of my control, where someone has stored utf-8 encoded Unicode data in regular varchar fields, so that e.g. the string 'Blåbærsyltetøy' is in the database as 'Bl\xc3\xa5b\xc3\xa6rsyltet\xc3\xb8y' :-/ Then I read the data out using adodbapi (which

Re: Lookuperror : unknown encoding : utf-8

2006-10-29 Thread thebjorn
Sachin Punjabi wrote: > I wanted to read a file encoded in utf-8 and and using the following > syntax in my source which throws me an error specifying Lookuperror : > unknown encoding : utf-8. Also I am working on Python version 2.4.1. You shouldn't have to do anything to have the utf-8 encoding a

Re: Is there a way to get utf-8 out of a Unicode string?

2006-10-30 Thread thebjorn
Fredrik Lundh wrote: > thebjorn wrote: > > > I've got a database (ms sqlserver) that's (way) out of my control, > > where someone has stored utf-8 encoded Unicode data in regular varchar > > fields, so that e.g. the string 'Blåbærsyltetøy' is in the dat

Re: Is there a way to get utf-8 out of a Unicode string?

2006-10-30 Thread thebjorn
Gerrit Holl wrote: > Hei, > > On 2006-10-30 08:25:41 +0100, thebjorn wrote: > > def unfk(s): > > return eval(repr(s)[1:]).decode('utf-8') > > ... > > Is there a less hack'ish way to do this? > > Slightly lack hackish: > &g

Re: how to write code into a blog post?

2006-11-04 Thread thebjorn
Jorge Vargas wrote: > Hi I know many people here blog so sorry for the OT. > > Currently I have a wordpress install and went I wanted to post some > code I notice how painfull it is. Indeed :-) I'm using the iG:Syntax Hiliter over on http://blog.tkbe.org after I got some comments about the lack o

Re: determining the source code and module based on the class

2007-07-15 Thread thebjorn
On Jul 16, 6:55 am, alf <[EMAIL PROTECTED]> wrote: ... > now I need a piece of code which based on the class name can point to > the module as well as the line number where the given class is defined. > > Is it doable in Python? look in the inspect module. -- bjorn -- http://mail.python.org/mai

Re: Catching a key press

2007-07-23 Thread thebjorn
On Jul 23, 9:05 am, westymatt <[EMAIL PROTECTED]> wrote: > This is without a gui toolkit. This is going to be implemented on > console i/o If you're on windows, you'll need the kbhit() and getch() functions in the msvcrt module. The up arrow returns two separate "keyboard- hits" (with ordinal val

Re: Compiling python2.5.1 results in 3.5MB python lib?

2007-07-29 Thread thebjorn
On Jul 29, 12:46 pm, simonbun <[EMAIL PROTECTED]> wrote: ... > How would I go about doing this? I'm not sure what to strip nor how to > do it. man strip -- bjorn -- http://mail.python.org/mailman/listinfo/python-list

Re: Latest models of Gibson guitars

2007-08-19 Thread thebjorn
On Aug 19, 8:41 pm, [EMAIL PROTECTED] wrote: > On 19 kol, 19:34, [EMAIL PROTECTED] wrote: > [spam] > > Hello, > > This is a newsgroup of programming language Python, stop with this! > > Regards, > Vedran As someone else pointed out, this is more widely disseminated than just c.l.py. If you feel t

Re: Sorting a list of Unicode strings?

2007-08-19 Thread thebjorn
On Aug 19, 8:09 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: [...] > In both Swedish and Danish, I believe, A-with-ring sorts AFTER the > letter Z in the alphabet; so, having Åaland (where I'm using Aa for > A-with-ring, since this newsreader has some problem in letting me enter > non-ascii charact

Re: An ordered dictionary for the Python library?

2007-09-12 Thread thebjorn
On Sep 12, 9:33 am, Mark Summerfield <[EMAIL PROTECTED]> wrote: > I feel that Python lacks one useful data structure: an ordered > dictionary. > > I find such data structures v. useful in C++. I know that in Python > the sort function is v. fast, but often I prefer never to sort but > simply to use

Re: Looping issues

2007-04-06 Thread thebjorn
On Apr 5, 8:01 pm, [EMAIL PROTECTED] wrote: > What I am trying to do is compare two files to each other. > > If the 2nd file contains the same line the first file contains, I want > to print it. I wrote up the following code: > > correct_settings = open("C:\Python25\Scripts\Output > \correct_settin

Re: adding a static class to another class

2007-09-16 Thread thebjorn
On Sep 17, 1:14 am, "Nathan Harmston" <[EMAIL PROTECTED]> wrote: > HI, > > I m trying to start an api in a similar way to the djangic way of > Class.objects.all(). Ie objects is a "Manager" class. > > So: > > class Foo(object): >def __init__(self): > self.test = "NEE" > > class Manager(

Re: super() doesn't get superclass

2007-09-19 Thread thebjorn
On Sep 19, 3:41 pm, Michele Simionato <[EMAIL PROTECTED]> wrote: > On Sep 19, 3:22 pm, Sion Arrowsmith <[EMAIL PROTECTED]> > wrote: > > > Ben Finney <[EMAIL PROTECTED]> wrote: > > > > If a function is named 'super' and operates on > > >classes, it's a pretty strong implication that it's about > >

Re: Mixin classes and single/multiple inheritance

2007-09-19 Thread thebjorn
On Sep 20, 6:52 am, Ben Finney <[EMAIL PROTECTED]> wrote: > Michele Simionato <[EMAIL PROTECTED]> writes: > > Since the language we have does have multiple inheritance, let's > > use it to implement mixins. > > ... > > So, multiple inheritance is giving us very little for the point of > > view of m

Re: Sets in Python

2007-09-19 Thread thebjorn
On Sep 20, 4:17 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: [...] > Data structures don't have problems. Programmers do. That's QOTW material :-) > ... And language > designers with sense build languages that minimize the programmers > problems, not maximize them. > ... > >

Re: Sets in Python

2007-09-20 Thread thebjorn
On Sep 20, 6:02 am, Karthik Gurusamy <[EMAIL PROTECTED]> wrote: > On Sep 19, 7:17 pm, Steven D'Aprano <[EMAIL PROTECTED] > [...] > > (2) Allow the hash of mutable objects to change, which means you can use > > mutable objects as keys in dicts but if you change them, you can no > > longer find them

Re: Sets in Python

2007-09-20 Thread thebjorn
On Sep 20, 9:50 am, thebjorn <[EMAIL PROTECTED]> wrote: it's bad form to reply to myself, I know, but > def __iter__(self): > for k in super(mdict,self).__iter__(): > yield eval(k) should probably be def __iter__(self): return (eval(k)

Re: sorting a list numbers stored as strings

2007-09-25 Thread thebjorn
On Sep 25, 2:45 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Tue, 25 Sep 2007 12:46:54 +0800, Delaney, Timothy (Tim) wrote: > > Carsten Haese wrote: > > >> On Mon, 2007-09-24 at 19:58 +0800, Delaney, Timothy (Tim) wrote: > >>> I'm sure that in some version of Python it wou

Re: sorteddict PEP proposal [started off as orderedict]

2007-09-25 Thread thebjorn
On Sep 25, 10:53 am, Mark Summerfield <[EMAIL PROTECTED]> wrote: > Hi, > > Below is a PEP proposal for a sorteddict. It arises out of a > discussion on this list that began a few weeks ago with the subject of > "An ordered dictionary for the Python library?", and a similar one on > the P3K mailing

Re: %s shortcut?

2007-09-25 Thread thebjorn
On Sep 26, 4:55 am, james_027 <[EMAIL PROTECTED]> wrote: > hi i have something like this > > cursor.execute(""" > select c.name, > (select from ap_invoice i where Month(i.date) = 1 and > Year(i.date) = %s and i.customer_id = c.id and i.status != 'CAN') jan, >

Re: ANN: PyPE 2.8.7

2007-09-25 Thread thebjorn
On Sep 25, 12:37 pm, stef <[EMAIL PROTECTED]> wrote: > Josiah Carlson wrote: > > === What is PyPE? === > > PyPE (Python Programmers' Editor) was written in order to offer a > > lightweight but powerful editor for those who think emacs is too much > > and idle is too little. Syntax highlighting is i

Re: ANN: PyPE 2.8.7

2007-09-25 Thread thebjorn
On Sep 25, 12:46 pm, stef <[EMAIL PROTECTED]> wrote: > Another problem, > I tried to run PyPE in my "old IDE", instead of double-clicking on the PyPE.exe file? Why? -- bjorn -- http://mail.python.org/mailman/listinfo/python-list

Re: sorteddict [was a PEP proposal, but isn't anymore!]

2007-09-29 Thread thebjorn
On Sep 29, 4:23 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: [...] > Another example would be if you had a library which serialised a dictionary > to xml. There is nothing wrong with the library if it doesn't care about > order, but if you have some other reason why you want the xml to be stable > (

Re: Program inefficiency?

2007-09-29 Thread thebjorn
On Sep 29, 5:22 pm, [EMAIL PROTECTED] wrote: > I wrote the following simple program to loop through our help files > and fix some errors (in case you can't see the subtle RE search that's > happening, we're replacing spaces in bookmarks with _'s) > > the program works great except for one thing. It

Re: sorteddict [was a PEP proposal, but isn't anymore!]

2007-09-29 Thread thebjorn
On Sep 29, 7:13 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: [...] > Right now I think there are probably three dict variants needed: sorteddict > (still waiting for a convincing use case), ordereddict (lots of use cases), > and this one: stabledict. What's stabledict? I'm assuming that ordereddict

Re: Program inefficiency?

2007-09-29 Thread thebjorn
On Sep 29, 7:55 pm, Pablo Ziliani <[EMAIL PROTECTED]> wrote: > thebjorn wrote: > > On Sep 29, 5:22 pm, [EMAIL PROTECTED] wrote: > > >> I wrote the following simple program to loop through our help files > >> and fix some errors (in case you can't see t

Re: strange unbound local error?

2007-09-29 Thread thebjorn
On Sep 29, 8:04 pm, [EMAIL PROTECTED] wrote: > hi folks, > > suppose this snipplet: > > spam = 42 > > def eggs(): > print spam > spam = spam + 1 > > if __name__=="__main__": > eggs() > > This thows an UnboundLocalError at line 4 (print statement). But if I > comment out line 5 (variable

Re: Program inefficiency?

2007-09-29 Thread thebjorn
On Sep 29, 8:32 pm, [EMAIL PROTECTED] wrote: > It think he's saying it should look like this: > > # File: masseditor.py > > import re > import os > import time > > p1= re.compile('(href=|HREF=)+(.*)(#)+(.*)(\w\'\?-<:)+(.*)(">)+') > p2= re.compile('(name=")+(.*)(\w\'\?-<:)+(.*)(">)+') > p100= re.com

Re: Program inefficiency?

2007-09-29 Thread thebjorn
On Sep 29, 9:32 pm, stdazi <[EMAIL PROTECTED]> wrote: > On Sep 29, 6:07 pm, [EMAIL PROTECTED] wrote: > > > You did not mention the OS, but because you are using > > "pathname\editfile.txt", it sounds like you are using an MS OS. From > > past experience with various MS OSes, I found that as the nu

Re: if then elif

2007-10-10 Thread thebjorn
On Oct 10, 11:03 pm, Larry Bates <[EMAIL PROTECTED]> wrote: [...] > > Boolean problem: > > if cal or fat <= 0 > > That may be the way you say it or "think" it but it won't work. > > 'cal or fat' is evaluated first. Since they both have values this ALWAYS > evaluates to 1 which is NEVER less than o

Re: "".join(string_generator()) fails to be magic

2007-10-11 Thread thebjorn
On Oct 11, 8:53 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Thu, 11 Oct 2007 01:26:04 -0500, Matt Mackal wrote: > > I have an application that occassionally is called upon to process > > strings that are a substantial portion of the size of memory. For > > various reasons, the resu

Re: Iterable Flattener with Depth.

2007-11-02 Thread thebjorn
On Nov 2, 6:32 am, praddy <[EMAIL PROTECTED]> wrote: > On Nov 1, 5:03 pm, [EMAIL PROTECTED] wrote: > > > Pradeep Jindal: > > > > Any comments? > > > Something with similar functionality (plus another 20 utility > > functions/classes or so) has probably to go into the std lib... :-) > > > Bye, > > b

Re: How can i find the form name without "nr=0"

2007-11-06 Thread thebjorn
On Nov 5, 6:05 pm, scripteaze <[EMAIL PROTECTED]> wrote: [...] > Well, i wasnt sure if you could have a form without a form name, i was > just thinking that it had one but maybe hidden and that i could > retrieve it I see you've got the answer you wanted already, but just for completeness: the fol

Re: Questions about remembering and caching function arguments

2007-11-11 Thread thebjorn
On Nov 12, 1:05 am, "Anand Patil" <[EMAIL PROTECTED]> wrote: > Hi all, > > I have two questions about a class, which we'll call MyWrapperClass, > in a package to which I'm contributing. > > 1) MyWrapperClass wraps functions. Each instance has an attribute > called 'value' and a method called 'eval'

Re: python - an eggs...

2007-11-12 Thread thebjorn
On Nov 12, 1:12 am, "bruce" <[EMAIL PROTECTED]> wrote: > Hi Diez... > > I've never used setuptools, (it's not on the box) and i don't have > easy_install tools installed... In the link you were given there is a section titled "Installing setuptools". I'm reading it aloud for you now... -- bjorn

Re: Calculate an age

2007-12-06 Thread thebjorn
On Dec 6, 11:19 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Dec 7, 8:34 am, Pierre Quentel <[EMAIL PROTECTED]> wrote: > > > Hi all, > > > I have searched in the standard distribution if there was a function > > to return the difference between 2 dates expressed like an age : > > number of years

How to memoize/cache property access?

2007-12-20 Thread thebjorn
I seem to be writing the following boilerplate/pattern quite frequently to avoid hitting the database until absolutely necessary, and to only do it at most once: class Foo(object): @property def expensive(self): if not hasattr(self, '_expensiv'): self._expensive =

Re: How to memoize/cache property access?

2007-12-20 Thread thebjorn
On Dec 20, 5:43 pm, Michele Simionato <[EMAIL PROTECTED]> wrote: > On Dec 20, 5:02 pm, thebjorn <[EMAIL PROTECTED]> > wrote: > > > I seem to be writing the following boilerplate/pattern quite > > frequently to avoid hitting the database until absolutely necessary .

Re: Connecting to SQL database

2007-12-20 Thread thebjorn
On Dec 20, 10:01 pm, bill ramsay <[EMAIL PROTECTED]> wrote: > On Fri, 14 Dec 2007 23:35:00 -0300, "Gabriel Genellina" > > <[EMAIL PROTECTED]> wrote: > >En Fri, 14 Dec 2007 23:24:24 -0300, Unknown <[EMAIL PROTECTED]> > >escribió: > > >> I have successfully connected to SQL2000 and MSDEE databases in

Re: Instrospection question

2007-12-21 Thread thebjorn
On Dec 21, 11:28 am, Matias Surdi <[EMAIL PROTECTED]> wrote: > I have the following code: [...] > As you can see, what I'm trying to do is "replace" a method with another > one wich is the same method but with a function applied to it (in this > case, a string concatenation ( +" modified")) > > Can

Re: Question about email-handling modules

2007-12-21 Thread thebjorn
On Dec 20, 4:15 pm, Robert Latest <[EMAIL PROTECTED]> wrote: > Steven D'Aprano wrote: [...] > > All methods are attributes (although the opposite is not the case), so if > > a method doesn't exist, you will get an AttributeError. > > I see. I've already gathered that Python likes to use different w

Re: Sorting Objects by property using locale

2007-12-21 Thread thebjorn
Donn Ingle wrote: > Hi, > Well, I'm beat. I can't wrap my head around this stuff. > > I need to create a list that will contain objects sorted by a "name" > property that is in the alphabetical order of the user's locale. > > I used to have a simple list that I got from os.listdir and I could do

Re: Bizarre behavior with mutable default arguments

2007-12-30 Thread thebjorn
On Dec 29, 7:17 pm, Istvan Albert <[EMAIL PROTECTED]> wrote: > On Dec 29, 12:50 pm, bukzor <[EMAIL PROTECTED]> wrote: > > > Is this functionality intended? It seems very unintuitive. This has > > caused a bug in my programs twice so far, and both times I was > > completely mystified until I realize

Re: Bizarre behavior with mutable default arguments

2007-12-30 Thread thebjorn
On Dec 30, 2:45 pm, Istvan Albert <[EMAIL PROTECTED]> wrote: > On Dec 30, 5:23 am, thebjorn <[EMAIL PROTECTED]> > wrote: > > >def age(dob, today=datetime.date.today()): > >... > > > None of my unit tests caught that one :-) > > interest

Re: Simple List division problem

2008-01-13 Thread thebjorn
On Jan 12, 8:33 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > marcstuart wrote: > > How do I divide a list into a set group of sublist's- if the list is > > not evenly dividable ? consider this example: > > > x = [1,2,3,4,5,6,7,8,9,10] > > y = 3 # number of lists I want to break x into > > z

Re: Simple List division problem

2008-01-13 Thread thebjorn
On Jan 13, 1:05 pm, thebjorn <[EMAIL PROTECTED]> wrote: > On Jan 12, 8:33 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > > > > marcstuart wrote: > > > How do I divide a list into a set group of sublist's- if the list is > > > not

Re: Simple List division problem

2008-01-13 Thread thebjorn
On Jan 13, 2:02 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > thebjorn wrote: > > > Eh... > > oh, forgot that it was "pulling requirements out of thin air" week on > c.l.python. Well, the OP requirements were to control the number of chunks, not the size of

Re: super, decorators and gettattribute

2008-01-13 Thread thebjorn
On Jan 13, 1:51 pm, Richard Szopa <[EMAIL PROTECTED]> wrote: > On Jan 13, 8:59 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > > > On Sat, 12 Jan 2008 14:23:52 -0800, Richard Szopa wrote: > > > However, I am very surprised to learn that > > > > super_object.__getattr__(name)(*args, **kwar

Re: How to get user home directory on Windows

2008-01-13 Thread thebjorn
On Jan 12, 6:50 pm, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > Update. > I found a way for getting the home directory of the user but it > requires to validate the user by providing username+password: > > def get_homedir(username, password): > token = win32security.LogonUser( > us

Re: super, decorators and gettattribute

2008-01-14 Thread thebjorn
On Jan 14, 1:41 pm, Richard Szopa <[EMAIL PROTECTED]> wrote: > On Jan 13, 3:31 pm, thebjorn <[EMAIL PROTECTED]> > wrote: > > > They do, except for when it comes to what super(..) returns. It isn't > > really an object in the sense that they're presente

Re: Using a dict as if it were a module namespace

2008-01-27 Thread thebjorn
On Jan 27, 8:45 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > I have a problem which I think could be solved by using a dict as a > namespace, in a similar way that exec and eval do. > > When using the timeit module, it is very inconvenient to have to define > functions as str

Re: file write question

2008-01-27 Thread thebjorn
On Jan 27, 4:02 am, "Robb Lane (SL name)" <[EMAIL PROTECTED]> wrote: > I have written a script which: > - opens a file > - does what it needs to do, periodically writing to the file... for a > few hours > - then closes the file when it's done > So my question is: > Would it be better to 'open' and

Re: translating Python to Assembler

2008-01-27 Thread thebjorn
On Jan 27, 9:58 am, [EMAIL PROTECTED] wrote: > On Fri, 25 Jan 2008 17:44:07 -0800 (PST), ajaksu <[EMAIL PROTECTED]> > wrote: > > > > >On Jan 25, 11:36 pm, ajaksu <[EMAIL PROTECTED]> wrote: > >> On Jan 25, 11:10 pm, [EMAIL PROTECTED] wrote: > >[...] > > >Gaah, is this what's going on? > > >[EMAIL PR

Re: Is there an easy way to sort a list by two criteria?

2008-02-09 Thread thebjorn
On Feb 10, 3:05 am, neocortex <[EMAIL PROTECTED]> wrote: > Hello! > I am a newbie in Python. Recently, I get stuck with the problem of > sorting by two criteria. In brief, I have a two-dimensional list (for > a table or a matrix). Now, I need to sort by two columns, but I cannot > figure out how to

Re: Python equivt of __FILE__ and __LINE__

2008-02-11 Thread thebjorn
On Feb 11, 4:55 pm, Gary Herron <[EMAIL PROTECTED]> wrote: > Bill Davy wrote: > > Writing a quick and dirty assembler and want to give the user the location > > of an error. The "assembly language" is Python. If the user wants to > > generat some object code they write something like: > > > Labe

Re: translating Python to Assembler

2008-02-11 Thread thebjorn
On Jan 27, 12:23 pm, [EMAIL PROTECTED] wrote: me: > >go troll somewhere else (you obviously don't know anything about > >assembler and don't want to learn anything about Python). > > >-- bjorn > > before you start mouthing off, maybe you should learn assembler. I suppose I shouldn't feed the troll

Re: Is there an easy way to sort a list by two criteria?

2008-02-11 Thread thebjorn
On Feb 11, 10:47 am, [EMAIL PROTECTED] wrote: [...] > A little known thing from Python 2.5: [...] > >>> sorted(lst, key=itemgetter(2, 1)) Cute, thanks :-) --bjorn -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Memory Manager

2008-02-17 Thread thebjorn
On Feb 17, 10:01 pm, Pie Squared <[EMAIL PROTECTED]> wrote: [...] > It seems to me that another, perhaps better strategy, would be to > allocate a large heap space, then store a pointer to the base of the > heap, the current heap size, and the beginning of the free memory. > When you need to 'alloc

Re: Looking for a Python Program/Tool That Will Add Line Numbers to a txt File

2008-02-18 Thread thebjorn
On Feb 15, 8:55 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote: > W. Watson wrote: > > See Subject. It's a simple txt file, each line is a Python stmt, but I > > need up to four digits added to each line with a space between the > > number field and the text. Perhaps someone has already done this or > >

Re: is this data structure build-in or I'll have to write my own class?

2008-02-20 Thread thebjorn
On Feb 20, 3:32 pm, "Jorge Vargas" <[EMAIL PROTECTED]> wrote: > On Feb 20, 2008 8:15 AM, Larry Bates <[EMAIL PROTECTED]> wrote: > > > Jorge Vargas wrote: > > > I need a data structure that will let me do: > > > > - attribute access (or index) > > > - maintain the order (for iter and print) > > > -

Re: Hyphenation module PyHyphen-0.3 released

2008-02-23 Thread thebjorn
On Feb 23, 8:35 pm, "Dr. leo" <[EMAIL PROTECTED]> wrote: > I am pleased to share with you the great features of the latest version. > Large parts of the sources were completely rewritten. Also, they are now > reasonably documented. > > Just go tohttp://pypi.python.org/pypi/PyHyphen/0.3 > > I was te

Re: Simple - looking for a way to do an element exists check..

2008-02-23 Thread thebjorn
On Feb 23, 6:18 pm, Paul Hankin <[EMAIL PROTECTED]> wrote: > On Feb 22, 7:01 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > > > On Feb 22, 12:54 pm, Paul Rubin wrote: > > > > Paul Rubin writes: > > > > if any(x==element[0] for x in a): > > >

Re: Simple - looking for a way to do an element exists check..

2008-02-23 Thread thebjorn
On Feb 24, 2:24 am, Paul Rubin <http://[EMAIL PROTECTED]> wrote: > thebjorn <[EMAIL PROTECTED]> writes: > > If the lists are long enough to care, either rewrite use a set-based > > solution if the items are hashable, or keep the elements sorted and > > rewrit

Re: Hyphenation module PyHyphen-0.3 released

2008-02-25 Thread thebjorn
On Feb 25, 3:56 am, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > > I don't know if I'm just doing it wrong, or if I can't use extensions > > compiled with mingw32 with the standard distribution Python > > executable? > > I was able to install on Windows XP with mingw: > > setup.py build -c mingw32

Re: Class definition attribute order

2008-08-09 Thread thebjorn
On Aug 9, 7:55 am, Michele Simionato <[EMAIL PROTECTED]> wrote: > On Aug 5, 5:05 am, Michele Simionato > > > Yep. Seehttp://stacktrace.it/articoli/2008/01/metaclassi-python-3000 > > (I am working on an English translation these days, > > but for the moment you can use Google Translator). > > >  M.

Is there a SOAP module that can do this...?

2008-09-10 Thread thebjorn
I've been trying to use SOAPpy and ZSI (with and without the use of wsdl2py) to communicate with a SOAP server (looks like it's a WebLogic server(?) in front of some enterprise java bean) and not having much luck. I got them to send me an example of what the bytes on the wire are supposed to look

Re: Is there a SOAP module that can do this...?

2008-09-11 Thread thebjorn
On Sep 10, 9:44 pm, Waldemar Osuch <[EMAIL PROTECTED]> wrote: > On Sep 10, 1:23 pm, thebjorn <[EMAIL PROTECTED]> > wrote:> I've been trying to use SOAPpy and ZSI (with and without the use of > > wsdl2py) to communicate with a SOAP server (looks like it's a We

Re: Q for Emacs users: code-folding (hideshow)

2010-07-16 Thread thebjorn
On Jul 15, 10:34 pm, Peter wrote: > On Jul 16, 2:45 am, kj wrote: > > > This is a question _for Emacs users_ (the rest of you, go away :)  ). > > > How do you do Python code-folding in Emacs? > > > Thanks! > > > ~K > [...] > Anybody else now of any better ideas or whatever? Now that I think > abo

Re: Cannot send email

2010-07-16 Thread thebjorn
On Jul 15, 7:07 pm, "D'Arcy J.M. Cain" wrote: > On Thu, 15 Jul 2010 09:50:57 -0700 (PDT) > > G F wrote: > > Does anyone have any ideas where the trouble is and what can be done > > about it? The little bit about: > > "reply: retcode (557); Msg: This mail server does not accept mail > > addressed

how to import a name from a module-path?

2009-06-16 Thread thebjorn
I'm storing the path to functions in a database and now I'd like to get a reference so I can execute them. I looked briefly at the imp module and got very confused... Currently I'm doing this: def import_object(path): module, obj = path.rsplit('.', 1) exec "from rootpkg.%s import %

Re: waling a directory with very many files

2009-06-16 Thread thebjorn
On Jun 15, 6:56 am, Steven D'Aprano wrote: > On Sun, 14 Jun 2009 22:35:50 +0200, Andre Engels wrote: > > On Sun, Jun 14, 2009 at 6:35 PM, tom wrote: > >> i can traverse a directory using os.listdir() or os.walk(). but if a > >> directory has a very large number of files, these methods produce very

Re: how to import a name from a module-path?

2009-06-16 Thread thebjorn
On Jun 16, 7:43 pm, Gary Herron wrote: > thebjorn wrote: > > I'm storing the path to functions in a database and now I'd like to > > get a reference so I can execute them. > > > I looked briefly at the imp module and got very confused...  Currently > > I