Re: Inconsistent reaction to extend

2005-09-09 Thread Timo

Jerzy Karczmarczuk kirjoitti:

> On the other hand, try
>
> p=range(4).extend([1,2])
>
> Then, p HAS NO VALUE (NoneType).
>
> With append the behaviour is similar. I didn't try other methods, but
> I suspect that it won't improve.
>
>
> WHY?

range(4) returns a list and Python's list.extend() returns None. Extend
is a in-place operation.

-- timo

-- 
http://mail.python.org/mailman/listinfo/python-list


Thread safe object cache without locking

2005-09-15 Thread Timo
I'm trying to make a thread safe object cache without locking.

The objects are cached by the id of the data dict given in __new__.
Objects are removed from the cache as soon as they are no longer
referenced. The type of the data must be a Python dict (comes from an
external source).

Here's what I've got so far:

import time
from weakref import ref

cache = {} # {id(data): ref_to_Foo(data), ...}

class Foo(object):

__slots__ = ('__weakref__', '_data')

def __new__(cls, data):
new_self = object.__new__(cls)

def remove(wr, _cache=cache, _data=data):
try:
del _cache[id(_data)]
except KeyError:
pass # should never happen

while 1:
self = cache.setdefault(id(data), ref(new_self, remove))()
try:
self._data = data
return self # this is new_self or a cached instance
except AttributeError:
# happens rarely: got a 'dead' cached instance
time.sleep(0) # small delay before retrying

# Usage example:
data = {'a':1, 'b':2}
a = Foo(data)
b = Foo(data)
assert a is b

I've got couple of assumptions based on I think the code is working
correctly:

a) Python's dict is thread safe, i.e. setdefault can't replace an
existing value until the key has been removed - no matter how many
threads are calling it simultaneously. Additionally, only one thread
succeeds in setting the new value.

b) Unreferenced ref(new_self, remove) objects are garbage collected
without the callbacks being called.

c) The remove() keeps a reference to the data dict. That should prevent
Python from reusing the object id too soon.

Are these assumptions correct? Do you have ideas for improvements
(especially regarding speed)? I'm restricted to Py2.3+ compatibility.

Thanks,
Timo

-- 
http://mail.python.org/mailman/listinfo/python-list


Erroneous line number error in Py2.4.1 [Windows 2000+SP3]

2005-04-06 Thread Timo
For some reason Python 2.3.5 reports the error in the following program
correctly:

  File "C:\Temp\problem.py", line 7
SyntaxError: unknown decode error

..whereas Python 2.4.1 reports an invalid line number:

  File "C:\Temp\problem.py", line 2
SyntaxError: unknown decode error

- problem.py starts -
# -*- coding: ascii -*-

"""
Foo bar
"""

# Ä is not allowed in ascii coding
- problem.py ends -

Does anyone have a clue what is going on? Without the encoding
declaration both Python versions report the usual deprecation warning
(just like they should be doing).

My environment: Windows 2000 + SP3.

BR,
Timo

--
http://mail.python.org/mailman/listinfo/python-list


Re: Erroneous line number error in Py2.4.1 [Windows 2000+SP3]

2005-04-07 Thread Timo
Martin v. Löwis wrote:
> Timo wrote:
> > Does anyone have a clue what is going on?
>
> No. Please make a bug report to sf.net/projects/python.
>

Done:

http://sourceforge.net/tracker/index.php?func=detail&aid=1178484&group_id=5470&atid=105470

BR,
Timo

--
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Timo
Steve Jobless kirjoitti:

> Let's say the class is defined as:
>
>   class MyClass:
> def __init__(self):
>   pass
> def func(self):
>   return 123
>
> But from the outside of the class my interpreter let me do:
>
>   x = MyClass()
>   x.instance_var_not_defined_in_the_class = 456
>
> or even:
>
>   x.func = 789
>
> After "x.func = 789", the function is totally shot.
>

You can avoid the problem by using the __slots__ definition and
new-style classes (inherit from object):

class MyClass(object):

__slots__ = ('bar',)

def func(self):
return 123

x = MyClass()
x.instance_var_not_defined_in_the_class = 456
==>
AttributeError: 'MyClass' object has no attribute
'instance_var_not_defined_in_the_class'

x.func = 789
==>
AttributeError: 'MyClass' object attribute 'func' is read-only

Only the bar-attribute can be set:

x.bar = 'foo'

-- timo

-- 
http://mail.python.org/mailman/listinfo/python-list


Mac OS distultils probelm

2008-05-19 Thread Timo
Hello there,

I'm working on a python extension module that I'm trying to install
using the distutils setup tools and I am running into a strange linker
problem. Here is the situation: I have a bunch of code (swig-wrapped C+
+ in this instance) that I want to compile into a module. The
compilation itself works just fine and so does the initial linking.
The linker command that distutils spits out looks somewhat like this

g++  -bundle -undefined dynamic_lookup mymodule_wrap.o  -o
_mymodule.so -framework Carbon -framework Cocoa -framework
ApplicationServices -framework AGL -framework OpenGL -framework GLUT -
framework Cocoa /usr/lib/libz.dylib

However, when I load the module in python a whole bunch of system
symbols are undefined starting in this case with aglSwapBuffers

ImportError: dlopen(_mymodule.so, 2): Symbol not found:
_aglSwapBuffers
Referenced from: _mymodule.so  Expected in: dynamic lookup

My understanding is that the _mymodule.so file should "know" that this
symbol came out of the AGL framework and thus look for it there. I
could understand if python wouldn't find the framework because of a
DYLD_LIBRARY_PATH issue or the like but here the problem seems to be
that the information from where the symbol came from is lost.

If I do a "more" on the _mymodule.so file that seems to be indeed what
happens. I see links to "/usr/lib/libz.dylib" and the system libraries
in there but none to the frameworks. However, now comes the really
interesting part. If I execute the *identical* command line from the
same shell I called "python setup.py install" from I get a different
library which *does* include the links to the frameworks. If I install
that file instead of the original everything works as expected.

So there seems to be a strange problem inside distutils. I looked at
that source code but couldn't make any sense out of it. Any idea of
what could cause this and how this could be fixed would be greatly
appreciated

Thanks
Timo

--
http://mail.python.org/mailman/listinfo/python-list


Re: filter in for loop

2008-08-28 Thread Timo
On 28 elo, 13:20, GHZ <[EMAIL PROTECTED]> wrote:

>
> is there a shortcut I'm missing?

(Adding to Bruno's comment)

This kind of style provides a reusable filter/generator-function and
as a bonus, the for-loop becomes easier to understand.

from os.path import abspath
from glob import iglob

def ipathnames(pattern):
return (abspath(n) for n in iglob(pattern))

for xmlfile in ipathnames('*.xml'):


-- timo
--
http://mail.python.org/mailman/listinfo/python-list


Re: Embedding Python in a shell script

2011-06-17 Thread Timo Lindemann
On Fri, 17 Jun 2011 00:57:25 +, Jason Friedman said:


> 
> but for various reasons I want a single script.  Any alternatives?

you can use a here document like this:


#! /bin/bash

/usr/bin/python2 << EOPYTHON
def hello():
print("Hello, World");

if __name__ == "__main__":
hello();

EOPYTHON
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Embedding Python in a shell script

2011-06-17 Thread Timo Lindemann
On Fri, 17 Jun 2011 22:15:57 +0200, Hans Mulder said:

> On 17/06/11 19:47:50, Timo Lindemann wrote:
>> On Fri, 17 Jun 2011 00:57:25 +, Jason Friedman said:
>>
>>
>>
>>> but for various reasons I want a single script.  Any alternatives?
>>
>> you can use a here document like this:
> That does not solve the problem as stated.  The OP wants to call python
> inside a loop and he wants to indent things properly:

so, wrap it inside a bash function like this:

#! /bin/bash

call_python() {
/usr/bin/python2 << EOPYTHON
def hello():
print("Hello, World $1");

if __name__ == "__main__":
hello();

EOPYTHON
}

for i in 1 2 3 4 5 6
do
call_python $i
done

That way, the indentation on is nicer; passing parameters to the script 
inside the heredoc might be mean if the parameters are formed 
difficultly, like, causing syntax errors if it's something like '"' or 
somesuch. Probably beside the point though. 

> For some ideas that may work, read the earlier posts in this thread.

maybe my news server doesn't fetch the whole thread. I didnt see any 
replies, and still don't except yours. 

Nice evenin'
-T.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to create a (transparent) decorator with status information?

2011-04-18 Thread Timo Schmiade
Hi all,

I'm currently occupying myself with python's decorators and have some
questions as to their usage. Specifically, I'd like to know how to
design a decorator that maintains a status. Most decorator examples I
encountered use a function as a decorator, naturally being stateless.

Consider the following:

def call_counts(function):
  @functools.wraps(function):
  def wrapper(*args, **kwargs):
# No status, can't count #calls.
return function(*args, **kwargs)
  return wrapper

Thinking object-orientedly, my first idea was to use an object as a
decorator:

class CallCounter:
  def __init__(self, decorated):
self.__function = decorated
self.__numCalls = 0

  def __call__(self, *args, **kwargs):
self.__numCalls += 1
return self.__function(*args, **kwargs)

  # To support decorating member functions
  def __get__(self, obj, objType):
return functools.partial(self.__call__, obj)

This approach however has three problems (let "decorated" be a function
decorated by either call_counts or CallCounter):

* The object is not transparent to the user like call_counts is. E.g.
  help(decorated) will return CallCounter's help and decorated.func_name
  will result in an error although decorated is a function.
* The maintained status is not shared among multiple instances of the
  decorator. This is unproblematic in this case, but might be a problem
  in others (e.g. logging to a file).
* I can't get the information from the decorator, so unless CallCounter
  emits the information on its own somehow (e.g. by using print), the
  decorator is completely pointless.

So, my question is: What would the "pythonic" way to implement a
decorator with status information be? Or am I missing the point of
decorators and am thinking in completely wrong directions?

Thanks in advance!

Kind regards,

Timo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to create a (transparent) decorator with status information?

2011-04-19 Thread Timo Schmiade
Hey Ian,

On Mon, Apr 18, 2011 at 01:07:58PM -0600, Ian Kelly wrote:
> In the simple case, just store the state on the wrapper function itself:
> 
> def call_counts(function):
>   @functools.wraps(function)
>   def wrapper(*args, **kwargs):
> wrapper.num_calls += 1
> return function(*args, **kwargs)
>   wrapper.num_calls = 0
>   return wrapper

Of course! Functions are first-class objects, so I can give them members
just as I would do with any other object. I'm still thinking too much
C++...

> If you want the state to be shared, you should probably store it in an
> object and use an instance method as the decorator:

Yes, this is the same idea that Wayne came up with. Thank you as well,
that helped me understand decorators a lot more.

Kind regards,

Timo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to create a (transparent) decorator with status information?

2011-04-19 Thread Timo Schmiade
Hey Wayne,

On Mon, Apr 18, 2011 at 04:04:15PM -0700, Wayne Witzel III wrote:
> Going with the object approach, you could use Borg to give yourself the state 
> between instances you mentioned. And since you are using an object, you'll 
> have access to the data without needing to return it from the decorator.
> 
> class StatefulDecorators(object):
> _state = {}
> def __new__(cls, *p, **k):
> self = object.__new__(cls, *p, **k)
> self.__dict__ = cls._state
> return self
> 
> def count_calls(self, function):
> @functools.wraps(function)
> def wrapper(*args, **kwargs):
> try:
> self.calls += 1
> except AttributeError:
> self.calls = 1
> return function(*args, **kwargs)
> return wrapper

Brilliant! I didn't realize you could use member functions as
decorators, too! That way, you can easily create closures to self,
solving all the problems I was seeing.

Just one question remains now: What is a "Borg" in this context?

Thank you.

Timo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to create a (transparent) decorator with status information?

2011-04-19 Thread Timo Schmiade
On Tue, Apr 19, 2011 at 08:20:05AM -0600, Ian Kelly wrote:
> On Tue, Apr 19, 2011 at 1:12 AM, Timo Schmiade  wrote:
> > Just one question remains now: What is a "Borg" in this context?
> 
> http://code.activestate.com/recipes/66531/
> -- 
> http://mail.python.org/mailman/listinfo/python-list

Thanks again!
-- 
http://mail.python.org/mailman/listinfo/python-list


can't use Python in Materialise Mimics

2022-03-26 Thread Timo Meijer


Dear Sir/Madam,

Due to uknown reasons my materialise mimics floating license does not recognize 
Python.
I have installed it under my C drive, program files, Python. But when selecting 
this folder it says it does not contain the program. I have followed these 
steps:

https://www.youtube.com/watch?v=iVBCNZykcrc&ab_channel=MaterialiseMedical

But unfortunately it does not work.
Could you help me out?

Kind regards,

Timo Meijer
0031651634920

Verzonden vanuit Mail<https://go.microsoft.com/fwlink/?LinkId=550986> voor 
Windows

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: syntax question

2018-06-02 Thread Timo Furrer
>From the Python documentation at
https://docs.python.org/3/tutorial/controlflow.html#lambda-expressions

> Small anonymous functions can be created with the lambda
<https://docs.python.org/3/reference/expressions.html#lambda> keyword. This
function returns the sum of its two arguments: lambda a, b: a+b. Lambda
functions can be used wherever function objects are required. They are
syntactically restricted to a single expression. Semantically, they are
just syntactic sugar for a normal function definition.

Thus, in your case the lambda is equivalent to:

def line(x):
return x + 3

Cheers, Timo

On Sat, Jun 2, 2018 at 1:12 PM Sharan Basappa 
wrote:

> Can anyone please tell me what the following line in a python program does:
>
> line = lambda x: x + 3
>
> I have pasted the entire code below for reference:
>
> from scipy.optimize import fsolve
> import numpy as np
> line = lambda x: x + 3
> solution = fsolve(line, -2)
> print solution
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
*Timo Furrer*

https://github.com/timofurrer
tuxt...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re:

2018-06-10 Thread Timo Furrer
Can you be more specific.
What did you try? In which environment? What was the error message you got?

On Sun, Jun 10, 2018 at 6:32 PM sagar daya  wrote:

> Couldn't install any module from pip
> Plz help???
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
*Timo Furrer*

https://github.com/timofurrer
tuxt...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Other notes

2005-01-06 Thread Timo Virkkala
[EMAIL PROTECTED] wrote:
Andrew Dalke:
(BTW, it needs to be 1 .. 12 not 1..12 because 1. will be interpreted
as the floating point value "1.0".)<
Uhm, I have to fix my ignorance about parsers.
Cannot a second "." after the first tell that the first "." isn't in
the middle of a floating point number?
Python uses an LL(1) parser. From Wikipedia:
""" LL(1) grammars, although fairly restrictive, are very popular because the 
corresponding LL parsers only need to look at the next token to make their 
parsing decisions."""

This may allow: assert 5 interval 9 == interval(5,9)
Maybe you could give an example of when you need this in real life?<
Every time you have a function with 2 parameters, you can choose to use
it infix.
But why would you want to? What advantage does this give over the standard 
syntax? Remember, in Python philosophy, there should be one obvious way to do 
it, and preferably only one. Adding a whole another way of calling functions 
complicates things without adding much advantage. Especially so because you 
suggest it is only used for binary, i.e. two-parameter functions.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why tuples use parentheses ()'s instead of something else like <>'s?

2005-01-06 Thread Timo Virkkala
[EMAIL PROTECTED] wrote:
I can't thank you enough for your reply and for everyones' great info
on this thread.  The end of your email gave a rock solid reason why it
is impossible to improve upon ()'s for tuples
Actually, you missed the point. The parentheses don't have anything to do with 
the tuple. They are just used for disambiguation. It's the commas that define 
the tuple.

--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: python without OO

2005-01-26 Thread Timo Virkkala
This guy has got to be a troll. No other way to understand.
--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: python without OO

2005-01-27 Thread Timo Virkkala
Davor wrote:
Timo Virkkala wrote:
This guy has got to be a troll. No other way to understand.
not really - it was not my intention at all - but it seems people get 
upset whenever this OO stuff is mentioned - and what I did not expect at 
all at this forum as I believed Python people should not be so OO 
hardcore (seems not all as quite a few have indicated in their 
replies)... Nevertheless, I think the discussion has several quite good 
points!
Yes, sorry about that. I posted too soon. After posting I read more of your 
posts and realized that you really mean it, so I tried to cancel my message, but 
apparently it got through (news message canceling has never been that reliable..).

I believe that if you take the time to do some Python programming, you can find 
out that OO, when used correctly, is not the huge monster your previous 
languages had led you to believe it is. In Python, you can use just the right 
amount of OO to make things easier and more sensible, without complicating 
things with huge inheritance trees and unnecessary polymorphism.

Again, sorry about my premature judgement.
--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: python without OO

2005-01-27 Thread Timo Virkkala
[EMAIL PROTECTED] wrote:
I think the OO way is slightly more obscure. It's obvious what x =
reverse(x) does, but it is not clear unless you have the source code
whether x.reverse() reverses x or if it returns a reversed list. If
x.reverse() does the former, a disadvantage relative to the procedural
approach is that a function can be used in an expression. It is clearer
and more concise to write
Sure, it's clear if in written code you see
x = reverse(x)
To me it would also be clear to see
x.reverse()
But what if you just see in some list that there is a reverse(sequence) 
function, or that a sequence has a reverse() method? To me, neither of these is 
clear. Do they return a new, reversed sequence or reverse in place?

When creating a new API, I would probably use a convention where reverse does it 
in place and reversed returns a new. So, in my API,

reverse(x)
y = reversed(x)
x.reverse()
y = x.reversed()
--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: [perl-python] 20050127 traverse a dir

2005-01-27 Thread Timo Virkkala
The Flow wrote:
Do you want to be taken seriously?
First, stop posting.
Second, learn perl.
Third, learn python.
No. Second, learn Python. Third, learn Perl (optional). :)
But we do agree on the first.
--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: [perl-python] daily tip website

2005-01-28 Thread Timo Virkkala
Xah Lee wrote:
Thanks to those who have made useful comments. They will be
assimilated.
The comments, or those who have made comments?
"Corrections are futile. You will be assimilated."
 --Xah Lee
--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie alert

2005-02-02 Thread Timo Virkkala
Valone, Toren W. wrote:
Traceback (most recent call last):
  File "C:/Python24/dialog1.py", line 29, in -toplevel-
d = MyDialog(root)
NameError: name 'MyDialog' is not defined
Suggestion: Read the place in your code where MyDialog is defined and compare it 
with where it is used. Check case. You'll find the problem :)

--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: python code with indention

2005-02-08 Thread Timo Virkkala
Xah Lee wrote:
is it possible to write python code without any indentation?
1) Why in the name of Xah Lee would you even want to?
2) If you need to ask questions this simple, are you sure you are the right 
person to write tutorials?
3) Do you even read the replies you get?

--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and version control

2005-02-09 Thread Timo Virkkala
Carl wrote:
What is the ultimate version control tool for Python if you are working in a
Windows environment? 
I would very much recommend Subversion. It's in no way specific to either 
Windows or Python, but it's a wonderful tool. If you've ever used CVS, you'll 
feel right at home. Or after 10 minutes of learning the commands, that is.

And as someone already suggested, TortoiseSVN is a great front-end for SVN. It 
integrates with the Windows shell very nicely.

http://subversion.tigris.org/
http://tortoisesvn.tigris.org/
--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: Faster way to do this...

2005-03-03 Thread Timo Virkkala
Harlin Seritt wrote:
Roy, I like what you showed: nums = [a for a in range(100)] . My
mistake for not expressing my question as well as I should have. Not
only am I looking for a way to fill in 100 spots (more or less) in an
array er... list, but I'd like to be able to do it in intervals of
2, 4, 8 etc. as well as other things.
range(2, 100, 4)
How about you fire up the interactive python and try
help(range)
;)
--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


PyOpenGL issues (glutGetModifiers())

2005-03-06 Thread Timo Finnilä
Hi,
I'm having some weird issues with Python 2.4 and PyOpenGL 2.0.2.01 (and 
also with older versions).

When I call glutGetModifiers from event handler functions (set using 
glutMouseFunc, glutMotionFunc etc...), it just says:

"GLUT: Warning in foo: glutCurrentModifiers: do not call outside core 
input callback."

And the return value is always zero.
This problem appeared once I installed PyOpenGL 2.0.2.01. Some older 
version did work fine otherwise, but crashed if CTRL was pressed during 
a mouse event. And oh, everything worked just fine with Python 2.3 and 
some older version of PyOpenGL.

I've already run out of ideas, so any help would be greatly appreciated.
Thanks.
--timof
--
http://mail.python.org/mailman/listinfo/python-list


Re: Closing files

2004-11-29 Thread Timo Virkkala
Daniel Dittmar wrote:
And then there are a lot of people who think that changing all the 
readlines one liner would be quite easy should the need of a Jython port 
arrive, so why bother about it now?
The problem with this approach is, when the time for the Jython port 
arrives, do you remember to do it?

--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: How is Python designed?

2004-12-02 Thread Timo Virkkala
Limin Fu wrote:
Hello,
Is there any technical description on internet of how
python is designed? Or can somebody give a short
description about this? I'm just curious.
Do you mean the structure and design of the language, or the process of 
designing the language?

Well, in either case, you'll probably find your answer at http://www.python.org
Take a look at the Docs -> Language Reference and PEP sections.
--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: creating generators from function

2004-12-08 Thread Timo Virkkala
Simon Wittber wrote:
I guess this changes my question to: Can I convert a function
containing an infinite loop, into a generator which will yield on each
iteration?
Why don't you just use threads? It would probably be easier in the long 
run...
--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python vs. Perl

2004-12-13 Thread Timo Virkkala
Christos TZOTZIOY Georgiou wrote:
Both languages cover all of your requirements.  So read as much
documentation needed to write some simple programs as examples doing
similar tasks to the one you want in *both* languages.  Test them that
they work.  Then forget about your problems.  Go to an island.  Dream.
Relax.  Come back without explanations six months later, and if they
take you back in the same company, read *both* of your example programs.
You'll know then which language to select (I would select the language
of the island natives, but that's another story :)
That's unfair! That approach leads to Python every time!
Oh wait, that was the purpose.. :)
--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: lies about OOP

2004-12-14 Thread Timo Virkkala
projecktzero wrote:
A co-worker considers himself "old school" in that he hasn't seen the
light of OOP.(It might be because he's in love with Perl...but that's
another story.) He thinks that OOP has more overhead and is slower than
programs written the procedural way. I poked around google, but I don't
know the magic words to put in to prove or disprove his assertion. Can
anyone point me toward some resources?
Sounds like your co-worker has a major case of premature optimization. I don't 
know about speed issues with OO, but for large projects, using OOP makes data 
encapsulation so much easier. Writing correct code with minimum effort should be 
the first goal, speed issues (at that level) should be brought into the game 
later on.

You should ask your co-worker if he also puts all his data in global variables 
:)
*wink*
--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: Should I always call PyErr_Clear() when an exception occurs?

2004-12-21 Thread Timo Virkkala
Nick Coghlan wrote:
Although coding in C when you have the Python API to lean on is a hell 
of a lot better than just coding in C. . .
I've lately been coding in C for a Unix programming course in our Univ. Although 
I've run into many interesting problems, I feel that making the same programs in 
Python would have been a LOT nicer. Less challenging, sure, but definitely more fun.

--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: html tags and python

2005-03-30 Thread Timo Virkkala
Hansan wrote:
I also want the user to choose a date
I will make this with another dropdownbox.
But if the first month is selected, then there should be 31 days in the days
dropdownbox, if the second month is selected there should be 28 days in the
dropdownbow.
I know this isn't the solution to your problem (the solution would be to use 
JavaScript), but if I was a user, I'd rather type in the day number myself than 
have to choose from a 31-long dropdown. Why don't you just give the user a text 
field and then validate the input.

Just my 2 cents..
--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: Daemon strategy

2016-02-06 Thread Timo Furrer
As Ben already said .. either deploy to Unix systems or use
subprocess.Popen and detach the process:

from subprocess import Popenfrom win32process import DETACHED_PROCESS
Popen(["YOURPROCESS"],creationflags=DETACHED_PROCESS,shell=True)



On Fri, Feb 5, 2016 at 10:52 AM, Ben Finney 
wrote:

> paul.hermeneu...@gmail.com writes:
>
> > It appears that python-deamon would be exactly what I need. Alas,
> > appears not to run on Windows. If I am wrong about that, please tell
> > me.
>
> You're correct that ‘python-daemon’ uses Unix facilities to create a
> well-behaved Unix daemon process.
>
> Since MS Windows lacks those facilities, ‘python-daemon’ can't use them.
>
> > To what tools should I turn?
>
> If what you need – the support to create a Unix daemon process – is
> available only on Unix by definition, it seems you'll need to deploy to
> Unix.
>
> > I am not eager to produce a "service" on Windows unless it cannot be
> > avoided.
>
> Agreed :-)
>
> --
>  \ “Wrinkles should merely indicate where smiles have been.” —Mark |
>   `\Twain, _Following the Equator_ |
> _o__)  |
> Ben Finney
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
*Timo Furrer*

https://github.com/timofurrer
tuxt...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Reading from stdin first, then use curses

2013-08-11 Thread Timo Schmiade
Hi all,

I wrote a replacement for urlview to properly extract URLs from emails.
You can find the first draft here:

  https://github.com/the-isz/pyurlview

When I call it with an email file passed to the '-f' argument, it does
pretty much what I want already. However, I intend to use it in mutt,
which pipes the message to the program like so:

macro pager \cu 'pyurlview.py' 'Follow links with pyurlview'

The problem is rather obvious but - unfortunately - not so easy to solve:

* The program reads the mail from stdin
* The terminal in which it runs is a pseudo-terminal (pipe)
* curses is not able to accept user input from the pseudo-terminal

The question is:

How do I read from stdin first and afterwards allow curses to read user
input?

Thanks in advance and kind regards,

Timo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading from stdin first, then use curses

2013-08-31 Thread Timo Schmiade
Hi again,

sorry for replying to my own mail, but is there really no solution? Can
curses really not be used in this situation?

Thanks again,

Timo

On Sun, Aug 11, 2013 at 02:05:11PM +0200, Timo Schmiade wrote:
> Hi all,
> 
> I wrote a replacement for urlview to properly extract URLs from emails.
> You can find the first draft here:
> 
>   https://github.com/the-isz/pyurlview
> 
> When I call it with an email file passed to the '-f' argument, it does
> pretty much what I want already. However, I intend to use it in mutt,
> which pipes the message to the program like so:
> 
> macro pager \cu 'pyurlview.py' 'Follow links with 
> pyurlview'
> 
> The problem is rather obvious but - unfortunately - not so easy to solve:
> 
> * The program reads the mail from stdin
> * The terminal in which it runs is a pseudo-terminal (pipe)
> * curses is not able to accept user input from the pseudo-terminal
> 
> The question is:
> 
> How do I read from stdin first and afterwards allow curses to read user
> input?
> 
> Thanks in advance and kind regards,
> 
> Timo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is Expressiveness in a Computer Language

2006-06-22 Thread Timo Stamm
Claudio Grondi schrieb:
> Looking this thread growing it appears to me, that at least one thing 
> becomes evident here:
> 
> Xah unwillingness to learn from the bad past experience contaminates 
> others (who are still posting to his trolling threads).

This is actually one of the most interesting threads I have read in a 
long time. If you ignore the evangelism, there is a lot if high-quality 
information and first-hand experience you couldn't find in a dozen books.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Xah's Edu Corner: What Languages to Hate

2006-04-29 Thread Timo Stamm
John Bokma schrieb:
> 
> I have warned this user that excessive offtopic cross-posting is not 
> allowed,[...]
> 


I just wrote to the abuse department at dreamhost, telling them that 
your accusations are highly exaggerated.


Timo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Software Needs Philosophers

2006-05-22 Thread Timo Stamm
Dražen Gemić schrieb:
> Xah Lee wrote:
>> Software Needs Philosophers
>>
> 
> Welcome to my junk filters 


Thanks for informing each and every reader of the newsgroups 
comp.lang.perl.misc, comp.lang.python, comp.lang.java.programmer, 
comp.lang.lisp, comp.lang.function about your junk filters.


Timo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: John Bokma harassment

2006-05-24 Thread Timo Stamm
Tim N. van der Leeuw schrieb:
> [EMAIL PROTECTED] wrote:
>> I agree there are limits to you right to free speech, but I believe Xah
>> Lee is not crossing
>> any boundaries. If he starts taking over newspapers and TV stations be
>> sure to notify me,
>> I might revise my position.
>> Immanuel
> 
> Perhaps he's not crossing boundaries of free speech, but he's
> repeatedly crossing boundaries on usenet nettiquette, even though
> repeatedly he's being asked not to do so.

And repeatedly, others have encouraged him because they appreciate his 
posts.


> but since I've stopped following threads originated by him

That's all you need to do if you are not interested in his posts.


Timo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: John Bokma harassment

2006-05-24 Thread Timo Stamm
John Bokma schrieb:
> Timo Stamm <[EMAIL PROTECTED]> wrote:
> 
>> Tim N. van der Leeuw schrieb:
> [...]
>>> but since I've stopped following threads originated by him
>> That's all you need to do if you are not interested in his posts.
> 
> You're mistaken. All you need to do is report it.

Why the hell should I do that? I find his postings interesting. Of 
course I am just a pathetic, egocentric sock puppet with a dent in my 
ego and not using my brains, according to your logic.

Thank you.


> After some time Xah will either walk in line with the rest of the world  > 
> [...]

You sound like a villain from a James Bond movie.


Timo
-- 
http://mail.python.org/mailman/listinfo/python-list


Using python 3 for scripting?

2009-03-22 Thread Timo Myyrä

Hi,

I'll have to do some scripting in the near future and I was 
thinking on using the Python for it. I would like to know which 
version of Python to use? Is the Python 3 ready for use or should 
I stick with older releases?


Timo
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using python 3 for scripting?

2009-03-22 Thread Timo Myyrä
Ok, I think I'll stick with the 2.6 then. I recall it gave 
warnings about things that are deprecated in 3.0 so it will make 
porting the scripts to 3.0 easier. 


I might try 3.0 once I know what kind of scripts are needed.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using python 3 for scripting?

2009-03-22 Thread Timo Myyrä
I might get summer job in doing some 2nd tier support and doing 
some scripting besides that in Solaris environment. I gotta see 
what kind of scripts are needed but I'd guess the 2.6 would be the 
safest option. 


Timo
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using python 3 for scripting?

2009-03-23 Thread Timo Myyrä
Not too keen on working with Solaris either. Did some small 
configuration last time I worked there and it was all a mess. I'm 
trying to convince them to switch to OpenBSD :)


Timo
--
http://mail.python.org/mailman/listinfo/python-list


Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations

2006-03-17 Thread Timo Stamm
Fuzzyman schrieb:
> Roedy Green wrote:
>> On 15 Mar 2006 22:20:52 -0800, "Xah Lee" <[EMAIL PROTECTED]> wrote,
>> quoted or indirectly quoted someone who said :
>>
>>> e. For example, the in-fix
>>> notation =E2=80=9C(3+(2*5))>7=E2=80=9D is written as =E2=80=9C3 2 5 * + 7 >=
>>> =E2=80=9D, where the
>> Not that Mr. Lee has ever shown much interest in feedback, but you
>> pretty well have stick to vanilla ASCII to get your notation through
>> unmangled on newsgroups.
> 
> Hmmm... it displays fine via google groups. Maybe it's the reader which
> is 'non-compliant' ?


Other charsets than US-ASCII are widely accepted in non-english 
newsgroups as long as the charset is properly declared.

Xah's posting was properly encoded and will display fine in every decent 
newsreader.


Timo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations

2006-03-17 Thread Timo Stamm
[EMAIL PROTECTED] schrieb:
> In comp.lang.perl.misc Timo Stamm <[EMAIL PROTECTED]> wrote:
>> Other charsets than US-ASCII are widely accepted in non-english 
>> newsgroups as long as the charset is properly declared.
>  
>> Xah's posting was properly encoded and will display fine in every decent 
>> newsreader.
> 
> It is not just the question of the newsreader, it is also a question of 
> whether
> the character set/font being used is capable of displaying the characters
> concerned. 

A character set doesn't display characters, it specifies the coupling of 
a character (grapheme) and its representation in a data format (number).

Because the specification of internet text messages only allows 7 bit 
ASCII, Multipurpose Internet Mail Extensions have been introduced. They 
define, for example, the quoted-printable transfer encoding.

Xah's posting properly declared a quoted-printable transfer encoding and 
the UTF-8 charset. There were no unspecified characters in the message, 
it was absolutely adhering to the recognized standards.


If this message doesn't display properly on your system - because your 
newsreader doesn't know how to decode quoted printable or because your 
operating system lacks a font to display the characters, this may be a 
problem. But it's your newsreader or your OS that is broken or not up to 
date.

BTW, the newsreader you are using should handle the posting fine.


Timo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting a Python program to run of off a flash drive?

2010-04-01 Thread timo verbeek
On Apr 1, 12:48 am, Abethebabe  wrote:
> I wanted to know if there was a way I could get a Python program to
> run off of my flash drive as soon as the computer (Windows) detected
> the device?
>
> For example I could have a a simple program that would create a text
> document on the computers desktop when my flash drive is detected.

You could use Autorun.inf if your using Windows but for linux I don't
now
-- 
http://mail.python.org/mailman/listinfo/python-list


Human word reader

2010-05-15 Thread timo verbeek
I'm planning to create a human word program
A human inputs a string
"Give me the weather for London please."
Then I will strip the string.
"weather for london"
Then I get the useful information.
what:"weather" where:"london"
After that I use the info.

I need help with getting the useful information how do I get the place
if I don't now how long the string is?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Human word reader

2010-05-15 Thread timo verbeek
On May 15, 1:02 pm, timo verbeek  wrote:
Place starts always with for

-- 
http://mail.python.org/mailman/listinfo/python-list


creating addon system

2010-05-21 Thread timo verbeek
What is the easiest way in python to create a addon system?
I found to easy ways:
* using a import system like this:
   for striper in stripers:
if striper["enabled"]:
exec("from strip import %s as _x"%striper["striper"])
string = _x.start(string)
* using exec
   for striper in stripers:
if striper["enabled"]:
use=open(stripper)
exec(use)

Do you now is the best way?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: creating addon system

2010-05-22 Thread timo verbeek
Is there not an other way to create a fast addon system?
A module or something like that
-- 
http://mail.python.org/mailman/listinfo/python-list


type error raise

2010-05-27 Thread timo verbeek
what is the problem with this code?

_base={"repeat":False,"string":"Progres has failed","works":True}
print _base
class dictreturn(_base):pass

this error
Traceback (most recent call last):
  File "", line 244, in run_nodebug
  File "C:\Documents and Settings\Owner\Desktop\Python\assistent new
\user\dictreturn.py", line 4, in 
class dictreturn(_base):pass
TypeError: Error when calling the metaclass bases
-- 
http://mail.python.org/mailman/listinfo/python-list