Re: No more Python support in NetBeans 7.0

2011-04-20 Thread Markus
I read it too.
I always preferred Netbeans + their Python plugin over Eclipse and
PyDev.

Perhaps I have another look for working with Aptana + PyDev for my web
development stuff, but I am afraid this enviroment (and the base,
Eclipse as it's main reason) is as user unfriendly as it always was.
But long years there was no other choice than Eclipse - Netbeans wasnt
the IDE it is now - and so the people started to build plugins for
Eclipse even being aware of its shortcomings.

I think I check out Activestates Komodo IDE.
I recognized that I use their free Komodo Edit more often lately and
liked the Editor already, perhaps the IDE will be a good choice.

I've seen right now, they put on the topic:
http://www.activestate.com/blog/2011/03/netbeans-drops-python-support-komodo-adds-more

Infoworld awarded it as best Python IDE, testing: Boa Constructor,
Eric, ActiveState's Komodo, Oracle's NetBeans, Aptana's Pydev,
PyScripter, SPE, Spyder, and WingWare's Wing IDE.

And if all fails, remember, there is always vim to fallback :)



On Mar 24, 4:32 pm, Kees Bakker  wrote:
> Hi,
>
> Sad news (for me, at least), in the upcoming version 7.0 of NetBeans
> there will be no Python plugin anymore.
>
> I have been using NetBeans for Python development for a while now
> and I was very happy with it.
>
> See this archive for 
> details:http://netbeans.org/projects/www/lists/nbpython-dev/archive/2010-11/m...http://netbeans.org/projects/www/lists/nbpython-dev/archive/2011-01/m...
> --
> Kees


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


Re: Learning Python

2005-10-11 Thread Markus
I do highly recommend this site, too.
Listen to the python411 podcast shows. It's great.



Jeff Fox wrote:
> Lots of links to all levels of tutorials and documentation here:
> http://www.awaretek.com/plf.html
> 
> Python Podcast too!
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I need Motivation

2005-11-06 Thread Markus
I can recommend you listening to the Python411 podcast.
http://www.awaretek.com/python/index.html

-Markus-



[EMAIL PROTECTED] wrote:
> I m not a python Expert or anythin
> i need help, i m losin my motivation to continue with python
> can anyone inspire me again.???
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Running multiple console processes and watching their output

2005-08-23 Thread Markus
If you are under UNIX, try the 'screen' command.

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


Re: Threading: Method trigger after thred finished

2011-10-20 Thread Markus
On Oct 20, 5:55 am, Steven D'Aprano  wrote:
> On Wed, 19 Oct 2011 13:14:21 -0700, markus.mj wrote:
> > Hi,
>
> > I am looking for help with following problem. I scripted threaded
> > database query, with session open per thread, and queries delivered
> > through queue. Every open DB session must be closed with "abort" or
> > "commit", however on which event should I trigger the DB disconnect?
> > Ideally it would close the DB as the thread class gets deconstructed,
> > but "__del__" does never fire.
>
> The __del__ destructor method is not guaranteed to be called in a timely
> fashion, if at all. My *guess* is that the main Python environment is
> shutting down when the daemon threads get killed, and the __del__ method
> never gets a chance to run.
>
> To be honest, I'm not sure why you are using daemon threads. It seems to
> me that blocking until the queue is empty makes the use of daemon threads
> pointless, but I'm not experienced enough with threads to be sure.
>
> The usual advice is to explicitly call destructors rather than rely on
> automatic __del__ methods. Given that, this works for me:
>
> import threading
> import Queue
> import time
>
> # Fill the queue.
> queue = Queue.Queue()
> queries = ["query"+str(i) for i in range(10)]
> for query in queries:
>     queue.put(query)
>
> # Make consumer threads.
> class ThreadSql(threading.Thread):
>     def __init__(self, queue):
>         threading.Thread.__init__(self)
>         self.queue = queue
>         # Open database connection instance
>         self.session = "+++connection+++"  # DbConnect()
>         self._open = True
>
>     def run(self):
>         while self._open:
>             # Grab a query from queue.
>             query = self.queue.get()
>             # And process it.
>             print self, query
>             time.sleep(1)
>             # Mark the queue job as done.
>             self.queue.task_done()
>
>     def close(self):
>         print "Closing", self
>         # self.session.Disconnect()
>         self._open = False
>
> threads = [ThreadSql(queue) for _ in range(4)]
> for t in threads:
>     t.setDaemon(True)
>     t.start()
>
> # Wait until the queue is empty, then close the threads.
> queue.join()
> for t in threads:
>     t.close()
>
> --
> Steven

Hi Steven,

great point with the explicit call of destructor.
I did a quick test and it is behaving exactly like I need.

Thank you very much!
Markus
-- 
http://mail.python.org/mailman/listinfo/python-list


How can I optimise this? [intended in good humour]

2006-07-24 Thread Markus
You know you're guilty of early/over optimisation, when it's almost two
in the morning and the file open in front of you reads as follows.

  The code you are about to read is real...
  Some of the variable names have been changed
  to protect the families of those involved.

[-snip-]

from timeit import Timer

if __name__=='__main__':
 t = Timer('len(argv)==1','from sys import argv')
 print "%f usec/pass" % (100 * t.timeit(number=10)/10)
 t = Timer('argv[0]==argv[-1]','from sys import argv')
 print "%f usec/pass" % (100 * t.timeit(number=10)/10)

[-snip-]

For anyone is in danger of making the same mistakes I've made...
the results were:

   0.219154 usec/pass
   0.297468 usec/pass


If anyone doesn't understand...
  Timer is a "Class for timing execution speed of small code snippets."
  The quoted description of Timer and the original code I derived the
  above snippet from, can be found in the Python documentation.

Finally, for anyone who is wondering...
  I will seek help as soon as I have some free time.

;)

Markus



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


parse GET/POST data on simple http server

2011-02-03 Thread Markus
Hi,

As a beginner in python, I am looking for example code that would help
me understand how to
code following idea:
1. Start minimal http server
2. Send GET or POST data (url encoded, or from form) - example
Name="Foo"
3. Analyze the GET/POST variable value on server and match to
different value
example 'if Name = "Foo" then retval = "Bar" '
4. serve the content of retval back to user as plain html

If some code snipped that does implement all or part of the algorithm
is known to you, please point me to it. I would be thankful for any
push to the right direction.

Thank you!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: parse GET/POST data on simple http server

2011-02-03 Thread Markus
On Feb 3, 9:35 am, Chris Rebert  wrote:
> On Thu, Feb 3, 2011 at 12:15 AM, Markus  wrote:
> > Hi,
>
> > As a beginner in python, I am looking for example code that would help
> > me understand how to
> > code following idea:
> > 1. Start minimal http server
>
> http://docs.python.org/library/basehttpserver.htmlhttp://docs.python.org/library/simplehttpserver.htmlhttp://docs.python.org/library/cgihttpserver.html
>
> > 2. Send GET or POST data (url encoded, or from form) - example
> > Name="Foo"
>
> http://docs.python.org/library/urllib.html#urllib.urlencode
>
> > 3. Analyze the GET/POST variable value on server and match to
> > different value
> >    example 'if Name = "Foo" then retval = "Bar" '
>
> http://docs.python.org/library/cgi.html
>
> > 4. serve the content of retval back to user as plain html
>
> > If some code snipped that does implement all or part of the algorithm
> > is known to you, please point me to it. I would be thankful for any
> > push to the right direction.
>
> You'll be reinventing quite a few wheels if you work at such a low
> level of abstraction. Have you considered using a web framework?
> Django (http://www.djangoproject.com/) is one of the popular ones,
> though there are a myriad of options
> (http://wiki.python.org/moin/WebFrameworks). I would recommend
> learning Python first and then a web framework, rather than trying to
> learn both in tandem.
>
> Cheers,
> Chris
> --http://blog.rebertia.com

Thank you for all that input, I will definitely check Django - it
looks very interesting.
I just found an example code that fits perfectly and is simple enough
for me to play with it.
http://stackoverflow.com/questions/336866/how-to-implement-a-minimal-server-for-ajax-in-python
And one older post handling the same case with HTTPS:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/a1e761a02a852821/2ff6f704b3a6749a?lnk=gst&q=server+parse+post#2ff6f704b3a6749a

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


Re: 10 sec poll - please reply!

2012-11-21 Thread markus . moldaschl
Am Dienstag, 20. November 2012 13:18:38 UTC+1 schrieb Michael Herrmann:
> Hi, 
> 
> 
> 
> I'm developing a GUI Automation library (http://www.getautoma.com) and am 
> having difficulty picking a name for the function that simulates key strokes. 
> I currently have it as 'type' but that clashes with the built-in function. 
> Example uses of 'type': 
> 
> 
> 
> type(ENTER)
> 
> 
> 
> type("Hello World!")
> 
> 
> 
> type(CTRL + 'a')
> 
> 
> 
> What, in your view, would be the most intuitive alternative name?
> 
> 
> 
> Here are my thoughts so far: I could call it 'press' but then our GUI 
> automation tool also allows you to click things and then "press" might be 
> mistaken for "pressing a button". A less ambiguous alternative is "type_keys" 
> but that is rather long and doesn't read as well, for instance in 
> type_keys(ENTER).
> 
> 
> 
> Thank you very much!

I would expect 'type' or 'press'. 'type' is maybe not the best solution because 
of overloading. I like 'press'.

Good luck, Mr. Michael ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


pyodbc utf-8

2012-12-06 Thread Markus Christen
good morning

i am using pyodbc 3.0.6 for win32 python 2.7.3
i used it to connect with a MsSql db. Now i have a little problem with the 
umlaut. i cant change anything in the db and there are umlauts like "ä", "ö" 
and "ü" saved. so i have to change my view (of django 1.4.1) to change \xfc 
into ü etc. but how i have to do this?
on my webpage the umlauts are correct (without helping fonts like ü (ü)). 
but not the umlauts out read out of my db.

Here the code i'm using:
-
conn = pyodbc.connect('DRIVER={SQL 
Server};CHARSET=UTF8;SERVER=MAURITIUS;DATABASE=baan5c;UID=portal;PWD=P0rtalReader')
cursor = conn.cursor()
cursor.execute("SELECT t_nama, t_bpid FROM ttccom100070 ORDER BY t_nama")
rows = cursor.fetchall()
-

helping tags like ", 'utf-8'" or something else didnt work till now. have 
anyone an idea how i can fix this problem? ^^

i thanks for help
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyodbc utf-8

2012-12-07 Thread Markus Christen
My webpage is using UTF-8 and utf-8 or unicode is on the DB. When i read out 
this files with Excel, i have no problems with the umlauts. I heared its a 
problem of pyodbc itself, cause it is only using ascii i think. I found this 
page here, but it was not really helpful for me. :( maybe i have not understood 
what this really means...
http://stackoverflow.com/questions/4805267/problem-with-unicode-decoding

maybe you can understand it and you can translate it for a noob. :D


Am Freitag, 7. Dezember 2012 13:16:09 UTC+1 schrieb Hans Mulder:
> On 7/12/12 08:41:27, Markus Christen wrote:
> 
> > good morning
> 
> > 
> 
> > i am using pyodbc 3.0.6 for win32 python 2.7.3
> 
> > i used it to connect with a MsSql db. Now i have a little problem with the 
> > umlaut.
> 
> > i cant change anything in the db and there are umlauts like "�", "�"
> 
> and "�" saved.
> 
> > so i have to change my view (of django 1.4.1) to change \xfc into � etc. 
> > but how i
> 
> > have to do this?
> 
> 
> 
> > on my webpage the umlauts are correct (without helping fonts like ü 
> > (�)).
> 
> > but not the umlauts out read out of my db.
> 
> 
> 
> Which encoding does your webpage use?
> 
> 
> 
> > Here the code i'm using:
> 
> > -
> 
> > conn = pyodbc.connect('DRIVER={SQL 
> > Server};CHARSET=UTF8;SERVER=MAURITIUS;DATABASE=baan5c;UID=portal;PWD=P0rtalReader')
> 
> > cursor = conn.cursor()
> 
> > cursor.execute("SELECT t_nama, t_bpid FROM ttccom100070 ORDER BY 
> > t_nama")
> 
> > rows = cursor.fetchall()
> 
> > -
> 
> >
> 
> > helping tags like ", 'utf-8'" or something else didnt work till now.
> 
> > have anyone an idea how i can fix this problem? ^^
> 
> 
> 
> I think the way forward would be to look at the data your code snippet
> 
> receives from the database.
> 
> 
> 
> Which datatype do the strings have?  Unicode or str or something else?
> 
> 
> 
> If the type is str, which encoding do they use?
> 
> If this isn't documented, you could at a few strings containing
> 
> non-ascii characters to see what codes are used, and compare
> 
> them to popular encodings such as uft8, latin1 and cp1252.
> 
> 
> 
> 
> 
> Hope his helps,
> 
> 
> 
> -- HansM

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


Re: pyodbc utf-8

2013-01-07 Thread Markus Christen
When i look at my output on my webpage, i can see this:
W\xe4denswil
but it have to be this:
Wädenswil
you know now what i can see exactly... im using django and they told me its a 
python problem with utf-8. when i turn off debug, i cant see the page, it give 
me an error 500.
the text "Danke für die..." on the bottom of my page is displayed correct. the 
error comes only when an umlaut is to post, out of the raw.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help writelines

2012-02-03 Thread Markus Rother

Hi,

You have to iterate.
Either with

for u in users:
fob.write( u + '\n' )

or with a lambda function.

always a good call: http://python.org/

greets,
M.

On 02/03/2012 09:27 PM, Anatoli Hristov wrote:

Hi everyone,

I`m totaly new in python and trying to figure out - how to write a 
list to a file with a newline at the end of each object.

I tried alot of combinations :) like:
users = ['toli','didi']
fob=open('c:/Python27/Toli/username','w')
fob.writelines(users) + '%s\N'
fob.close()
 or fob.writelines('\N' % users)
or fob.writelines('%s\N' % users)
but nothing of dose works...

Could you help me find out the right syntaxes?

Thanks





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


Running Python on a Computer Cluster in the Cloud - cloudnumbers.com

2011-07-18 Thread Markus Schmidberger
Dear Python users,

cloudnumbers.com provides researchers and companies with the access to
resources to perform high performance calculations in the cloud. As
cloudnumbers.com's community manager I may invite you to register and
test your Python application on a computer cluster in the cloud for
free: http://my.cloudnumbers.com/register

We are looking forward to get your feedback and consumer insights. Take
the chance and have an impact to the development of a new cloud
computing calculation platform.

Our aim is to change the way of research collaboration is done today by
bringing together scientists and businesses from all over the world on a
single platform. cloudnumbers.com is a Berlin (Germany) based
international high-tech startup striving for enabling everyone to
benefit from the High Performance Computing related advantages of the
cloud. We provide easy access to applications running on any kind of
computer hardware from single core high memory machines up to 1000
cores computer clusters.

To get more information check out our web-page
(http://www.cloudnumbers.com/) or follow our blog about cloud computing,
HPC and HPC applications: http://cloudnumbers.com/blog


Key features of our platform for efficient computing in the cloud are:

* Turn fixed into variable costs and pay only for the capacity you need.
Watch our latest saving costs with cloudnumbers.com video:
http://www.youtube.com/watch?v=ln_BSVigUhg&feature=player_embedded

* Enter the cloud using an intuitive and user friendly platform. Watch
our latest cloudnumbers.com in a nutshell video:
http://www.youtube.com/watch?v=0ZNEpR_ElV0&feature=player_embedded

* Be released from ongoing technological obsolescence and continuous
maintenance costs (e.g. linking to libraries or system dependencies)

* Accelerated your Python, C, C++, Fortran, R, ... calculations through
parallel processing and great computing capacity - more than 1000 cores
are available and GPUs are coming soon.

* Share your results worldwide (coming soon).

* Get high speed access to public databases (please let us know, if your
favorite database is missing!).

* We have developed a security architecture that meets high requirements
of data security and privacy. Read our security white paper:
http://d1372nki7bx5yg.cloudfront.net/wp-content/uploads/2011/06/cloudnumberscom-security.whitepaper.pdf


Best
Markus


-- 
Dr. rer. nat. Markus Schmidberger 
Senior Community Manager 

Cloudnumbers.com GmbH
Chausseestraße 6
10119 Berlin 

www.cloudnumbers.com 
E-Mail: [email protected] 


* 
Amtsgericht München, HRB 191138 
Geschäftsführer: Erik Muttersbach, Markus Fensterer, Moritz v. 
Petersdorff-Campen 

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


planet.python.org blog registration

2011-07-18 Thread Markus Schmidberger
Hello,

whom I have to contact to get a blog aggregated in planet.python.org?

Thanks
Markus

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


Pure python standard library and License

2011-03-03 Thread Markus Schaber
Hi,

 

We want to include IronPython in one of our products, including the pure
Python part of the python standard library. It seems that the IronPython
installer packagers simply copied the pure python part of the standard
library (the directory tree of .py files which is installed by cPython
and IronPython installers in the lib/ subdirectory) from cPython.

 

Now, this directory comes with a LICENSE.txt which contains a
conglomerate of several licenses, and for us (and our Lawyers), it is
not entirely clear which part of the license applies to the pure Python
part of the standard library, and which applies to other files (like the
Berkeley Database license).

 

Our current understanding is that all the .py files which do not contain
any explicit mentioning of a license are covered by the Python licenses
(the first three licenses of the LICENSE.txt), and that e. G. the
Berkeley Database License only applies to the bsddb module which is
implemented in C, and thus is currently neither included with nor usable
from IronPython.

 

Is there anyone who can confirm this interpretation?

 

Maybe the LICENSE.txt should clarify somehow which of the licenses
applies to which part of the software.

 

Best regards

Markus Schaber

___

We software Automation.

3S-Smart Software Solutions GmbH
Markus Schaber | Developer
Memminger Str. 151 | 87439 Kempten | Germany | Tel. +49-831-54031-0 |
Fax +49-831-54031-50

Email: [email protected] <mailto:[email protected]>  |
Web: http://www.3s-software.com <http://www.3s-software.com> 
CoDeSys internet forum: http://forum.3s-software.com
<http://forum-en.3s-software.com> 
Download CoDeSys sample projects:
http://www.3s-software.com/index.shtml?sample_projects
<http://www.3s-software.com/index.shtml?sample_projects> 

Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner |
Trade register: Kempten HRB 6186 | Tax ID No.: DE 167014915 

 

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


AW: Pure python standard library and License

2011-03-04 Thread Markus Schaber
Hi, Terry,

Von: Terry Reedy
> Your interpretation seems reasonable, but only a paid lawyer (or
ultimately a judge) can 'confirm' a legal interpretation. Sorry, we
programmers generally hate the system.

I also am a programmer, and not a lawyer.

And our paid lawyer cannot look into the code (where most files do not
even actually have any copyright header) and magically guess which of
the files might be covered by the Berkeley license.

In the meantime, we found
http://docs.python.org/release/2.6.6/license.html which has some better
descriptions of which license applies to which part of the code, but
that file is not equal to the LICENSE.txt which was distributed with the
IronPython installer nor with the Python 2.6 binary distribution we
installed.

This is why he asked us to confirm with the developers of python that
none of the non-copyright-annotated .py files in the standard library
are actually covered by the Berkeley license.

>> That said, I suspect you or your lawyers are worrying too much. None
of the licensors are looking to play gotcha and I do not know that there
have been any court cases involving Python.

> I presume you are using some version of Python 2.

As the last stable version of IronPython implements Python 2.6, I
conclude that the installer includes the standard library in a 2.6
compatible version - however, it seems not to be the version distributed
with cPython 2.6.6.

> In 3.2, the license file has the four general licenses (CWI, CNRI,
BeOpen, PSF) in one section and 16 specific licenses related to various
library modules (each identified) in another. There is no BSD license
because bsddb in no longer included.

That also applies to the published license for cPython 2.6.6 (link
above) which lacks the Berkeley license, but not the license actually
installed with the installer (which still contains the bsddb module). It
identifies itself as:
| Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit
(Intel)] on win32

> You could take the disappearance of the BD licence with the
disappearance of the bsddb module as confirmation of your hypothesis;-).

It is a strong indicator, but no guarantee that all the .py files
without copyright headers are not covered by the Berkeley license.

Thanks for your efforts!

Best regards,

Markus Schaber
-- 
We software Automation.

3S-Smart Software Solutions GmbH
Markus Schaber | Developer
Memminger Str. 151 | 87439 Kempten | Germany | Tel. +49-831-54031-0 |
Fax +49-831-54031-50

Email: [email protected] | Web: http://www.3s-software.com 
CoDeSys internet forum: http://forum.3s-software.com
Download CoDeSys sample projects:
http://www.3s-software.com/index.shtml?sample_projects

Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner |
Trade register: Kempten HRB 6186 | Tax ID No.: DE 167014915 

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


AW: Pure python standard library and License

2011-03-04 Thread Markus Schaber
Hi,

First, sorry for sending an HTML message to the list, this was not
intended.

I now found out that http://docs.python.org/release/2.6.6/license.html
does actually explain which part of the software is covered by which
part of the license, but contains a different subset of licenses than
the LICENSE.txt - two of the differences are the Berkeley part, and the
windows binary build part.

This is just adding somewhat more confusion...

Thanks,
Markus

Original Message:
Betreff: Pure python standard library and License

Hi,

We want to include IronPython in one of our products, including the pure
Python part of the python standard library. It seems that the IronPython
installer packagers simply copied the pure python part of the standard
library (the directory tree of .py files which is installed by cPython
and IronPython installers in the lib/ subdirectory) from cPython.

Now, this directory comes with a LICENSE.txt which contains a
conglomerate of several licenses, and for us (and our Lawyers), it is
not entirely clear which part of the license applies to the pure Python
part of the standard library, and which applies to other files (like the
Berkeley Database license).

Our current understanding is that all the .py files which do not contain
any explicit mentioning of a license are covered by the Python licenses
(the first three licenses of the LICENSE.txt), and that e. G. the
Berkeley Database License only applies to the bsddb module which is
implemented in C, and thus is currently neither included with nor usable
from IronPython.

Is there anyone who can confirm this interpretation?

Maybe the LICENSE.txt should clarify somehow which of the licenses
applies to which part of the software.

Best regards

Markus Schaber

___
We software Automation.

3S-Smart Software Solutions GmbH
Markus Schaber | Developer
Memminger Str. 151 | 87439 Kempten | Germany | Tel. +49-831-54031-0 |
Fax +49-831-54031-50

Email: [email protected] | Web: http://www.3s-software.com 
CoDeSys internet forum: http://forum.3s-software.com
Download CoDeSys sample projects:
http://www.3s-software.com/index.shtml?sample_projects

Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner |
Trade register: Kempten HRB 6186 | Tax ID No.: DE 167014915 

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


AW: import python module from C++ code

2011-03-06 Thread Markus Schaber
Hi,

> von Arthur Mc Coy:

> Still need the answer to the question: " howto embed given python file
> (which contains python class and its members) into the c++ application
? "

There is no straight way of embedding a Python module into a c++
application.

You will have to embed the python interpreter, and command it to load
the module in question and execute the code you want.

> I have to pass the arguments from c++ to python and back so I need to
do
> conversions. They are ok. Fails PyImport_Import(my_module) call saying
"No
> module called mymodule". Then I need to create a mymodule based on
given
> python file (its name mymodule.py). Can it be achieved using SWIG ?

Did you configure the module search path properly?

Regards,
Markus
-- 
http://mail.python.org/mailman/listinfo/python-list


Which subversion interface is the most used one?

2011-03-26 Thread Markus Schaber
Hi,

at one of our projects, we could make use of a subversion interface for
IronPython. But there seems none to exist.

The easiest way would be to directly expose SharpSVN to the IronPython
scripts, but that is not a very pythonic solution. So we had the Idea
of porting the existing python interfaces to IronPython.

And here the confusion starts, there seem to exist at least three of
them (those are the ones I found being prepackaged on debian):

python-subversion: Seems to be a rather autogenerated wrapper around
libsvn - thus being feature-complete, but rather unpythonic.

python-svn (pysvn): Seems to be written in C++, and give a somehow
pythonic interface to the most important functionality.

python-subvertpy: Seems to aggregate the advantages of the two previous
solutions, but I did not find any API documentation.

It seems that porting one of them to IronPython in a 1:1 fashion is no
feasible solution.

So I came up with the Idea of simply re-implementing the API of one of
those packages in C#, in a way that it can be exposed as IronPython
module, using SharpSVN or Monodevelop-VersionControl as backend. This
seems to be a rather low cost way of providing subversion functionality
to IronPython, in a way compatible with at least some of the cPython
Subversion applications.

Now my question:

Which one of the SVN interfaces are established and broadly used?

I don't want to risk to put effort into implementing a dead API when 
others are alive.

I have a slight tendency to pysvn, as it seems to be well documented
and pythonic.

Thanks for your comments.


Markus

-- 
Probleme kann man niemals mit derselben Denkweise lösen, durch
die sie entstanden sind. (Albert Einstein)

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


Checking network input processing by Python for a multi-threaded server

2019-04-29 Thread Markus Elfring
Hello,

I constructed another multi-threaded TCP server for my needs
(based on the available software documentation).
https://docs.python.org/3/library/socketserver.html#asynchronous-mixins

I constructed also a corresponding script which should send nine record sets
(which get extracted from a simple JSON file) to this server on my local host
by the software “Python 3.7.2-3.1” (for an openSUSE system).
Related background information can be seen for a discussion topic like
“Data exchange over network interfaces by SmPL scripts”.
https://systeme.lip6.fr/pipermail/cocci/2019-April/005792.html
https://lore.kernel.org/cocci/[email protected]/

The file name for the client script is passed by a parameter to a command
which is repeated by this server in a loop.
It is evaluated then how often a known record set count was sent.
I got a test result like the following.


elfring@Sonne:~/Projekte/Coccinelle/janitor> time /usr/bin/python3 
list_last_two_statements_from_if_branches-statistic-server3.py
"return code"|"received records"|"command output"|incidence
0|9||63
0|5||5
0|13||2
0|10||5
0|11||7
0|8||3
0|7||3
0|14||3
0|6||4
0|12||3
0|4||2

real1m23,301s
user0m6,434s
sys 0m1,430s


* How should this data processing approach be adjusted so that the same number
  of records will be handled in a consistent way?

* Which challenges from inter-process communication should be taken better into
  account for the involved programming interfaces (because of multi-threading)?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking support for efficient appending to mapped data

2019-04-30 Thread Markus Elfring
> The file name for the client script is passed by a parameter to a command
> which is repeated by this server in a loop.

Additional explanations can be helpful for the shown software situation.


> It is evaluated then how often a known record set count was sent.

It was actually determined for a specific function variant how many input
record sets were available for data processing by the server in a loop 
iteration.


> I got a test result like the following.
>
>
> elfring@Sonne:~/Projekte/Coccinelle/janitor> time /usr/bin/python3 
> list_last_two_statements_from_if_branches-statistic-server3.py
> "return code"|"received records"|"command output"|incidence
> 0|9||63
> 0|5||5
> 0|13||2
…

Such a test result shows that some records could be handled by the server
within the time range from the start of a command and the exit of
the corresponding child process which sends desired data back to
its caller.
A fraction of records can be handled only at a subsequent iteration
if no session management was applied as in this test case.


> * How should this data processing approach be adjusted so that the same number
>   of records will be handled in a consistent way?

There is a need to add session management so that required context information
will be connected with the provided input data. Each session needs to be
identified by an unique key. The Python programming language provides the data
type “dict” for such a mapping as standard functionality.
https://docs.python.org/3/library/stdtypes.html#mapping-types-dict

Python's support for associative containers is generally nice.
But I find that consequences from modification of mapped data can become more
interesting for the mentioned use case.
The operator “+=” (augmented assignment) can be used there, can't it?
The appending of data is supported for some types by this operation.
I am informed in the way that some data types expect that a well-known
method like “append” must (or should be) be called instead for such
an “addition” (if you care for efficient data processing).
https://docs.python.org/3/library/stdtypes.html#mutable-sequence-types

Now I am looking again for further clarifications and improvements
in this area.
Would you like to share any more ideas here?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking network input processing by Python for a multi-threaded server

2019-04-30 Thread Markus Elfring
> Does this mean that the second number in a listing like the above
> should be approximatively equal?

The expectation (or hope) was that an identical number of record sets
would be available for each loop iteration in such a data processing approach
by the server.
But the reality is different for the observed input value distribution.


> Then, obviously, your threads must communicate among themselves
> and wait in case they have too much run ahead.

This is a software design option. I am looking again for adjustments
around programming interfaces for efficient appending to mapped data
according to required context management.


> As you say to have created a "multi-threaded TCP server", I assume
> that your server spawns a thread for each TCP connection.

Is this the software behaviour we usually get from
the class “socketserver.ThreadingMixIn”?


> Then, you can concentrate on proper multi-thread synchronization
> and forget about "inter-process communication challenges".

I showed an experiment where I put a loop around a test command.
I am wondering also about varying data processing results from
the execution of a single command. The visualisation of output
statistics seems to be more challenging for such a test case.
Can any other test tools help a bit more here?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Dynamic selection for network service ports?

2019-04-30 Thread Markus Elfring
> * Which challenges from inter-process communication should be taken better 
> into
>   account for the involved programming interfaces (because of 
> multi-threading)?

I would like to clarify another recurring challenge with network configuration.
A port number should be selected somehow for the service where the desired
input data will be received.

It can be nice when a fixed port can be specified for such data exchange.
Advanced service management can achieve a reasonably safe number allocation.

But I would occasionally prefer a dynamic selection for some data processing
approaches on my test systems.
How does the support look like for the handling of ephemeral ports by
programming interfaces for Python?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Dynamic selection for network service ports?

2019-04-30 Thread Markus Elfring
> In Python, there's a certain amount of support. You can attempt to
> bind to a port, and if you fail, try the next one in a sequence.

* The zero seems to be also an usable parameter here.
  Is the system configuration documentation unclear about the applied
  value range for the port allocation?
  Can it happen that special permissions would be needed for a setting?

* How are the chances to improve programming interfaces around
  the module “socketserver”?


> It's simple, it's straight-forward, and it doesn't cause problems.

Would you like to reduce connection management difficulties because of
an error message like “OSError: [Errno 98] Address already in use”?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Dynamic selection for network service ports?

2019-05-01 Thread Markus Elfring
> You'll get anything in the ephemeral ports range.

From which documentation source did you get this information for
the handling of a zero as an useful setting?


> But the other cause is that you recently shut the server down,
> and the port is still in the TIME_WAIT state.

Does this technical detail occasionally increase the need to choose
an additional number for a quickly restarted service in a dynamic way?


> You can avoid this with the SO_REUSEADDR flag.

Can such a configuration parameter be used also together with
programming interfaces from the module “socketserver”?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Dynamic selection for network service ports?

2019-05-01 Thread Markus Elfring
> If your server listens on a random port how does the client know
> which port to connect to?

I am fiddling also with the data processing variant that such connection
properties are passed as parameters for a command which is executed
as a child process so that desired data can be sent back to its caller.

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking network input processing by Python for a multi-threaded server

2019-05-01 Thread Markus Elfring
> https://docs.python.org/3/library/socketserver.html#asynchronous-mixins

An example is provided also in this software documentation.
May I expect that data were completely received from clients and accordingly
processed by the request handler in the started threads after
the statement “server.shutdown()” was sucessfully executed?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking network input processing by Python for a multi-threaded server

2019-05-01 Thread Markus Elfring
> https://docs.python.org/3/library/socketserver.html#asynchronous-mixins

I have constructed a pair of small scripts for another test.
A command (which refers to the second Python script) is executed 100 times
by “subprocess.run()” with parameters so that the child process can send six
test records back to the caller over a TCP connection.

1. The received records are appended to a global list variable during
   each loop iteration.

2. The list length is appended to another global list variable.

3. The stored list lengths are counted by grouping of this information.

   Now I wonder again about a test result like the following for
   the software “Python 3.7.2-3.1” (for an openSUSE system).


elfring@Sonne:~/Projekte/Python> time /usr/bin/python3 test-statistic-server1.py
incidence|"available records"|"return code"|"command output"
44|6|0|
12|5|0|
13|4|0|
16|3|0|
2|7|0|
8|2|0|
3|8|0|
1|1|0|
1|9|0|

real0m29,123s
user0m5,925s
sys 0m1,073s


Does this data processing approach indicate a need for further software 
corrections?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking network input processing by Python for a multi-threaded server

2019-05-01 Thread Markus Elfring
>   Why not provide them so that anyone trying to analyze what you are
> seeing can try them for themselves.

I assume that an other information system can be more appropriate
for file distribution than this mailing list.


>   Starting a full process takes time

This is usual. - Such an action would be necessary for the test case.


>   Do you have ANY synchronization enabled,

I would expect that this is provided by the run time system for the
Python scripting language.


>   so that you start all the children

The main process waits on the exit for the single started command
in each loop iteration.


> and they all wait for a single "go" signal to be set

No.


> -- so that they all start processing at the same time?

I suggest to take another look at the description for the test algorithm.


>   No idea what is in each loop...

An instance for the class “threaded_TCP_server” and a call of 
“subprocess.run(…)”.


>   If there is only one list (implied by #1)

There are two lists adjusted.

1. Storage for received records before the statement “server.shutdown()”
   (and a reset to an empty list) is executed at the end of each loop iteration.

2. List lengths are recorded for analysis after the data collection phase.


>   Again, it is not clear what is being counted here...

How many record sets were stored and are accessible at one point in time
in such a data structure?


>   What is an "incidence", how is "available records" determined?

The generated table shows how often a specific number of record sets
was temporarily available for further data processing.
I would expect that the correct count should be 100 (once) here
(instead of the display of deviations from the original six test records).


>   Also, TCP is a stream protocol, not a record protocol.

This view is generally fine.

JSON data structures are transmitted by the discussed approach.


> A client could use, say, 6 separate .send() operations,

This should be happening in this test.


> while the server receives everything in a single .recv() call.

I hope that the execution of the statement “server.shutdown()” triggers
a separation in the reported inter-process communication.

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Dynamic selection for network service ports?

2019-05-01 Thread Markus Elfring
>   https://docs.python.org/3.4/library/socketserver.html
> about the middle of the page...

It seems that you would like to refer to an other document.
https://docs.python.org/3/library/socket.html#socket-example

Under which circumstances will the execution of the method “socket.setsockopt”
be triggered by a class like “socketserver.TCPServer”?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Dynamic selection for network service ports?

2019-05-01 Thread Markus Elfring
> For the truly lazy, we have hash links.

Thanks for your reminder.


> https://docs.python.org/3/library/socketserver.html#socketserver.BaseServer.allow_reuse_address

The relationship of this class attribute with the identifier (or option) 
“SO_REUSEADDR”
might become easier to find.
The use of such a configuration parameter might need further considerations.

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking network input processing by Python for a multi-threaded server

2019-05-02 Thread Markus Elfring
>> May I expect that data were completely received from clients and accordingly
>> processed by the request handler in the started threads after
>> the statement “server.shutdown()” was sucessfully executed?
>
> Python delegates those low level services to the underlaying
> network library, which likely will implement the TCP specification.

* How do you think about data processing consequences when record sets are
  concurrently received and are appended to a global list (for a Python 
variable)?

* Would you expect that the run time system takes care for data consistency
  because of involved multi-threading?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking network input processing by Python for a multi-threaded server

2019-05-02 Thread Markus Elfring
>> An instance for the class “threaded_TCP_server” and a call of 
>> “subprocess.run(…)”.
>>
>   And how many connections does the subprocess make?

A new TCP connection is performed with the information from the passed 
parameters
for each call of the function “sendall”. The test command will send JSON data
over these six connections then.


> A full connect(), send(), close() for each output?

Yes, for this test variant.


> OTOH, if you are making multiple connect() calls, then OS scheduling
> could result in multiple server threads running.

This functionality is desired.


…
> Of course, you still have to use your head!
…
> For instance, it makes no sense to use a forking server
…

I would expect that the main test process will not be forked here.


>> I hope that the execution of the statement “server.shutdown()” triggers
>> a separation in the reported inter-process communication.
>
>   .shutdown() stops the server from processing new connections...

I hope so, too.
(Additional server objects can be created in subsequent loop iterations.)

How does this interpretation fit to the wording “Tell the serve_forever() loop
to stop and wait until it does.” from the documentation of
the class “socketserver.BaseServer”?


> It does nothing for the nature of TCP streams

This aspect should be fine.


>   I'd be tempted to convert the master and subprocess from TCP to UDP,
> just to see if there is a difference.

I do not want to change the data transmission technique for this use case.


I suggest to take another look at a related discussion topic like
“Data exchange over network interfaces by SmPL scripts” if you would prefer
to review a concrete source code example instead of recognising
data processing consequences from a known test algorithm.
https://systeme.lip6.fr/pipermail/cocci/2019-April/005792.html
https://lore.kernel.org/cocci/[email protected]/


Will it help to add a bug report in an issue tracker?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking network input processing by Python for a multi-threaded server

2019-05-03 Thread Markus Elfring
> In any multi-threaded application, you must be carefull when
> accessing (and especially modifying) shared (e.g. "global") objects.
> In general, you will need locks to synchronize the access.

I agree to this general view.


> Appending to a list (and some other elementary operations
> on Python data structures) is protected by Python's "GIL"
> (= "Global Interpreter Lock") and thereby becomes "atomic".
> Thus, if all you do is appending - then the append has no need
> of explicite locking.

Thanks for such information.


> It does not protect the integrity of your data structures.

It can be that the data protection needs to be extended occasionally.
But I am more interested in the detail that a specific Python list variable
should reflect the received record sets from a single test command
in a consistent way.

Did all extra worker threads exit after the statement “server.shutdown()”
was successfully executed?


> Thus, if your threads modify shared objects, then you are responsible
> to protect access to them with appropriate locking.

How do you think about to improve the distinction for the really
desired lock granularity in my use case?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking network input processing by Python for a multi-threaded server

2019-05-03 Thread Markus Elfring
>   I suggested UDP as a TEST, not for the end use...

I can understand such a suggestion.
Can it distract from other software surprises?


> If UDP gives you the results you expect, it most likely means there is a 
> problem

There is a questionable software behaviour still waiting for a proper solution
(without switching the data transmission technique for this use case).


> in how you are processing TCP data.

Which impressions did you get from the implementation of the published
Python functions “receive_data” and “receive_message” (according to
the previously mentioned links)?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking network input processing by Python for a multi-threaded server

2019-05-04 Thread Markus Elfring
>   Server.shutdown() sets a flag that tells the main server to /stop
> accepting new requests/.

Can it be that this method should perform a bit more resource management
(according to the selected configuration like “socketserver.ThreadingMixIn”)?


>   So far as I can tell, for a threaded server, any threads/requests that
> were started and haven't completed their handlers will run to completion --
> however long that handler takes to finish the request. Whether
> threaded/forked/single-thread -- once a request has been accepted, it will
> run to completion.

This is good to know and such functionality fits also to my expectations
for the software behaviour.


> Executing .shutdown() will not kill unfinished handler threads.

I got a result like the following from another test variant
on a Linux system.

elfring@Sonne:~/Projekte/Python> time python3 test-statistic-server2.py
incidence|"available records"|"running threads"|"return code"|"command output"
80|6|1|0|
1|4|3|0|
1|4|4|0|
3|5|2|0|
1|5|3|0|
5|7|1|0|
1|3|4|0|
1|8|1|0|
1|4|1|0|
3|5|1|0|
1|4|2|0|
1|3|2|0|
1|6|2|0|

real0m48,373s
user0m6,682s
sys 0m1,337s


>> How do you think about to improve the distinction for the really
>> desired lock granularity in my use case?
>
>   If your request handler updates ANY shared data, YOU have to code the
> needed MUTEX locks into that handler.

I suggest to increase the precision for such a software requirement.


> You may also need to code logic to ensure any handler threads have completed

Can a class like “BaseServer” be responsible for the determination
if all extra started threads (or background processes) finished their work
as expected?


> before your main thread accesses the shared data

I became unsure at which point a specific Python list variable
will reflect the received record sets from a single test command
in a consistent way according to the discussed data processing.


> -- that may require a different type of lock;

I am curious on corresponding software adjustments.


> something that allows multiple threads to hold in parallel
> (unfortunately, Event() and Condition() aren't directly suitable)

Which data and process management approaches will be needed finally?


>   Condition() with a global counter (the counter needs its own lock)
> might work: handler does something like

How much do the programming interfaces from the available classes support
the determination that submitted tasks were completely finished?


> The may still be a race condition on the last request if it is started
> between the .shutdown call and the counter test (ie; the main submits
> .shutdown, server starts a thread which doesn't get scheduled yet,
> main does the .acquire()s, finds counter is 0 so assumes everything is done,
> and THEN the last thread gets scheduled and increments the counter.

Should mentioned system constraints be provided already by the Python
function (or class) library?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking network input processing by Python for a multi-threaded server

2019-05-04 Thread Markus Elfring
> If you have a multi-threaded application and you want to be on
> the "safe side", you always use your own locks.

I suggest to reconsider your software expectations around
the word “always”.
There are more software design options available.


> Python uses locks to protect its own data structures.
> Whether this protection is enough for your use of Python types
> depends on details you may not want to worry about.

I agree to such a general view.


> For example: most operations on Python types are atomic
> (if they do not involve some kind of "waiting" or "slow operation")
> *BUT* if they can detroy objects, then arbitrary code
> (from destructors) can be executed and then they are not atomic.

The safe handling of finalizers can trigger development challenges.


> As an example "list.append" is atomic (no object is detroyed),
> but "list[:] = ..." is not: while the list operation itself
> is not interrupted by another thread, the operation may destroy
> objects (the old list components) and other threads may get control
> before the assignment has finished.

How would you determine (with the help of the Python function/class library)
that previously submitted tasks were successfully executed?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking network input processing by Python for a multi-threaded server

2019-05-04 Thread Markus Elfring
>>> Server.shutdown() sets a flag that tells the main server to /stop
>>> accepting new requests/.
>>
>> Can it be that this method should perform a bit more resource management
>> (according to the selected configuration like “socketserver.ThreadingMixIn”)?
>>
>   There isn't much more it can do

I see further software design possibilities.


> -- it has been a long standing axiom that killing threads is not recommended.

This data processing approach will trigger various development challenges.


>>> You may also need to code logic to ensure any handler threads have completed
>>
>> Can a class like “BaseServer” be responsible for the determination
>> if all extra started threads (or background processes) finished their work
>> as expected?
>
>   You are asking for changes to the Python library for a use case
> that is not common.

I find this view questionable.


> Normally connections to a server are independent and do not share common data

Would you like to clarify corresponding application statistics any further?


> -- if there is anything in common,

Do you identify any more shared functionality?


> it is likely stored in a database management system

An use case evolved into my need to work also with an ordinary Python list
variable for a simple storage interface.


> which itself will provide locking for updates,

It is nice when you can reuse such software.


> and the connection handler will have to be coded to handle retries
> if multiple connections try to update the same records.

I am not concerned about this aspect for my test case.


> Servers aren't meant to be started and shutdown at a rapid rate

Their run times can vary considerably.


> (it's called "serve_forever" for a reason).

Will an other term become more appropriate?


>   If the socketserver module doesn't provide what you need,

It took a while to understand the observed software behaviour better.


> you are free to copy socketserver.py to some other file (myserver.py?),
> and modify it to fit your needs.

Will it help to clarify any software extensions with corresponding maintainers?


> Maybe have the function that spawns handler threads append the thread ID
> to a list, have the function that cleans up a handler thread at the end
> send its ID via a Queue object,

This approach can be reasonable to some degree.


> and have the master periodically (probably the same loop that checks
> for shutdown), read the Queue, and remove the received ID from the list
> of active threads.

I imagine that there are nicer design options available for notifications
according to thread terminations.


> On shutdown, you loop reading the Queue and removing IDs from the list
> of active threads until the list is empty.

Will a condition variable (or a semaphore) be more helpful here?


>> How much do the programming interfaces from the available classes support
>> the determination that submitted tasks were completely finished?
>>
>   Read the library reference manual and, for those modules with Python
> source, the source files (threading.py, socketserver.py, queue.py...)
>
>   The simpler answer is that these modules DON'T...

I suggest to improve the software situation a bit more.


> It is your responsibility.

This view can be partly appropriate.


> socketserver threading model is that the main server loops waiting
> for connection requests, when it receives a request it creates
> a handler thread, and then it completely forgets about the thread

I find that this technical detail can be better documented.


> -- the thread is independent and completes the handling of the request.

Would you occasionally like to wait on the return value from such
data processing?
(Are these threads joinable?)


> If you need to ensure everything has finished before starting
> the next server instance, you will have to write the extensions
> to socketserver.

I might achieve something myself while it can be also nice to achieve
adjustments together with other developers.


>> Should mentioned system constraints be provided already by the Python
>> function (or class) library?
>
>   Again, the model for socketserver, especially in threaded mode, is that
> requests being handled are completely independent. shutdown() merely stops
> the master from responding to new requests.

I find this understanding of the software situation also useful.


>   In a more normal situation, .shutdown() would be called
> and then the entire program would call exit.

* Do you expect any more functionality here than an exit from a single thread?

* Does this wording include the abortion of threads which were left over?


> It is NOT normal for a program to create a server, shut it down,
> only to then repeat the sequence.

Will your understanding of such an use case grow, too?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking network input processing by Python for a multi-threaded server

2019-05-13 Thread Markus Elfring
> And in addition, you can derive your own class from `socketserver`
> and override methods to provide whatever additional functionality
> you think is necessary.

Such a programming possibility remains generally.
I am curious if the software development attention can be adjusted
also in this area.

I imagine that it can be easier to depend on a higher level
system infrastructure.
How do you think about to reuse software extensions around
the standard “CORBA” like “omniORB”?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking network input processing by Python for a multi-threaded server

2019-05-13 Thread Markus Elfring
> Nowadays, I develop typically web applications.
> There, something similar to "CORBA" is used: WSDL described
> "web services". Typically, they use the web infrastructure
> and its protocols ("http", "https") for communication.

The popularity varies for these programming interfaces over time.

* I am trying to get also a data processing variant working
  based on the JSON format together with an extended socket
  server class.

* Do you eventually know any proxy services which would provide
  useful data type conversions?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking network input processing by Python for a multi-threaded server

2019-05-13 Thread Markus Elfring
> Nowadays, I develop typically web applications.
> There, something similar to "CORBA" is used: WSDL described
> "web services". Typically, they use the web infrastructure
> and its protocols ("http", "https") for communication.

The popularity varies for these programming interfaces over time.

* I am trying to get also a data processing variant working
  based on the JSON format together with an extended socket
  server class.

* Do you eventually know any proxy services which would provide
  useful data type conversions?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking network input processing by Python for a multi-threaded server

2019-05-18 Thread Markus Elfring
> socketserver threading model is that the main server loops waiting for
> connection requests, when it receives a request it creates a handler thread,

This data processing style can be generally fine as long as you would like
to work without a thread (or process) pool.


> and then it completely forgets about the thread

I have taken another look at the implementation of the corresponding methods.
https://github.com/python/cpython/blob/3.7/Lib/socketserver.py#L656

I get an other impression from the statements “self._threads.append(t)” 
(process_request)
and “thread.join()” (server_close).


> -- the thread is independent and completes the handling of the request.

Will a corresponding return value bet set?


> If you need to ensure everything has finished before starting the next server 
> instance,

I am still looking for the support of software constraints in this direction.


> you will have to write the extensions to socketserver.

Will the development situation evolve any more here?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking network input processing by Python for a multi-threaded server

2019-05-19 Thread Markus Elfring
>> I get an other impression from the statements “self._threads.append(t)” 
>> (process_request)
>> and “thread.join()” (server_close).
>
>   Okay -- v3.7 has added more logic that didn't exist in the v3.5 code
> I was examining... (block_on_close is new).

Thanks for such a version comparison.


>   However, I need to point out that this logic is part of server_close(),
> which is not the same as shutdown(). You have been calling shutdown() which
> only ends the loop accepting new connections, but leaves any in-process
> threads to finish handling their requests.
>
>   server_close() needs to be called by your code, I would expect AFTER
> calling shutdown() to stop accepting new requests (and starting new threads
> which may not be in the list that the close is trying to join).

Should this aspect be taken into account by the code specification “with 
server:”?


> And after calling server_close() you will not be able to simply "restart" the 
> server
> -- you must go through the entire server initialization process
> (ie: create a whole new server instance).

This should be finally achieved by the implementation of my method 
“perform_command”.
I hope that corresponding data processing can be cleanly repeated then
as desired for test purposes.

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking network input processing by Python for a multi-threaded server

2019-05-24 Thread Markus Elfring
> The file name for the client script is passed by a parameter to a command
> which is repeated by this server in a loop.
> It is evaluated then how often a known record set count was sent.

In which time ranges would you expect the receiving of the complete JSON data
which were sent by the child process (on the local host during my test)?
Can the program termination be taken into account for waiting on
still incoming data from the server socket?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Checking refusal of a network connection

2019-05-31 Thread Markus Elfring
Hello,

I can start a service as desired.

elfring@Sonne:~/Projekte/Bau/C++/test-statistic-server1/local> 
./test-statistic-server2 & /usr/bin/ss -t -l -p -H|grep test
[1] 8961
waiting for connections
server_id: localhost
server_port: 35529
LISTEN 0   123  [::1]:35529  [::]:* 
 users:(("test-statistic-",pid=8961,fd=3))
elfring@Sonne:~/Projekte/Bau/C++/test-statistic-server1/local> 0 connections 
were handled.


But I wonder about the following error message then.

elfring@Sonne:~/Projekte/Python> /usr/bin/python3 
~/Projekte/Python/socket-send_json_data.py --server_id localhost --server_port 
35529
Using Python version:
3.7.2 …
Traceback …:
…
  File "/home/elfring/Projekte/Python/socket-send_json_data.py", line 17, in 
send_data
so.connect((args.server_id, args.server_port))
ConnectionRefusedError: [Errno 111] Connection refused


How should this inter-process communication difficulty be resolved?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking refusal of a network connection

2019-05-31 Thread Markus Elfring
>   Well, providing minimal code samples that produce the problem would be 
> a start.

I prefer an other approach to clarify relevant software configuration 
differences.


>   Otherwise we are just guessing...

I can offer other data before.


> Maybe you have a firewall problem.

I hope not.

I can try another server variant out as expected.


elfring@Sonne:~/Projekte/Python> /usr/bin/python3 test-server2.py &
[1] 14067
elfring@Sonne:~/Projekte/Python> /usr/bin/ss -t -l -p -H|grep python
LISTEN0  5  127.0.0.1:search-agent 0.0.0.0:*
 users:(("python3",pid=14067,fd=3))
elfring@Sonne:~/Projekte/Python> /usr/bin/python3 socket-send_json_data.py 
--server_id localhost --server_port 1234
Using Python version:
3.7.2 (default, Dec 30 2018, 16:18:15) [GCC]
elfring@Sonne:~/Projekte/Python> Result:
…


Can connections work also with a network service address like “[::1]:35529”
(which would be used by the C++ server implementation so far)?
How does the software situation look like for the support of the IPv6 loopback 
address?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking refusal of a network connection

2019-06-01 Thread Markus Elfring
> Also, it can be very useful to strace the client process, eg:

Do you find the following background information more helpful
for the desired clarification of unexpected software behaviour?

elfring@Sonne:~/Projekte/Python> LANG=C strace -e trace=network 
/usr/bin/python3 socket-send_json_data.py --server_id localhost --server_port 
37351
Using Python version:
3.7.2 …
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_IP) = 3
socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0) = 5
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4
connect(4, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = 0
sendto(4, "\2\0\0\0\r\0\0\0\6\0\0\0hosts\0", 18, MSG_NOSIGNAL, NULL, 0) = 18
recvmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="hosts\0", 
iov_len=6}, {iov_base="\310O\3\0\0\0\0\0", iov_len=8}], msg_iovlen=2, 
msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, 
cmsg_data=[5]}], msg_controllen=20, msg_flags=MSG_CMSG_CLOEXEC}, 
MSG_CMSG_CLOEXEC) = 14
connect(3, {sa_family=AF_INET, sin_port=htons(37351), 
sin_addr=inet_addr("127.0.0.1")}, 16) = -1 ECONNREFUSED (Connection refused)
Traceback …:
…
  File "socket-send_json_data.py", line 17, in send_data
so.connect((args.server_id, args.server_port))
ConnectionRefusedError: [Errno 111] Connection refused
+++ exited with 1 +++


> You can also strace the running service process:

I do not observe additional function calls for the TCP client connection
attempt here.


> Also, on the service side it isn't enough to create the service socket,
> you also need to do an accept IIRC.

This should be performed by my implementation of the C++ function “setup”.

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking refusal of a network connection

2019-06-01 Thread Markus Elfring
>> connect(3, {sa_family=AF_INET, sin_port=htons(37351), 
>> sin_addr=inet_addr("127.0.0.1")}, 16) = -1 ECONNREFUSED (Connection refused)
>
>   Without seeing the code, I'd be suspicious of that difference.

I would expect that the IPv4 address from such a connection attempt
would be automatically converted to a IPv6 loopback address.

Unfortunately, the direct specification “… socket-send_json_data.py --server_id 
::1 …”
does not work at the moment because of the error message “socket.gaierror: 
[Errno -9]
Address family for hostname not supported”.

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking refusal of a network connection

2019-06-01 Thread Markus Elfring
>> I would expect that the IPv4 address from such a connection attempt
>> would be automatically converted to a IPv6 loopback address.
>
> You haven't said which OS you are using, but as far as I know this
> expectation will be frustrated at least on Linux: There ::1 and
> 127.0.0.1 are distinct addresses.

How does this view fit to information from the Linux programmer's manual?
See also: command “man 7 ipv6”

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking refusal of a network connection

2019-06-01 Thread Markus Elfring
> Which specific information in that man page contradicts what I wrote?

We can agree that the mentioned IP addresses are distinct.
But the corresponding functionality should be equivalent.


> If you think of
>
> | IPv4 connections can be handled with the v6 API by using the
> | v4-mapped-on-v6 address type; thus a program needs to support only
> | this API  type to  support  both  protocols.
>
> please note that 127.0.0.1 mapped to IPv6 is ::7f00:1, not ::1.

I find another information like “This is handled transparently by
the address handling functions in the C library.” also interesting.


> So you still need to bind to two addresses.

I am unsure about this conclusion.

Under which circumstances will the Python programming interfaces
support the direct usage of the identification “::1”?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking refusal of a network connection

2019-06-01 Thread Markus Elfring
> It looks like the service isn't listening at the time the so.connect is 
> called.

* I get an other impression from the programs “/usr/bin/netstat” and 
“/usr/bin/ss”.

* The data transmission seems to work also for my small script 
“socket-send_test_data1.tcl”
  (even when the identification “::1” was passed as a command parameter).

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking support for network connections from Python client to IPv6 server

2019-06-01 Thread Markus Elfring
> "Handled transparently" means that an ipv6 server can handle connections
> from ipv4 clients without doing anything special.

It is nice if this conversion is working.


> They just appear to come from a specific IPv6 address range.

I got expected connections by my small script “socket-send_test_data1.tcl”.


>> Under which circumstances will the Python programming interfaces
>> support the direct usage of the identification “::1”?
>
> I'm not sure I understand the question. They do.

How would like to explain the error message “socket.gaierror: [Errno -9]
Address family for hostname not supported” on my Linux test system then?

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking support for network connections from Python client to IPv6 server

2019-06-02 Thread Markus Elfring
>> How would like to explain the error message “socket.gaierror: [Errno -9]
>> Address family for hostname not supported” on my Linux test system then?
>
> Can you supply a tiny standalone piece of code demonstrating this error 
> please?

The following script part would be relevant.

…
def send_data(x):
   with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as so:
   global args
   so.connect((args.server_id, args.server_port))
…


If the address family “AF_INET6” was passed instead, the identification “::1”
can work also as a command parameter.
The data transmission seems to succeed by my script “socket-send_json_data2.py” 
then.

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking support for network connections from Python client to IPv6 server

2019-06-02 Thread Markus Elfring
>> How would like to explain the error message “socket.gaierror: [Errno -9]
>> Address family for hostname not supported” on my Linux test system then?
>
> Can you supply a tiny standalone piece of code demonstrating this error 
> please?

The following script part would be relevant.

…
def send_data(x):
   with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as so:
   global args
   so.connect((args.server_id, args.server_port))
…


If the address family “AF_INET6” was passed instead, the identification “::1”
can work also as a command parameter.
The data transmission seems to succeed by my script “socket-send_json_data2.py” 
then.

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking refusal of a network connection

2019-06-03 Thread Markus Elfring
> How would this conversion take place?  Localhost is 127.0.0.1.
> Localhost6 is ::1.  They are different

My configuration file “/etc/hosts” provides the following information
as usual.

“…
::1 localhost ipv6-localhost ipv6-loopback
…”


> and you cannot route between the two.

I got other expectations for the corresponding software behaviour.


> What I can see is that your server binds to localhost6 and your client
> is trying to connect to localhost.

I am curious to clarify the circumstances further if such a combination
can also work finally.

If my software test client would pass the IPv6 address family for a connection,
both processes would use the same network protocol version.

Regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Zope3 Examples?

2005-09-28 Thread Markus Wankus
Hi All,

Does anyone know of any good Zope3 examples?  I'm new to Zope and I just 
want to start with a simple website, and later move on to a more complex 
site with interactive calendar, obligatory 
blog/wiki/buzzword-of-the-day-thingy, etc.

I started by installing Zope2 and Plone but it was very slow, and quite 
frankly I didn't want to end up looking like "another Plone site".  I 
did a bunch of surfing and found some suggestions along the lines that 
Zope3 was basically ready for primetime, and would combine the best of 
Plone and Zope2.. and be faster.  So, naturally, I removed Zope2 and 
Plone and quickly installed Zope3!  ;o)  Well, it is definitely faster. 
  The problem is, it doesn't look like there are any applications (if I 
may use that term) for it yet.
I'm starting in on the docs now, and I'll probably break down and pay 
through the nose for the book, but I was just wondering if I perhaps 
made a bad choice and should go back to Zope2/Plone - or will it all be 
worth the effort?

I found the very cool SchoolBell project, and I hope to delve into the 
source for that as a learning experience, but I must admit I was hoping 
for a more Plone-type experience with Zope3 out of the box.  It looks to 
me like that sort of thing just isn't there yet.  That's fine if that's 
the case - I can wait (I have a lot of reading and learning to do anyway).

I guess I'm just wondering if there are any other resources out there I 
haven't found in my Googling yet.  I also found this nice-looking TODO 
sample (which looks like the best place to start, frankly) which I plan 
on using as a starting point as well 
(http://toulouse.amber.org/archives/simple_todo_application/index.html).

Thanks,
Markus
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Zope3 Examples?

2005-09-29 Thread Markus Wankus
bruno modulix wrote:
> Markus Wankus wrote:
>> Hi All,
>>
>> Does anyone know of any good Zope3 examples?  
> 
> Ask the Zope mailing-list. Zope is a world by itself, and is usually not
> discussed here.
> 
> BTW, Zope3 is a really really new thing, so you won't find much existing
> apps. When it's said that it offers 'the best from Plone', (s/plone/cmf/
> IMHO), it's about framework/system architecture, not OOTB application.
> 

Will do - thanks for the info.

Yeah - I was wondering if that's what 'the best from Plone' meant after 
I installed it - however there seem to be a lot of Plone people with 
their backs up over Zope3 moving in on their territory.  If it doesn't 
do all the cool GUI stuff (yet) I would think it could only be good for 
Plone to move to Zope3 as well.  It would only make it faster and more 
lightweight.  Ah well - off to the Zope mailing list.

FWIW - I shuddered at all the different Python web frameworks out there 
and I didn't want to get into "coding" a site right away.  However - it 
looked like I didn't have much choice so I figured if I was going to do 
it I may as well go whole hog and jump into the uber-framework that is 
Zope.  Perhaps I should give my head a shake and try out a nice, simple 
alternative first.  I have a feeling I'll be trying out Snakelets.  I 
really like the idea of a self-contained webserver that is 
super-lightweight.

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


Re: Zope3 Examples?

2005-09-30 Thread Markus Wankus
Jean-François Doyon wrote:
> Markus,
> 
> Zope 3 is mature as a framework, but does not provide much "out of the 
> box".  It's a basis upon which to build applications like Plone ... If 
> you are looking for something that provides Plone-like features on top 
> of Zope 3, it doesn't exist (yet).
> 
> Personally, I'm waiting for this: http://www.z3lab.org/
> But it'll be a while yet!
> 

Yes - I was watching the screencasts (well, animations) on this and it 
looks incredible!  I can't wait to play with something like this.

> Zope 3 is brilliant, but complex, and quite the departure from Zope 2, 
> so it'll take a while for the take up to occur.
> 
> What might work better for you is to use Zope 2 + the CMF, without 
> Plone.  Plone can be fairly heavy and rigid, the CMF alone might give 
> you the tools you need.  I use Zope 2 with success and good performance 
> on a hig traffic website, I wouldn't discount it just because of your 
> first impression ... There are many tweaks available that will 
> considerably improve performance for production systems.
> 
> Cheers,
> J.F.
> 

Thanks for the reply - maybe I'll give it another shot.  I'm currently 
demoing Snakelets.  Quite a turn in the opposite direction, but small 
and super-easy to get going with.  I think once this project gets a few 
good webapps under its belt (and maybe I can contribute there!) this 
could be a nice solution for many people.  At least a good starting 
point for someone like me who knows a good deal about Python and nothing 
about web frameworks.

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


Re: Zope3 Examples?

2005-09-30 Thread Markus Wankus
Gerhard Häring wrote:
> Markus Wankus wrote:
>> [...] Thanks for the reply - maybe I'll give it another shot.  I'm 
>> currently demoing Snakelets.  Quite a turn in the opposite direction, 
>> but small and super-easy to get going with. [...]
> 
> I also found Snakelets a pleasure to use and chose it for implementing a 
> clan homepage in early 2005.
> 
> I'm still very interested in the Python/Web/RDBMS field and tried to 
> follow the developments since then. I didn't actually build anything 
> real, only played a little bit with CherryPy and the megaframeworks 
> built upon, Subway and TurboGears.
> 
> If I had to choose again, I'd use TurboGears, despite the fact that it's 
> very young and still developing.
> 
> -- Gerhard
> 

Good to know.  I have watched the screencast for Turbogears but haven't 
tried it yet.  There seemed to be a lot of "magic" methods going on 
there, and you could tell the guy doing the screencast had done that 
more than once. ;o)  I guess once you run through the manual it would 
all make sense.

I figure I'll give Snakelets a good go first.  Is your Snakelets-based 
page up and accessible somewhere?

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


Re: Learning Python

2005-10-11 Thread Markus Rosenstihl
On 2005-10-10 18:50:18 +0200, Paul DiRezze <[EMAIL PROTECTED]> said:

> I'm spending the next two weeks off and I'm looking to take a crack at 
> learning how to program in Python.  Here's a list of the places I've 
> bookmarked:
> 
> http://www.python.org/doc/ and more specifically
> http://wiki.python.org/moin/
> http://wiki.python.org/moin/BeginnersGuide
> http://www.python.org/doc/Intros.html
> http://www.python.org/topics/
> 

I liked these to, and the Tutorila from python.org

http://www.byteofpython.info/

http://divintopython.org


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


Nicer way of strip and replace?

2005-10-11 Thread Markus Rosenstihl
Hi,
I wonder if i can make this  nicer:

In my case a list is created from a bill which is a tab seperated file 
and each line looks like this:

"Verbindungen Deutsche Telekom vom 03.08.2005 bis 
10.08.2005" "ISDN"  "Deutsche Telekom 
AG" "Rufnummer" "123456789" "3" "Verbindungen zu T-Mobile  
AktivPlus xxl sunday"   "19483" "19""0,1719""3,27"  "16"


I create the list in the following way:

rechnung_raw=open('filename', 'r').readlines()

for line in rechnung_raw:
the_line=string.split(line, '\t')
rechnung.append(the_line)

Now, I have a loop which does basically:

for element in anotherlist:  #anotherlist contains line numbers
euro=euro + float(string.replace(string.strip(rechnung[element][10], 
'"'), ',' , '.'))



I replace commata with dots, then delete leading/trailing "s then add 
to a sum after converting it to a float.
This looks ugly (I htink)  and I wonder if there is a nicer way to 
strip commata and change the comma to a dot already when reading in.
Or should i do it with a shell script before processing in python?

Regards
Markus


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


Re: Nicer way of strip and replace?

2005-10-11 Thread Markus Rosenstihl
On 2005-10-11 23:45:46 +0200, Paul Rubin <http://[EMAIL PROTECTED]> said:

> Markus Rosenstihl <[EMAIL PROTECTED]> writes:
>> This looks ugly (I htink)  and I wonder if there is a nicer way to
>> strip commata and change the comma to a dot already when reading in.
>> Or should i do it with a shell script before processing in python?
> 
> First of all you should just set your locale to use comma instead
> of dot as the numeric decimal, instead of translating commas to dots.

Yes that is true, but most of the time I use a dot as numerical decimal.


> 
> Second, for the field separation, see if you can configure the csv
> module to do it for you.

indeed, it did it correctly by default:

read_file = csv.reader(open('2005_08_Rechnung_4963184011.dat', 'r'), 
delimiter="\t")
for row in read_file:
rechnung.append(row)




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


Re: Nicer way of strip and replace?

2005-10-12 Thread Markus Rosenstihl
On 2005-10-12 01:29:28 +0200, Paul Rubin  said:
> 
> Oh cool.  I think you could even say:
> 
>rechnung = list(read_file)
> 
> instead of the for loop.

Yes, that is working too.


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


Re: IDLE history, Python IDE, and Interactive Python with Vim

2005-02-03 Thread Markus Wankus
I highly recommend trying pyDev.  0.9 just came out, and I find 0.85 
very usable and quite cool.  There is nice debug support, and 
context-sensitive code completion as well as real-time validation of 
your code.  This is an exciting project with a bright future in my opinion.

Markus.
Ashot wrote:
This is sort of both Python and Vim related (which is why I've posted 
to  both newsgroups).

Python related:
--
I have been frustrated for quite some time with a lack of a history  
command in IDLE (in fact with IDLE in general).  Often I'll develop new  
code at the command line, testing each line as I go.  Currently I have 
to  copy and paste, removing outputs and the ">>>" at each line.
Is it perhaps possible to make some kind of hack to do this (dump a  
command history)?

Idle in general isn't that great IMO, so I was wondering also if there 
are  better alternatives out there?  What do people use mostly?  I've 
tried  something called pyCrust, but this too didn't have history and 
some other  things I was looking for.  On a more general note, although 
the agility  and simplicity of Python make programming tools like an IDE 
less  necessary, it still seems that Python is lacking in this 
departement.  The  PyDev plug-in for Eclipse seems like good step in 
this direction, although  I haven't tried it yet.  Does anyone have any 
experience with this, or  perhaps can point me to other tools.

Vim related:
--
Ideally, it would be nice to have a command mapped to a keystroke that 
can  append the last executed command to a file.  Even better would be a 
system  that would integrate the file editing and interactive command 
line tool  more seamlessly.  Something along the lines of a debugger + 
file editor  + command line utility, where file editor = vim.  I know 
that vim has a  utility for running python commands from its command 
prompt, but I have  had a hard time getting this to work in windows and 
haven't explored it.   Has anyone seen/tried a system along these lines, 
perhaps incorporating  the python debugger (pdb)?  I can see something 
that will run the file you  are editing in vim up to the cursor or a 
mark with a set_trace at the line  you are editing.

Any info is appreciated, thanks.
--
Ashot Petrosian
University of Texas at Austin, Computer Sciences
--
http://mail.python.org/mailman/listinfo/python-list


Re: [EVALUATION] - E01: The Java Failure - May Python Helps?

2005-02-03 Thread Markus Wankus
OH GOD!  I cannot believe Ilias has shown up here...
Google his name - he has been banned from Netbeans and Eclipse (and 
Hibernate, and others...) for good reason.  Can you imagine how much of 
a Troll you need to be to *actually* get "banned" from the newsgroups of 
open source projects such as those?

I realize your admirable intentions and the fact that you are simply 
trying to help (the beauty of this community), but I beg you all 
now...PLEASE...do not feed this troll.  Any responses to his posts will 
simply snowball into the biggest waste of time and energy this newsgroup 
has ever seen.I'll let Google fill in the rest of the picture.  You 
can decide whether or not you want to respond to his posts.

Markus.
Jeremy Bowers wrote:
On Thu, 03 Feb 2005 09:26:08 +0200, Ilias Lazaridis wrote:
My question is essentially:
How many of those constructs are already supported by python (and the 
surrounding open-source-projects):

http://lazaridis.com/case/stack/index.html

This post is hard to follow, but I'm going to assume this is the core
question, as it is labelled as such.
The first thing that leaps to mind is that you need to play with Python
for a bit to get a full analysis of it. Due to the nature of Python, some
of the things you have in that list don't really apply. 

The most obvious example of this is "code generation": Assuming you mean
what I think you mean, the sort of thing you have in the C++ or Java world
where you click a couple of boxes, push "next" a few times, and have
several hundred kilobytes of impenetrable source code pop out as your
project's "framework", it doesn't generally apply. In Python, you can
actually write frameworks that can be made to do useful things in a small
handful of lines.
For a good example of that, I'd recommend the Twisted tutorial:
http://twistedmatrix.com/documents/current/howto/tutorial/index . In
Python, if a framework makes you write reams of boilerplate... it's
probably because someone just came from Java and isn't thinking in Python
yet. :-) Code generation in Python is generally a non-starter. (Few rare
counterexamples, but it's nothing like the Necessary Crutch it is in the
C++ world.) Generally, every line in that Twisted tutorial, even in the
final program, is *doing something*, not satisfying the framework with
necessary boilerplate.
As for the rest of your requirements, you have specified your "technology
stack" in terms of *goals*, not capabilities, so for quite a lot of them,
there is no answer except, "Yes, Python can do that, and generally easier
than most anything else". For instance, "Use of metadata within the design
(on text level [code file])" can mean a thousand things. For what it's
worth, Python tends to make it so easy I do it all the time, but for any
given way you mean it, I can't promise there exists a pre-rolled framework
for you.
So I can only speak generally. Given your list, you may find that Python
is weak in the "graphical programming" department; drop-and-drop GUI
generation isn't as well-tuned as VB. (I, for one, consider that
development methodology toxic and actively dangerous, but I can understand
why you miss it.)
Skipping down to your evaluation sequence:
* Create a class: Well, I'll show you this one:
class Something: pass
There, a class.
* Simple GUI: You may wish to check out Boa Constructor, as the closest
thing to the GUI generator you probably want. There are at least 3 major
viable GUI toolkits for Python and several other minor (but still capable)
ones.
* Embedded DBs: I don't know, Google for your embedded DB name + Python.
Failing that, there are several ways to wrap your embedded DB such that a
Python program can use it.
* Web GUI: There are more Python web frameworks than you can shake a stick
at, and I don't mean "some guys hacked together templating system" either;
there are a lot of very mature systems out there, expressing a lot of
different philosophies. Given some of your other requirements, for a
web-based application I'd recommend examining Zope.
* Deployment: I don't generally have enough problems with this to be worth
thinking about. I don't know what the state of the remote debugging is on
Python; Google "remote debugging Python".
* For your "complex updates", I see two distinct things there; half of the
depend on the database, not Python. For the other half, it depends on if
you mean "while the program is still running". If so, they are
challenging. If not, they are trivial.
* I'd recommend adding "testability" to your stack, and refer you to the
"unittest" module; others can suggest their preferred testing modules, but
I tend to stick with that as the general framework is available in a lot
of languages that I use. If by evolutive development you are includi

Re: [EVALUATION] - E01: The Java Failure - May Python Helps?

2005-02-04 Thread Markus Wankus
Fredrik Lundh wrote:
Markus Wankus wrote:

Google his name - he has been banned from Netbeans and Eclipse (and Hibernate, and others...) for 
good reason.  Can you imagine how much of a Troll you need to be to *actually* get "banned" from 
the newsgroups of open source projects such as those?

have Pythoneers ever "banned" anyone from a public forum?  it's not like
we haven't seen trolls and crackpots before, you know.
 

I know - which is why it is even more amazing he can get banned from 
other open source groups similarly tolerant as this one...

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


Re: Thoughts on Guido's ITC audio interview

2005-06-28 Thread Markus Wankus
Stephen Kellett wrote:
> In message <[EMAIL PROTECTED]>, Simon 
> Brunning <[EMAIL PROTECTED]> writes
> 
>> Eclipse's refactorings are a great boon, I find. Refectoring is never
>> *fully* automatic, of course, but the ability to, for example, select
>> a chunk of code and have it extracted into a separate method with all
>> needed arguments and the return value worked out for you is very
>> helpful. All you have to do is give the new method a name. And this
>> sort of thing can certainly improve readability.
> 
> 
> This is not an attach on you Simon, but if people are relying on that 
> type of thing for increases in software productivity they are hiring the 
> wrong people.
> 
> Stephen

Have you ever tried anything that provides real, usable refactoring like 
Eclipse does with Java?  I guarantee if you used it more than a few 
times your view would most likely change.

The fact is, code evolves.  You simply cannot write high-quality 
software in one pass.  Good refactoring tools save time, and therefore 
money.  I sure wouldn't hire anyone who thought otherwise...

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


Re: Thoughts on Guido's ITC audio interview

2005-06-29 Thread Markus Wankus
Stephen Kellett wrote:
> In message <[EMAIL PROTECTED]>, Markus Wankus 
> <[EMAIL PROTECTED]> writes
> 
>> Have you ever tried anything that provides real, usable refactoring 
>> like Eclipse does with Java?  I guarantee if you used it more than a 
>> few times your view would most likely change.
> 
> 
> I was forced to use Eclipse recently. Dreadful. I really disliked it. I 
> never got as far as wanting to refactor things. I couldn't wait to stop 
> using it.
> 
>> The fact is, code evolves.  You simply cannot write high-quality 
>> software in one pass.
> 
> 
> Total agreement. My point is that productivity gains from refactoring 
> tools are the least of your worries. Hiring good staff that know how to 
> write, test and debug software is very much more important than the 
> amount of time a refactoring tool will save.
> 
> Stephen

Well, I have been using it for 2 years now, and while I still prefer 
Python "big-time" to Java, I have really grown to love Eclipse.  To each 
his own I guess.

I agree you shouldn't bank on productivity gains from refactoring tools. 
And I agree they are definitely no kind of replacement for good 
people.  I just think it is silly not to benefit from them.

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


Re: Tricky Dictionary Question from newbie

2005-07-11 Thread Markus Weihs
Hi!


 Dict = {'rt': 'repeated', 'sr':'repeated', 'gf':'not repeated'} 
 NewDic = {}

 for k,v in Dict.items():
 NewDic.setdefault(v, []).append(k)


Regards, mawe



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


Re: Thoughts on Guido's ITC audio interview

2005-07-12 Thread Markus Wankus
Stephen Toledo-Brown wrote:
> Tony Meyer wrote:
> 
>>> Everyone complaining about Eclipse in this thread needs to go try 
>>> 3.1. The interface is much much much more responsive.
>>
>>
>>
>> The problem with Eclipse, IMO, is Java.  I've tried 3.1 on a WinXP 
>> machine
>> and, like just about any Java program, it's incredibly slow and a real 
>> pain
>> to use.  On a (similarly spec'd) Mac OS X Tiger machine, it runs nice and
>> smoothly and is reasonably nice to use.  I'd happily recommend that Mac
>> users try Eclipse, but never a Windows (Python) programmer.
> 
> 
> I've not tried Mac, but under both Windows and Linux on x86, I find 
> Eclipse (3.0) is slow with less than 1.25 GB of RAM, reasonably fast 
> with 1.5GB or more. Processor speed and disk speed don't seem to be 
> anywhere near as important.

I guess we all have different views on "slow".  I have been using it to 
develop a full IDE in Eclipse for over 2 years (since 2.1), and I can't 
understand where you guys are coming from.  I self-host (run a 
development Eclipse SDK, plus a Runtime - that's 2 Eclipse's 
running...sometimes 3) all day every day and it does admittedly get 
"slow", but only down when I am doing serious debugging (Eclipse 
debugging the internals of Eclipse).

I only have 512MB RAM, and a wimpy 1.3 GHz Athlon on Windows.  And BTW - 
if you used Eclipse seriously, you would know that Mac and Linux are 
inherently slower than Windows due to the SWT GUI library lagging 
performance-wise on those platforms (especially GTK on Linux), so I have 
no idea how you can resonably say that you would *never* recommend a 
Windows programmer to try Eclipse.  Those types of performance claims 
are simply not true (beyond a 10 minute evaluation), and it's just plain 
silly to say Eclipse is not usable on Windows.

My opinion - If you aren't willing to try something new, or have an 
aversion to it in the first place, nothing we can say will change your 
mind.  As for me - I'll continue to enjoy the benefits of Eclipse's 
tools - especially with PyDev coming along the way it is.

The ultimate would be for something like Jython or JPype to come to 
fruition so Eclipse plugins could be written in Python.  Now *that* 
would be something.  Actually, the *ultimate* would be to implement the 
equivalent of Eclipse in Python, but that is a pipe dream... ;o)

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


Re: Thoughts on Guido's ITC audio interview

2005-07-12 Thread Markus Wankus
Markus Wankus wrote:
> 
> My opinion - If you aren't willing to try something new, or have an 
> aversion to it in the first place, nothing we can say will change your 
> mind.

Correction...

*There are some people, who* if they aren't willing to try something 
new, or have an aversion to it in the first place, nothing we can say 
will change their mind.

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


Re: GUI tookit for science and education

2005-08-16 Thread Markus Rosenstihl
>> It doesn't have much math built in.  For functions you have to
>> plot points.
> 
> If you want to plot stuff, the gnuplot-py module is very easy
> to use.  http://sourceforge.net/projects/gnuplot-py/
> 
> The one feature that I'd really like to add is the ability to
> plot a python function object.  Currently you can plot a
> function specified by a string (e.g. "sin(x) * sin(x)**2"), or
> a sequence of data points.  It would be nice to be able to pass
> an actual function.

matplotlib is also ver good possibility

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


Re: Creating Pie Chart from Python

2005-09-16 Thread Markus Weihs
Hi!

I tried your script and got the following error:

  Traceback (most recent call last):
File "pie_chart.py", line 302, in OnPaint
  self.OnDraw()
File "pie_chart.py", line 336, in OnDraw
  segment.Draw(self.angle, self.rot, self.explode)
File "pie_chart.py", line 46, in Draw
  glPopMatrix()
  OpenGL.GL.GLerror: [Errno 1281] invalid value

What am I doing wrong?


Regards, Markus


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


Re: How to copy a file from one machine to another machine

2005-09-21 Thread Markus Rosenstihl
Hi
I think scp is also a solution. I am sure there exist free sshserveres 
for windows. THat would make the stuff a bit more secure, and the login 
can be automated via public-key.

Regards
Markus

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


Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-22 Thread Markus Wankus
George Sakkis wrote:
"Ilias Lazaridis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]

Nick Vargish wrote:
You can excuse yourself from this one and stop replying to comments,
but you don't get to unilaterally declare a discussion over.
[...]
The discussion is over.
At least the in-topic one.
Everything else is babbling, hairsplitting, playing an AI which does not
understand writings and all this unproductive garbage.
The Essence is this one, as stated before:
[huge copy paste of previous post]

The Essence is irrelevant.
-
-
-
All your thread are belong to us.
-
-
-
For great justice!
;o)
--
http://mail.python.org/mailman/listinfo/python-list


Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-23 Thread Markus Wankus
Nick Vargish wrote:
Ilias Lazaridis <[EMAIL PROTECTED]> writes:

Guido is the one, who should care by time about the status of the
python-community.

That one crashed my parser.
Sounds like a new Ministry song - "Guido Crashed my Parser".  Could be 
the sequel to "Jesus Built My Hot Rod".
--
http://mail.python.org/mailman/listinfo/python-list


Handle user abort

2005-02-25 Thread Markus Franz
Hallo!

I use Python mostly for CGI (using Apache). And now I habe a problem:
How can I handle the situation if a user clicks on ?abort? in the
browser?
It seems that a CGI-script is NOT stopped at this point. Is there any
signal send to the CGI-process if the user clicks on ?abort??
Thank you.

Best regards

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


Handle user abort inside of a CGI-script

2005-02-25 Thread Markus Franz
Hallo!


I use Python mostly for CGI (Apache). And now I habe a problem: How
can I handle the situation if a user clicks on "abort" in the browser?
It seems that a CGI-script is NOT stopped at this point. Is there any
signal send to the CGI-process if the user clicks on "abort"?
Thank you.


Best regards

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


SAX: Help on processing qualified attribute values

2005-03-10 Thread Markus Doering
Hey,
I am trying to process XML schema documents using namespace aware SAX 
handlers. Currently I am using the default python 2.3 parser:

parser = xml.sax.make_parser()
parser.setFeature(xml.sax.handler.feature_namespaces, 1)
At some point I need to parse xml attributes which contain namespace 
prefixes as their value. For example:


The default SAX parser does a good job on dealing with qualified names 
as xml tags, but is there a way I can access the internal sax mapping 
between prefixes and full namespaces to be able to parse "qualified 
attribute values"? A simple private dictionary prefix2namespace would be 
sufficient.
Or is there a way I can tell the parser to do so for me? I tried to keep 
track of namespace declarations myself with the handler, but if you use 
 namespace aware parsing startElementNS() omits those declarations from 
the resulting attribute list of that method.

Parsing the following XML bit:
http://www.namespacetbd.org/darwin2"; />
does not produce any attribute with startElementNS()
	def startElementNS(self, name,qname,attrs):
		print "Name:%s QName=%s, Attributes=%s"%(unicode(name),unicode(qname), 
unicode(["%s=%s"%(k,v) for k,v in attrs.items()]) )

results in
Name:(None, u'mapping') QName=mapping, Attributes=[]
Should I maybe try another parser than the default one (Expat?)
Thanks for any help,
Markus
--
 Markus Döring
 Botanic Garden and Botanical Museum Berlin Dahlem,
 Dept. of Biodiversity Informatics
 http://www.bgbm.org/BioDivInf/
--
http://mail.python.org/mailman/listinfo/python-list


How do I convert characters into integers?

2004-12-14 Thread Markus Zeindl
Hello,
I want to write a simple encrypter, but I've got a problem:
How can I convert characters into integers?
I have got a string from the user, for example "Hi!".
Now I get every character with a loop:

buffer = ""
for i in range(len(message)):
  ch = message[i-1:i]
  ...

The character is saved in ch.
Here is the problem. I got a string with one character and I
want his ascii representain, for "a" -> 97
but I want to calculate like iCh = iCh+3 or something else.
The next step is how I convert it back to an char and append it
to the buffer, but that' no problem.
thx
--
http://mail.python.org/mailman/listinfo/python-list


Re: How do I convert characters into integers?

2004-12-14 Thread Markus Zeindl
Grant Edwards wrote:
On 2004-12-14, Markus Zeindl <[EMAIL PROTECTED]> wrote:

I want to write a simple encrypter, but I've got a problem:
How can I convert characters into integers?

$ python
Python 2.3.4 (#2, Aug 19 2004, 15:49:40) 
[GCC 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.

ord('A')
65
thank you!
--
http://mail.python.org/mailman/listinfo/python-list


Change vars in the parent process

2004-12-21 Thread Markus Franz
Hi!


Is there any possibility to change vars inside a parent process from
the inside of a child process?
Thanks


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


Processes and their childs

2004-12-21 Thread Markus Franz
Hi!


Inside a Python script (I use Python 2.4) several different child
processes are created by using os.fork().

My problem: I want only the parent process to print some output and
then create the child processes. But even If I use print BEFORE using
os.fork, everything that was printed by the parent process untill this
point is printed by every child process again. How can I avoid this?

Does anybody habe a solution for my problem???
Thanks.


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


Execute code after death of all child processes

2004-12-24 Thread Markus Franz
Hallo!


I have a problem with this little script written in Python:


import sys, os, time
texts = ['this is text1', 'this is text 2']
for current_text in env_sources[0:]:
pid = os.fork()
if pid == 0:
time.sleep(2)
print current_text
break

As you is create some child processes depending on the number of vars
in ?texts?. My problem is: How can I run some code after all child
processes have been finished? (The code should be run only in the
parent process.)

I tried:

import sys, os, time
texts = ['this is text1', 'this is text 2']
for current_text in env_sources[0:]:
pid = os.fork()
if pid == 0:
time.sleep(2)
print current_text
break
os.waitpid(-1, 0)
print 'this is the end'

But this didn't work, 'this is the end' will be showed several times.

Can you help me?

Tanks.


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


Execute code after death of all child processes - (corrected posting)

2004-12-25 Thread Markus Franz
Hallo!


I have a problem with this little script written in Python:


import sys, os, time
texts = ['this is text1', 'this is text 2']
for current_text in env_sources[0:]:
 pid = os.fork()
 if pid == 0:
  time.sleep(2)
  print current_text
  break

As you is create some child processes depending on the number of vars
in ?texts?. My problem is: How can I run some code after all child
processes have been finished? (The code should be run only in the
parent process.)

I tried:

import sys, os, time
texts = ['this is text1', 'this is text 2']
for current_text in texts[0:]:
pid = os.fork()
if pid == 0:
time.sleep(2)
print current_text
break
os.waitpid(-1, 0)
print 'this is the end'

But this didn't work, 'this is the end' will be showed several times.

Can you help me?

Tanks.


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


Embedding Python

2005-03-26 Thread Markus Franz
Hi!

I wanted to run some Python code from inside a C program, so I did it
like it was explained in the Python manual:

#include 
int main(int argc, char *argv[]) {
Py_Initialize();
PyRun_SimpleString("print 'Hallo World!'\n");
Py_Finalize();
return 0;
}

Then I tried to compile this by using the command: gcc halloworld.cpp
But everytime I get the following errors:

/home/mmf/tmp/ccVD2V4h.o(.text+0x1d): In function `main':
: undefined reference to `Py_Initialize'
/home/mmf/tmp/ccVD2V4h.o(.text+0x2a): In function `main':
: undefined reference to `PyRun_SimpleString'
/home/mmf/tmp/ccVD2V4h.o(.text+0x32): In function `main':
: undefined reference to `Py_Finalize'
/home/mmf/tmp/ccVD2V4h.o(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status

What am I doing wrong?

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


Re: Embedding Python

2005-03-26 Thread Markus Franz
Diez B. Roggisch wrote:
/home/mmf/tmp/ccVD2V4h.o(.text+0x1d): In function `main':
: undefined reference to `Py_Initialize'
/home/mmf/tmp/ccVD2V4h.o(.text+0x2a): In function `main':
: undefined reference to `PyRun_SimpleString'
/home/mmf/tmp/ccVD2V4h.o(.text+0x32): In function `main':
: undefined reference to `Py_Finalize'
/home/mmf/tmp/ccVD2V4h.o(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status
What am I doing wrong?
Not linking against libpython.so?
I don't understand what you mean...
Markus
--
http://mail.python.org/mailman/listinfo/python-list


Get document as normal text and not as binary data

2005-03-27 Thread Markus Franz
Hi.

I used urllib2 to load a html-document through http. But my problem
is:
The loaded contents are returned as binary data, that means that every
character is displayed like lÀÃt, for example. How can I get the
contents as normal text?

My script was:

import urllib2
req = urllib2.Request(url)
f = urllib2.urlopen(req)
contents = f.read()
print contents
f.close()

Thanks!

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


Re: Get document as normal text and not as binary data

2005-03-28 Thread Markus Franz
Diez B. Roggisch wrote:
You get what the server sends. That is always binary - either it _is_ a
binary file, or maybe in an unknown encoding. 
And how can I convert those binary data to a "normal" string with 
"normal" characters?

Best regards
Markus
--
http://mail.python.org/mailman/listinfo/python-list


Re: Get document as normal text and not as binary data

2005-03-29 Thread Markus Franz
Diez B. Roggisch wrote:
Addendum: If you give us the url you're fetching data from, we might be able
to look at the delivered data ourselves.
To guess my problem please have a look at the document title of 
<http://portal.suse.de/sdb/de/1997/01/xntp.html>

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


Re: Get document as normal text and not as binary data

2005-03-29 Thread Markus Franz
Kent Johnson wrote:
My guess is the html is utf-8 encoded - your sample looks like 
utf-8-interpreted-as-latin-1. Try
contents = f.read().decode('utf-8')
YES! That helped!
I used the following:
...
contents = f.read().decode('utf-8')
contents = contents.encode('iso-8859-15')
...
That was the perfect solution for my problem! Thanks a lot!
Best regards
Markus
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python IDE like NetBeans/Delphi IDE

2005-04-05 Thread Markus Wankus
More specifically, check out the pydev plugin for Eclipse.
pydev.sourceforge.net
M.
Larry Bates wrote:
Take a look at ActiveState:
http://www.activestate.com/Products/ActivePythonFamily/?_x=1
or for something more general:
http://www.eclipse.org/
Larry Bates
[EMAIL PROTECTED] wrote:
Hi !
I search for an IDE that working in Windows, and knows these functions:
A.) Automatic name searching/showing/extending on classes with
keypressing (like Netbeans, or Delphi Ctrl+Space).
B.) Debugging: breakpoints, step on lines (code), watch variables.
Or A and B both.
Please help me.
Thanx:
ft
--
http://mail.python.org/mailman/listinfo/python-list


Use string in URLs

2005-04-07 Thread Markus Franz
Hi.
I want to use the string "rüffer" in a get-request, so I tried to encode it.
My problem: But with urllib.quote I always get "r%FCffer", but I want to 
get "r%C3%BCffer" (with is correct in my opinion).

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


Re: Does Tk provide ComboBox ?

2005-04-10 Thread Markus Weihs
> Does Tkinter provide a combobox or do I have to find some way of making
> a listbox do the job ?

Hi!

In Tkinter this is called "OptionMenu".
If you don't like it, PMW (http://pmw.sourceforge.net/) has a 
*real* Combobox :)

Regards, mawe

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


Re: c-extension crashes unexpected

2005-04-23 Thread Markus Wintermann
John Machin schrieb:

> ...
>
> Some suggestions:
> 
> 1. Try Pyrex. You get to write in a higher-level language and it does
> all the boring ugly error-prone stuff for you -- this includes
> reference counting as well! Look at the C code that Pyrex generates,
> to see what Pyrex is saving you from.
> 2. If you still insist on DIY, look at some of the Python source code
> in the Modules and Objects directories to see how it is done.
> 3. Examine carefully the book or whatever you have been learning from.
> If it doesn't cover topics like always checking for errors, throw it
> in the garbage bin (and tell the world via this newsgroup). If it does
> cover such topics but you've been ignoring it, well then, it's up to
> you what you do next :-)
> 
> HTH,
> John

many thanks.

it works now, but i´ll try to do the whole thing with pyrex.
because i´m not so familiar with error handling.
i tried to write this with some tutorials and there is always written
something like:
"i know it´s no nice style to have no errorhandling but for excercise
purpose that´s not necessary."
and i never know what to add.
luckily now the good pyrex will do this for me,
if i get it to work.
-- 
http://mail.python.org/mailman/listinfo/python-list


Bug? ( () == [] ) != ( ().__eq__([]) )

2013-08-04 Thread Markus Rother

Hello,

The following behaviour seen in 3.2 seems very strange to me:

As expected:
>>> () == []
False

However:
>>> ().__eq__([])
NotImplemented
>>> [].__eq__(())
NotImplemented

And:
>>> bool(NotImplemented)
True

Hence:
>>> bool(().__eq__([]))
True
>>> ( () == [] ) != ( ().__eq__([]) )
True

How/why can this be intended?

Thanks, everybody.

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


Re: Bug? ( () == [] ) != ( ().__eq__([]) )

2013-08-05 Thread Markus Rother

Thanks for the good explanation.

My intention was to pass a custom method/function as a comparator
to an object.  My misconception was, that __eq__ is equivalent to
the '==' operator, and could be passed as a first class function.
Apparently, that is not possible without wrapping the comparison
into another function/method.

Best regards,
Markus R.

On 05.08.2013 01:06, Chris Angelico wrote:

On Sun, Aug 4, 2013 at 11:35 PM, Markus Rother  wrote:

Hello,

The following behaviour seen in 3.2 seems very strange to me:

As expected:

() == []

False

However:

().__eq__([])

NotImplemented

[].__eq__(())

NotImplemented


You don't normally want to be calling dunder methods directly. The
reasoning behind this behaviour goes back to a few things, including a
way to handle "1 == Foo()" where Foo is a custom type that implements
__eq__; obviously the integer 1 won't know whether it's equal to a Foo
instance or not, so it has to defer to the second operand to get a
result. This deferral is done by returning NotImplemented, which is an
object, and so is true by default. I don't see any particular reason
for it to be false, as you shouldn't normally be using it; it's more
like a "null" state, it means "I don't know if we're equal or not". If
neither side knows whether they're equal, then they're presumed to be
unequal, but you can't determine that from a single call to __eq__.

ChrisA



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


Re: Language design

2013-09-11 Thread Markus Rother
Hello all,

Thanks for this thread.  Here are my two cents...

On 10.09.2013 08:09, Steven D'Aprano wrote:
> What design mistakes, traps or gotchas do you think Python has? Gotchas 
> are not necessarily a bad thing, there may be good reasons for it, but 
> they're surprising.

"""
1. Occasionally, one encounters a strange idiom.  Syntactically
legal and consistent, though:

>>> +4++4
8
>>> -4+-4
-8
>>> -4-+4
-8


2. Reduce removed from standard library.  That is a big fail, in
my opinion.


3. The default return value of methods is None instead of self.
If it was self, it would be possible to chain method calls (which
is called a cascade in smalltalk).


>>> lst = []
>>> lst.append(1).append(2).append(3) ## FAIL
Traceback (most recent call last):
...
AttributeError: 'NoneType' object has no attribute 'append'


Instead, this works:


>>> class Coll(list):
...
... def add(self, e):
... self.append(e)
... return self
...
>>> lst = Coll()
>>> lst.add(1).add(2).add(3) ## OK
[1, 2, 3]


A very practical use case is, that the return value of None makes
all of these methods unusable for reduce.


>>> from functools import reduce
...
>>> many = [{1: 'a'}, {2: 'b'}, {3: 'c'}]
...
>>> reduce(lambda d, other : d.update(other), many, {}) ## FAIL
Traceback (most recent call last):
...
AttributeError: 'NoneType' object has no attribute 'update'


Again, one would have to define an update function with an
explicit return value.

>>> many = [{1: 'a'}, {2: 'b'}, {3: 'c'}]
...
>>> def fn(d, other):
... d.update(other)
... return d
...
>>> reduce(fn, many, {}) ## OK
{1: 'a', 2: 'b', 3: 'c'}


4. As has been mentioned already, some built-in functions do magic
stuff behind the scenes:


>>> () == []
False


But:


>>> bool(().__eq__([]))
True


Because:


>>> ().__eq__([])
NotImplemented


which yields True when cast to boolean.
"""

Greets,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Language design

2013-09-12 Thread Markus Rother
On 10.09.2013 08:09, Steven D'Aprano wrote:
> What design mistakes, traps or gotchas do you think Python has? Gotchas 
> are not necessarily a bad thing, there may be good reasons for it, but 
> they're surprising.

I have one more:

Dictionaries should iterate over their items instead of their keys.

Looking forward to contrary opinions.

Greets,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   >