Re: user modules

2006-10-05 Thread Tuomas
the context; they are not modified. The locals are currently unused. The fromlist should be a list of names to emulate ``from name import ...'', or an empty list to emulate ``import name''. When importing a module from a package, note that __import__('A.B', ...) returns package A when fromlist is empty, but its submodule B when fromlist is not empty. Tuomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Alphabetical sorts

2006-10-16 Thread Tuomas
My application needs to handle different language sorts. Do you know a way to apply strxfrm dynamically i.e. without setting the locale? Tuomas Neil Cerutti wrote: > On 2006-10-16, Ron Adam <[EMAIL PROTECTED]> wrote: > >>I have several applications where I want to sort lists

Re: cross-linked version of the python documentation

2006-10-20 Thread Tuomas
tom arnall wrote: > Is there a cross-linked version of the python documentation available? Is > anyone interested in starting a project for such? > > tom arnall > north spit, ca > usa > pydoc serves as such a cross-linked version of the python *online* documentation TV -- http://mail.python.o

Re: pylint: What's wrong with the builtin map()

2006-10-22 Thread Tuomas
Georg Brandl wrote: > Some people think that all occurences of map() must be replaced > by list comprehensions. The designer of pylint seems to be > one of those. So it seems, but why? Formally spoken we ase "using variable 'x' before assigment" in the comprehension too. #!/usr/bin/python """tes

pylint: What's wrong with the builtin map()

2006-10-22 Thread Tuomas
#!/usr/bin/python """test pydev_0.9.3/../pylint""" __revision__ = "test_mod 0.1 by TV 06/10/22" lst = ['aaa', ' bbb', '\tccc\n'] lst = map(lambda x: x.strip(), lst) result = """ No config file found, using default configuration * Module test_mod W: 6: Used builtin function 'map' E:

Re: __div__ not recognized automatically

2006-11-02 Thread Tuomas
Try a=(b+c)/NumX(2) TV Anton81 wrote: > Hello! > > I wrote a class > > class NumX: > ... > def __add__(self,other): > ... > def __div__(self,other): > if not isinstance(other,NumX): other=NumX(other) > ... > > Somewhere else I use > > a=(b+c)/2 > > where all variables are

forwarding *arg parameter

2006-11-05 Thread Tuomas
>>> def g(*arg): ... return arg ... >>> g('foo', 'bar') ('foo', 'bar') >>> # seems reasonable ... >>> g(g('foo', 'bar')) (('foo', 'bar'),) >>> # not so good, what g should return to get rid of the outer tuple TV -- http://mail.python.org/mailman/listinfo/python-list

Re: forwarding *arg parameter

2006-11-05 Thread Tuomas
Diez B. Roggisch wrote: > Tuomas schrieb: > >> >>> def g(*arg): >> ... return arg >> ... >> >>> g('foo', 'bar') >> ('foo', 'bar') >> >>> # seems reasonable >> ... >&g

Re: forwarding *arg parameter

2006-11-05 Thread Tuomas
Steven D'Aprano wrote: > You could write something like this: > > def g(*arg): > # Detect the special case of a single tuple argument > if len(arg) == 1 and type(arg[0]) == tuple: > return arg[0] > else: > return arg > > but now tuple arguments are treated differently

Re: forwarding *arg parameter

2006-11-05 Thread Tuomas
Tuomas wrote: > def g(*arg): > return arg > > def f(*arg): > return g(arg) > > How can g know if it is called directly with (('foo', 'bar'),) or via f > with ('foo', 'bar'). I coud write in f: return g(arg[0], arg[1]) if

Re: forwarding *arg parameter

2006-11-05 Thread Tuomas
Stargaming wrote: > Either you take one of the snippets here: > http://aspn.activestate.com/ASPN/search?query=flatten§ion=PYTHONCKBK&type=Subsection > > > or just use arg[0] clever (as mentioned a few times in this thread). Thanks. My solution became: >>> def flattern(arg): ... result = [

Re: forwarding *arg parameter

2006-11-05 Thread Tuomas
Dennis Lee Bieber wrote: > On Sun, 05 Nov 2006 17:42:30 GMT, Tuomas <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > >>I am looking a shorter way to do the above in the case: >> >>def g(*arg): >> return arg >> >

Re: forwarding *arg parameter

2006-11-06 Thread Tuomas
Dennis Lee Bieber wrote: > On Sun, 05 Nov 2006 22:51:00 GMT, Tuomas <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > >>> >> >>I fylly agree with tis: "Typically, the responsibility should be on the >>CALLER, not the C

Re: forwarding *arg parameter

2006-11-06 Thread Tuomas
Steven D'Aprano wrote: > On Sun, 05 Nov 2006 19:35:58 +, Tuomas wrote: > > >>Thanks. My solution became: >> >> >>> def flattern(arg): >>... result = [] >>... for item in arg: >>... if isinstance(item, (l

Re: forwarding *arg parameter

2006-11-06 Thread Tuomas
Steve Holden wrote: > Suppose you did actually want to do this you have chosen about the worst > possible way: the use of global variables to condition function > execution is a sure way to get into trouble. Consider if somebody else > want to use your function: they also have to set a global in

Re: forwarding *arg parameter

2006-11-07 Thread Tuomas
Steven D'Aprano wrote: > On Mon, 06 Nov 2006 13:03:55 +, Tuomas wrote: > > >>If you read the whole chain you find out what we were talking of. > > > I had already read the whole thread, and I've read it again in case I > missed something the first t

Catching toplevel move and resize

2006-09-16 Thread Tuomas
From a PyGTK component I would like to react moving and resizing the toplevel window. I try to connect the toplevel 'frame-event' to my callback, but the toplevel do not fire on moving or resizing. Any suggestions? Tuomas (Linux, Python 2.3, GTK 2.6.7) -- http://mail.python.o

Re: Catching toplevel move and resize

2006-09-16 Thread Tuomas
Pontus Ekberg wrote: > You are probably looking for "configure_event". That's it! Works fine, thanks. Tuomas -- http://mail.python.org/mailman/listinfo/python-list

Message dialog on 'focus-out-event'

2006-09-18 Thread Tuomas
# My second trial was to include self.grab_focus() before # show_message, but it gives focus to the toplevel # gtk.gdk.Window and I lose access to the entry. # Any suggestions? # Tuomas Vesterinen -- http://mail.python.org/mailman/listinfo/python-list

Re: "list index out of range" error

2006-09-20 Thread Tuomas
_lines-1) k has the same value and k+1 owerflows the list index range. Try for j in range(1, no_lines): ... if list_initial[k-1] < list_initial[k]: ... Tuomas > temp_str = list_initial[k] > elif list_initial[k] == list_initial[k+1]: >

gtk.Entry Colors

2006-09-24 Thread Tuomas
I would like to manipulate PyGTK Entry widget's background and foreground colors. Is it possible? How? Tuomas -- http://mail.python.org/mailman/listinfo/python-list

Re: gtk.Entry Colors

2006-09-24 Thread Tuomas
MonkeeSage wrote: > Tuomas wrote: > >>I would like to manipulate PyGTK Entry widget's background and >>foreground colors. Is it possible? How? > > > Yes, it is possible: > > # widget color > entry.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(&quo

Re: gtk.Entry Colors

2006-09-25 Thread Tuomas
MonkeeSage wrote: > Tuomas wrote: > >>Yes, I read the reference before posting here. I tried something like: > > > Hi Tuomas, > > I didn't mean to say that you hadn't read the docs (I had a hard time > finding the right methods in the docs too, even tho

Re: Resuming a program's execution after correcting error

2006-09-28 Thread Tuomas
e <= end_point: try: do_complex_computation(case) except Exception: print case break If you get an error you repair the program and set start_point=case and go on with the program. Tuomas -- http://mail.python.org/mailman/listinfo/python-list

Re: interleaving dictionary values

2006-11-22 Thread Tuomas
[EMAIL PROTECTED] wrote: > Hello, > > I was trying to create a flattened list of dictionary values where each > value is a list, and I was hoping to do this in some neat functionally > style, in some brief, throwaway line so that it would assume the > insignificance that it deserves in the grand s

Re: How to find script's directory

2007-08-19 Thread Tuomas
#!/usr/bin/python # module show_my_path # ... import os print 'os.path.abspath(__file__):', os.path.abspath(__file__) # ... # end of module [EMAIL PROTECTED] class]$ python >>> import show_my_path os.path.abspath(__file__): /misc/proc/py/test/class/show_my_path.py >>> [EMAIL PROTECTED] class]$ p

Re: sorting a list of lists

2007-08-27 Thread Tuomas
>>> records = [['dog',1,2], ['chair',2,1], ['cat',1,3], ['horse',3,4], ... ['table',3,2], ['window',3,5]] >>> sorted(records, key = lambda x: (x[1], x[2])) [['dog', 1, 2], ['cat', 1, 3], ['chair', 2, 1], ['table', 3, 2], ['horse', 3, 4], ['window', 3, 5]] [EMAIL PROTECTED] wrote: > Hi, > > i

Undeterministic strxfrm?

2007-09-04 Thread Tuomas
Python 2.4.3 (#3, Jun 4 2006, 09:19:30) [GCC 4.0.0 20050519 (Red Hat 4.0.0-8)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import locale >>> def key(s): ... locale.setlocale(locale.LC_COLLATE, 'en_US.utf8') ... return locale.strxfrm(s.encode('utf8

Re: REGULAR EXPRESSION

2007-09-04 Thread Tuomas
gt;> re.compile('(\+{0,1})?([0-9]+)').findall('879+34343') [('', '879'), ('+', '34343')] Tuomas Vesterinen -- http://mail.python.org/mailman/listinfo/python-list

Re: Undeterministic strxfrm?

2007-09-04 Thread Tuomas
Gabriel Genellina wrote: > En Tue, 04 Sep 2007 07:34:54 -0300, Tuomas > <[EMAIL PROTECTED]> escribi�: > >> Python 2.4.3 (#3, Jun 4 2006, 09:19:30) >> [GCC 4.0.0 20050519 (Red Hat 4.0.0-8)] on linux2 >> Type "help", "copyright", "credits

Re: Undeterministic strxfrm?

2007-09-04 Thread Tuomas
ter and I should kick strxfrm off and take strcoll instead. It costs converting the seach key in every step of the search. Tuomas > Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Undeterministic strxfrm?

2007-09-05 Thread Tuomas
uffer is resized, and strxfrm is called > again. That's a rather common sequence when buffer sizes are not known > in advance. > [Note that `dest` is indeterminate, NOT the function return value which > always returns the required buffer size] > OK, I made too quick conclusions of the man text without knowing the details. Tuomas -- http://mail.python.org/mailman/listinfo/python-list

Re: interesting puzzle......try this you will be rewarded...

2007-09-07 Thread Tuomas
To save your time: http://ilikeit.desiblogz.com/363/ojofuffo,+ojofuffo,+ojofuffo+-+Solutions+to+the+Hacking+puzzle++by+freestuffhotdeals.com.html Renu wrote: > Hi, > > Just click on this link n use ur common sence to navigate. > > It has 23 pages one after the other, starting from this first >

Re: An ordered dictionary for the Python library?

2007-09-12 Thread Tuomas
Mark Summerfield wrote: > I feel that Python lacks one useful data structure: an ordered > dictionary. Why it should be a dict. With it you can only maintain the order x1http://mail.python.org/mailman/listinfo/python-list

Exceptions and unicode messages

2007-03-21 Thread Tuomas
This works: >>> raise StandardError(u'Wrong type') Traceback (most recent call last): File "", line 1, in ? StandardError: Wrong type but don't in Finnish: >>> raise StandardError(u'Väärä tyyppi') Traceback (most recent call last): File "", line 1, in ? StandardError>>> >>> Any solution

Re: Exceptions and unicode messages

2007-03-21 Thread Tuomas
ok = excepthook >>> class UserError(StandardError): ... def __str__(self): ... return self.args[0] ... >>> raise UserError(u'Väärä tyyppi') Traceback (most recent call last): File "", line 1, in ? UserError: Väärä tyyppi >>> Tuomas Tuomas

Problems with datetime.datetime.strptime

2009-05-09 Thread Tuomas Vesterinen
r %Z' strftime('%m/%d/%Y')='05/09/2009' strptime('05/09/2009','%m/%d/%Y')= 2009-05-09 00:00:00 strftime('%r')='11:26:12 AM' strptime('11:26:12 AM','%r')= 'r' is a bad directi

Re: Problems with datetime.datetime.strptime

2009-05-10 Thread Tuomas Vesterinen
Nick Craig-Wood wrote: Tuomas Vesterinen wrote: I hoped that I could get rid of my special module _strptime2 when porting to Python 3.0. But testing is a disappointment. [snip] C : strftime('%a %b %e %H:%M:%S %Y')='Sat May 9 11:26:12 2009' strptime('Sat

Ambiguous locale.strxfrm

2009-05-22 Thread Tuomas Vesterinen
ts" or "license" for more information. >>> import locale >>> locale.setlocale(locale.LC_COLLATE, 'en_US.utf8') 'en_US.utf8' >>> key1=locale.strxfrm('maupassant guy') >>>> for i in range(10): ... print(locale.strxf

Re: Ambiguous locale.strxfrm

2009-05-23 Thread Tuomas Vesterinen
Thanks. Bug report done, issue 6093. Tuomas Vesterinen Gabriel Genellina wrote: En Fri, 22 May 2009 06:32:40 -0300, Tuomas Vesterinen escribió: This was fixed once in Python 2.5, but in Python 3.0 the bug celebrates its comeback. The tail of the strxfrm result is ambiguous. Python 3.0.1

Connecting to the users preferred email client

2009-12-04 Thread Tuomas Vesterinen
If I want to open a html-page from Python code I can say: >>> import webbrowser >>> webbrowser.open('index.html') Is there a standard way to init an email in users preferred email client like Thubderbird, Evolution etc.? Tuomas Vesterinen -- http://mail.python

Re: Connecting to the users preferred email client

2009-12-04 Thread Tuomas Vesterinen
Mike Driscoll wrote: On Dec 4, 5:28 am, Tuomas Vesterinen wrote: If I want to open a html-page from Python code I can say: >>> import webbrowser >>> webbrowser.open('index.html') Is there a standard way to init an email in users preferred email client lik

Using site-packages with alt-installed Python version

2010-05-16 Thread Tuomas Vesterinen
ocal/lib/python2.4/site-packages/gtk-2.0/glib/__init__.py", line 22, in ? from glib._glib import * ImportError: /usr/lib/libpyglib-2.0-python.so.0: undefined symbol: _PyObject_CallFunction_SizeT What I should say more to get access to the GTK? Tuomas Vesterinen -- http://mail.python.org/mailman/listinfo/python-list

Re: joining files

2010-05-16 Thread Tuomas Vesterinen
On 05/16/2010 05:04 PM, Dave Angel wrote: (You forgot to include the python-list in your response. So it only went to me. Normally, you just do reply-all to the message) mannu jha wrote: On Sun, 16 May 2010 13:52:31 +0530 wrote mannu jha wrote: Hi, I have few files like this: file1: 22

Re: Using site-packages with alt-installed Python version

2010-05-16 Thread Tuomas Vesterinen
On 05/16/2010 02:38 PM, Alister wrote: On Sun, 16 May 2010 12:07:08 +0300, Tuomas Vesterinen wrote: I am testing an application GUI with Python 2.4, 2.5 and 2.6. The native Python (in Fedora 12) is 2.6. Versions 2.4 and 2.5 are alt-installed. Aplication GUI uses: import pygtk pygtk.require

Python preprosessor

2009-06-07 Thread Tuomas Vesterinen
'foo', 'bar') #endif results: > cpp -E -Dpython2 test_cpp.py ... print u'foo', u'bar' Any other suggestions? Tuomas Vesterinen -- http://mail.python.org/mailman/listinfo/python-list

Re: Python preprosessor

2009-06-07 Thread Tuomas Vesterinen
Peter Otten wrote: Tuomas Vesterinen wrote: I am developing a Python application as a Python2.x and Python3.0 version. A common code base would make the work easier. So I thought to try a preprosessor. GNU cpp handles this kind of code correct: Any other suggestions? http

Re: Get the class name

2009-06-07 Thread Tuomas Vesterinen
Kless wrote: Is there any way of to get the class name to avoid to have that write it? --- class Foo: super(Foo, self) --- * Using Py 2.6.2 >>> class Foo(object): ... def cls(self): ... return self.__class__ ... >>> Foo().cls() -- http://mail.python.or

Re: Python preprosessor

2009-06-08 Thread Tuomas Vesterinen
R. David Murray wrote: Tuomas Vesterinen wrote: I am developing a Python application as a Python2.x and Python3.0 version. A common code base would make the work easier. So I thought to try a preprosessor. GNU cpp handles this kind of code correct: #ifdef python2 print u'foo&#x

Re: Python preprosessor

2009-06-08 Thread Tuomas Vesterinen
Roger Binns wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Tuomas Vesterinen wrote: I am intensively using 2to3.py. So I have 2 codebase: one in py2 and the other in py3. The expectation would be that you only maintain the py2 code and automatically generate the py3 code on demand

ANNOUNCEMENT: Tinybooker accounting released

2009-08-18 Thread Tuomas Vesterinen
Tinybooker 0.2.2 released at http://tinybooker.org/ Tinybooker is an accounting program offering the dual accounting core functionality for moderate size accountings: * Assisted establishing new accountings * Localized scheme templates * Easy entering and saving new entries * Sta