Re: Python for philosophers

2013-05-16 Thread Schneider
Maybe the implementation of the Python Interpreter could be seen as 
transition function.
This can be understand in detail, but it even if you know how the 
interpreter works, you don't really know to work

_with_ the interpreter.
Even more, there are a lot of decisions, which are made 'by design' and 
don't have a clear answer. to see why somethings are
done in the way they are done you have to understand the philosophy of 
programming with python.


bg,
Johannes

On 13.05.2013 02:34, Gregory Ewing wrote:

Citizen Kant wrote:
What I do here is to try to "understand". That's different from just 
knowing. Knowledge growth must be consequence of understanding's 
increasing. As the scope of my understanding increases, the more I 
look for increasing my knowledge. Never vice versa, because, knowing 
isn't like to be right, it's just knowing.


It doesn't always work that way. With some facts plus a
theory, you can deduce more facts. But it's always possible
for there to be more facts that you can't deduce from what
you already know.

But take in account that with "shortening" I refer to "according to 
Python's axiomatic parameters".


I think what you're trying to say is that it takes an
expression and reduces it to a canonical form, such as
a single number or single string.

That's true as far as it goes, but it barely scratches
the surface of what the Python interpreter is capable
of doing.

In the most general terms, the Python interpeter (or
any other computer system, for that matter) can be thought
of as something with an internal state, and a transition
function that takes the state together with some input
and produces another state together with some output:

   F(S1, I) --> (S2, O)

(Computer scientists call this a "finite state machine",
because there is a limited number of possible internal
states -- the computer only has so much RAM, disk space,
etc.)

This seems to be what you're trying to get at with your
game-of-chess analogy.

What distinguishes one computer system from another is
the transition function. The transition function of the
Python interpreter is rather complicated, and it's
unlikely that you would be able to figure out all its
details just by poking in inputs and observing the
outputs. If you really want to understand it, you're
going to have to learn some facts, I'm sorry to say. :-)




--
GLOBE Development GmbH
Königsberger Strasse 260
48157 MünsterGLOBE Development GmbH
Königsberger Strasse 260
48157 Münster
0251/5205 390

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


serialize a class to XML and back

2013-05-23 Thread Schneider

Hi list,

how can I serialize a python class to XML? Plus a way to get the class 
back from the XML?


My aim is to store instances of this class in a database.

bg,
Johannes

--
GLOBE Development GmbH
Königsberger Strasse 260
48157 MünsterGLOBE Development GmbH
Königsberger Strasse 260
48157 Münster
0251/5205 390

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


Re: serialize a class to XML and back

2013-05-31 Thread Schneider

On 26.05.2013 22:48, Roy Smith wrote:

In article ,
  Chris Rebert  wrote:


On May 23, 2013 3:42 AM, "Schneider"  wrote:

Hi list,

how can I serialize a python class to XML? Plus a way to get the class

back from the XML?

There's pyxser: http://pythonhosted.org/pyxser/


My aim is to store instances of this class in a database.

Honestly, I would avoid XML if you can. Consider using JSON (Python
includes the `json` module in the std lib) or pickle instead. Compared to
XML: The former is more standardized (in the context of serializing
objects) and less verbose; the latter is more efficient (if you don't care
about cross-language accessibility); both have more convenient APIs.

Some other points...

If you care about efficiency and want to use json, don't use the one
that comes packaged with the standard library.  There are lots of
third-party json packages (ujson is the one we use) which are
significantly faster.  Not sure if that's true of the newest python
releases, but it was certainly true in 2.6.


I think performance can be a problem in future. This question is part of 
a multi-user rss-reader solution, which I'm going to develop.


I want to store the feed entries (+ some additional data) as XML in a 
database.



The advantage of pickle over json is that pickle can serialize many
types of objects that json can't.  The other side of the coin is that
pickle is python-specific, so if you think you'll ever need to read your
data from other languages, pickle is right out.



--
GLOBE Development GmbH
Königsberger Strasse 260
48157 MünsterGLOBE Development GmbH
Königsberger Strasse 260
48157 Münster
0251/5205 390

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


Re: serialize a class to XML and back

2013-05-31 Thread Schneider

On 25.05.2013 07:54, dieter wrote:

Schneider  writes:


how can I serialize a python class to XML? Plus a way to get the class
back from the XML?

My aim is to store instances of this class in a database.

In case you want to describe the XML data via an XML-schema
(e.g. to exchange it with other applications; maybe via
WebServices), you may have a look at "PyXB".


The approach of "PyXB" may be a bit different from yours:

   It starts with an XML-schema description and from
   it generates Python classes corresponding to the types
   mentioned in the schema.

   Instances of those classes can then be easily serialized
   to XML and XML documents corresponding to types defined
   in the schema can easily be converted into corresponding
   class instances.

   It is not too difficult to customize the classes
   used for a given type - e.g. to give them special methods
   related to your application.


You may want to start with your (arbitrary) Python classes
and get their instances serialized into an adequate XML document.

This will not work in all cases: some things are very difficult
to serialize (maybe even not serializable at all - e.g. locks).


I have just small classes containing text (strings)  numbers (as ids) 
and references to other classes of this type.




If you plan to use anything already existing, then almost
surely, this will impose restrictions of your classes.




--
GLOBE Development GmbH
Königsberger Strasse 260
48157 MünsterGLOBE Development GmbH
Königsberger Strasse 260
48157 Münster
0251/5205 390

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


Re: Critic my module

2013-07-25 Thread Schneider

Hi,

nice idea.

mybe -  for security reasons - you should ensure, that the right tool is 
called and not some tool put the path with the same name.


bg,
Johannes

On Thu 25 Jul 2013 03:24:30 PM CEST, Devyn Collier Johnson wrote:

Aloha Python Users!

   I made a Python3 module that allows users to use certain Linux
shell commands from Python3 more easily than using os.system(),
subprocess.Popen(), or subprocess.getoutput(). This module (once
placed with the other modules) can be used like this

import boash; boash.ls()

   I attached the module. I plan to release it on the Internet soon,
but feel free to use it now. It is licensed under LGPLv3.

   The name comes from combining "Boa" with "SHell". Notice that the
module's name almost looks like "BASH", a common Linux shell. The Boa
is a constrictor snake. This module makes Unix shells easier to use
via Python3. This brings the system shell closer to the Python shell.


Mahalo,

Devyn Collier Johnson
devyncjohn...@gmail.com






--
GLOBE Development GmbH
Königsberger Strasse 260
48157 MünsterGLOBE Development GmbH
Königsberger Strasse 260
48157 Münster
0251/5205 390
--
http://mail.python.org/mailman/listinfo/python-list


Re: Critic my module

2013-07-29 Thread Schneider

Hi,

lets uses the ls example:
the way you do it now implies, that you search your PATH variable until 
it finds a
program called 'ls'. So if we are able to change the PATH variable, and 
put out own
'ls' somewhere in the (new) paths, calling you ls() will execute 
whatever we want our

own  ls' to do.

Second remark: if the behavior of some tools is changed (for examples 
with using aliases)
we cannot expect the called tool (in the example: 'ls') to give the same 
output on

every system.

this can be avoided (mostly) by ensuring that the right program (in the 
example /bin/ls) is called, and not only ls.


bg,
Johannes

On 07/26/2013 12:39 PM, Devyn Collier Johnson wrote:


On 07/25/2013 09:58 AM, Schneider wrote:

Hi,

nice idea.

mybe -  for security reasons - you should ensure, that the right tool 
is called and not some tool put the path with the same name.


bg,
Johannes

Devyn Collier Johnson On Thu 25 Jul 2013 
03:24:30 PM CEST, Devyn Collier Johnson wrote:

Aloha Python Users!

   I made a Python3 module that allows users to use certain Linux
shell commands from Python3 more easily than using os.system(),
subprocess.Popen(), or subprocess.getoutput(). This module (once
placed with the other modules) can be used like this

import boash; boash.ls()

   I attached the module. I plan to release it on the Internet soon,
but feel free to use it now. It is licensed under LGPLv3.

   The name comes from combining "Boa" with "SHell". Notice that the
module's name almost looks like "BASH", a common Linux shell. The Boa
is a constrictor snake. This module makes Unix shells easier to use
via Python3. This brings the system shell closer to the Python shell.


Mahalo,

Devyn Collier Johnson
devyncjohn...@gmail.com






--
GLOBE Development GmbH
Königsberger Strasse 260
48157 MünsterGLOBE Development GmbH
Königsberger Strasse 260
48157 Münster
0251/5205 390


What do you mean by that Schneider?

Mahalo,

Devyn Collier Johnson
devyncjohn...@gmail.com



--
GLOBE Development GmbH
Königsberger Strasse 260
48157 MünsterGLOBE Development GmbH
Königsberger Strasse 260
48157 Münster
0251/5205 390

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


Re: Lambda function Turing completeness

2013-07-31 Thread Schneider

On Wed 31 Jul 2013 08:53:26 AM CEST, Musical Notation wrote:

Is it possible to write a Turing-complete lambda function (which does not 
depend on named functions) in Python?


what should a sinlge Turing-complete lambda function be?
For me, a programming language can be Turing-complete or a function can 
be universal,  e.g. like an interpreter for a  programming language.


bg,
Johannes

--
GLOBE Development GmbH
Königsberger Strasse 260
48157 MünsterGLOBE Development GmbH
Königsberger Strasse 260
48157 Münster
0251/5205 390
--
http://mail.python.org/mailman/listinfo/python-list


SSH Connection with Python

2012-10-25 Thread Schneider

Hi Folkz,
how can i create a SSH-Connection with python? I have to send some 
commands to the remote host and parse their answers.

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


Re: SSH Connection with Python

2012-10-29 Thread Schneider

thank you guys for the huge list of answers,
In my setting I have to access some routers and firewall from a 
linux-client.


I think I'll try Fabric.


On 26.10.2012 06:20, Rodrick Brown wrote:

On Oct 25, 2012, at 6:34 AM, Schneider  wrote:


Hi Folkz,
how can i create a SSH-Connection with python? I have to send some commands to 
the remote host and parse their answers.
greatz Johannes

Fabric is the way to go!


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


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


Python performance

2013-08-02 Thread Schneider

Hi list,

I have to write a small SMTP-Relay script (+ some statistic infos) and 
I'm wondering, if this
can be done in python (in terms of performance, of course not in terms 
of possibility ;) ).


It has to handle around 2000 mails per hour for at least 8hours a day 
(which does not mean, that it is allowed not to respond the rest of the day.


Can this be done? or should I better use some other programming language?
My second choice would be erlang.

bg,
Johannes


--
GLOBE Development GmbH
Königsberger Strasse 260
48157 MünsterGLOBE Development GmbH
Königsber
ger Strasse 260
48157 Münster
0251/5205 390

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


Re: Python performance

2013-08-02 Thread Schneider

On Fri 02 Aug 2013 02:59:26 PM CEST, Tim Chase wrote:

On 2013-08-02 14:00, Schneider wrote:

I have to write a small SMTP-Relay script (+ some statistic infos)
and I'm wondering, if this
can be done in python (in terms of performance, of course not in
terms of possibility ;) ).

It has to handle around 2000 mails per hour for at least 8hours a
day (which does not mean, that it is allowed not to respond the
r

est of the day.


Can this be done? or should I better use some other programming
language? My second choice would be erlang.


I suspect it depends on a lot of factors:

- will your network connection support that much traffic?  (And an
   ISP that will grant you permission to spew that volume of email?)


yes, because we are the ISP.


- are these simple text emails, or are they large with lots of
   attachments, inline images, PDFs, or whatever?


any kind of mail. No restrictions allowed.


- are the statistics that you're gathering simple, or do they require
   complex analysis of the documents passing through?


very simple statistics, mostly counting and time statistics.


- is the load 8hr straight of spewing email, or is it bursty?  If
   it's bursty, you can internally queue them up when load gets high,
   delivering them from that queue when load diminishes.  Given the
   store-and-forward nature of email, there's no guarantee that if
   you spewe

d them at ~33/minute (that/s a little faster than one

   every two seconds), they'd arrive at their destination any faster
   than if you'd queued them up and sent them at a more steady rate.


I guess it's bursty. I don't have finer granulated information about 
their time distribution.



-tkc



Queuing the mails for a while is not possible, because the tool should 
sit between the client and smtp-server.

It should act as proxy, not as server.

bg,
Johannes



--
GLOBE Development GmbH
Königsberger Strasse 260
48157 MünsterGLOBE Development GmbH
Königsberger Strasse 260
48157 Münster
0251/5205 390
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python performance

2013-08-02 Thread Schneider

On 08/02/2013 03:09 PM, Ray Cote wrote:

- Original Message -

From: "Schneider" 
To: python-list@python.org
Sent: Friday, August 2, 2013 8:00:09 AM
Subject: Python performance

Hi list,

I have to write a small SMTP-Relay script (+ some statistic infos)
and
I'm wondering, if this
can be done in python (in terms of performance, of course not in
terms
of possi

bility ;) ).


It has to handle around 2000 mails per hour for at least 8hours a day
(which does not mean, that it is allowed not to respond the rest of
the day.


A quick calculation shows that 2,000 mails per hour is less than 1 email every 
second.
Plenty of time to handle individual emails.


This is just true, if the mails arrive equally distributed. We cannot 
ensure this.

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


Re: What minimum should a person know before saying "I know Python"

2013-09-26 Thread Schneider

I would say it's a little bit more:
You have to know the keywords and (basic) concepts, e.g. you really have 
to understand what it means, that everything is a class.
If you get foreign, you have to be able to understand it. And the other 
way round, given a problem, you should be able to write a working solution.


bg
Johannes

On 09/20/2013 06:23 PM, Mark Janssen wrote:

I started Python 4 months ago. Largely self-study with use of Python 
documentation, stackoverflow and google. I was thinking what is the minimum 
that I must know before I can say that I know Python?

Interesting.  I would say that you must know the keywords, how to make
a Class, how to write a loop.  That covers about 85% of it.



--
GLOBE Development GmbH
Königsberger Strasse 260
48157 MünsterGLOBE Development GmbH
Königsberger Strasse 260
48157 Münster
0251/5205 390

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


Good Python Book

2013-10-09 Thread Schneider

Hi List,

I'm looking for a good advanced python book. Most books I looked at up 
to now are on beginners level.
I don't need a reference (that's online) or a book explaining how to use 
the interpreter or how to use list comprehensions on the one side and 
skipping topics like decorators, metaclasses on the other side.


any suggestions?

bg,
Johannes

--
GLOBE Development GmbH
Königsberger Strasse 260
48157 MünsterGLOBE Development GmbH
Königsberger Strasse 260
48157 Münster
0251/5205 390

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


Re: Debugging decorator

2013-10-28 Thread Schneider


On 10/26/2013 01:55 AM, Yaşar Arabacı wrote:

Hi people,

I wrote this decorator: https://gist.github.com/yasar11732/7163528

When this code executes:

 @debugging
 def myfunc(a, b, c, d = 48):
 a = 129
 return a + b

 print myfunc(12,15,17)

This is printed:

 function myfunc called
 a 12
 c 17
 b 15
 d 48
 assigned new value to a: 129
 returning 144
144

I think I can be used instead of inserting and deleting print
statements when trying to see what is
passed to a function and what is assingned to what etc. I think it can
be helpful during debugging.

It works by rewriting ast of the function and inserting print nodes in it.

What do you think?




Looks very nice, but I've three  questions:

1. What happens, if a function has more then one decorator? Wouldn't it 
be better to

just remove the debugging decorator instead of removing all decorators?

2. In the case of an assignment (but holds for the return statement too).
think about the following code:

a = 0
@debugging
def foo():
a = a +  1

def bar():
#assign something else to a

Imagine foo() and bar() being called in two different threads. Wouldn't 
it be better


to replace  a = a + 1 by

|global_debugging_lock_objekt.acquire()|
a = a + 1
print "assigned new value to a, %r", a
|global_debugging_lock_objekt.release()|

for some global lock object.

3. What happens in the case of  a += 1?

bg,
Johannes

--
GLOBE Development GmbH
Königsberger Strasse 260
48157 MünsterGLOBE Development GmbH
Königsberger Strasse 260
48157 Münster
0251/5205 390

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


Re: Creating an object that can track when its attributes are modified

2013-03-07 Thread Schneider

Hi,
maybe you could do this by a decorator on the setattr method. It should 
look more or less

like your implementation, but in my eyes it's a cleaner and can be reused.

Further, I would use a stack for each attribute, so that you can restore 
all previous values.


bg,
Johannes

On 03/06/2013 05:07 PM, Ben Sizer wrote:

I am trying to make an object that can track when its attributes have been 
assigned new values, and which can rollback to previous values where necessary. 
I have the following code which I believe works, but would like to know if 
there are simpler ways to achieve this goal, or if there are any bugs I haven't 
seen yet.


class ChangeTrackingObject(object):
 def __init__(self):
 self.clean()

 def clean(self):
 """Mark all attributes as unmodified."""
 object.__setattr__(self, '_dirty_attributes', dict())

 def dirty_vals(self):
 """Returns all dirty values."""
 return dict( [ (k,v) for k,v in self.__dict__.iteritems() if k in 
self._dirty_attributes]  )

 def get_changes_and_clean(self):
 """Helper that collects all the changes and returns them, cleaning the dirty flags at 
the same time."""
 changes = self.dirty_vals()
 self.clean()
 return changes

 def rollback(self):
 """Reset attributes to their previous values."""
 for k,v in self._dirty_attributes.iteritems():
 object.__setattr__(self, k, v)
 self.clean()

 def __setattr__(self, key, value):
 # If the first modification to this attribute, store the old value
 if key not in self._dirty_attributes:
 if key in self.__dict__:
 self._dirty_attributes[key] = object.__getattribute__(self, 
key)
 else:
 self._dirty_attributes[key] = None
 # Set the new value
 object.__setattr__(self, key, value)


I am aware that adding a new attribute and then calling rollback() leaves the 
new attribute in place with a None value - maybe I can use a special DeleteMe 
marker object in the _dirty_attributes dict along with a loop that calls 
delattr on any attribute that has that value after a rollback.

I also believe that this won't catch modification to existing attributes as 
opposed to assignments: eg. if one of the attributes is a list and I append to 
it, this system won't notice. Is that something I can rectify easily?

Any other comments or suggestions?

Thanks,


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


Re: USBLock : lock/unlock your computer with a USB key

2013-04-12 Thread Schneider

On 11.04.2013 22:16, Ian Kelly wrote:

On Thu, Apr 11, 2013 at 9:23 AM, Ethan Furman  wrote:

On 04/11/2013 04:13 AM, Sven wrote:

Yes, I had the idea to add bluetooth too, removes the whole plugging and
unplugging spiel. I might start work on that,
and if anyone else wants to dive in and help, feel free. I will probably
need to refactor the Listener a little, or
create a USB and BT listener class.


Doesn't BlueTooth have a 30 foot range?  For locking I'd rather be at 10 or
even 5 feet away.

Pair it with a Google Glass and have it lock after you've stopped
looking at the screen for 30 seconds.


Maybe not with Google Glass, but with a web cam placed on top of the 
screen. Like Samsung does since the Galaxy S III.
There it just happens the other way round: no lock as long as you have 
your face in front of the phone.


bg,
Johannes

--
GLOBE Development GmbH
Königsberger Strasse 260
48157 MünsterGLOBE Development GmbH
Königsberger Strasse 260
48157 Münster
0251/5205 390

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


Add header at top with email.message

2018-09-14 Thread Thomas Schneider
Hi,

the EmailMessage class of email.message provides the methods
add_header() and __setitem__() to add a header to a message.
add_header() effectively calls __setitem__(), which does
`self._headers.append(self.policy.header_store_parse(name, val))`.  This
inserts the header at the bottom.

It is, however, sometimes desired to insert a new header at the top of
an (existing) message.  This API doesn’t directly allow this.  In my
opinion, add_header() should have a flag at_top=False or similar, so
that one can get this behaviour (it’ll be a bit difficult with
__setitem__).  What do you think about this?  Is there a feasible way to
do this and change the library?  Should I post it somewhere where the
devs can hear it and suggest that?

Thanks,
--qsx
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Add header at top with email.message

2018-09-17 Thread Thomas Schneider
Jason Friedman  writes:

> I suppose you already figured out that you can call __delitem__() to
> clear the headers and add them back in whatever order you like.

Well, this would mean saving all headers, deleting all, inserting my
own, and adding the saved original headers again.  Seems complicated.

> I'm interested in learning more about your use case.  Do you have a
> third party with fixed logic that requires the headers in a particular
> order?

Yes, RFC 5321, section 4.4[0] :)

> When an SMTP server receives a message for delivery or further
> processing, it MUST insert trace ("time stamp" or "Received")
> information at the beginning of the message content, as discussed in
> Section 4.1.1.4.

To trace the path a message went, those headers do need to be in a
particular order, or else they won’t make any sense.

[0]: https://tools.ietf.org/html/rfc5321#section-4.4
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 1 Million users.. I can't Scale!!

2005-09-28 Thread Michael Schneider
I would need to get a better picture of your app.

I use a package called twisted to handle large scale computing
on multicore, and multi-computer problems


http://twistedmatrix.com/

Hope this is useful,
Mike

yoda wrote:
> Hi guys,
> My situation is as follows:
> 
> 1)I've developed a service that generates content for a mobile service.
> 2)The content is sent through an SMS gateway (currently we only send
> text messages).
> 3)I've got a million users (and climbing).
> 4)The users need to get the data a minimum of 5 seconds after it's
> generated. (not considering any bottlenecks external to my code).
> 5)Generating the content takes 1 second.
> 
> I'm considering moving to stackless python so that I can make use of
> continuations so that I can open a massive number of connections to the
> gateway and pump the messages out to each user simultaneously.(I'm
> thinking of 1 connection per user).
> 
> My questions therefore are:
> 1)Should I switch to stackless python or should I carry out experiments
> with mutlithreading the application?
> 2)What architectural suggestions can you give me?
> 3)Has anyone encountered such a situation before? How did you deal with
> it?
> 4)Lastly, and probably most controversial: Is python the right language
> for this? I really don't want to switch to Lisp, Icon or Erlang as yet.
> 
> I really need help because my application currently can't scale. Some
> user's end up getting their data 30 seconds after generation(best case)
> and up to 5 minutes after content generation.  This is simply
> unacceptable.  The subscribers deserve much better service if my
> startup is to survive in the market.
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


What python idioms for private, protected and public?

2005-09-29 Thread Michael Schneider
I have been following this thread with great interest.

I have been coding in C++ since the late 80's and Java since the late 90's.


I do use private in these languages, with accessors to get at internal 
data.

This has become an ingrained idiom for me.  When I create a python 
object, it is natural for me to want  to use familiar idioms.


Hare are the places where private is useful to me:


Design Intent:

1) mark an object as dirty in a setter (anytime the object is changed, 
the dirty flag is set without requiring a user to set the dirty flag

2) enforce value constraints (even if just during debugging)

3) lazy init, don't bring the data in until needed

4) adding debug info

5)  more here


I do write code that violates private
- memory ptr access in C++
- reflection in java
- aspects in java

I usually violate private when adding an aspect to a class, and
I don't want this code in every class.  Example,  persistence.


I really like the C# properties, you can access data with a data
accessor, but add functionality is triggered when accessing the data.

I like the data access syntax, better then the set/get functions.  I 
need the functionality to achieve the design goals above, so i use 
function, but the are ugly, especially in math code.


It would be easy for me to say "Add public and private to python so I
can code the way that I am used to".  What are some python alternatives 
to achieve the design intents specified above above?

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


Re: What python idioms for private, protected and public?

2005-09-29 Thread Michael Schneider
Frederik,

Thank you very much for the info on properties, that is very useful.

Sorry about the public typo, that should have been protected. I should
not post before coffee hits :-)

Happy coding,
Mike

Fredrik Lundh wrote:
> Michael Schneider wrote:
> 
> 
>>1) mark an object as dirty in a setter (anytime the object is changed,
>>the dirty flag is set without requiring a user to set the dirty flag
> 
> 
> properties.
> 
> 
>>2) enforce value constraints (even if just during debugging)
> 
> 
> properties.  (when you no longer need to enforce things, switch back
> to a plain attribute).
> 
> 
>>3) lazy init, don't bring the data in until needed
> 
> 
> properties.
> 
> 
>>4) adding debug info
> 
> 
> properties.
> 
> 
>>5)  more here
> 
> 
> properties.
> 
> 
>>It would be easy for me to say "Add public and private to python so I
>>can code the way that I am used to".
> 
> 
> huh?  what do "private" and "public" have to do with what you're describing?
> 
> 
>>What are some python alternatives to achieve the design intents specified
>>above above?
> 
> 
> properties.
> 
> http://users.rcn.com/python/download/Descriptor.htm#properties
> 
>  
> 
> 
> 

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


Re: So far

2005-10-06 Thread Michael Schneider
Take a look at:

http://wingware.com/

It is only $35.00 for an IDE. (30 day free eval version)

I use eclipse for java, and have become quite fond of tab completion.

Mike

CppNewB wrote:
> I am absolutely loving my experience with Python.  Even vs. Ruby, the syntax 
> feels very clean with an emphasis on simplification.
> 
> My only complaint is that there doesn't appear to be a great commercial IDE 
> for the language.  I've tried Komodo, etc and they are nice applications, 
> but they don't feel like they give me the "power" like a Visual Studio or 
> Delphi (I wish I could articulate better the differences).Finding a 
> descent GUI builder has been a challenge as well.  Most of them have support 
> for Dialogs, but what about more complex UI's?  I may need a resizable frame 
> within a resizable frame? I haven''t found a GUI builder with a great feel 
> yet.
> 
> Other than that, my experience has been wonderful.  Even after my 
> complaints, I plan on sticking with Python for a while. 
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Problems with properties

2005-10-14 Thread Michael Schneider
Hello All,

I have been working on learning how to use python properties.

The get property access is working, but the the set
property is not working.

Rather then dispatching the property assignment to setNothing, the
property object is being replaced with a string.

I must be doing something very stupid here.

Could someone please point out my error, I have dents in my forehead
for this one.

Thanks,
Mike



--

from unittest import TestCase
import unittest


class Task:
   def __init__(self,command):
 self._command = command

   def setNothing(self, value):
 raise AttributeError

   def getCommand(self):
 return self._command

   command=property(getCommand, setNothing)


class taskTest(TestCase):

 def testTask(self):
 t = Task("dir c:")
 c = t.command
 self.assertEquals("dir c:", c)

 # should fail, but doesn't
 t.command = "foo Bar"

 self.assertEquals("dir c:", t.command)



if __name__ == "__main__":
 unittest.main()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problems with properties

2005-10-14 Thread Michael Schneider
Thanks to all,  I added the object as a subclass (should this be 
required for 2.4.1 ???)

I also switched to the decorator with the @property syntax

Thank you very much for the help for adding @property to the language.

what a great language :-)

Mike


Michael Schneider wrote:
> Hello All,
> 
> I have been working on learning how to use python properties.
> 
> The get property access is working, but the the set
> property is not working.
> 
> Rather then dispatching the property assignment to setNothing, the
> property object is being replaced with a string.
> 
> I must be doing something very stupid here.
> 
> Could someone please point out my error, I have dents in my forehead
> for this one.
> 
> Thanks,
> Mike
> 
> 
> 
> --
> 
> from unittest import TestCase
> import unittest
> 
> 
> class Task:
>   def __init__(self,command):
> self._command = command
> 
>   def setNothing(self, value):
> raise AttributeError
> 
>   def getCommand(self):
> return self._command
> 
>   command=property(getCommand, setNothing)
> 
> 
> class taskTest(TestCase):
> 
> def testTask(self):
> t = Task("dir c:")
> c = t.command
> self.assertEquals("dir c:", c)
> 
> # should fail, but doesn't
> t.command = "foo Bar"
> 
> self.assertEquals("dir c:", t.command)
> 
> 
> 
> if __name__ == "__main__":
> unittest.main()


-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problems with properties

2005-10-14 Thread Michael Schneider
Thanks to all,  I added the object as a subclass (should this be 
required for 2.4.1 ???)

I also switched to the decorator with the @property syntax

Thank you very much for the help for adding @property to the language.

what a great language :-)

Mike


Michael Schneider wrote:
> Hello All,
> 
> I have been working on learning how to use python properties.
> 
> The get property access is working, but the the set
> property is not working.
> 
> Rather then dispatching the property assignment to setNothing, the
> property object is being replaced with a string.
> 
> I must be doing something very stupid here.
> 
> Could someone please point out my error, I have dents in my forehead
> for this one.
> 
> Thanks,
> Mike
> 
> 
> 
> --
> 
> from unittest import TestCase
> import unittest
> 
> 
> class Task:
>   def __init__(self,command):
> self._command = command
> 
>   def setNothing(self, value):
> raise AttributeError
> 
>   def getCommand(self):
> return self._command
> 
>   command=property(getCommand, setNothing)
> 
> 
> class taskTest(TestCase):
> 
> def testTask(self):
> t = Task("dir c:")
> c = t.command
> self.assertEquals("dir c:", c)
> 
> # should fail, but doesn't
> t.command = "foo Bar"
> 
> self.assertEquals("dir c:", t.command)
> 
> 
> 
> if __name__ == "__main__":
> unittest.main()


-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Read/Write from/to a process

2005-10-25 Thread Michael Schneider
Jas,

I use a python called twisted to run processes as you describe.

Twisted is an event-driven framework that brings a change in the
way that you look at things.

take a look at:

http://twistedmatrix.com/projects/core/documentation/howto/process.html

Good luck, hope this is useful,
Mike


jas wrote:
> Hi,
>   I would like to start a new process and be able to read/write from/to
> it.  I have tried things like...
> 
> import subprocess as sp
> p = sp.Popen("cmd.exe", stdout=sp.PIPE)
> p.stdin.write("hostname\n")
> 
> however, it doesn't seem to work.  I think the cmd.exe is catching it.
> 
> I also tried
> f = open("out.txt", "w")
> sys.stdout = f
> os.system("cmd.exe")
> 
> ..but out.txt didn't contain any output from cmd.exe
> 
> So, how can I create a process (in this case, cmd.exe) on Windows and
> be able to read/write from/to it?
> 
> Thanks
> 


-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


weakrefs to functions for observer pattern

2005-11-02 Thread Michael Schneider
Hello All,

I am comming back to python after being away for several years.

I would like to use weak refs in an observer pattern implementation.

The problme that I have seems to be that weakrefs can't manage functions.

--- from docs: 
http://www.python.org/doc/current/lib/module-weakref.html

Not all objects can be weakly referenced; those objects which can 
include class instances, functions written in Python (but not in C), 
methods (both bound and unbound), sets, frozensets, file objects, 
generators, type objects, DBcursor objects from the bsddb module, 
sockets, arrays, deques, and regular expression pattern objects. Changed 
in version 2.4: Added support for files, sockets, arrays, and patterns.

---

Is there a technique that I can use to leverage weak references to I 
don't have to unregister my observers?

Thanks
Mike

PS.  here is the code that I have been working with (Note: I commendout 
out the weak ref creation.


import types
class Observable(object):

 def addObserver(self, observer, events=None):
 if not hasattr(self, '_observers'):
 #self._observers = weakref.WeakKeyDictionary()
 self._observers = {}

 if observer is None:
 return

 if events is not None and type(events) not in (types.TupleType,
 types.ListType):
 events = (events,)
 self._observers[observer] = events

 def removeObserver(self, callable):
 if not hasattr(self, '_observers'):
 return

 if self._observers.has_key(callable):
 del self._observers[callable]

 ##
 # Notify all currently-registered Observers.
 #
 # This observer will be called if the event is one that the
 # Observer is interested in, or if event is 'None'
 #
 # @param event The event to notify the Observers about.  None
 # means no specific event.
 #
 # *args  - standard arguments - passed through to observer
 # **kw   - keyword arguments - passed through to observer
 def notifyObservers(self, event=None, *args, **kw):

 if not hasattr(self, '_observers'):
 return

 for cb, events in self._observers.items():
 if events is None or event is None or event in events:
 if  cb is not None:
 cb(self, event, *args, **kw)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: weakrefs to functions for observer pattern

2005-11-03 Thread Michael Schneider
Alex Martelli wrote:
> Michael Schneider <[EMAIL PROTECTED]> wrote:
> 
> 
>>I would like to use weak refs in an observer pattern implementation.
>>The problme that I have seems to be that weakrefs can't manage functions.
> 
> 
> They can manage just fine functions written in *Python*, just not
> "builtin functions*, i.e., ones written in *C*.  Just wrap any builtin
> function you need to register as observer into a tiny Python-coded
> wrapper and live happily ever after.
>...
> 
>>Not all objects can be weakly referenced; those objects which can 
>>include class instances, functions written in Python (but not in C), 
> 
> 
> 
> Alex
Alex,

Thank you, I mis-read the docs.

The mistake I  made was having was using a weak reference as a key in 
the dictionary.

Weak references will be very useful for me.

I really enjoy python.  So many good things have been added to the 
language without taking the fun away :-)

Mike

-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using Which Version of Linux

2005-11-05 Thread Michael Schneider
I have been away from unix/linux for a couple of years.

I went with SUSE.   Just do an install all, and 10 gig later you
are done.

Very simple install, very easy admin with YAST.

If you are a power admin, there may be better release.  But if you want
simple, but powerful, SUSE has worked well for me.

Good Luck,
Mike


[EMAIL PROTECTED] wrote:
> ok, i m going to use Linux for my Python Programs, mainly because i 
> need to see what will these fork() and exec() do. So, can anyone tell 
> me which flavour of linux i should use, some say that Debian is more 
> programmer friendly, or shold i use fedora, or Solaris. Because these 
> three are the only ones i know of that are popular and free.


-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: AJAX => APAX? Or: is there support for python in browsers?

2005-11-16 Thread Michael Schneider
Alex,

Good point.   Can python be used to write firefox extensions that could 
be called from javascript?

1) javascript would come in on the HTML page
2) javascript would communication with the Extension API
3) the extension would be written in python

That way, you would only need to make your extension's API safe to the wild.

It would require the user to download an extension, but flash, et all 
seem to do ok.

Is this possible today?

Thanks
Mike


PS.  Sorry for my ignorance on this, I am a client-side developer, 
trying to explore serious client development.

Alex Martelli wrote:
> Tim Roberts <[EMAIL PROTECTED]> wrote:
>...
> 
>>Internet Explorer will allow any registered ActiveScript language to be
>>used in a web page.  Python qualifies.  In the latest Win32 extensions,
>>there is a script in win32comext/axscript/client/pyscript.py that will
>>register Python as an ActiveScript language.
>>
>>The you can say
>>
>>  
>>  print "

Hello, there.

" >> > > > Out of curiosity, how "sandboxed" is this Python? I remember a similar > solution being withdrawn once because it wasn't really safely sandboxed, > so the ``script'' could easily do any arbitrary damage to the machine... > > > Alex -- The greatest performance improvement occurs on the transition of from the non-working state to the working state. -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for small, impressive 3D-related Python script

2005-11-29 Thread Michael Schneider
Ken,

I would suggest that you embed python in your app (very easy to do).

-And convert several of your existing scripts to python.

-Show them a stack of python books for customer training purposes

- Drive excel with python (allows integration of your product with other 
products.

- Pick an area of functionality that your product offers today that your
customer would like to customize.

- convert this alg to python
- hack you product to execute the python script
- code a variant of the alg in python
- execute your variant to demonstrate that python can lower custom 
development cost, and provide points of extensibility


Have fun,
good luck,
Mike

Kenneth McDonald wrote:
> I'm not trying to persuade my company to offer Python as a scripting  
> language for their product, but I am trying to give them examples of  
> things that Python can do easily that cannot be done easily with  their 
> current proprietary scripting language. After that it would be  their 
> decision. As the product is a 3D package, I'm looking for  something in 
> this field.
> 
> This does _not_ have to use PyOpenGL, or for that matter, any Python  3D 
> package. In fact, my ideal would be a Python script that simply  uses 
> L-Systems (Lindenmayer systems) as in "The Algorithmic Beauty of  
> Plants", to generate plantlike OBJ files that can then be displayed  in 
> our program. In general, something that generates an OBJ file  would 
> probably be preferable to something that actually uses  PyOpenGL, 
> Blender, etc, as then I can just display the OBJ file in  our program to 
> say, "This is the sort of thing that can be easily  done by Python 
> without recourse to any other programs".
> 
> So please, any suggestions are welcome.
> 
> As always, many thanks to this group,
> Ken


-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-07 Thread Michael Schneider
[EMAIL PROTECTED] wrote:
  ,, 

  However there is one thing I don't like in python,
> that is, scoping by indentation. But it would not annoy me so much that
> make me decide to implement a new language^_^.
> 
> 
> Regards,
> 
> Limin
> 


I find these comments interesting.  It is very common for people to 
complain about indentation.

I have helped several very large companies create C++ coding
standards.

One common requirement is very fixed indentation rules.  These
rules are often encoded into lint-like tools.  These tools
treat indentation errors like compile time errors.


These are often the same people that don't want to use python because
it uses indentation ..

It is humorous if stand back and look from a distance greater then 10 
feet :-)

Mike


-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to ping in Python?

2005-12-07 Thread Michael Schneider
I telnet to port 13 (returns time)

Hope this is helpful,
Mike

Nico Grubert wrote:
> Hi there,
> 
> I could not find any "ping" Class or Handler in python (2.3.5) to ping a 
> machine.
> I just need to "ping" a machine to see if its answering. What's the best 
> way to do it?
> 
> Kind regards,
> Nico


-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to ping in Python?

2005-12-07 Thread Michael Schneider
Les,

I only ping internal machines.  You are right about shutting down ports.

When we disable telent, we also disable ping.  Many people may not though,

good luck,
Mike

Laszlo Zsolt Nagy wrote:

> Michael Schneider wrote:
>
>> I telnet to port 13 (returns time)
>>
> The problem is that most modern up-to-date servers use firewalls. They 
> only open the ports that are absolutely necessary. Usually the time 
> service is part of inetd, which is disabled by default, on most of the 
> servers. PING ICMP may work, but sometimes it does not either. In the 
> worst case, all port are closed and you have no way to tell if there 
> is a computer or not.
>
> Can you tell more about what kind of server do you need to "ping"?
>
> Example: if you need to know if a web server is alive, you should 
> connect to port 80 (http). If the connection was successful, you can 
> close the connection immeditelly. You can expect a HTTP server to open 
> the HTTP port, but all other ports may be closed.
>
>   Les
>
>
>
>


-- 
The greatest performance improvement occurs on the transition of from the 
non-working state to the working state.

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


Re: Ant (with Python extensions) good replacement for distutils?

2005-12-07 Thread Michael Schneider
I would vote against ant because java must be installed to run it.


The bootstrap install should be very simple.  If you make python usage
dependent on:

1) download java
2) install java
3) add java to path
4) download ant
5) install ant
6) add ant to path
7) download ptyhon
8) install python
9) add python to path
10) download package
11) run ant to install package

just food for thought,
Mike

[EMAIL PROTECTED] wrote:
> I know distutils well but don't know anything about Ant except that it
> is a build
> tool from Apache project.
> 
> Could it possible be better or as good as distutils?
> (There are extensions for Python.)
> 
> Chris
> 


-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python OGL Shader Programming

2005-09-19 Thread Michael Schneider
Just curious,  is anyone using python for OGL 2.0 shader language 
development?

Which lib are you using?

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


Differences between obj.attribute and getattr(obj, "attribute")

2013-12-11 Thread Johannes Schneider

Hi list,
can somebody explain me the difference between accessing attributes via
obj.attribute and getattr(obj, "attribute")?

Is there a special reason or advantage when using getattr?

bg,
Johannes

--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn

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


Re: Differences between obj.attribute and getattr(obj, "attribute")

2013-12-11 Thread Johannes Schneider

thank you guys.
On 11.12.2013 10:36, Chris Angelico wrote:

2013/12/11 Johannes Schneider :

can somebody explain me the difference between accessing attributes via
obj.attribute and getattr(obj, "attribute")?

Is there a special reason or advantage when using getattr?

You use getattr when the attribute name comes from a string, rather
than a literal. There's no advantage to it when you know ahead of time
what attribute you're looking for. It's useful when you iterate over
dir(), for instance:

print("You can call...")
n=0
for attr in dir(x):
 if callable(getattr(x,attr)):
 print("x.%s()"%attr)
 n+=1
print("...",n," options.")

ChrisA



--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn

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


Re: Brython (Python in the browser)

2013-12-27 Thread Johannes Schneider

On 27.12.2013 07:14, Pierre Quentel wrote:

Hi,

Ever wanted to use Python instead of Javascript for web client programming ? 
Take a look at Brython, an implementation of Python 3 in the browser, with an 
interface with DOM elements and events

Its use is very simple :
- load the Javascript library brython.js : 

Imports in Python

2014-01-21 Thread Johannes Schneider

Hi List,
I remember some document explaining the python imports in detail 
somewhere, but I don't have any idea where it was. Even no idea if it 
was in the List or some blogbost.


Does anybody of you have some suggestions where I can find those 
informations besides the official documentation?


bg,
Johannes

--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn
--
https://mail.python.org/mailman/listinfo/python-list


Re: matlabFunction Equivalent?

2014-01-21 Thread Johannes Schneider

On 20.01.2014 23:09, rpi.bal...@gmail.com wrote:

Hey all,

I'm new at Python, so if you see any mistakes feel free to let me know.

I'm trying to take a symbolic expression and turn it into a variable equation 
or function. I think that just an expression of variables would be preferable.

I have a range equation which I form using symbols and then take various 
derivatives of it. I then want to have these derivatives on hand to use for 
various functions, but short of using sub every time or just copy pasting from 
the console output (I don't want to do that), I can't find an efficient way to 
do this. Matlab had matlabFunction which was really handy, but I don't think 
Python has an equivalent.


import numpy as np
import scipy as sp
import sympy as sy
import math as ma

x, y, z, x_s, y_s, z_s, theta, theta_dot, x_dot, y_dot, z_dot = sy.symbols('x y 
z x_s y_s z_s theta theta_dot x_dot y_dot z_dot')

rho = (x**2 + y**2 + z**2 + x_s**2 + y_s**2 + z_s**2 - 2*(x*x_s + 
y*y_s)*sy.cos(theta) + 2*(x*y_s - y*x_s)*sy.sin(theta) - 2*z*z_s)**(0.5)

rho_dot = (x*x_dot + y*y_dot + z*z_dot - (x_dot*x_s + y_dot*y_s)*sy.cos(theta) 
+ theta_dot*(x*x_s + y*y_s)*sy.sin(theta) + (x_dot*y_s - 
y_dot*x_s)*sy.sin(theta) + theta_dot*(x*y_s - y*x_s)*sy.cos(theta) - 
z_dot*z_s)/rho

drho_dx = sy.diff(rho, x)

drho_dy = sy.diff(rho, y)

drho_dz = sy.diff(rho, z)

#I then want drho_dx, etc to be variable expressions with x, y, z, etc as 
variables instead of symbols or numbers. I could do:

x, y, z = 1200, 1300, 1400 #m

drho_dx = subs([x, x], [y, y], [z, z])

#but this seems inefficient to do multiple times. Thoughts?



If you  don not mind installing other programs, maybe you can have a 
look at sage (www.sagemath.org). That's a ComputerAlgebraSystem using 
python as its base and supporting most (all?) of the python syntax and 
moduls


bg,
Johannes



--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn
--
https://mail.python.org/mailman/listinfo/python-list


Re: SIngleton from __defaults__

2014-01-23 Thread Johannes Schneider

On 22.01.2014 20:18, Ned Batchelder wrote:

On 1/22/14 11:37 AM, Asaf Las wrote:
Chris is right here, too: modules are themselves singletons, no matter
how many times you import them, they are only executed once, and the
same module object is provided for each import.


I'm not sure, if this is the whole truth.

think about this example:

cat bla.py
a = 10

cat foo.py
from bla import a

def stuff():
return a

cat bar.py
from foo import stuff
print stuff()
a = 5
print stuff()

from bla import *
print a

python bar.py
10
10
10

here the a is coming from bla and is known in the global namespace. But 
the value differs in stuff() and before/after the import statement. So 
the instance of the module differs -> it cannot be a singelton.


bg,
Johannes

--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn
--
https://mail.python.org/mailman/listinfo/python-list


Re: SIngleton from __defaults__

2014-01-24 Thread Johannes Schneider

thnx guys.

On 24.01.2014 01:10, Terry Reedy wrote:

  Johannes Schneider  Wrote in
  message:

On 22.01.2014 20:18, Ned Batchelder wrote:

On 1/22/14 11:37 AM, Asaf Las wrote:
Chris is right here, too: modules are themselves singletons, no matter
how many times you import them, they are only executed once, and the
same module object is provided for each import.


I'm not sure, if this is the whole truth.

think about this example:

cat bla.py
a = 10

cat foo.py
from bla import a


This makes a a global in foo, bound to 10


def stuff():
  return a


This a refers to the global a in foo.


cat bar.py
from foo import stuff
print stuff()
a = 5


This bar.a is irrelevant to the behavior of stuff.


print stuff()

from bla import *
print a

python bar.py
10


foo.a == 10


10


foo.a == 10


10


bla.a == 10


here the a is coming from bla


Twice

and is known in the global namespace.

There is no global namespace outside of modules.


the value differs in stuff()


No it does not.

and before/after the import statement.

foo.a does not change. bar.a is never used.


So the instance of the module differs


Nope. Each of the three module instances is constant. The bindings
within each could change, but there are no rebinding in the code above.




--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn
--
https://mail.python.org/mailman/listinfo/python-list


Re: SSH/Telnet program to Router/switch

2014-02-19 Thread Johannes Schneider

On 19.02.2014 09:14, Sujith S wrote:

Hi,

I am new to programming and python. I am looking for a python script to do 
ssh/telnet to a network equipment ? I know tcl/perl does this using expect/send.

Do we have expect available in python as well or need to use some other method ?

Regards
Sujith





I'm using paramiko to access some routers and firewalls from python and 
it works very well.


bg,
Johannes


--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn
--
https://mail.python.org/mailman/listinfo/python-list


Re: The sum of numbers in a line from a file

2014-02-21 Thread Johannes Schneider

s = 4
e = 7
with f = file('path_to_file) as fp:
for line in f:
if line.startswith(name):
avg =  sum(map(int, filter(ambda x : len(x) > 0,
s.split(' '))[s : e])) / (e -  s)






On 20.02.2014 17:22, kxjakkk wrote:

Let's say I have a sample file like this:

Name1   2 34 5  6 78

name1099-66-7871   A-FY10067815998
name2999-88-7766   A-FN99   100969190
name3000-00-0110AUD5100281976
name4398-72-P/FY7684496978
name5909-37-3689A-FY97941006179

For name1, I want to add together columns 4, 5, 6, and get an average from 
that, then do the same for the last two columns. I want to do this for every 
name.

All I've got is
sum([int(s.strip()) for s in open('file').readlines()])




--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn
--
https://mail.python.org/mailman/listinfo/python-list


Re: why i have the output of [None, None, None]

2014-04-10 Thread Johannes Schneider

because thats the return value of [...]
print retuns None.

On 10.04.2014 15:54, length power wrote:

 >>> x=['','x1','x2','x3','   ']
 >>> x
['', 'x1', 'x2', 'x3', '   ']
 >>> [print("ok") for it in x if it.strip() !=""]
ok
ok
ok
[None, None, None]

i understand there are three 'ok' in the output,but why i have the
output of [None, None, None]





--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn
--
https://mail.python.org/mailman/listinfo/python-list


Re: The “does Python have variables?” debate

2014-05-08 Thread Johannes Schneider

On 08.05.2014 02:35, Ben Finney wrote:

Marko Rauhamaa  writes:

[..]

Python, on the other hand, has this behaviour::

 foo = [1, 2, 3]
 bar = foo  # ‘bar’ binds to the value ‘[1, 2, 3]’
 assert foo == bar  # succeeds
 foo[1] = "spam"# ‘foo’ *and* ‘bar’ now == [1, "spam", 3]

[..]

IMHO this is the behavior of having a variable pointing to it's value; 
foo to the list and bar to foo.



consider the following:
>>> def f(l):
... l[1] = 'foo'
...
>>> l1 =  [1,2,3]
>>> f(l1)
>>> l1
[1, 'foo', 3]

this means, l1 consists of "pointers" to its values.
Otherwise, it's not calling by reference, because

>>> g(l1)
>>> l1
[1, 'foo', 3]

does not change l1. Once again, if I pass an object it behaves like 
calling by reference:


>>> class A:
... a = 0
...
>>> a = A()
>>> a.a
0
>>> def h(a1):
... a1.a = 1
...
>>> h(a)
>>> a.a
1

bg,
Johannes


--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn
--
https://mail.python.org/mailman/listinfo/python-list


Re: The possibility integration in Python without an equation, just an array-like file

2014-05-16 Thread Johannes Schneider
If you do not have a closed form for T(E) you cannot calculate the exact 
value of I(V).


Anyway. Assuming T is integrable you can approximate I(V).

1. Way to do:
interpolate T(E) by a polynomial P and integrate P. For this you need 
the equation (coefficients and exponents) of P. Integrating is easy 
after that.


2. other way:
Use Stair-functions: you can approximate the Value of IV() by the sum 
over T(E_i) * (E_{i+1} - E_i) s.t. E_0 = E_F-\frac{eV}{2} and E_n = 
E_F+\frac{eV}{2}.



3 one more way:
use a computer algebra system like sage.

bg,
Johannes

On 16.05.2014 10:49, Enlong Liu wrote:

Dear All,

I have a question about the integration with Python. The equation is as
below:
and I want to get values of I with respect of V. E_F is known. But for
T(E), I don't have explicit equation, but a .dat file containing
two columns, the first is E, and the second is T(E). It is also in the
attachment for reference. So is it possible to do integration in Python?

Thanks a lot for your help!

Best regards,
​

--
Faculty of Engineering@K.U. Leuven
BIOTECH@TU Dresden
Email:liuenlon...@gmail.com <mailto:liuenlon...@gmail.com>;
enlong@student.kuleuven.be <mailto:enlong@student.kuleuven.be>;
enlong@biotech.tu-dresden.de <mailto:enlong@biotech.tu-dresden.de>
Mobile Phone: +4917666191322
Mailing Address: Zi. 0108R, Budapester Straße 24, 01069, Dresden, Germany






--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn
--
https://mail.python.org/mailman/listinfo/python-list


Re: What happens when you 'break' a generator?

2014-07-29 Thread Johannes Schneider

On 29.07.2014 09:18, Frank Millman wrote:

there's not print 'done' statement at the and.



Here I break the loop -

x = test()
for j in x:
 print(j)
 if j == 2:
 break

Now the output is -

start
0
1
2

'done' does not appear, so the generator does not actually terminate. What
happens to it?

My guess is that normal scoping rules apply. Using my example, the generator
is referenced by 'x', so when 'x' goes out of scope, the generator is
garbage collected, even though it never completed.

Is this correct?

Frank Millman






--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn
--
https://mail.python.org/mailman/listinfo/python-list


shutil.copyfile is incomplete (truncated)

2013-04-11 Thread Rob Schneider
Using Python 2.7.2 on OSX, I have created a file in temp space, then use the 
function "shutil.copyfile(fn,loc+fname)" from "fn" to "loc+fname".

At the destination location, the file is truncated. About 10% of the file is 
lost.  Original file is unchanged.

I added calls to "statinfo" immediately after the copy, and all looks ok 
(correct file size).

filecmp.cmp(fn,loc+fname)
print "Statinfo:"+fn+":\n", os.stat(fn)
print "Statinfo:"+loc+fname+":\n", os.stat(loc+fname)

But when I look at the file in Finder, destination is smaller and even looking 
at the file (with text editor) file is truncated.

What could be causing this?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: shutil.copyfile is incomplete (truncated)

2013-04-11 Thread Rob Schneider
Thanks. Yes, there is a close function call  before the copy is launched. No 
other writes.
Does Python wait for file close command to complete before proceeding?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: shutil.copyfile is incomplete (truncated)

2013-04-11 Thread Rob Schneider

> The close method is defined and flushing and closing a file, so
> 
> it should not return until that's done.
> 
> 
> 
> What command are you using to create the temp file?
> 
> 

re command to write the file: 
f=open(fn,'w')
... then create HTML text in a string
f.write(html)
f.close 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: shutil.copyfile is incomplete (truncated)

2013-04-11 Thread Rob Schneider
> I would consider the chance that the disk may be faulty, or the file 
> 
> system is corrupt. Does the problem go away if you write to a different 
> 
> file system or a different disk?
> 

It's a relatively new MacBook Pro with a solid state disk.  I've not noticed 
any other disk problems. I did a "repair permissions" (for what it's worth). 
Maybe I'll have it tested at the Genius Bar.  I don't have the full system on 
another computer to try that; but will work on that today.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: shutil.copyfile is incomplete (truncated)

2013-04-11 Thread Rob Schneider

> 
> > Or that the filesystem may be full? Of course, that's usually obvious
> 
> > more widely when it happens...
> 
> > 
> 
> > Question: is the size of the incomplete file a round number? (Like
> 
> > a multiple of a decent sized power of 2>)
> 
> 
> 
> Also on what OS X file system type does the file being created reside, 
> 
> in particular, is it a network file system?
> 

File system not full (2/3 of disk is free)

Source (correct one) is 47,970 bytes. Target after copy of 45,056 bytes.  I've 
tried changing what gets written to change the file size. It is usually this 
sort of difference.

The file system is Mac OS Extended Journaled (default as out of the box).  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: shutil.copyfile is incomplete (truncated)

2013-04-11 Thread Rob Schneider

> The file system is Mac OS Extended Journaled (default as out of the box).

I ran a repair disk .. .while it found and fixed what it called "minor" 
problems, it did something.  However, the repair did not fix the problem. I 
just ran the program again and the source is 47,970 bytes and target after copy 
if 45,056.

Interestingly, the test I run just after the copy , i run a file compare:

code:

 if showproperties: 
print "Filecompare :",filecmp.cmp(fn,loc+fname)
print "Statinfo:"+fn+":\n", os.stat(fn)
print "Statinfo:"+loc+fname+":\n", os.stat(loc+fname)

results:

Filecompare : True
Statinfo:/var/folders/p_/n5lktj2n0r938_46jyqb52g4gn/T/speakers.htm:
posix.stat_result(st_mode=33188, st_ino=32205850, st_dev=16777218L, st_nlink=1, 
st_uid=501, st_gid=20, st_size=45056, st_atime=1365749178, st_mtime=1365749178, 
st_ctime=1365749178)
Statinfo:/Users/rmschne/Documents/ScottishOilClub/SOC Board Doc Sharing 
Folder/Meetings/speakers.htm:
posix.stat_result(st_mode=33188, st_ino=32144179, st_dev=16777218L, st_nlink=1, 
st_uid=501, st_gid=20, st_size=45056, st_atime=1365749178, st_mtime=1365749178, 
st_ctime=1365749178)

It shows file size 45,056 on both source and target, which is the file size of 
the flawed target, and is not what Finder shows for source.

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


Re: shutil.copyfile is incomplete (truncated)

2013-04-12 Thread Rob Schneider
On Friday, 12 April 2013 09:26:21 UTC+1, Cameron Simpson  wrote:
> 
> | > > Question: is the size of the incomplete file a round number? (Like
> 
> | > > a multiple of a decent sized power of 2>)
> 
> [...]
> 
> | Source (correct one) is 47,970 bytes. Target after copy of 45,056
> 
> | bytes.  I've tried changing what gets written to change the file
> 
> | size. It is usually this sort of difference.
> 
> 
> 
> 45046 is exactly 11 * 4096. I'd say your I/O is using 4KB blocks,
> 
> and the last partial block (to make it up to 47970) didn't get
> 
> written (at the OS level).
> 
> 
> 
> Earlier you wrote:
> 
> | I have created a file in temp space, then use the function
> 
> | "shutil.copyfile(fn,loc+fname)" from "fn" to "loc+fname".
> 
> and:
> 
> | Yes, there is a close function call  before the copy is launched. No other 
> writes.
> 
> | Does Python wait for file close command to complete before proceeding?
> 
> 
> 
> Please show us the exact code used to make the temp file.
> 
> 
> 
> I would guess the temp file has not been closed (or flushed) before
> 
> the call to copyfile.
> 
> 
> 
> If you're copying data to a tempfile, it will only have complete
> 
> buffers (i.e. multiples of 4096 bytes) in it until the final flush
> 
> or close.
> 
> 
> 
> So I'm imagining something like:
> 
> 
> 
>   tfp = open(tempfilename, "w")
> 
>   ... lots of tfp.write() ...
> 
>   shutil.copyfile(tempfilename, newfilename)
> 
> 
> 
> Note above no flush or close of tfp. So the final incomplete I/O
> 
> buffer is still in Python's memory; it hasn't been actually written
> 
> to the temp file because the buffer has not been filled, and the file
> 
> has not been closed.
> 
> 
> 
> Anyway, can you show us the relevant bits of code involved?
> 
> 
> 
> Cheers,
> 
> -- 
> 
> Cameron Simpson 
> 
> 
> 
> Processes are like potatoes.- NCR device driver manual

Thanks for the observation. 

Code (simplified but results in same flaw) (which a close, far as I can tell).

def CreateSpeakerList1():
import shutil
import filecmp
import os.path 

t=get_template('speaker_list.html')
fn=TEMP_DIR+SOC_SPEAKER_LIST
fn=tempfile.gettempdir()+"/"+SOC_SPEAKER_LIST
f=open(fn,'w')
speaker_list=Speaker.objects.order_by('status__order','targetmtg__date')
print "Creating " + SOC_SPEAKER_LIST +  " ..."
html=(smart_str(t.render(Context(
{
'css_include_file':CSS_INCLUDE_FILE,
'css_link':False,
'title': ORG_NAME+" Speaker List",
'speaker_list': speaker_list,
}
f.write(html)
f.close
print "Wrote "+fn
shutil.copyfile(fn,SOC_GENERAL_OUTPUT_FOLDER+SOC_SPEAKER_LIST)
print "Filecompare 
:",filecmp.cmp(fn,SOC_GENERAL_OUTPUT_FOLDER+SOC_SPEAKER_LIST)
print "Statinfo:"+fn+":\n", os.stat(fn)
print "Statinfo:"+SOC_GENERAL_OUTPUT_FOLDER+SOC_SPEAKER_LIST+"\n", 
os.stat(SOC_GENERAL_OUTPUT_FOLDER+SOC_SPEAKER_LIST)
return

Output on latest run:

Creating speakers.htm ...
Wrote /var/folders/p_/n5lktj2n0r938_46jyqb52g4gn/T/speakers.htm
Filecompare : True
Statinfo:/var/folders/p_/n5lktj2n0r938_46jyqb52g4gn/T/speakers.htm:
posix.stat_result(st_mode=33188, st_ino=32332374, st_dev=16777218L, st_nlink=1, 
st_uid=501, st_gid=20, st_size=45056, st_atime=1365758139, st_mtime=1365758139, 
st_ctime=1365758139)
Statinfo:/Users/rmschne/Documents/ScottishOilClub/Output/speakers.htm
posix.stat_result(st_mode=33188, st_ino=32143886, st_dev=16777218L, st_nlink=1, 
st_uid=501, st_gid=20, st_size=45056, st_atime=1365758029, st_mtime=1365758139, 
st_ctime=1365758139)


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


Re: shutil.copyfile is incomplete (truncated)

2013-04-12 Thread Rob Schneider
On Friday, 12 April 2013 10:22:21 UTC+1, Chris Angelico  wrote:
> On Fri, Apr 12, 2013 at 7:18 PM, Rob Schneider  wrote:
> 
> >   f.close
> 
> 
> 
> Yep, there's the problem! See my previous post for details. Change this to:
> 
> 
> 
> f.close()
> 
> 
> 
> and you should be sorted.
> 
> 
> 
> ChrisA

Slapping forehead ... hard.  Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2005-12-29 Thread Michael Schneider
Congratulations to Guide,

Mike

Harald Armin Massa wrote:
> Guido at Google: a message in THE public forum c.l.p.
> 
> A confirmation by Martellibot, that Guido is IN FACT sitting 15m
> distant from him; and everybody in Python knows where Martellibot has
> his desk.
> 
> Can it get more official than this?
> 
> yeah:
> a confirmation by Greg Stein @ Google within slashdot, that Guido is
> working at Google.
> 
> I am sure that more people in the Python community are reading c.l.p.
> and /. than the washington post, the people affected have been
> informed.
> 
> I guess that's as formal and official as it can get.
> 
> And concerning Guido, Python, community and leadership:
> 
> Guido is the designer, the creator of Python. He has nearly unlimeted
> trust in his design decisions: we all know, that he is THE gifted
> language designer. His proclamations are accepted because he has proven
> over time that he knows what's best for the language.
> 
> Allow me to quote Greg Stein:
> "Ha! Guido would quit in a heartbeat if you tried to make him manage
> people. That just isn't where he's at. He's absolutely brilliant and
> loves to write excellent code. Great. We're gonna let him do just that
> :-)"
> 
> So, Google with their geek-version of the Playboy-Mansion, free massage
> parleurs, free lunch and dinner and best recruitment tactics on the
> planet and the known universe will not be able to make Guido manage
> people.
> 
> Somehow the Python community managed itself through the years... Python
> grew healthy and steadily; forked less then usual, inspired other
> languages and got faster and faster and faster.
> 
> Maybe only mediocre and less ideas need a great leader. Maybe a great
> idea can lead for itself?
> 
> Harald
> 
> --
> GHUM Harald Massa
> persuadere et programmare
> Harald Armin Massa
> Reinsburgstraße 202b
> 70197 Stuttgart
> 0173/9409607
> 


-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing pins to the RS232

2005-12-31 Thread Michael Schneider
Jay,

Couple of points that may help you.

1) A serial port does not have data ports 0-n.  A serial port takes a 
byte (8 bits), then shifts them down a single pipe using a chip called a
UART (feel free to google for unfamiliar terms).

example

Bit pattern 1010 1010

would be shifted one bit at a time

1
0
1
0

1
0
1
0

a one is +5 volts on single send line of the UART and 0 is 0 volts.

RS232 uses a different mapping for 1's and 0's (but is still serial)

1 - ~-3V - -12 V
0 0-12 V

So you slap a chip on between the UART and the RS232 pin  (usually a 
MAX232)  that translates the voltages for you.

On the other end of the wire

232 socket
MAC232
UART (usually built into the microcontroller)
Register in Microcontroller


I like playing at this level.   I would recommend using AVR 
microcontroller (easiest to program and there is an open source
gcc compiler).

for $20.00 US you can buy the butterfly eval board with:
- microcontroller
- max232 all wired up for rs232 connection from your computer
- lcd display
- temperature sensor
- light sensor
- the avr mega169 has many goodies
 - analog - digital converter
 - digital -> analog converter
 - LCD controller

This is a great bargin.

If you are starting out in microcontrollers.  I would suggest that you 
go to:

http://smileymicros.com/

They sell a nice package for $90.00

- butterfly eval board
- great, easy to follow book on how to develop on microcontrollers for 
the beginer.
- project kit - includes everything you need to build all of the 
projects (even includes the wire ;-)


There are python libs that support Ateml Avr connections:


It is easy to use your rs232 serial with a microcontroller at the other 
end of the wire.  Microcontrollers are cheap.  If you fry why is 
connected to your devices, you are only out the microcontroller.


Have fun,
Mike



[EMAIL PROTECTED] wrote:
> I want to write to the pins of an RS232 without using the serial
> protocol.  The use would be every pin could act to complete a circuit
> in customized hardware.  I could use python to communicate serially to
> a BASIC stamp or a Javelin stamp and then use the stamp to set however
> many pins as 0's or 1's but should it be that hard to do with python.
> I've looked through how python does serial with the "serial" module but
> it just uses Java's javax.comm libraries.  Is there anyway to do very
> low level device writing to COM ports?
> 
> In summary I'm looking for something like:
> ser = serial.Serial(0)
> ser.pin0 = 1
> ser.pin1 = 1
> ser.pin2 = 1
> 
> 
> 
> or
> ser.write('0xFF')
> which would set 8 pins on the RS232 cable to 1's
> 


-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


Weird gcc errors while installing "MySQL-python" module

2007-09-02 Thread Jonas Schneider
Hi guys,

I´m experiencing weird error messages while installing MySQL-python
with easy_install... I have no idea where the errors come from.

Read the whole output at http://pastebin.com/m3859cf40
It´s really a lot...

Someone got ideas?

Greets
Jonas

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


Re: Choosing a new language

2007-12-29 Thread Achim Schneider
Rico Secada <[EMAIL PROTECTED]> wrote:

> 
> Second, I need some advice.
> 
http://www.nondot.org/sabre/Mirrored/AdvProgLangDesign/

Learn, or better said understand, those and then choose wisely.

Lisp throws lambda calculus right into your face, which is a good
thing. Scheme might be the better choice, it's lexically scoped:
http://mitpress.mit.edu/sicp/
There are also video lectures with people with funny hats speaking wise
words.

For lisp, (and also a good read if you go for scheme, same with the
wizard book above the different way round), the book of choice is
http://www.paulgraham.com/acl.html

Python is Yet Another Scripting Language, borrowing concepts from more
advanced languages. You might want to go for the real thing instead,
although it's certainly nice.

Haskell is to scheme what a basketball basket is to a trash bin. It's
typed strictly and pure, but with some effort you will also be able to
throw your trash through the basket as well as find a trash bin big
enough for your ball
. 
-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Choosing a new language

2007-12-31 Thread Achim Schneider
Tim Roberts <[EMAIL PROTECTED]> wrote:

> Xah Lee <[EMAIL PROTECTED]> wrote:
> >
> >Let me tell you, since you know PHP, that PHP and Perl are
> >practically identical in their high-levelness or expressiveness or
> >field of application (and syntax), and, Perl and Python are pretty
> >much the same except their syntax.
> 
> I agree with the fundamental sentiment here, but it's important to
> note that the syntax difference between Perl and Python is an enormous
> consideration.
> 
> The biggest problem with Perl's syntax, in my view, is that it is
> darned near impossible to write Perl code that can be read and
> understood later, by anyone, including the author.  I've used both
> languages extensively, and even with all of that experience, it takes
> considerable effort for me to go back to the Perl scripts I wrote 4
> or 5 years ago and grasp what they actually do.
> 
> With Python, on the other hand, much of the source code reads like
> English prose.  It's certainly possible to code "write-only"
> sequences by abusing comprehensions and generators, but obfuscations
> like that are the exception rather than the rule.

Should I start a flame war? Shouldn't I?

It's New Year's Eve, after all, fits quite nicely.

Perl excels on executing braindumps. Python is quite good in that area,
too.

Haskell, too, but only if you think Haskell. And Haskell has style.
Good style. Very good style, to be exact. 

In the end that means that you can't read your Perl and Python programs
'cos your brain was a bit muddy at the time you wrote it.

Well, with Haskell this would never happen, as you wouldn't have ever
been able to write such atrocious code in the first place.

You would rather think about the problem in detail, get disabused by
old aunty typecheck, abstract, and write completely unintelligent code
_after_ understanding that your brainmuddiness was actually complete
clarity, it was the language you were trying to implement it in that
made it muddy.

And now please all stop posting and let me get completely drunk in
relative peace.

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Using python22.dll with Python 2.5?

2008-10-22 Thread Martin Schneider

Hi!

I'd like to use the numpy library (which runs on Python 2.5) in the same 
project with another (mandatory) library which needs python22.dll. When 
I try to compile I get an error similar to "python22.dll not compatible 
with the current Python version."


Has anybody an idea how to solve this?

Thanks for your ideas.
Best regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Two-dimensional array tutorial?

2008-10-22 Thread Martin Schneider

Hi!

I'd like to handle two-dimensional arrays. My first choice, the numpy 
library, doesn't seem to be an option due to compatibility issues (see 
my other thread about python22.dll).


Is there a tutorial somewhere how to handle 2d-arrays with vanilla Python?

Thanks and best regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: Two-dimensional array tutorial?

2008-10-22 Thread Martin Schneider

Diez B. Roggisch schrieb:

Can't you just get Numpy (or it's predecessors, Numeric) compiled against
ptyhon2.2?


I tried Numeric, but e.g. it doesn't seem to feature transpose...

How do I compile Numpy against python2.2? :-)

Thanks for your answers and best regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: Two-dimensional array tutorial?

2008-10-22 Thread Martin Schneider

Robert Kern schrieb:

Martin Schneider wrote:

I tried Numeric, but e.g. it doesn't seem to feature transpose...


Yes, it does. Numeric.transpose()


Then I must have made a mistake. I'll look into it. Thanks for the 
correction.



How do I compile Numpy against python2.2? :-)


You cannot. The first version of numpy required Python >= 2.3.


Yeah, I read in your other post, which crossed mine. Sh*t :-)

Thanks and best regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: concatenate the elements in each list of a list of lists

2008-07-23 Thread Michael Schneider
Am Wed, 23 Jul 2008 08:33:57 -0700 wrote antar2:

> I already asked a similar question, but encounter problems with
> python...
> How can I concatenate the elements in each list of a list of lists
> 
> list_of_listsA =
> 
> [['klas*', '*', '*'],
> ['mooi*', '*', '*', '*'],
> ['arm*', '*', '*(haar)']]
> 
> wanted result:
> 
> list_of_listsA =
> 
> [['klas* * *']
> ['mooi* * * *']
> ['arm* * *(haar)']]
> 
> Thanks a lot !

Hello,

maybe this will help:

In [5]: list_of_listsA = [['klas*', '*', '*'], ['mooi*', '*', '*', '*'], 
['arm*', '*', '*(haar)']]
In [6]: s = ""
In [7]: print [[s.join(item)] for item in list_of_listsA]
[['klas***'], ['mooi'], ['arm***(haar)']]

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


Re: Tkinter: The good, the bad, and the ugly!

2010-12-30 Thread Arndt Roger Schneider

rantingrick schrieb:

On Dec 29, 6:41 pm, Gerry Reno  wrote:


wxPython looks good but I don't see anyone developing support for things
like smartphones.



No wx is not the answer to our problems



Rather: ... to *your* problem...




Also, what do you think about frameworks such as pyjamas?  It lets you
write in python and compiles everything down to Javascript so it can be
used across the Web as well as on the desktop.



Hmm, this is like two double edged swords smashing one another in
battle.

Sword One: On one hand web frameworks are going to be really big soon
-- however legacy GUI's are not going away any time soon!


There are enough out there in the wild,
they will last quite for awhile indeed;
but it's time for them to die.



Sword Two: On the other hand web frameworks provide awesome cross
platform ability that is surly only going to get better as time goes
-- however i utterly hate JavaScript (although much worse web
languages exist!). And sending requests back and forth between Python,
JavaScript,


Apparently the authors do know that, too:
MessageID:,
*sigh* no svg.

BTW: Look in comp.lang.javascript:
javascript is framework/toolkit resistent.

 and BrowserX is also a real PITA. Because even though

everyone knows this is coming all the major browsers are trying to
insert their API into the mix. So that Joe Scripter has to write code
that is compatible between many browsers. Until the world agrees on a
unified API --AND IMPLEMENTS IT SERIOUSLY-- we are at the mercy of
drunken sailors at the helm.


svg: opera, chrome, safari(including ios), ie9, firefox.
Although svg is missing under webkit/android
--Apple kept the hardware accelerated part to themeselves.
Goolge is currently implementing hardware acceleration for svg in 
chrome/webkit, likewise Microsoft/ie.

Lets wait and see when svg becomes available in android, too.

Although smil is quiet another subject.



I believe pyjamas has a bright future in the web playground, however
we still need to focus our community efforts towards a Python based
GUI. I can see a pythonGUI and pyjamas existing side by side in mutual
harmony for many years.



pyjamas: Perhaps without javascript.

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


Re: [OT] Python like lanugages

2011-01-17 Thread Arndt Roger Schneider

Tim Harig schrieb:
[snip]


This isn't such a tragedy Erlang as it is for other managed VMs because
Erlang/BEAM makes powerful usage of its VM for fault tolerance mechanisms.  I
don't know of any other VM that allows software upgrades on a running system.


styx, the distributed operating system inferno, language: limbo.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter: The good, the bad, and the ugly!

2011-01-18 Thread Arndt Roger Schneider

Terry Reedy schrieb:

On 1/16/2011 11:20 PM, rantingrick wrote:


Ok, try this...

 http://juicereceiver.sourceforge.net/screenshots/index.php
 http://www.sensi.org/~ak/pyslsk/pyslsk6.png
 http://www.wxwidgets.org/about/screensh.htm



Ok, wxwidgets can look at least as good as tk. Agreed that wxpython 
might instead link to the excellent wxwidgets page.




Well, tosssing screenshots around doesn't prove wether
a framwork/toolkit is good or not;
It only displays the developers commitment to create
a work of art.

Lets examine one of your examples:
http://juicereceiver.sourceforge.net/screenshots/index.php#mac

Overall impression:
The software was designed for windows; more or less
following the windows hci-guidelines,
The windows version is resonable good.

About the Aqua screenshots:

 1. Negative actions are located on the falling diagonale.
2-3. The select background and foreground inside the multi-column 
listbox have the wrong color--the used color originates from text fields.

 4. The multi-column listbox should have vertical gridlines.
5-6. Too much top and bottom padding inside the column header.
 7. The column texture is wrong --there is a visible line in the bottom.
 8. There are white boxess around the input fields.
 9. Header column label and lisstbox content are not aligned.
10. There is separator line between the status bar and the
brusshed dialog.
11. Last picture: there is a single page inside the tabet
control.
12. Last picture: The text "Select radio ..." is trucated,
the dialog isn't large enough.
13. The Scheduler activation should come before
customizing the scheduler.
14. The dialog uses sunken group boxes for some sections,
these group should be 2% darker than their surrounding
container.
15. The spacing rules from the aqua hci guidlines are
violated. The inner tabset should have 20px distance from
both sides, 20px from the bottom, 14px from top.
16. Second last picture: The button lables are truncated.
17. Tree: Uses the wrong folder symbols--from windows--,
select background and foreground are wrong, too.

- The Aqua hci-guidlines discourage group boxes,
  the same with the windows guidlines, too. Get rid
  off group boxes.

- second last picture: There should be more top
  padding for the checkbutton inside the white rectangle;
  best the same as left-padding.

- There no focus frames visilbe inside these screenshots,
  it would be interessting to see how those are realised.

- The icon buttons should be brushed, likewise shoud the
  column header have brushed background.

- Aqua hci guidelines: All dialogs should
  have a centered appearance.

Back to rantingrick 21st century toolkit/framwork:
Let's have a look at the numbers:
Worlwide pc market are 300 Million pcs per year,
this number includes desktops(2/3) and servers(1/3).
Your gui app is not relevant on servers.
Quite a good deal of the remaining pc's are sold in
countries with rampant ilict software copies;
Since there are no software cost for these copies
the people tend to install the big, bloated software
pieces from named computer companies
--you wont sell linux there, because it is more
  expensive than an ilict windows+office++.

~ 100 Million potential new desktop users for you.

Apple's projection for the ipad in 2011 are 65 Million pieces,
iphone and ipod touch will be roughly the same.
130 Million ios pieces.


~ 130 Million new ios users for you.


The android market is still unclear, but I do suppose
it will rival ios, lets say 100 Million in 2011.

~ 100 Million new android users for you.


Microsoft mobile and blueberry are wildcards;
no serious forecast is possible for these devices.
Lets assume:

~ 50 Million blueberry, windows mobile.

Total is: 380 Million potential new user for your application.


wxWidgets: 3600 LOC, python: 140 LOC
--these are very old numbers, but from the same time period.

wxWidgets on desktop, present for windows, Aqua and X11.
wxWidgets on ios, possible but unlikely, the thing is way to big
for any ios device.
wxWidgets on android not realistic.
wxWidgets on blueberry not possible.
wxWidgets on windows mobile; development is
silverlight with .net, so wxWidgets would have to be
ported to .net; not realistic.

python on desktop, present.
python on ios, possible --if not yet present.
python on android, present.
python on blueberry, possible.
python on windows mobile, present--but .net support deprecated by ms.

The smartphone and table market has only started, yet.
In 2011 the mobile market is already larger than the desktop pc,
almost 3 times largerv.

The desktop pc market is in decline; there is
however a shift toward pc-servers, instead.
It is anybodies guess how far the pc-desktop decline will go.
Every 21st century toolkit or framework must run on
mobile platforms!

wxWidgets was written ~1992, it is a copy of
mfc, which in turn is a copy of MacApp. MacApp
is also OSS, maintained through an industrie consortium.
Why do yo

Re: Tkinter: The good, the bad, and the ugly!

2011-01-18 Thread Arndt Roger Schneider

Octavian Rasnita schrieb:

From: "Arndt Roger Schneider" 



At least keep the disclaimer:
>> Well, tosssing screenshots around doesn't prove wether
>> a framwork/toolkit is good or not;
>> It only displays the developers commitment to create
>> a work of art.



Overall impression:
The software was designed for windows; more or less
following the windows hci-guidelines,
The windows version is resonable good.




This is the most important thing, because most users use Windows. Those 
who have other preferences are not forced to choose Windows, so it's 
their choice, and if the interface doesn't look so nice, that's it.




See disclaimer.
Since you mentioned "nice": I do not use such words
to charcterize a gui. I think the developers of said software
tried hard to make it "nice" and "beauty", hence  the brushed
background and group-boxes --BTW: the windows Guidelines also
discourage using group-boxes for usability reasons (see Theo. Mandel
object oriented user interfaces).



Back to rantingrick 21st century toolkit/framwork:
Let's have a look at the numbers:
Worlwide pc market are 300 Million pcs per year,
this number includes desktops(2/3) and servers(1/3).
Your gui app is not relevant on servers.
Quite a good deal of the remaining pc's are sold in
countries with rampant ilict software copies;
Since there are no software cost for these copies



Python is an open source software and the programmers that use Python 
might also prefer to offer open source software for free so this is not 
important. And "not legal" is not a very correct term, because somebody 
from Iran or North Corea must respect the laws from his/her country and 
in her/his country some things might not be forbidden by law, so it may 
be perfectly legal.




Nice cropping,
>>the people tend to install the big, bloated software
>pieces from named computer companies
>>--you wont sell linux there, because it is more
>>  expensive than an ilict windows+office++.

Illict as in unlicensed. Law has nothing to do with it.
And yes these unlicensed sofware has an negative
impact on the distribution of free open source software.

I wonder, what license do you use in your own work,
and what do you think about people which violate your license?



~ 100 Million potential new desktop users for you.

Apple's projection for the ipad in 2011 are 65 Million pieces,
iphone and ipod touch will be roughly the same.
130 Million ios pieces.
The android market is still unclear, but I do suppose
it will rival ios, lets say 100 Million in 2011.

~ 100 Million new android users for you.


Microsoft mobile and blueberry are wildcards;
no serious forecast is possible for these devices.
Lets assume:

~ 50 Million blueberry, windows mobile.

Total is: 380 Million potential new user for your application.


wxWidgets: 3600 LOC, python: 140 LOC
--these are very old numbers, but from the same time period.



This is a bad comparison because the programs targetted to the mobile 
phones are in most cases very different than the programs that need to 
be used on the desktop.


This is the marketplace for all gui applications,
and not a comparision.

Do you want to say that WxPython is not good just because it doesn't 
work well on mobile phones?


I do not comment on the quality of either wxWidgets
nor wxPython. Both exist for certain reasons.
The desktop pc was the sole target for all the
big C++ gui class liraries in 1992. Over time a large code
base evolved which makes it very difficult to get these class
libraries into new
markets--such as today with mobile devices.

Those numbers show that only the mobile phones are important, because 
there are more mobile phones than computers.




No, it doesn't. There are billions of mobile phones with
graphical user interfaces, still these phones weren't
relevant for gui applications.

Well, Python needs a better GUI lib for using them on desktop computers, 
not on mobile phones.




wxWidgets is suiteable for the desktop.


The desktop pc market is in decline; there is
however a shift toward pc-servers, instead.



What do you mean by declining? Are there fewer desktop PCs today than a 
year ago?


I am writing about graphical applications not computers.




Looking into wxWidgets:
Interactivity: keyboard focus, shortcuts, function keys,
  active foreground, active background are obsolete.
  hovering tooltips obsolete, status bar to large, obsolete.
  scrolled dialogs, obsolete. OK, Cancel, Retry, Abort
  buttons, obsolete, file dialogs obsolete, old style printing
  obsolete, drag-and-drop obsolete...



Who says that they are obsolete?
A good GUI interface should offer keyboard accessibility. Otherwise it 
is broken.


OK, I take keyboard focus back.




Summary wxWidgets:
wxWidgets is large scale C++ library from the 20th century,
solemnly dedicated toward desktop computers.

Re: Tkinter: The good, the bad, and the ugly!

2011-01-18 Thread Arndt Roger Schneider

rantingrick schrieb:

On Jan 18, 7:09 am, Arndt Roger Schneider 
wrote:



Summary wxWidgets:
wxWidgets is large scale C++ library from the 20th century,
solemnly dedicated toward desktop computers.
wxWidgets originates from a time before templates
were used in C++ and thus duplicates many of
today's C++ features.
wxWidgets is not suitable for a modern type
GUI ad thus clearly not the toolkit/framework
of the 21st century.




Alight i'll except that Rodger. Wx may be unusable for the mobile
market. And since the mobile market is exploding --and will continue
to explode-- then we need to consider this. However, does any GUI
library exist that can handle desktop, mobile, and accessibility and
do it all in a 21st century way? You slaughtered wx but failed to
provide any alternative, however i am listing to your advice contently
because it is very good advice. Read on...


Thanks! Again this is not about the quality of wxWidgets,
wxWidgets grew large because there was vested interest in it.
Its success is its undoing.



We DO need to consider the mobile market in this decision. Maybe it is
time for us to actually get on the cutting edge of GUI's. Maybe we
should head an effort to create a REAL 21st century GUI that can
handle desktop, mobile, and accessibility, and do it all whilst
looking very sharp! Sure we rob from peter to pay paul. We will use
Tkinters awesome API and geometry managers, wxPythons feature
richness, and any other code we can steal to make this work!


I am not sure whether this sarcasms or for real...,
so I'll take for genuine.

Tk is also doomed, and Tkinter isn't Tk.
You are right about keeping the separate geometry
managers, though.

For starters:
http://kenai.com/projects/swank

Swank publishes java/swing classes as tk
in jtcl, which is similar to what tkinter does for
python and tk.

It should be feasible to use swank with the
tkinter interface for jpython--without jtcl.
However, this doesn't make tkinter mobile,
neither is swing available on android.
When you look into the android developer
documents concerning the gui, then you can see
that the gui model is quite similar to tk.
So I suppose android can be reached by jpython
in a two stage process.

The other devices are more difficult to reach, though.
There is webkit on some, but not all. Webkit
is available for the desktop, ios and android--today without svg.

There are two ways to gain graphical independence:
First a basic implementation for each platform and
second through abstraction.

With abstraction I mean to base the gui on a common graphical
model present on all platforms and hence to implement the
"toolkit" on-top of it in python (not C, C++, java,javascript), python!
The single common graphical model is SVG.



Then we can "advertise" python as the best GUI language available. I
have nothing against seeing Python on more devices and this would no
doubt bring that dream into fruition. There is a huge hole in the
market at this very moment and we need to pounce on it like a hungry
tiger on wildebeest. Just think how wonderful it would be to switch
from mobile to desktop and still write beatiful Python code.



So be it.
-roger
--
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter: The good, the bad, and the ugly!

2011-01-18 Thread Arndt Roger Schneider

rantingrick schrieb:

On Jan 18, 12:25 pm, Arndt Roger Schneider 
wrote:


rantingrick schrieb:


On Jan 18, 7:09 am, Arndt Roger Schneider 




We DO need to consider the mobile market in this decision. Maybe it is
time for us to actually get on the cutting edge of GUI's. Maybe we
should head an effort to create a REAL 21st century GUI that can
handle desktop, mobile, and accessibility, and do it all whilst
looking very sharp! Sure we rob from peter to pay paul. We will use
Tkinters awesome API and geometry managers, wxPythons feature
richness, and any other code we can steal to make this work!


I am not sure whether this sarcasms or for real...,
so I'll take for genuine.




No this is real, albeit a bit fantastical. Thats probably why you
thought it was sarcasm :).

However, we need to start a revolution in the GUI world. Currently we
(as developers) are slaves to the OEM's and OS's. This must change. We
must unify GUI coding the same way OpenGL unified graphics coding.
Multiplicity is ruining any and all advancements in Graphical User
Interfaces. Sure multiplicity is great in emerging systems (language,
culture, GUI, etc, etc) However at some point  you must reign in this
multiplicity and harness the collective knowledge into an all
encompassing standard. OpenGUI is that standard.  It should be shipped
with every OS in the world. This is the only way we can have mobile,
desktop, and accessibility all combined into one beautiful package.
Then the contest come down to who can create the best abstraction API.



There has been no advancement in GUI-Design. Today it looks and
behaves just the way Bill Atkinson designed it.
Technical revolutions are made by disruptive thoughts,
which are never collective.
...The problem with gui-design:It requires an graphical artist,
a well versed writer, a software architect and a programmer.
The first two job description are the important ones.

...No OS-vender is going to allow that, it equals
lost control.





Tk is also doomed, and Tkinter isn't Tk.
You are right about keeping the separate geometry
managers, though.

For starters:http://kenai.com/projects/swank



This looks like a very young project (beta) and i could not find a
widget set. However i will investigate more. Thanks



alpha


However we need to think beyond even a Python community scale. This
problem is inherent in every language community out there. We to unify
the GUI standard. And we are a decade behind in development. (yes i am
completely serious about all of this!).




Then we did find common ground.
-roger
--
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter: The good, the bad, and the ugly!

2011-01-18 Thread Arndt Roger Schneider

Adam Skutt schrieb:

On Jan 18, 8:09 am, Arndt Roger Schneider 
wrote:


Back to rantingrick 21st century toolkit/framwork:
Let's have a look at the numbers:
Worlwide pc market are 300 Million pcs per year,
this number includes desktops(2/3) and servers(1/3).
Your gui app is not relevant on servers.



You should tell this "fact" to just about every major enterprise
software manufacturer out there.  They all ship GUI tools intended to
be used on the server.  Some of them ship only GUI tools or CLI tools
that are worthless, making you use the GUI tools.



The desktop pc market is in decline; there is
however a shift toward pc-servers, instead.
It is anybodies guess how far the pc-desktop decline will go.
Every 21st century toolkit or framework must run on
mobile platforms!



Until we have pixel-perfect touch sensors, toolkits for devices with
pointer interfaces (e.g., PCs) and toolkits for devices with touch
interfaces (e.g., phones and tablets) will necessarily be different.

You note this yourself: the UI paradigms that work well when you have
a pixel-perfect pointer do not work at all when you have a touch
screen, especially on a limited size and resolution display.



Yes I did and that's how it is.


Even if you're provided a "single" toolkit, you still end up with two,
maybe three, different applications, each using different widgets
targeted for the device they run on.  And no one provides a "single"
toolkit: while Silverlight can run on the desktop, the web, and now on
Windows Phone, you can't use the same widgets everywhere; ditto with
Cocoa for OS X and Cocoa Touch for iTouch devices.

While some further unification is obviously possible, it's rather
doubtful we'll ever have unified widgets that are truly workable on
the web, on the "desktop", and on a portable touch screen device.



Think about all the programmers earning their butter and bread :-).
Forget toolkits and widgets for awhile.
What remains are specific types of human/computer interactions,
a visual representation on a screen and a predefined behaviour
for said human action.

E.g. a button is:
A function gets asychnronously performed in response to
a finger/mouse click and release inside a certain screen area.

--A widget is essentially a logical abstraction.




wxWidgets was written ~1992, it is a copy of
mfc, which in turn is a copy of MacApp. MacApp
is also OSS, maintained through an industrie consortium.
Why do you not use the original framework?




Because it's not cross-platform, I'd imagine.  The entire point of
wxWidgets was to provide a cross-platform "OOP" UI toolkit.  It
closely copies MFC since MFC and XView were the two "backends" it
supported.



MacApp is/was cross-platform, Apple pulled the plug
on the non-mac platforms; the industrie
consortium took charge of the other platforms.




Screen resolution:
  The time of 72ppi CRT monitors is over. A GUI
  framework/toolkit must be resolution independent,
  including all icons and indicators;
  it should use decluttering (newspeak:ZUI).




WPF is the only functional resolution-independent UI toolkit in
existence.  While I don't disagree with you in principal, practice is
pretty heavily divorced from principal here.  Principal doesn't help
me write GUI applications today.



wxWidgets is not suitable for a modern type
GUI ad thus clearly not the toolkit/framework
of the 21st century.



None of the toolkits accessible from CPython are suitable for a 21st
century guy by your standard.  If we talk about IronPython,
Silverlight becomes the closest, but it isn't a panacea by any stretch
of the imagination.

Adam


According to Microsoft neither is silverlight.
-roger
--
http://mail.python.org/mailman/listinfo/python-list


Re: Screen readers for Tkinter (was Re: Tkinter: The good, the bad, and the ugly!

2011-01-21 Thread Arndt Roger Schneider

Littlefield, Tyler schrieb:
 >And of course, it should also offer support for Windows, since most of 
the computer users use Windows, especially those who need accessibility 
features.

uh. no, and no.
Plenty of those utilizing screen readers are using macs nowadays, as 
well as vinux or some derivitave there of.



Do you have first hand experience with it under AQUA?
I think Tk-aqua (also 8.6) should work out-of-the-box
with brail-lines, text-to-speech and such;
the older carbon built however wont...

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


Re: [Code Challenge] WxPython versus Tkinter.

2011-01-23 Thread Arndt Roger Schneider

rantingrick schrieb:

[snip]

1. You cannot define the terms--restrict your opponent--
   and battle it yourselves.
2. Your specified directory browser is useless.
   --At least define that the directory browser must have
 constant complexity to work with volatile
 data over a network...

-roger

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


Re: Problem with giant font sizes in tkinter

2011-02-11 Thread Arndt Roger Schneider

Steven D'Aprano schrieb:

On Thu, 10 Feb 2011 15:48:47 +, Cousin Stanley wrote:



Steven D'Aprano wrote:



I have a tkinter application under Python 2.6 which is shows text in a
giant font, about twenty(?) times larger than expected.

The fonts are set using:

titlefont = '-Adobe-Helvetica-Bold-R-Normal-*-180-*' 
buttonfont = '-Adobe-Helvetica-Bold-R-Normal-*-140-*' 
labelfont = '-Adobe-Helvetica-Bold-R-Normal-*-140-*' 



 Although I've been a linux user for several years, that type of font
 spec hurts my head  :-)

 Will the more simplistic type of tuple spec not work in your tkinter
 application ?



I don't know, but I'll give it a try.

Nevertheless, I'd like to learn how to diagnose these sorts of font 
issues. Can anyone suggest where I should start?






Those adobe helveticas are bitmap fonts.
Tk 8.5 uses freetype to render fonts under X11,
if you wish to use outdated bitmap fonts under X11,
then disable-xft when building Tk 8.5.

I do assume there are different tk versions on your
various platforms, and the troubling one is with
version 8.5 --8.5 uses anti-aliasing hence freetype.

Recommendation: Get rid of bitmap fonts under X11.

BTW the default fonts under Linux are:
bitstream vera sans (for helvetica)
bitstream vera (for times)
and bitstream vera sans mono (for courier).

In my opion those bitstream fonts are much better
than the mentioned Adobe fonts.

-roger




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


Re: Displaying SVG in tkinter using cairo and rsvg

2011-02-16 Thread Arndt Roger Schneider

Martin P. Hellwig schrieb:

Hi all,

Information on using tkinter for displaying an svg image seems a bit low 
spread on the Internet. I recently played around with pygame and svg and 
realized, hold on this can be done with tk too. So I thought I post a 
little example for future generations :-) (and also have stored at 
http://dcuktec.googlecode.com/hg/source/examples/cairo_rsvg_tkinter.py).


So here it is if you are interested:

[snip]

raster images from SVG:
There are multiple methods to convert a scalable vector graphic
into a bitmap.
In addition to cairo, librsvg and rsvg imageMagick contains a
vector graphic format similar to svg--gradients and transparency
are problematic for this approach, but its a while since I had
looked into it...

My product Jeszra imports svg into Tk(using tkpath
http://jeszra.sourceforge.net/jeszra/Jeszra_TechnicalNotes.html#d0e10279
), preserving it as a vector graphics.
There are, of course, limitations to what can be preserved in Tk:

http://jeszra.sourceforge.net/jeszra/SVG_Import.html

The other way is much simpler to convert a Tk graphics into
svg, which is also implemented in Jeszra.
All svg graphics on http://jeszra.sourceforge.net and 
http://gestaltitems.sourceforge.net are generated by Jeszra from

Tk (there are some hundred graphics)...

The generator API is open and a draft documentation is online at:
http://jeszra.sourceforge.net/api/ch01s04.html
http://jeszra.sourceforge.net/api/index.html

Jeszra API Concerning svg:
http://jeszra.sourceforge.net/api/ch04.html
http://jeszra.sourceforge.net/api/ch05.html
http://jeszra.sourceforge.net/api/ch06.html
http://jeszra.sourceforge.net/api/ch07.html
http://jeszra.sourceforge.net/api/ch08.html

Here is an overview about Jeszra, SVG and Tk:
http://jeszra.sourceforge.net/api/pictures/overview.svg


The svg on those page gets on-demand converted into flash,
for the internet explorer.

Is there anyting else You want to know about svg?

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


Re: Displaying SVG in tkinter using cairo and rsvg

2011-02-16 Thread Arndt Roger Schneider

Martin P. Hellwig schrieb:

On 02/16/11 09:04, Arndt Roger Schneider wrote:


[snip]

tkpath does not seem to come standard with Python's tk version when I 
looked into it a couple of years ago, but maybe it has now?



tk canvas and tkpath share the same interface, the first tkpath was
a plugin into the tk canvas. A tkinter wrapper class will
be a simple subclass of tk canvas introducing the new item types:
path, ppolygone, polyline, circle, elipsis, pimage, prect, ptext, group 
and for tkpath 0.3 three

additional messages for: style, gradient and distance, that's all
~50 lines of code.


Is there anyting else You want to know about svg?



No not really :-), I just wanted to display a SVG in tkinter with the 
minimal amount of external dependencies, since I have achieved that I 
thought I share my experience, so that the next time someone google 
tkinter and display svg it will return something that (well at least of 
the time of this writing) worked.




Well CAIRO is sort of a shifting target...
--currently I am stuck with PPC and new CAIRO versions cannot longer
being built on it anymore :-(--

CAIRO can be real pain on non-X11-linux platforms. ImageMagick
is simpler than CAIRO cross-platform wise.

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


Re: Python and Tkinter Programming by John Grayson

2010-05-31 Thread Arndt Roger Schneider

Pradeep B schrieb:


On Sat, May 29, 2010 at 7:33 PM, Kevin Walzer  wrote:

 


Tkinter doesn't wrap native printing API's. There are a few extensions that
do it, but they are platform specific and not complete.

The usual ways of printing are like this:

1. If you're outputting data from the text widget, write that to a temporary
text file and print via lpr.

2. If you're outputting data from the canvas, write that to a temporary
postscript file and print via lpr.

This is on Unix/MacOS. Not sure what the equivalent API on Windows is.

--Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
--
http://mail.python.org/mailman/listinfo/python-list

   




Thanx Kevin.

Anybody can throw light on how to do the same in Windows ?

-pradeep


 


The conventional --crude-- way is to take the bitmap of a
window and to stretchDIBBitBlt it onto the printer device in windows
and osx. Native printer dialogs do exist for both platforms ...

When you do not need a printer dialog:
Convert the Tk-GUI to SVG, then wrap it into a fo-xml wrapper
--fo accepts inline SVG-- and use fop for printing.
This approach works cross-platform, albeit you need a Java
intallation (fop is a Java application).

You can use http://jeszra.sourceforge.net to generate SVG for a complete 
Tk-GUI.

In addition. there is a python/tkinter SVG export project for the Tk canvas
--search the tkinter wiki.


-roger

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


Re: GUIs - A Modest Proposal

2010-06-07 Thread Arndt Roger Schneider

Terry Reedy schrieb:


Ant
I agree that the current tk situation is not completely satisfactory. 
In particular, the IO facilities are inadequate and have not, to my 
knowledge, changed in a decade. Image input formats are limited. There 
is no canvas output as an image. (Output of the canvase display list 
as a dialect of postscript that not everything can read is not a 
substitute for this.)




Hah, You are ill-informed.
tkpath 0.3 contains a surface element, which renders vector graphics 
elements

in an off-screen tk image.

Forget postscript!
Generate SVG from  a tk canvas or --better-- from tkpath.
Jeszra (from me) generates SVG. There is also a SVG export
package available in python/tkinter, search the tkinter wiki.


However...
I think it important that Python come with a minimal IDE that is 
adequate for someone like me doing Python-only development. I thank 
the programmers of IDLE. So merely deleting tk/tkinter is not an 
option. Indeed, having something similar to and at least as good as 
IDLE for any candidate gui replacememt should and I think would be a 
requirement for consideration.



Yes, use emacs or vim, without any GUI.

The problem with the big gui application frameworks are that they are 
too big. The two I have glanced at -- wx... and qt -- have much more 
than gui stuff and duplicate parts of the Python stdlib and other 3rd 
party libs.



The question is:
What sort of devices are being used by
*normal* computer owners in the near future?

My guess: It wont be a Desktop Computer.

Will any big GUI-Framework work on those devises?

No!

Will a light-weight GUI-toolkit being ported to these
devices ?

Perhaps, but not likely.

Will any scripting language run on such devices?

Perhaps, but not likely, if then it will be
Ecmascript or a 4GL.

Will SVG run on thoses devices?

Yes, it must, because SVG is an integral part
of OEBPS, and the tiny implementation is already
part most mobile phones. Take a look at SVG for
BlackBerry for instance.



As for a small gui written in Python, you seem to have ignored the 
link to pygui. Of course that has its own problems. Among others: it 
is incomplete; it ignore Python 3 (requires 2.3+ should be 2.3 to 
2.6), which is the only place it could be added; the api sytle is not 
standard in Python (get_xx and set_xx methods instead of direct access 
or properties); and there is nothing yet like IDLE.
What would be required is a Python3 GUI project with multiple 
contributors.


Terry Jan Reedy


What sort of GUI project?


On the initial proposition:
Grapical design is art and art requires an artist.
A community cannot work like an artist. The best a
community of top-class *graphical designers*  could produce
would be of mediocre quality.

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


Re: GUIs - A Modest Proposal

2010-06-08 Thread Arndt Roger Schneider

Terry Reedy schrieb:


On 6/7/2010 5:25 PM, Arndt Roger Schneider wrote:


Terry Reedy schrieb:


...


Hah, You are ill-informed.



How about 'under-informed'? That I readily admit ;-)


tkpath 0.3 contains a surface element, which renders vector graphics
elements in an off-screen tk image.



As far as I know, tkpath is either not part of the tk that comes with 
python, or not accessible via tkinter, or not documented.





3x Correct. Tkpath 0.2 is a plugin into tk canvas.
Tkpath 0.3 is a standalone replecement for tk canvas.
The tkpath interface is identical to tk canvas, but it features additional
objects: path, polyline, ppolygon, pline, ptext, circle, ellipse, radial 
gradients,

linear gradients, groups and styles.


The original tk canvas elements are the same as with tkpath,
but the new elements are the tk counterpart to those elements listed inside
the svg 1.1 specification.

As for documentation;
Use the Jeszra book, the svg 1.1 specification and the
ascii text documentation distributed with tkpath.

tkpath bypasses the X-emulation layer for the new elements under Windows
and OSX. CAIRO is the backend under X11.



Forget postscript!



Gladly!


Generate SVG from a tk canvas or --better-- from tkpath.
Jeszra (from me) generates SVG.



I found http://jeszra.sourceforge.net/
It looks interesting but not quite what I need, which is to export a 
tk canvas that I draw on with Python in a form I can import into 
OpenOffice.



OpenOffice does --not yet-- have an svg import filter.
You will have to convert SVG into another format.

For example: use a fo-wrapper around your SVG and convert this
fo-xml into pdf (fop / java).

Other options are: inkscape, adobe illustrator,
gimp--if you can life with a raster image.


I guess SVG import has highest priority within the OpenOffice project
--you wont need such workarounds for long.



 There is also a SVG export


package available in python/tkinter, search the tkinter wiki.



I presume you mean there is a 3rd party python add-on package that 
exports from a tk canvas. Can you be more specific as to what you meant?


Googling 'tkinter wiki' got me to http://tkinter.unpythonic.net/wiki/
wiki.python.org/moin/TkInter has a link to the same.
Searching there for 'svg' title or text has no hits.
Searching PyPI also turns up nothing obvious.

Googling further, I found canvasvg.py at
http://wm.ite.pl/proj/canvas2svg/index.html
via an answer to a question at
http://bytes.com/topic/python/answers/629332-saving-output-turtle-graphics 


I will give it a try.

Terry Jan Reedy


That was it! Be aware only tk canvas elements are exported to SVG by this
package. Jeszra on the other hand converts an entire GUI into SVG.
I don't have any experience with this python package--for obvious reasons.
What you should look after is how raster images are included in the
generated SVG; and try each of the 12 different arrow shapes for tk line.


If you have controls on your canvas:
You may use the screenshot facility of tkImg to create an
image from each control, then embed the screenshot base64 encoded
inside the generated SVG.-


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


Re: GUIs - A Modest Proposal

2010-06-11 Thread Arndt Roger Schneider

rantingrick schrieb:


On Jun 10, 9:38 pm, Stephen Hansen  wrote:

 


Also-- you're just starting to get wrong.

http://docs.python.org/library/tix.html

They don't -call- them the things you are, but between ComboBox, and the
flexibility of HList and TList... it actually offers quite a lot.
   



Urm, do you *know* what a Grid widget is Stephen? (hint: Excel) Do you
*know* what a ListCtrl is Stephen? (Hint: File Browser in report or
iconlabel views) Neither of those widgets exists in the Tix package.
And how do i *know* this? Well because unlike you i have actually
written code with Tix widgets, obviously you have not.

 




All this stuff is present in Tk!

OpenGL:
tkzinc, a 2D visualiation system based on OpenGL,
this one is widley used in air-traffic control...
BTW: tkinc features the best transformation system in the
IT--the author got a patent for it.

canvas3d, OpenGL-3D.

In addition there are *very very very large* visualization systems 
available in Tk:

vtk for example...


ListCtrl --besides that I truely hate this type of controls, an 
aggregation of usablility problems--

tkTreeCtrl is a true clone of MSWIN Explorer


Spreadsheet:
Well, whow doesn't exist in Tix! Are you sure? Hint: look again.
There is tktable, technically well done with on-demand data aquisition,
looks really ugly. An open field to display your artistic prowess.

Once upon a time there was a complete
spreadsheet application written in C++/Tk: abacus.


The TList only displays iconlabels in a wrapping column format, not in
any "report mode" ala: Windows Explorer("details mode"). The HList
widget is for showing a tree structure and is NOTHING like either a
ListCtrl or a Grid.

 



See above.
But notice this windows explorer type sort of thing is a major offence
on other platforms.

My own approach for such an interface function is to use seperate window
types, it reduces the maintainment cost for such an application.


HList:
Well *now* I am speachless. Did you actually even do a superfical
research on the topic?

BLT-tree
bwidget-tree
rtl_tree
hugelist
tkTreeCtrl (mentioned above)
ttk:treectrl
tablelist
tixtreecontrol


Just scanning the docs of a module (that you know jack about) and then
parroting off some baseless arguments are bound to bite you in the
@ss! *egg on face*
 



Please enjoy it.

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


Re: GUIs - A Modest Proposal

2010-06-13 Thread Arndt Roger Schneider

lkcl schrieb:


[snip]

it's the exact same thing for SVG image file-format.  i'm
_definitely_ not convinced that "SVG the image fileformat" is The One
True Way to design images - but i'm equally definitely convinced of
the power of SVG manipulation libraries which allow for the creation
SVG images using declarative programming.

 



You rather severly underestimate the impact from SVG!
1. SVG is a complete visualization system and not an fancy way to create 
icons.

   SVG and SMIL are an extreme powerful environment. With it's
   possible to create(design) sophisticated graphical and interactive 
--resolution independent--

   applictions without resorting to javascript or direct DOM manipulations.
   Javascript or other languages are still necessary to feed data into 
an SVG

   visualization, but not for much more. Further more SVG and the GPU are
   a natural combination.

2. Many of CSS shiny new features --such as animation originate
  from SVG.
3. SVG-Print: Printing is one of the biggest problems in
  the current IT-landscape. I do not want to install printer
  drivers on each telephon I own, neither on any other device --mobile
  or not. The printer must contain a computer running an OS and has to
  handle an agreed upon page description language (Xml based)...


Using HTML/CSS/DOM/javascript for application building:
Well, yes can be done. HTML is however text oriented; each
application entirely based on this technology will be satured
with text. HTML works reasonable well with applications of the past
two decades, but the importance of text is dwindling and other
graphical means of communication become more and more relevant.


but, all that having been said, and returning to "HTML and CSS (the
fileformats)", there's a lot to be said for convincing people who are
stuck in those worlds of the benefits and freedom of declarative
programming... _without_ having to get involved directly in
javascript.

 



Any User Interface should be pre-determined;
this concept allows the consequent separation of
application logic and presentation. It's not only important
for Web-applications!


that web apps are about to take over
the world, etc. There is still a place for GUI toolkits 


that
are not based on the DOM,
   



that there definitely are.

 


or whatever the W3C technology of the month is.
   



:) don't underestimate how much time and money is going into the W3C
standards!  and remember, someone's got to implement them, so the
actual proof of the pudding is not what the W3C thinks but whether the
technology ends up actually in the hands of users and is successful
_for users_.

l.

 


The mony part is definitly important. Tk is actually a good example for
the working of money-politics (the absence thereof).

-roger


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


Re: Customising Tk widgets

2010-09-21 Thread Arndt Roger Schneider

Peter schrieb:

I am using Windoze, I suspect the appearance attributes I am asking
about here are platform dependent?

Using Tkinter, I would like to generate a Checkbutton that is filled
in with a solid colour rather than a tick mark when selected.



tk = Tk()
tk.option_add("*Checkbutton.inidcatorOn", 0)


Could somebody provide some pointers as to how I could achieve this?

Also, John Shipman's Tkinter reference shows the Radiobutton drawn as
a diamond and yet when I create one in Windows I get a circle - again,
how and where do I need to look to change this behaviour?

Thanks
Peter


Shipman's screenshots are made under Tk 8.4/X11, featureing the
motif look-a-like.

Tk 8.4 follows the windows user style guide (windows95) under windows.

You could still get the motif look under windows:
Tk 8.5 is bundled with a theming engine ttk, this engine
uses the built-in theming engine under windows xp and later,
but also allows you to supplant this engine.
The related ttk theme is called "classic".

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