Python-UK Community on google+

2012-12-07 Thread Martin P. Hellwig
Hi All,

I created the Python-UK Community on google+, so if you are using google+ and 
you are interested in Python and you are interested in the UK, I heartily 
invite you to join.

My intention is to transfer the ownership to the PyCon UK organization, which I 
already have contacted a member of.

You can find it here:
https://plus.google.com/u/0/communities/109155400666012015869

Hope to see you soon :-)

Martin P. Hellwig

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


Re: debugging in eclipse

2012-11-15 Thread Martin P. Hellwig
On Thursday, 15 November 2012 12:29:04 UTC, chip...@gmail.com  wrote:
 Hi all!
 
 
 
 I have a stupid problem, for which I cannot find a solution...
 
 
 
 I have a python module, lets call it debugTest.py.
 
 
 
 and it contains:
 
 def test():
 
 a=1
 
 b=2
 
 c=a+b
 
 c
 
 
 
 so as simple as possible.
 
 
 
 Now I would like to debug it in eclipse.. (I have pydev and all)
 
 so the question is how do I debug the test function? (by debug I mean go into 
 it in the debugging mode and execute step by step, inspect the variables and 
 so on.. you know, like it is so easily done in Matlab for example).
 
 
 
 I place a break point in the function, run the debugger and it stars and is 
 terminated immediately. (of course it does not know where to go..)
 
 
 
 So how can I do this? please help!
 
 
 
 Thank you all in advance!

I assume you have at the end of the debugTest.py file something like this:

if __name__ == '__main__':
   test()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Article on the future of Python

2012-09-25 Thread Martin P. Hellwig
On Tuesday, 25 September 2012 09:14:27 UTC+1, Mark Lawrence  wrote:
 Hi all,
 
 I though this might be of interest.
 http://www.ironfroggy.com/software/i-am-worried-about-the-future-of-python
 -- 
 
 Cheers.
 Mark Lawrence.

I glanced over the article but it seems to me another 'I am afraid this is not 
the silver bullet I wanted it to be' article without actually going into the 
need of a silver bullet or whether the concept of a silver bullet is sound at 
all.

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


Re: simple client data base

2012-09-03 Thread Martin P. Hellwig
On Monday, 3 September 2012 15:12:21 UTC+1, Manatee  wrote:
 Hello all, I am learning to program in python. I have a need to make a
 
 program that can store, retrieve, add, and delete client data such as
 
 name, address, social, telephone number and similar information. This
 
 would be a small client database for my wife who has a home accounting
 
 business.
 
 
 
 I have been reading about lists, tuples, and dictionary data
 
 structures in python and I am confused as to which would be more
 
 appropriate for a simple database.
 
 
 
 I know that python has real database capabilities but I'm not there
 
 yet and would like to proceed with as simple a structure as possible.
 
 
 
 Can anyone give me some idea's or tell me which structure would be
 
 best to use?
 
 
 
 Maybe its a combination of structures? I need some help.
 
 
 
 Thanks for your help.

How about the half-way house, sqlite3 which comes with python?

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


Re: Writing a wrapper - any tips?

2012-07-13 Thread Martin P. Hellwig
On Friday, 13 July 2012 05:03:23 UTC+1, Temia Eszteri  wrote:
 I#39;m going to be looking into writing a wrapper for the Allegro 5 game
 development libraries, either with ctypes or Cython. They technically
 have a basic 1:1 ctypes wrapper currently, but I wanted to make
 something more pythonic, because it#39;d be next to impossible to deal
 with the memory management cleanly in the script itself.
 
 Anything I should keep in mind? Any tips to pass on to a first-time
 module writer, pitfalls to watch out for, etc.?
cut
I would split the wrapping in layers, the lowest layer is a one on one exposure 
of the library with your wrapper, I would rather avoid ctypes for performance 
reasons, however if performance is not a concern ctypes is excellent and 
broadly available.

The next layer is purely there to make the lower layer pythonic, i.e. apply 
namespaces, automatic handling of memory, PEP8 naming convetions, etc. etc.
just what you would expect from a modern pure python module

The next layer, if you want to, contains tools that are often used in that 
concept, think in the line of design patterns.

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


Re: code review

2012-06-30 Thread Martin P. Hellwig
On Saturday, 30 June 2012 21:30:45 UTC+1, Alister  wrote:
 On Sat, 30 Jun 2012 21:38:58 +0200, Thomas Jollans wrote:
 
  On 06/30/2012 08:39 PM, Thomas 'PointedEars' Lahn wrote:
  Peter Otten wrote:
  
  If you spell it
 
  def is_valid_password(password):
  return mud.minpass = len(password) = mud.maxpass
 
cut
 Surely this fits perfectly with the lines 1  7 in the zen of python 
 (import this)
 Beautifull is better than ugly and Readability counts
 
Agree, however I like to stress the don't make me unnecessary read with care 
rule. Meaning if I read that line, I have to read it carefully to make sure I 
understand what is happening, the following would not do that although syntax 
wise equal:

def length_between_min_max(password):
   return(mud.minpass = len(password) = mud.maxpass)
   

def is_valid_password(password):
   valid = True

   if not length_between_max_min(password):
  valid = False

   if some_other_test(password):
  valid = False


  return(valid)

This I can read, typically I would not even read what the function 
length_beteen_max_min does as long as there is no bug in it because, it is 
perfectly english clear what the intention is.

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


Re: code review

2012-06-29 Thread Martin P. Hellwig
On Friday, 29 June 2012 20:41:11 UTC+1, Alister  wrote:
 On Fri, 29 Jun 2012 09:03:22 -0600, Littlefield, Tyler wrote:
 
  On 6/29/2012 1:31 AM, Steven D'Aprano wrote:
  On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote:
 
  On Jun 29, 12:57 pm, Littlefield, Tyler ty...@tysdomain.com wrote:
  I was curious if someone wouldn't mind poking at some code. The
  project page is at:http://code.google.com/p/pymud Any information is
  greatly appreciated.
  I couldn't find any actual code at that site, the git repository is
  currently empty.
  
  OOPS, sorry. Apparently I'm not as good with git as I thought.
  Everything's in the repo now.
 
 I am no expert but from what have picked up so far
 
 from x import 
 
  is frowned upon in most cases 

from x import * is frowned upon, however, from x import y is fine IMHO.
 
 also this section in main strikes me as a bit odd and convoluted
 
 w = world()
 serv = server(client)
 w.server = serv
 serv.world = w
 
 I think you are cross referencing classes  would be better to 
 investigate inheritance.
 

Generally speaking, read PEP8 and apply it please, there are tools like pylint 
that can help you with that. It also seems you are doing things quite java 
like, but I guess that is just a thing of getting used to python.

If you are planning to let your code being used like a framework that is 
extended by others, try to avoid more advanced functions just because they seem 
handy, always ask yourself is it clearer?

Try to unit-test your code and try to gain some decent code coverage, that will 
increase maturity of your code rather quickly.

But for the rest it looks like you are good in organizing it all in 
sub-modules, which is a very nice thing to see.

Good luck!

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


Re: Open Source: you're doing it wrong - the Pyjamas hijack

2012-05-09 Thread Martin P. Hellwig

On 09/05/2012 12:02, anth...@xtfx.me wrote:
cut all

Hello C Anthony,

I am an pyjs user and introduced the project as one of the fundamental 
parts of a new application that is now core of a company of a reasonable 
size (30+), customers include several companies in the top 10 of largest 
IT infrastructures, I can mail you a list in private if you wish so.


I agree that the project leadership had certainly room for improvement.
I also agree that to move forward there had to be made some choices.

However, as the person introducing this project in a commercial venture, 
I am also the one having the responsibility of it in my setting.


I have been put in a position where I have to come up with answers, like 
why the examples page didn't work, why the project seems fragile and if 
there is any viability at all.


Of course, I still believe in the project, with all it warts and so 
forth. However my position has been made needlessly difficult, because 
the action you took did not leave room for choice.


Let me explain this, if you had forked the project, created a new 
domain, mailing list and, took over the majority of the devs, I would be 
able to make a choice if I go with the new guys or stick with the couple 
of old ones, just like the xorg fork.


If your argument is that this was your intention but was persuaded to do 
other wise, I would say that is a lapse of judgement and not a very good 
restart of the project.


Unfortunately mistakes made in public, even if arguably they are not 
mistakes at all, are not easy forgotten and can end up haunting you.


I hope you will take these comments with you as a lesson learned, I do 
wish you all the best and look forward to the improvements you are going 
to contribute.


--
Martin P. Hellwig (mph)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python randomly exits with Linux OS error -9 or -15

2012-04-09 Thread Martin P. Hellwig

On 09/04/2012 11:01, Janis wrote:
cut weird exit codes
My experience is that these kind of behaviors are observed when (from 
most to least likeliness):

- Your kernel barfs on a limit, e.g. space/inodes/processes/memory/etc.
- You have a linked library mismatch
- You have bit rot on your system
- You have a faulty linked library
- You have a faulty kernel

The last two are academic for me as I never have seen it in real life, 
but could be possible and the bit rot one only bit me once in the last 
15 years (well I since then use RAID on all but convenience systems).


hth

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


Re: f python?

2012-04-08 Thread Martin P. Hellwig

On 08/04/2012 12:11, Xah Lee wrote:
cut all
Hi Xah,

You clearly didn't want help on this subject, as you really now how to 
do it anyway. But having read your posts over the years, I'd like to 
give you an observation on your persona, free of charge! :-)


You are actually a talented writer, some may find your occasional 
profanity offensive but at least it highlights your frustration.
You are undoubtedly and proven a good mathematian and more important 
than that self taught. You have a natural feel for design (otherwise you 
would not clash with others view of programming).

You know a mixture of programming languages.

Whether you like it or not, you are in the perfect position to create a 
new programming language and design a new programming paradigm.
Unhindered from all the legacy crap, that keep people like me behind (I 
actually like BNF for example).


It is likely I am wrong, but if that is your destiny there is no point 
fighting it.


Cheers and good luck,

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


Re: Eclipse, C, and Python

2012-03-20 Thread Martin P. Hellwig

On 20/03/2012 06:00, Richard Medina Calderon wrote:

Hello Forum. I have installed Python comnpiler in Eclipse Classic for Windows.
After a while I have installed the C compiler. However, somehow now when I try 
to run my code in Python it shows me for default Ant

Run --Ant Build

I switched my workspace but still. Do you know how to solve this?..

Thanks


You might want to install the PyDev plugin and switch to that 
perspective (after configuring it).


Cheers,

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


Re: speaking at PyCon

2012-01-31 Thread Martin P. Hellwig

On 29/01/2012 03:32, Eric Snow wrote:

This is my first year speaking at PyCon, so I solicited
speaking/preparation advice from a bunch of folks, particularly
focusing on the PyCon speaking experience.  I've compiled the results
and put them online:

http://ref.rtfd.org/speakers

This is still rough, and feedback is welcome, as is more advice.  :)
For anyone speaking at the conference (or generally), I hope this will
be helpful.  Thanks!

-eric



Good general presentation tips, I have another suggestion:
If you bring your own laptop, make sure to practice connecting it to the 
projector and have a special presentation account (which you also used 
for your practice and nothing else).


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


Re: Where to put data

2012-01-26 Thread Martin P. Hellwig

On 25/01/2012 17:26, bvdp wrote:

cut explanation of bikeshed argument, where do I put the darn things

Well once you think about distributing, here is the guide line I use:

- If it is meant as a library that can be 'imported' in python:
 site-packages is the place to be, some linux distros are rather 
creative with them so be careful.


- If it is a 'stand-alone' application that just happens to use the 
python interpreter as a dependency:
 /usr/local/bin for the executable script and /usr/local/lib for the 
program module(s) itself, of course this is platform dependent, consult 
posix first and then distribution/os specific preferences.


- If the additional (binary) data is static in nature:
 /usr/local/share is the right place (or whichever preference the 
distribution/os has)


- If the additional (binary) data is dynamic in nature (like databases) 
and the program is run as a daemon:

 /usr/local/,  /var/ or /opt/

- If the additional (binary) data is dynamic and it is run per user:
 $HOME/.[application name]/ (the famous dot files in your home folder).

All that is unix like of course, Windows tend to put it all in the 
application folder in the Program Files folder, and user specific data 
in the profiles Application Data.


Of course opinions vary so I can only say this is what I usually follow, 
with the wisdom bestowed upon me by unix admins that where much more 
experience then I ever will be and always had a fit when I didn't put it 
in the right directory.


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


Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-24 Thread Martin P. Hellwig

On 24/01/2012 05:57, Rick Johnson wrote:
cut rant
I would wish that pedantic citizens of the British colony in America 
stopped calling whatever misinterpreted waffle they produce, English.


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


Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-24 Thread Martin P. Hellwig

On 24/01/2012 14:51, J wrote:

On Tue, Jan 24, 2012 at 09:05, Martin P. Hellwig
martin.hell...@gmail.com  wrote:

On 24/01/2012 05:57, Rick Johnson wrote:
cut rant
I would wish that pedantic citizens of the British colony in America stopped
calling whatever misinterpreted waffle they produce, English.


I, sir, as a citizen of that FORMER British colony here on the
continent of North America, am offended by this baseless insult. I
know waffles, sir, I eat waffles and I can guarantee that no American
calls their waffles English.  We have English Muffins and Belgian
Waffles, but no English Waffles.  Though I am particularly fond of
Blueberry Waffles, myself.

Which reminds me, time for breakfast.


Dear Jeff, I do applaud your impeccable taste and appreciate the 
colourful description of your objections. And I rightfully accept that 
you where forced to misinterpret 'waffle' so you could keep consistency 
in the classification of being pedantic.


Having said that,  I do like to bring to your attention that her 
Majesty, never ratified the 'Declaration of Independence'. :-)


--
mph

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


Re: icmp and raw sockets in python

2011-12-13 Thread Martin P. Hellwig

On 13/12/2011 16:50, Sagy Drucker wrote:

hello

Hi

i am relatively new to python, so please be considerate...
As I am only responding to one of your questions, perhaps it would be 
best if you don't get any other more helpful replies to split your 
questions up and post them separately.


i'm implementing a server and a client via raw_sockets.
i have the necessary privileges.

now, the server i defined so:
host = socket.gethostbyname(socket.gethostname())
address = (host, 4)
sockSer = socket.socket(socket.AF_INET, socket.SOCK_RAW,
socket.IPPROTO_ICMP)
sockSer.bind(address)
sockSer.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
packet, addr = sockSer .recvfrom(4096)   # wait for packet from client

Q1) why can't i simply type: hosts = 'localhost'.
if i do so, it doesn't allow me to write the line:
sockSer.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON).
only when doing gethostbyname(socket.gethostname()) i get
192.168.1.101
and then it works.


cut other questions
Well localhost should resolve to 127.0.0.1/8 which is attached to the 
loopback interface, my gut feeling is that this interface has a 
particular set of restrictions which you are encountering.

Sorry I can't be more helpful.

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


Re: Clever hack or code abomination?

2011-12-01 Thread Martin P. Hellwig

On 01/12/2011 03:15, Roy Smith wrote:
cut
Well, I have seen much worse, so the WTFs/minute(*) count won't be too bad.

However, as  general rule for readability; If you think you have to ask, 
don't bother asking, spend that time rethinking and write a more 
readable solution.



*) http://www.osnews.com/story/19266/WTFs_m

--
mph

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread Martin P. Hellwig

On 17/11/2011 23:54, W. eWatson wrote:
cut

My mistake above. I was talking about the previous 2.5.2 of install in
Win7. Where I'm at is 2.7.2 now. However, I still find in very odd there
is no Edit with IDLE when I right-click on junk.py. That's the way it
worked on 2.5.2 on my XP and earlier, 2010, on Win7. Downright frustrating.



Well if I was still a windows administrator and you would be one of my 
users, I would first make sure that your profile or windows installation 
is not pooped as it definitively smells like that.


After being reassured that this is not the case I would then search the 
interwebs for something like extending right click context menu.


Probably hitting something like this:

http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/how-can-i-customize-right-click-mouse-context-menu/5ea7104f-2213-41b9-9933-83f25da086d1

And after that searching where this 'idle' you speak of is actually 
located, probably finding something like this:


http://stackoverflow.com/questions/118260/how-to-start-idle-python-editor-without-using-the-shortcut-on-windows-vista

Then it rest me to combine them both, after promising myself not to 
install one version of a particular program 'for all users' and then 
'updating' for 'only me' as this can screw up the default settings quite 
badly.


But hey I haven't been a win admin since I switched over to FreeBSD 
years and years ago. I find it immensely reassuring that the problems I 
encounter on my systems are all my fault, well actually that is just the 
same as with windows, just less obvious there.


Luckily I am no longer an administrator either as I couldn't stand it 
anymore when users spill their frustrations, although perfectly 
understandable, unto those who are actually willing to help.


Something to do with attitude or so, speaking if which, I do apologize 
for my own attitude, but given the choice of just ignoring you or lacing 
my post with patronization I though that the latter one was the least 
bad of them two.


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


Re: Execute a command on remote machine in python

2011-11-15 Thread Martin P. Hellwig

On 11/15/11 12:04, Roark wrote:

Hi,

I am first time trying my hands on python scripting and would need
some guidance from the experts on my problem.

I want to execute a windows command within python script from a client
machine on a remote target server, and would want the output of the
command written in a file on client machine. What is the way it could
be achieved.



If your doing windows to windows then you could wrap PsExec 
(sysinternals) or the open source but more or less abandoned RemCom 
(http://sourceforge.net/projects/rce).


Disadvantage is that both of them are a royal PITA to wrap nicely.
There are multiple problems with re-redirected STDOUT/STDERR

Advantage is that you don't need to configure anything on the target 
machine.


hth
--
mph


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


Re: webapp development in pure python

2011-10-25 Thread Martin P. Hellwig

On 10/25/11 15:13, Arnaud Delobelle wrote:

On 25 October 2011 14:50, Laszlo Nagygand...@shopzeus.com  wrote:


  Hi,

Anyone knows a framework for webapp development? I'm not talking about
javascript/html compilers and ajax frameworks. I need something that does
not require javascript knowledge, just pure Python. (So qooxdoo is not
really an option, because it cannot be programmed in Python. You cannot even
put out a window on the center of the screen without using javascript code,
and you really have to be a javascript expert to write useful applications
with qooxdoo.)

What I need is a programmable GUI with windows, event handlers and
extensible widgets, for creating applications that use http/https and a web
browser for rendering.


So you're looking for something like Google Web Toolkit but using
Python instead of Java...

Do you know about pyjamas (http://pyjs.org/)?  I've never used it, but
I think it endeavours to be what you are looking for.

HTH



Second that, I use it for a couple of my projects for exactly that.

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


Language Enhancement Idea to help with multi-processing (your opinions please)

2011-10-13 Thread Martin P. Hellwig
First of all let me say that I have no authority or knowledge of 
language design or multi-processing except from a user point of view, 
having a decade or so experience.
I would like your opinion and appreciate any feedback and value any 
hints to documentation, procedures or related ramblings :-).


I was wondering if there could be an advantage to add another control 
flow statement.
For the purpose of this writing let's say ooo which stands for 'out of 
order'.


For example;

def do_something():
a = 4
b = 2
c = 1
ooo:
a += 1
b += 2
c += 3
print(a, b, c)

What I would expect to happen that all statements within the ooo block 
may be executed out
of order. The block itself waits till all statements are returned before 
continuing.


What do you think?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Language Enhancement Idea to help with multi-processing (your opinions please)

2011-10-13 Thread Martin P. Hellwig

On 13/10/2011 15:13, Stefan Behnel wrote:

Martin P. Hellwig, 13.10.2011 14:35:

I was wondering if there could be an advantage to add another control
flow
statement.


Changes at that level must be very well justified, are often rejected
for the reason of being not too complicated to write in some other form
and are close to impossible to get accepted when requiring a new keyword.

Also, the right place to discuss (and, more importantly, search for
previous) ideas about language changes is the python-ideas mailing list.



For the purpose of this writing let's say ooo which stands for 'out of
order'.

For example;

def do_something():
a = 4
b = 2
c = 1
ooo:
a += 1
b += 2
c += 3
print(a, b, c)

What I would expect to happen that all statements within the ooo block
may
be executed out
of order. The block itself waits till all statements are returned before
continuing.


This looks like a rather special case. What if you need more than one
statement to accomplish a single step?


Aah yes haven't thought about that, was more thinking like wrap multiple 
steps in a function and put that as one line, but yeah that kind of 
stuff gets very unpythonic very quickly.



What if the number of parallel
tasks is not fixed at coding time? I don't think there are many problems
that you can solve with this feature.

Also: the GIL will not allow you to take a major advantage from the
parallel execution of a set of statements, as only one of the statements
can use the interpreter at a time.


Well I was more or less thinking in the line that the interpreter when 
parsing such a statement can, if there are multiple cpu's available, 
fire the appropriate amount of other interpreters and do all the passing 
and locking of data for you.




And, on a related note: Cython has freshly gained support for parallel
loops based on OpenMP, so you may be able to solve your problem with
Cython instead of using plain Python.

Well funny enough I don't really have a problem with it, I am a happy 
consumer of multiprocessing, but I was just wondering if there would be 
a way to do it simpler and more pythonic.



Stefan



Thanks for your feedback it was very enlightening although for what the 
idea is concerned disappointing as it more or less makes it obvious that 
such a thing is a no-go.


Cheers,

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


Re: Python without a tty

2011-09-29 Thread Martin P. Hellwig

On 29/09/2011 10:21, Steven D'Aprano wrote:

I have a Python script which I would like to test without a tty attached
to the process. I could run it as a cron job, but is there an easier way?

I am running Linux.




Well you could double fork and drop the parent, that would lose the tty
which is the same effect what you get when you want a daemon.

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


Re: How to daemonize a HTTPServer

2011-09-01 Thread Martin P. Hellwig

On 01/09/2011 04:16, babbu Pehlwan wrote:

I have written a http server using BaseHTTPServer module. Now I want
to instantiate it through another python script. The issue here is
after instantiate the control doesn't come back till the server is
running. Please suggest.


Sounds like something you could use the multiprocessing module for, but 
then again my crystal ball is a bit fuzzy today.


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


Re: Ten rules to becoming a Python community member.

2011-08-16 Thread Martin P. Hellwig

On 16/08/2011 18:51, Prasad, Ramit wrote:

Incorrect past tense usage of used to:
 I used to wear wooden shoes 



Incorrect description using used to:
 I have become used to wearing wooden shoes 



Correct usage of used to:
 Wooden shoes can be used to torture someone 


Double you tee eff? Maybe this is a cultural language difference, but I believe 
all of the above are correct. Well, I am not sure about the middle one but the 
other two are valid.

Well admittedly English isn't my native language, But indeed all 
sentences seem correct to me.


With the first sentence meaning: in the past I wore wooden shoes, but 
presently I do not.


With the second sentence meaning: in the past I was not used to (i.e. 
uncomfortable, hey bonus points!) wearing wooden shoes, but presently I 
am used to it (although not necessarily comfortable, but at least not 
uncomfortable).


I actually can't figure out a way of saying those two sentences more 
concise or correct then it has been given.


But then again I do recognize that these are quite 'Germanic'* ways of 
constructing sentences, as in freely mixing past, present and future to 
indicate that a certain description is restricted to a specific time frame.



* For the lack of a better description, I am not a linguist, but I was 
born in Germany and I am often guilty of mixing times.


Also RR, congratualation to another troll post that turned out quite 
interesting :-)


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


Re: Syntactic sugar for assignment statements: one value to multiple targets?

2011-08-16 Thread Martin P. Hellwig

On 03/08/2011 02:45, gc wrote:
cut

a,b,c,d,e = *dict()

where * in this context means something like assign separately to
all.

CUT

Any thoughts? Thanks!


Well got a thought but I am afraid it is the opposite of helpful in the 
direct sense. So if you don't want to hear it skip it :-)


Although I can not proficiently argument it, it has a certain code smell 
to it. In the sense that it could hint that there is a better more 
readable way of solving that particular problem (taking in account that 
the one letter labels are pure for demonstration purpose).


I would love to see an example where you would need such a construct.

--
mph

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


Re: Rant on web browsers

2011-06-14 Thread Martin P. Hellwig

On 14/06/2011 07:31, Chris Angelico wrote:
cut

But if anyone feels like writing an incompatible browser, please can
you add Python scripting?


You might find that Pyjamas already fill your needs python/javascript 
wise. It is truly great to just write python, translate it, and then 
have it work in the browser.


--
mph

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


Re: English Idiom in Unix: Directory Recursively

2011-05-18 Thread Martin P. Hellwig

On 17/05/2011 23:20, Ian Kelly wrote:

On Tue, May 17, 2011 at 4:26 PM, Xah Leexah...@gmail.com  wrote:

Though, if you think about it, it's not exactly a correct description.
“Recursive”, or “recursion”, refers to a particular type of algorithm,
or a implementation using that algorithm.


Only when used as programming jargon.  In mathematics, recursive
function does *not* mean a function implemented using a recursive
algorithm.  It's just a formal definition of a specific class of
mathematical functions.

As it turns out, recursive also has a non-technical definition,
which again has nothing to do with algorithms except in the broadest
sense:

recursiveadj.
1. pertaining to or using a rule or procedure that can be applied repeatedly
(from dictionary.com)

This definition fits the Unix usage perfectly.


I concur, although my dictionary defines the base of the word:
to happen many times or to happen again

http://dictionary.cambridge.org/dictionary/british/recur#recur__3

Perhaps the gp of the post might profit from a more holistic approach 
when adopting an opinion or at least consult a dictionary before going 
into a rant.


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


Re: py3k buffered IO - flush() required between read/write?

2011-05-11 Thread Martin P. Hellwig

On 11/05/2011 19:08, Genstein wrote:

On 11/05/2011 19:24, Terry Reedy wrote:

writing and reading. If you want others to look at this more, you should
1) produce a minimal* example that demonstrates the questionable
behavior, and 2) show the comparative outputs that raise your question.


Thanks for a quick response. Perhaps I was being unclear - in py3k,
given the following code and assuming no errors arise:

  f = open(foo, w+b)
  f.write(b'test')
  f.seek(0)
  print(f.read(4))

What is the printed result supposed to be?

i) b'test'
ii) never b'test'
iii) platform dependent/undefined/other

All the best,

-eg.


from:
http://docs.python.org/py3k/library/functions.html#open

open(file, mode='r', buffering=-1, encoding=None, errors=None, 
newline=None, closefd=True)¶

cut
buffering is an optional integer used to set the buffering policy. Pass 
0 to switch buffering off (only allowed in binary mode), 1 to select 
line buffering (only usable in text mode), and an integer  1 to 
indicate the size of a fixed-size chunk buffer. When no buffering 
argument is given, the default buffering policy works as follows:


* Binary files are buffered in fixed-size chunks; the size of the 
buffer is chosen using a heuristic trying to determine the underlying 
device’s “block size” and falling back on io.DEFAULT_BUFFER_SIZE. On 
many systems, the buffer will typically be 4096 or 8192 bytes long.
* “Interactive” text files (files for which isatty() returns True) 
use line buffering. Other text files use the policy described above for 
binary files.



So given that explanation, and assuming I understand it, I go for option 
'iii'.


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


Re: Development tools and practices for Pythonistas

2011-04-26 Thread Martin P. Hellwig

On 26/04/2011 14:39, snorble wrote:
cut explanation
I would strongly advice to get familiar with:
- Lint tools (like PyLint)
- Refactoring
- Source Control Systems (like Mercurial Hg)
- Unit Testing with Code Coverage

Followed by either writing your own toolset that integrates all of the 
above or start learning an IDE that has that stuff built-in (my personal 
preference is the latter with my current IDE being PyDev (Eclipse)).


Yes you will be less productive for a couple of weeks, but I promise you 
that once you know the above you win that time back very shortly, or if 
you are as chaotic as me, within a week :-).


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


Re: my computer is allergic to pickles

2011-03-07 Thread Martin P. Hellwig

On 05/03/2011 01:56, Bob Fnord wrote:
cut

Any comments, suggestions?


No but I have a bunch of pseudo-questions :-)

What version of python are you using? How about your OS and bitspace 
(32/64)? Have you also tried using the non-c pickle module?  If the data 
is very simple in structure, perhaps serializing to CSV might be an option?

--
mph

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


Re: Newbie...

2011-02-24 Thread Martin P. Hellwig

On 02/24/11 19:22, wisecrac...@tesco.net wrote:

Hi all...

I am new to this list so treat me gently... ;o)


I for one welcome you :-)


I use Python almost totally differently to the vast majority of people. I like 
banging the metal.


Well I can assure you that although you might be indeed in a minority, 
it is absolutely unlikely you are alone in that.



As I know of no other way to give my Python code away I thought I`d join here.


I'd would suggest you put it on a free repository like googlecode 
(http://code.google.com/) or my personal favourite bit bucket 
(https://bitbucket.org/) but there are many other out there too. 
Coincidentally both I have mentioned support Mercurial HG, which is 
largely written in Python too.


And just post now and again a status update with links to the repository.

Thanks for sharing and happy sharing!
cut

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


Re: Displaying SVG in tkinter using cairo and rsvg

2011-02-16 Thread Martin P. Hellwig

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

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:


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?


cut

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.


Thanks for the info though.

--
mph




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


Displaying SVG in tkinter using cairo and rsvg

2011-02-15 Thread Martin P. Hellwig

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:

---
#! /usr/bin/env python

Tkinter example for displaying SVG in a PhotoImage class using cairo and 
rsvg.
Note that this is relatively slow, this is mainly due to converting the 
cairo

surface data to the appropriate rgb values and putting each pixel in the
PhotoImage class.

import cairo
import rsvg
# I had a bit of trouble finding the rsvg python wrapper, turns out it 
is part
# of the GnomePythonDesktop package, windows users are even less 
supported see:
# http://cairographics.org/cairo_rsvg_and_python_in_windows/ to get it 
working.

import Tkinter

def _alpha_blending(rgba, back):
Return a rgb tuple composed from a rgba and back(ground) tuple/list.
paired = zip(rgba[:-1], back)
alpha = rgba[-1]
tmp = list()
for upper, lower in paired:
blend = (((255 - alpha) * lower) + (alpha * upper)) / 255
tmp.append(blend)

return(tuple(tmp))

def convert(bgra_buffer, width, height):
Convert bgra buffer to photoimage put
idx = 0
end = len(bgra_buffer)
arguments = list()

while idx  end:
rgba = (ord(bgra_buffer[idx + 2]),
ord(bgra_buffer[idx + 1]),
ord(bgra_buffer[idx + 0]),
ord(bgra_buffer[idx + 3]))
back = (255, 255, 255)
rgb = _alpha_blending(rgba, back)
arguments += rgb
idx += 4

template = ' '.join(height *['{%s}' % (' 
'.join(width*[#%02x%02x%02x]))])

return(template % tuple(arguments))


def photoimage_from_svg(file_path_name):
Return a Tkinter.PhotoImage with the content set to the rendered 
SVG.

svg = rsvg.Handle(file=file_path_name)
width, height = svg.get_dimension_data()[:2]
surface = cairo.ImageSurface(cairo.FORMAT_RGB24, int(width), 
int(height))

context = cairo.Context(surface)
svg.render_cairo(context)
image = Tkinter.PhotoImage(width=width, height=height)
data = convert(surface.get_data(), width, height)
image.put(data)
return(image)

if __name__ == '__main__':
SVG = ?xml version=1.0 encoding=UTF-8 standalone=no?
svg
   xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#;
   xmlns:svg=http://www.w3.org/2000/svg;
   xmlns=http://www.w3.org/2000/svg;
   id=test version=1.1 width=900 height=600
   rect id=redwidth=300 height=300 x=000 y=000
  style=fill:#ff;fill-opacity:1.0;stroke:none /
   rect id=green  width=300 height=300 x=300 y=000
  style=fill:#00ff00;fill-opacity:1.0;stroke:none /
   rect id=blue   width=300 height=300 x=600 y=000
  style=fill:#ff;fill-opacity:1.0;stroke:none /
   rect id=black  width=300 height=300 x=000 y=300
   style=fill:#00;fill-opacity:1.0;stroke:none /
   rect id=grey  width=300 height=300 x=300 y=300
   style=fill:#00;fill-opacity:0.5;stroke:none /
   rect id=white width=300 height=300 x=600 y=300
  style=fill:#ff;fill-opacity:1.0;stroke:none /
/svg
import os, tempfile
#
PATH = tempfile.mkstemp()[1]
OPEN = open(PATH, 'w')
OPEN.writelines(SVG)
OPEN.close()
ROOT = Tkinter.Tk()
#
IMAGE = photoimage_from_svg(PATH)
#
os.remove(PATH)
BUTTON = Tkinter.Button(ROOT, image=IMAGE)
BUTTON._photoimage = IMAGE
BUTTON.grid()
Tkinter.mainloop()
---
--
mph
--
http://mail.python.org/mailman/listinfo/python-list


Re: locale settings and date parsing under windows

2011-02-03 Thread Martin P. Hellwig

On 02/03/11 10:59, AlienBaby wrote:

On Feb 3, 10:22 am, AlienBabymatt.j.war...@gmail.com  wrote:

Hi,

I'm attempting to convert some date-time strings from a text file
under windows into a datetime object as returned by strptime()

However, the strings can represent dates in various formats based on
the country of origin, for example shortened month names etc.. are
different between countries.

I am trying to set the correct locale for strptime to work, but I'm
having a lot of trouble doing this under windows.

IE, wher the date is in the Danish Language,

import locale
locale.setlocale('LC_ALL',locale.normalize('da_DK'))

gives

locale.Error: unsupported locale string.

I have tried various ways but always hit the same error.

I understand setting LC_ALL may not be what I require, I was first
looking to simply get the locale setting correctly before I started
changing only the date-time specific elements.

Any help or pointers much appreciated. Current searching around is
revealing a fair amount of confusion..!

Thanks,

Matt.


As often happens, writing that out and the working through a bit more,
I resolved my own question.

It ended up being a simple matter of translating from posix codes to
windows codes, so 'fr_FR' becomes 'French_France'...

thanks,

MAtt.


You might also want to have a look at the contents of:
locale.locale_alias

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


Should there be a 'core' python install? (was Re: Tkinter: The good, the bad, and the ugly!)

2011-01-17 Thread Martin P. Hellwig

On 01/17/11 19:39, rantingrick wrote:
cut

Q: If you could replace Tkinter with any module/library (THAT IS NOT A
GUI OR IDE!!) what would you like to see fill its place?

cut

Some systems, like FreeBSD have Tkinter and IDLE as a separate package 
which is not installed by default. Purely because those systems don't 
assume that the user has X installed.


Though since this is a windows world, that argument is rather mood.
But then again the win32 extension modules aren't installed by default, 
rather inconsistent in that perspective.


You could argue that there is some advantage especially for starters, 
having at least something to start on (IDLE), but on the other hand 
there are already a couple of special 'distribution packages' that aim 
to include anything remotely python related.


I think that the ones that should make these decisions (if any) are 
those how spend _their_ time integrating the dependencies and making the 
builds for public download.


Perhaps for pythons 3 lifetime there should still be a 'python' 
maintained tkinter integration. But I don't see any reason why this 
should be continued for 4, fortunately it is not my call and I actually 
quite like Tkinter.


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


Re: Should there be a 'core' python install? (was Re: Tkinter: The good, the bad, and the ugly!)

2011-01-17 Thread Martin P. Hellwig

On 01/17/11 22:00, rantingrick wrote:

On Jan 17, 2:09 pm, Martin P. Hellwigmartin.hell...@dcuktec.org
wrote:


fortunately it is not my call and I actually
quite like Tkinter.



Are you sure about that Martin? :)))


From: Martin P. Hellwigmartin.hell...@dcuktec.org
Newsgroups: comp.lang.python
Subject: Re: GUIs - A Modest Proposal
Date: Fri, 11 Jun 2010 07:10:35 +0100

[...snip...]

Though I don't like tkinter either, but I don't seem to hate it as
much as others do.


hmm?
Yep when I started looking much more at other toolkits, I started to 
like Tkinter more and more. Maybe it its simplicity, or that not every 
thing starts with a bloody g or that it is actually cross platform 
usable without jumping through hoops charted in a map where lat/long 
references have been omitted because in the future a map of mars will 
not cause confusion, even though it is totally irrelevant now.


Actually my favourite GUI toolkit at the moment is pyjamas.

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


Re: Multiple independently started python processes and sharing of a module

2011-01-14 Thread Martin P. Hellwig

On 01/14/11 03:04, Kushal Kumaran wrote:

- Original message -

Hi all,

I have the following problem (which I already have a hacked around
solution that works but I'd would like some more input on it):

I have a situation where multiple python processes are started
independently from each other but by the same user with the same
environment (as happens with mod_wsgi, when not using daemon mode).

All of these processes access a single module which needs
synchronization for some of the commands, for example a db (MySQLdb)
module where when a select is done, the fetchall must be done of that
same process before another process can do anything else.



If the processes are independent, they are not sharing the database connection, 
unless you've taken steps to make it so.  MySQLdb imported in one process 
should not interfere with MySQLdb importerd in another process.


snip



It might be a misconfiguration but, under mod_wsgi with apache it does.

Cheers,

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


Re: Multiple independently started python processes and sharing of a module

2011-01-14 Thread Martin P. Hellwig

On 01/14/11 10:05, Kushal Kumaran wrote:
cut

This might help though:
https://code.google.com/p/modwsgi/wiki/ProcessesAndThreading

It seems if you're not using 'daemon' mode, global data might be shared.


Yes I read that thoroughly before I started out implementing a solution.
But in my case I wanted something that worked as expected and not be 
depending on specific configuration of underlying technology as I can 
not assure that these condition will be met.



You could create new connections for each request (and close them when
done).  There won't be interference between select/fetch across
multiple database connections.  Additionally, the documentation of
MySQLdb says it is a bad idea to share database connections between
threads.



That is a possible solution too, however the performance impact is in 
the range of 40% while doing forced synchronization and overhead of the 
singleton wrapper is around 20%. So the latter is what I have gone with.


Thanks for bouncing off ideas though, much appreciated.

--
mph


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


Multiple independently started python processes and sharing of a module

2011-01-13 Thread Martin P. Hellwig

Hi all,

I have the following problem (which I already have a hacked around 
solution that works but I'd would like some more input on it):


I have a situation where multiple python processes are started 
independently from each other but by the same user with the same 
environment (as happens with mod_wsgi, when not using daemon mode).


All of these processes access a single module which needs 
synchronization for some of the commands, for example a db (MySQLdb) 
module where when a select is done, the fetchall must be done of that 
same process before another process can do anything else.


How would I go and provide synchronization?
Locking does not seem to work because there is no relationship between 
all the python processes except that they are started by the same user.


Currently my solution is to wrap the module around a module that when 
used creates a directory and pipes to the process 
(multiprocessing.Connection) thus enforcing single access and within 
that I have wrapped the db function around again so that select 
statement as mentioned above is actually an execute followed by a fetchall.


I still have the nagging feeling that I have reinvented a squared wheel 
or am totally missing the point.


Any suggestions/comments are greatly appreciated,

Thanks in advanced,

Martin P. Hellwig
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python documentation too difficult for beginners

2010-11-02 Thread Martin P. Hellwig

On 11/02/10 10:42, jk wrote:
cut

Is there much chance that the Python maintainers will change their
documentation system to make it more like Java or PHP? How would I go
about trying to make that happen?
I am by no means an authority however since you ask it here I feel 
compelled to give you my opinion :-)


In general I would think that more documentation is always welcome, if 
you feel like you can make a contribution, excellent, please do!


However, I found that the documentation available was enough for me, and 
I didn't even have to go to the googles for that.


Typing help(thing_i_want_info_of) in the interpreter gives me precise 
consistent information for what I need to do with whatever it is I am 
doing and yes that is largely a replication of what is mentioned on the 
site itself (well more the other way around actually).


In the odd cases this doesn't help me, I google for examples.
If that doesn't help I look at the modules __file__ and open that module 
to read the source.


And when I started 10 odd years ago with Python it was my first language 
with no prior confusion of other languages, since then I extended my 
knowledge with C and assembler but on a day to day basis I still use Python.


--
mph

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


Re: pylint -- should I just ignore it sometimes?

2010-10-21 Thread Martin P. Hellwig

On 10/20/10 22:09, Seebs wrote:

On 2010-10-20, Matteo Landilandima...@gmail.com  wrote:

Another situation in which I needed to disable such kind of warnings
is while working with graphics modules.
I often use variable names such as x, y, z for coordinates, or r,g,b for colors.
Would longer names make the reader's life easier?


Interesting point.  Which is really easier to read:

x, y, z = p.nextpoint()

xCoordinate, yCoordinate, zCoordinate = polygon.nextPointCoordinates()

-s


Although intuitively I would say the shorthand, however that is 
depending on the context being me knowing at least the basics of 3d 
spaces and having the pre-warning that you are going to mention 
something with either coordinates or colours.


Take away this pre-information, as you would when first reading an 
application, and all of the sudden the latter would be much clearer to 
the fellow programmer.


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


Re: pylint -- should I just ignore it sometimes?

2010-10-19 Thread Martin P. Hellwig

On 10/19/10 20:57, Seebs wrote:

So, I'm messing around with pylint.  Quite a lot of what it says
is quite reasonable, makes sense to me, and all that.

There's a few exceptions.

Well, as with all styles IMHO, if there is a _good_ reason to break it, 
then by all means do, but you might want to consider putting in a 
comment why you did that and add the #pylint: disable-msg=message_id 
on that line. If that is overkill, why not just comply to the standard 
and avoid all the fuzz?


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


Re: pylint -- should I just ignore it sometimes?

2010-10-19 Thread Martin P. Hellwig

On 10/19/10 23:36, Seebs wrote:
cut

It seems like a
very odd measure of complexity; is it really that unusual for objects to have
more than seven meaningful attributes?

Speaking without context here, so take it with as much salt as required 
;-), it is not that unusual. However there are some things to consider, 
for example are all these attributes related to each other? If so 
wouldn't it be more pythonic to have one attribute which is a dictionary 
and store your stuff in there?


I follow pylint pretty strict and only tend to ignore it when making it 
lint-friendly would mean making it less readable or less logically.


As everything pylint is a really useful tool especially when you just 
start writing in python and it can give you valuable clues on how to 
improve your programming. So just take it as hints that there might be 
ways to write it better, have a think about it, perhaps ask as you have 
done, and happily ignore it if all else fails :-)


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


Re: looping through possible combinations of McNuggets packs of 6,9 and 20

2010-08-13 Thread Martin P. Hellwig

SPOILER ALTER: THIS POST CONTAINS A POSSIBLE SOLUTION

On 08/12/10 21:41, News123 wrote:


On 08/12/2010 09:56 PM, Martin P. Hellwig wrote:

On 08/11/10 21:14, Baba wrote:
cut

How about rephrasing that question in your mind first, i.e.:

For every number that is one higher then the previous one*:
 If this number is dividable by:
 6 or 9 or 20 or any combination of 6, 9, 20
 than this number _can_ be bought in an exact number
 else
 print this number



you are allowed to mix.
15 is neither divisable by 6 nor by nine, but 9 + 6 = 15


I was aware of that, thats whhy I wrote:
or any combination of 6, 9, 20



I guess, trying to find the result with divisions and remainders is
overly complicated.


Python 2.6.4 (r264:75706, Jul  1 2010, 12:52:41)
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd8
Type help, copyright, credits or license for more information.
 MODULO_COMBINATIONS = [[20], [9], [6],
...[20, 9], [20, 6], [9, 20],
...[9, 6], [6, 20], [6, 9],
...[20, 9, 6], [20, 6, 9], [9, 20, 6],
...[9, 6, 20], [6, 20, 9], [6, 9, 20]]

 def apply_combinations_on(number):
... tmp = list()
... for combination in MODULO_COMBINATIONS:
... remainder = number
... for modulo_value in combination:
... if remainder == 0:
... remainder = None
... break
...
... result = remainder % modulo_value
...
... if result == remainder :
... remainder = None
... break
...
... remainder = result
...
... if remainder == 0:
... tmp.append(str(combination))
... return(tmp)
...
 print(apply_combinations_on(15))
['[9, 6]']


What is so over complicated about it?

--
mph

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


Re: looping through possible combinations of McNuggets packs of 6,9 and 20

2010-08-13 Thread Martin P. Hellwig

On 08/13/10 10:46, Peter Otten wrote:

Martin P. Hellwig wrote:


SPOILER ALTER: THIS POST CONTAINS A POSSIBLE SOLUTION

No it wasn't :-)


which should be 1*9 + 2*6

What am I missing?



Aah interesting, 21 % 9 returns 3 instead of 12, which makes sense of 
course. I guess the algorithm has to be adapted in a way that if the 
value is bigger or equal twice the size of the modulo value you need to 
iterate over it, something like:

for minus_multiplier in range(1, int(number, modulo_value)+2):
number = number - (modulo_value * minus_multiplier)
do the rest of the loop

Probably another ten lines or so to make it working as it should

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


Re: looping through possible combinations of McNuggets packs of 6,9 and 20

2010-08-12 Thread Martin P. Hellwig

On 08/11/10 21:14, Baba wrote:
cut

How about rephrasing that question in your mind first, i.e.:

For every number that is one higher then the previous one*:
If this number is dividable by:
6 or 9 or 20 or any combination of 6, 9, 20
than this number _can_ be bought in an exact number
else
print this number

* There are an infinite amount of numbers, just imagine the biggest
number you can think of and I say plus 1 :-)


Next thing you have to do is figure out how to write this in python,
particularly getting all the combinations of divisions can be tricky.
Hint; you are not really interested in the division result but rather if 
a division would be complete or give a remainder (modulo operator).
If you get an remainder this could be okay if that can divided by one of 
the other numbers, and so forth till you ran out of combinations.


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


Re: GUI automation tool (windows)

2010-08-10 Thread Martin P. Hellwig

On 08/10/10 20:13, News123 wrote:

On 08/10/2010 12:25 PM, Alex Barna wrote:

On Aug 10, 10:05 am, Lawrence D'Oliveiro  Can’t understand the point
to it. “GUI automation” is a contradiction in

terms, because a GUI is designed for use by humans to do manual tasks, not
ones that can be automated.


Automating GUI is for testing.

And sometimesfor working around SW, whch has no cli or other interface
and should be automated

That and when you are forced using a gui and need to 'copy and paste' 
between two programs that have no native bridge except for the one that 
is between the keyboard and chair, then it is nice to know that there is 
a way of automating it.


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


Re: xmlrpc and processes

2010-08-09 Thread Martin P. Hellwig

On 08/09/10 07:50, iu2 wrote:

Hi,

I have a SimpleXMLRPCServer running on one PC.
I need several ServerProxy-s talking to it, each one running on a
different PC. That is, I run on each PC a client application, that
talks to the one server using xml-rpc.

Is the xml-rpc designed to work like this? If not, is there something
I can do to still be able to work with xml-rpc in this architucture?

Thank you very much
Yeah should be no problem, you might get some ideas from reading this 
'wrapper':

http://code.google.com/p/dcuktec/source/browse/source/wrapped_xmlrpc_server/rpc.py

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


Re: python styles: why Use spaces around arithmetic operators?

2010-07-26 Thread Martin P. Hellwig

On 07/27/10 00:06, rantingrick wrote:

On Jul 26, 5:20 pm, Peng Yupengyu...@gmail.com  wrote:

This webpagehttp://www.python.org/dev/peps/pep-0008/recommends the
following. It looks to me that both styles are fine. Could anybody let
me know what the rationale is behind this recommendation?


The rational is simple. Guido is God and if you don't follow his words
then you will be tortured. His favorite means is by forcing you to
wear Dutch wooden shoes every day whist programming Ruby! ;-)


Wat is er mis met klompen?

--
mph

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


Re: grailbrowser now running under python 2.5 (probably above too)

2010-07-11 Thread Martin P. Hellwig

On 07/11/10 04:59, Luke Kenneth Casson Leighton wrote:

source at:
http://github.com/lkcl/grailbrowser

$ python grail.py (note the lack of python1.5 or python2.4)

conversion of the 80 or so regex's to re has been carried out.
entirely successfully or not is a matter yet to be determined.  always
a hoot to try browsing http://www.bbc.co.uk or http://www.youtube.com
with a browser from 11+ years ago, it still cannot be resisted as
grail is the only working graphical web browser in the world written
in pure python [pybrowser is still in development, stalled].

l.

Congrats!
Are you planning to take over the world with grail and pyjs? :-)

--
mph

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


Re: Opinions please -- how big should a single module grow?

2010-07-09 Thread Martin P. Hellwig

On 07/09/10 05:37, Steven D'Aprano wrote:

This is a style question rather than a programming question.

How large (how many KB, lines, classes, whatever unit of code you like to
measure in) should a module grow before I should break it up into a
package? I see that, for example, decimal.py is  3000 lines of code, so
I can assume that 3 KLOC is acceptable. Presumably 3000 KLOC is not.
Where do you draw the line?

For the purposes of the discussion, you should consider that the code in
the module really does belong together, and that splitting it into sub-
modules would mean arbitrarily separating code into separate files.



Personally I like to split up my module quite early and the main 
criteria is whether this improves (IMO) maintainability.
So if I can refactor stuff that with some adaption can be used multiple 
times I put it in its own module. I rarely exceed 1KLOC per module and 
on average are on half of that.


--
mph

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


Re: any issues with long running python apps?

2010-07-09 Thread Martin P. Hellwig

On 07/09/10 20:13, Les Schaffer wrote:

i have been asked to guarantee that a proposed Python application will
run continuously under MS Windows for two months time. And i am looking
to know what i don't know.
Get a good lawyer and put into the contract, the last thing you want is 
a windows update that restarts the host and you are responsible because 
you guaranteed that it would run continuously.


On the technical side; as Christian Heimes already pointed out, split 
the programs. Specifically I would have 1 service for data gathering, 
two separate watchdog services (that checks whether the other watchdog 
is still running and the 'core' service).


The GUI should be an user side app and the services could be too, 
however consider running the services under the appropriate system 
account as in the past I have seen some strange things happening with 
services under user account, especially if there are password policies.


I don't see from the interpreter point of view no reason why it couldn't 
work, it is much more likely your host system will mess things up (even 
if it wouldn't be windows).

cut rest
--
mph
--
http://mail.python.org/mailman/listinfo/python-list


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Martin P. Hellwig

On 07/06/10 16:50, sturlamolden wrote:


Just a little reminder:

Microsoft has withdrawn VS2008 in favor of VS2010. The express version
is also unavailable for download.:((

cut
Public download that is, people like me who have a MSDN subscription can 
still download old versions like Visual Studio 2005.


So I would say that there is no particular hurry.
I would think that everyone really serious about MS development with MS 
tools should get an MSDN subscription anyway, it saves you a lot of 
money in the long run.


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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Martin P. Hellwig

On 07/06/10 21:19, sturlamolden wrote:

On 6 Jul, 21:49, Christian Heimesli...@cheimes.de  wrote:


I agree, the situation isn't ideal. I see if I can get in contact with
Microsoft's open source team. Perhaps they can keep the download link to
VS 2008 EE working.


It seems the MSDN subscription required to get VS 2008 costs one
dollar less than $1200. So it does not fit within everyone's budget.


Take in the cost of your operating system, and the ones you want to test 
against, perhaps you also like to use office.
Although I am not a windows developer per se, I do use windows XP, 2000 
2003, 2008, Vista and 7 for testing. I also use office for all those 
clients who think that this is the only format.


1200 USD is actually quite cheap, but then again I didn't pay that 
because I am either always been in an academic license (about 70 EUR a 
year) or like now in a program for businesses who just start up (free 
with my bank as supporting agent). When this 3 year subscription is over 
I fall anyway in the cheaper renewals and if not I am sure that there is 
some other brand new scheme like they did for the last decade.


Anyway, if you want to provide tools for platforms that are closed 
source that means that there are costs for the developer and the client.
Although the cost for MS platforms are reasonable (as a developer and 
you know you way around, that means go a couple of times to those free 
MS events and it is quite likely you get an MSDN subscription for being 
such a good loyal puppy), there are always costs.


If you don't like that better convince your target audience about an 
open source operating system, whichever that may be.


--
mph


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


Re: git JSONRPC web service and matching pyjamas front-end

2010-06-30 Thread Martin P. Hellwig

On 06/30/10 03:29, CM wrote:

On Jun 29, 6:54 pm, Luke Kenneth Casson Leightonl...@lkcl.net
wrote:

as more than just a proof-of-concept but to get pyjamas out of looking
like a nice toy, doesn't do much, great demos, shame about real
life,

cut

If may be
generated with pyjamas but I'm not sure how this fulfills your wish to
do something that does more than doesn't do much.  I would expect a
demo to at least have some typical GUI features on it--or am I
completely missing the point of what you're doing?

I think lkcl wanted to demonstrate that it is more than 'a nice toy' 
and that there is an actual real world application for it.
I am not sure why he seems to have the urge to do that as for me I am 
already convinced about its usability.


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


Re: compile as exe with arguments

2010-06-28 Thread Martin P. Hellwig

On 06/28/10 11:18, dirknbr wrote:

I want to compile as an exe using py2exe but the function should take
arguments. How would I do this? Currently my exe runs (no errors) but
nothing happens.



I am not sure if I understand your question correctly, have you used a 
module like optparse and it doesn't do anything? It works for me the 
last time I used it.


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


Re: Community (A Modest Proposal)

2010-06-13 Thread Martin P. Hellwig

snip all
At first I wanted to response in the style of 'karma is a bitch' or 
'what goes around comes around' but then I considered that won't be 
helping much, so I only did at first in a meta sort of way, sorry for that.
The thing is that sometimes for no good or appealing reasons, which I 
personally think in this case isn't so, the whole world is against you.


So I would propose that, instead of beating up a dead horse (I try to 
write from your point of view) you fork the project, call it Rython (or 
whatever you fancy) and create the community you want by patching up the 
language to your standards.


I promise if there is something where I am competent enough I will 
seriously consider contributing.


--
mph

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


safer ctype? (was GUIs - A modest Proposal)

2010-06-12 Thread Martin P. Hellwig

On 06/12/10 08:21, Martin v. Loewis wrote:
cut

The issue is not that you may mistakes in the ctypes code, thus allowing
users to crash Python. The issue is that if users remove ctypes (which
they may want to do because it's not trustworthy), then your module will
stop working (unless you have a fallback for the case that ctypes is
unavailable).

cut
Got me thinking, is it perhaps doable to have a 'safe' ctype that is 
guaranteed to be in the stdlib? Perhaps crippling it in a sense that it 
only allows a known set of functions to be called?
My gut feeling is that you open a can of worms here but I would 
appreciate your opinion.


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


Re: a +b ?

2010-06-11 Thread Martin P. Hellwig

On 06/11/10 15:19, superpollo wrote:

yanhua ha scritto:

hi,all??

cut

s = input()


this does not work
nitpicking Well it does if it is python 3 and not 2 as you are using 
:-)/nitpicking

cut
--
mph

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


Re: GUIs - A Modest Proposal

2010-06-11 Thread Martin P. Hellwig

On 06/11/10 07:00, rantingrick wrote:
cut

I would
bet that only myself, Kevin, and only a handful of others use Tkinter
for anything more than education purposes. AFIK, Kevin is THE ONLY
PYTHON programmer producing real professional GUI's with Tkinter -- i
encourage anyone else to speak up if your out there producing real
Tkinter GUI. (psst: i don't think we'll be seeing mobs in the streets,
really i don't)


The Karaoke Network, Kiosk machine uses tkinter on win32 for the 
passcode interface (on screen keyboard).
Randstad HR Solutions (before that part has been sold off) had several 
small database tools (which where cli orientated) using tkinter for 
interactivity on win linux/win32.


Though I don't like tkinter either, but I don't seem to hate it as much 
as others do.


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


Re: GUIs - A Modest Proposal

2010-06-09 Thread Martin P. Hellwig

On 06/09/10 14:37, D'Arcy J.M. Cain wrote:

On 09 Jun 2010 06:05:43 GMT
Steven D'Apranosteve-remove-t...@cybersource.com.au  wrote:

I think the only way to end this pointless discussion is this:

Hitler would have loved Tkinter!


Sorry, Quirk's Exception to Godwin's Law says that you can't invoke
Godwin's Law on purpose.

How about a meta/meta reference if the poster would apologize now with 
'Ich habe es nicht gewusst' ?


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


Re: GUIs - A Modest Proposal

2010-06-08 Thread Martin P. Hellwig

On 06/06/10 03:22, ant wrote:

I get the strong feeling that nobody is really happy with the state of
Python GUIs.
Tkinter is not widely liked, but is widely distributed. WxPython and
PyGtk are both
powerful, but quirky in different ways. PyQt is tied to one platform.
And there are
dozens more.


Yeah I have the same problem with washing machines, I usually end up in 
one setting that works for me. But then again if Apple would make a 
washing mashing with only one button that says 'wash' everybody would be 
upset again because their favourite fabric does not have a special 
setting and users would be confused whether to put in washing powder 
before of after they have pushed the button.




Whether or not we like graphics programming, it's not going to go
away. I get the
uneasy feeling whenever I start a new project that there should be a
'better' GUI
than the ones I currently use (WxPython and PyGtk).


Perhaps the problem is saying 'GUI', sure by definition they're all 
graphical and ment for the user, but the interface is ambiguous, 
something that works well for touchscreen devices fails completely for 
voice control and is perhaps confusing for pointers or keyboard 
interaction.
The next problem is integration, do I want to make it feel like it is 
part of the overall GUI (if there is any) or do I define my own 
'standard'. With so many variables and different angles, it is no wonder 
that there are so many different toolkits. Though I have to say that 
most toolkits seems to struggle to define their own purpose.




Fragmentation is our enemy. Our resources are being dissipated. Is it
not time to
start again? We have shown that it is possible to do the right thing,
by creating Python3.


That was not starting again (perhaps in coding terms) but in design 
terms it was more or less glorified clean-up. Besides fragmentation is 
the natural state if anything has multiple, equally right (or wrong), 
interpretations.




I ask the group; should we try to create a new GUI for Python, with
the following
properties?:

- Pythonic
- The default GUI (so it replaces Tkinter)
- It has the support of the majority of the Python community
- Simple and obvious to use for simple things
- Comprehensive, for complicated things
- Cross-platform
- Looks good (to be defined)
- As small as possible in its default form


Cross-platform for GUI is a female dog, I have no idea what the right 
solution is, but being non native all the time might not be the worst of 
all possibilities.


If so, what are the next steps?
World domination and making GUI's against the law, everybody back to the 
command line, driven by either voice, virtual/real keyboard or a direct 
brain interface :-)


The Python SIG on GUIs closed years ago. Should that be revived?

This is A Modest Proposal (J. Swift). In a sense, I am suggesting
that
we eat our own babies.


All reasonable to me even if you don't build a new gui.


But don't we owe it to the community?

That is the same as saying 'Do I owe it to myself?', well do you?

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


Re: GUIs - A Modest Proposal

2010-06-08 Thread Martin P. Hellwig

On 06/08/10 07:59, rantingrick wrote:

On Jun 8, 1:39 am, Martin P. Hellwigmartin.hell...@dcuktec.org
wrote:

On 06/06/10 03:22, ant wrote:


I get the strong feeling that nobody is really happy with the state of
Python GUIs.
Tkinter is not widely liked, but is widely distributed. WxPython and
PyGtk are both
powerful, but quirky in different ways. PyQt is tied to one platform.
And there are
dozens more.


Yeah I have the same problem with washing machines, I usually end up in
one setting that works for me. But then again if Apple would make a
washing mashing with only one button that says 'wash' everybody would be
upset again because their favourite fabric does not have a special
setting and users would be confused whether to put in washing powder
before of after they have pushed the button.


And thats exactly not what the argument is about here. Including any
GUI in any language that satisfies everyone's personal tastes is
impossible. We are not trying to please X,Y,and Z. Nor or we are
secretly scheming to win GUI Builder of the year awards.

Should ANY GUI be included in Python's stdlib, well probably not.
However, if you DO include a GUI it should at least be the lightest-
weight-up-to-date-save-the-download-rate GUI it can be!


Well that is tkinter than, it is reasonably lightweight and disliked for 
different reasons by everyone equally.


--
mph

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


Re: GUIs - A Modest Proposal

2010-06-08 Thread Martin P. Hellwig

On 06/08/10 22:14, Ethan Furman wrote:

Grant Edwards wrote:

On 2010-06-08, Martin v. Loewis mar...@v.loewis.de wrote:

TkInter - Tcl - Tk - Xlib

Is the Tcl intepreter really need to use this GUI? Why not:

(Pyton -) Tkinter-API - Xlib ?

Even if this was possible (which it is not)


Why is it not possible? It seems to have been done for other
languages.


cut
Yes indeed, however gp forgot another step:
tkinter  tcl  tk  xlib/xcb  x server
There are already some more or less usable (though they look abandoned) 
experiments that do this:

https://launchpad.net/twisted-x11
http://python-xlib.sourceforge.net/

However I don't think that x11 represents that majority (just a gut 
feeling I have no data to back this claim up) of gui users, so an equal 
solution should be found for windows and macs.


I do think it is technically possible to have your own window manager in 
python on x11 but I have no idea if you have equal possibilities on mac 
and windows (for example to define your own window decoration).

Though considering tk does just that I would guess this to be the case.

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


Re: Python Forum

2010-06-03 Thread Martin P. Hellwig

On 06/03/10 11:16, Pierre Quentel wrote:
cut

I'm not saying that pythonforum.org is the best solution but it
certainly looks more attractive than c.l.p. to the new generation of
Python users

- Pierre


On the other hand it might not be so bad that you don't get questions 
from users here who are unable to use a nntp reader or news to mail service.


Other 'forums' that specifically target users unaware of their opposable 
thumbs certainly have a right of existence, though you wouldn't find me 
there.


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


Re: Python Forum

2010-06-03 Thread Martin P. Hellwig

On 06/03/10 12:46, Michele Simionato wrote:

On Jun 3, 12:28 pm, Martin P. Hellwigmartin.hell...@dcuktec.org
wrote:

On the other hand it might not be so bad that you don't get questions
from users here who are unable to use a nntp reader or news to mail service.


I am unable to use a nntp reader or news to mail service. I use the
Google Groups interface and I am happy with it.


Good for you, just a shame that quite a bit of the regulars here ignore 
anything that comes from google groups, not me though, I just mentally 
ignore posts.


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


Re: multiprocessing and accessing server's stdout

2010-05-28 Thread Martin P. Hellwig

On 05/28/10 13:17, Adam Tauno Williams wrote:
cut


You should be able to point it any any file-like object.  But, again,
why?

If you have the data in the process why send it to stdout and redirect
it.  Why not just send the data to the client directly?


Well you might want to multiplex it to more then one client, not saying 
that this is the case here, just something I imagine possible.


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


Re: multiprocessing and accessing server's stdout

2010-05-28 Thread Martin P. Hellwig

On 05/28/10 21:44, Adam Tauno Williams wrote:

On Fri, 2010-05-28 at 15:41 +0100, Martin P. Hellwig wrote:

On 05/28/10 13:17, Adam Tauno Williams wrote:
cut

You should be able to point it any any file-like object.  But, again,
why?
If you have the data in the process why send it to stdout and redirect
it.  Why not just send the data to the client directly?

Well you might want to multiplex it to more then one client, not saying
that this is the case here, just something I imagine possible.


That still doesn't make sense.  Why 'multiplex stdout'?  Why not just
multiplex the data into proper IPC channels in the first place?


I am going on a stretch here, I mostly agree with you, just trying to 
illustrate that there could be corner cases where this is sensible.
The current situation could be that there is a client/server program 
(binary only perhaps) which is not multi-user safe.


Python can be used as a wrapper around the server to make it 
multi-client, by emulating the exact behavior towards the client, the 
client program does not have to be changed.


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


Re: confusing error with nntplib

2010-05-27 Thread Martin P. Hellwig

On 05/27/10 02:01, Eduardo Alvarez wrote:

When trying to use nntplib to connect to the news server nntp.aioe.org,
a bizarre sequence of events occurs:

1) I import the module, and create an instance, as follows:

s = nntplib.NNTP('nntp.aioe.org')

I get no errors, which leads me to believe all went well. The I try
fetching info on a newsgroup (in this case, comp.lang.python):

s.group('comp.lang.python')

I then get the following error:

Traceback (most recent call last):
   File stdin, line 1, inmodule
   File /usr/lib/python2.6/nntplib.py, line 345, in group
 resp = self.shortcmd('GROUP ' + name)
   File /usr/lib/python2.6/nntplib.py, line 259, in shortcmd
 return self.getresp()
   File /usr/lib/python2.6/nntplib.py, line 214, in getresp
 resp = self.getline()
   File /usr/lib/python2.6/nntplib.py, line 206, in getline
 if not line: raise EOFError
EOFError

Running this a *second* time, gives me the following, different error:

Traceback (most recent call last):
   File stdin, line 1, inmodule
   File /usr/lib/python2.6/nntplib.py, line 345, in group
 resp = self.shortcmd('GROUP ' + name)
   File /usr/lib/python2.6/nntplib.py, line 258, in shortcmd
 self.putcmd(line)
   File /usr/lib/python2.6/nntplib.py, line 198, in putcmd
 self.putline(line)
   File /usr/lib/python2.6/nntplib.py, line 193, in putline
 self.sock.sendall(line)
   File string, line 1, in sendall
socket.error: [Errno 32] Broken pipe

As this is a broken pipe, I reconnect to the server, the same way as
before. When I *then* retrieving the newsgroup's info, I get no errors.

I'm pretty baffled by this. It might be an issue with the server itself,
but still, any input would be very appreciated.

yours,



Here is how I approached it:

# Lets see first if the server is available
[mar...@aspire8930 /usr/home/martin]$ telnet nntp.aioe.org nntp
Trying 94.75.214.90...
Connected to nntp.aioe.org.
Escape character is '^]'.
200 nntp.aioe.org InterNetNews NNRP server INN 2.5.1 ready (posting ok)
^]
telnet quit
Connection closed.
# Okidoki seems fine

# lets fire up python
[mar...@aspire8930 /usr/home/martin]$ python
Python 2.6.4 (r264:75706, Apr  9 2010, 12:45:45)
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd8
Type help, copyright, credits or license for more information.
 import nntplib
 s = nntplib.NNTP('nntp.aioe.org')
 s.group('comp.lang.python')
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/local/lib/python2.6/nntplib.py, line 345, in group
resp = self.shortcmd('GROUP ' + name)
  File /usr/local/lib/python2.6/nntplib.py, line 259, in shortcmd
return self.getresp()
  File /usr/local/lib/python2.6/nntplib.py, line 214, in getresp
resp = self.getline()
  File /usr/local/lib/python2.6/nntplib.py, line 206, in getline
if not line: raise EOFError
EOFError
# Ah yes the same error, good at least the same problem.

# Lets see what the docs has to say about it.
 help(nntplib.NNTP)
Help on class NNTP in module nntplib:

class NNTP
 |  # The class itself
 |
 |  Methods defined here:
 |
 |  __init__(self, host, port=119, user=None, password=None, 
readermode=None, usenetrc=True)

 |  Initialize an instance.  Arguments:
 |  - host: hostname to connect to
 |  - port: port to connect to (default the standard NNTP port)
 |  - user: username to authenticate with
 |  - password: password to use with username
 |  - readermode: if true, send 'mode reader' command after
 |connecting.
 |
 |  readermode is sometimes necessary if you are connecting to an
 |  NNTP server on the local machine and intend to call
 |  reader-specific comamnds, such as `group'.  If you get
 |  unexpected NNTPPermanentErrors, you might need to set
 |  readermode.
 |
# readermode seems to be worth a shot:
 s = nntplib.NNTP('nntp.aioe.org', readermode=True)
 s.group('comp.lang.python')
('211 2444 50405 52862 comp.lang.python', '2444', '50405', '52862', 
'comp.lang.python')


# okidoki got something, but I have no idea why, perhaps need to have
# a look at the source to see what that mode actually does.
# But then again I think it would be better if you would do
# that and if you are feeling generous might contribute back
# to this thread what your findings where.

--
mph



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


Re: if, continuation and indentation

2010-05-27 Thread Martin P. Hellwig

On 05/27/10 13:22, HH wrote:

I have a question about best practices when it comes to line wrapping/
continuation and indentation, specifically in the case of an if
statement.

When I write an if statement with many conditions, I prefer to use a
parenthesis around the whole block and get the implicit continuation,
rather than ending each line with an escape character.  Thus, using
the example from the style guide (http://www.python.org/dev/peps/
pep-0008/) I would write:

 if (width == 0 and
 height == 0 and
 color == 'red' and
 emphasis == 'strong' or
 highlight  100):
 raise ValueError(sorry, you lose)

The problem should be obvious -- it's not easy to see where the
conditional ends and the statement begins since they have the same
indentation.  Part of the problem, I suppose, is that Emacs indents
'height' and the other lines in the conditional to 4 spaces (because
of the parenthesis).  How do people deal with this situation?

Thanks,
Henrik


Well style guide aside (if pylint is happy with it, so am I) it depends 
on what I want to emphasize.


For example if it is really one long line with every item in it being 
equally important I do this:
if width == 0 and height == 0 and color == 'red' and emphasis == 
'strong' \
 or 
highlight  100:

raise ValueError(sorry, you lose)

In case it doesn't display correctly, I break up the line to nearest 
80th character and align the remaining part on the next line to the 
right to the 80th character.


If I want to emphasize visually a certain part I would do something like 
this:


if width == 0 and height == 0 and color == 'red' \
   and emphasis == 'strong' or highlight  100:
raise ValueError(sorry, you lose)

But these are my preference, and since it is most likely that I have to
read again what I have written I write it in a way that it is most 
readable to me within the constraints of pylint.


--
mph

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


Re: Chatroom

2010-05-24 Thread Martin P. Hellwig

On 05/24/10 19:50, narcissus wrote:

Hello , I want to create a program that is one chatroom and everyone
has this program can Enter into that chatroom. how can i do this?

and i want gui for it too (GTK)


What have you tried so far?

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


Re: where are the program that are written in python?

2010-05-21 Thread Martin P. Hellwig

On 05/21/10 11:21, Deep_Feelings wrote:

python is not a new programming language ,it has been there for the
last  15+ years or so ? right ?

Yeah about the same as Java


however by having a look at this page http://wiki.python.org/moin/Applications
i could not see many programs written in python (i will be interested
more in COMMERCIAL programs written in python ). and to be honest ,i
tried some of the programs in that list and all the programs that i
tried either dead projects or so buggy !
It's a wiki, if anybody is interested they could change the page, I 
actually have never looked at it.


1- where are the programs that is written in python ?
2- python is high productivity language : why there are no commercial
programs written in python ?

is python a valid practical programming language ?
why it is not used in commercial software ?
My experience is that Python is the FreeBSD of the programming 
languages. For example, the average user knows mac and windows, the 
average admin knows there is also something like linux, and the average 
linux admin knows there is also something like BSD.


please don't mention programs where python was used as a glue ,those
programs are not actually written in python.
Python is used in a lot in custom applications, while off the shelve 
software needs a lot of buzzwords to shift any market interest.
I have participated in a couple of 'pure' Python programs, used by 
Airbus, Randstad and a whole fleet of small firms. But yes, off the 
shelve software seems to be either written in Java or any .net equivalent.


any help will be appreciated

thank you


hth
--
mph

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


250

2010-05-20 Thread Martin P. Hellwig

On 05/20/10 07:51, cosmeticsafrolatino wrote:

hi
250 locahost.local Hello WimaxUser3645-219.wateen.net [110.36.45.219], 
pleased to meet you

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


Re: Picking a license

2010-05-09 Thread Martin P. Hellwig

On 05/09/10 04:49, Paul Rubin wrote:
cut

As I read it, he is saying that when someone releases free software,
they have for all intends and purposes lost control over its use, so
they should have made peace with the fact and surrender gracefully.
I'm asking why he doesn't think Microsoft has lost control the same way.


Microsoft has indeed lost control of it in the same way, it is just 
because we here in the 'western' world spend huge amount of money on 
prosecuting and bringing to 'justice' does who, whether for commercial 
purposes or otherwise, make a copy of a piece of code. Think about it, 
it is not stealing, the original is still there and no further resources 
where needed from the original developer.


What I am saying is that all this license crap is only needed because we 
are used to a commercial environment where we can repeatedly profit from 
the same work already done.


I am not saying that you should not profit, of course you should 
otherwise there is no interest in making it in the first place.


What I am saying is that we as developers should encourage pay for work 
and not pay for code. This will, as I believe it, keep everything much 
more healthy and balanced. At least we can cut all the crap of software 
patents and copyrights.


For those who say it can't be done, sure it can, all you have to do is 
nothing, it takes effort to enforce policies.


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


Re: Picking a license

2010-05-09 Thread Martin P. Hellwig

On 05/09/10 18:24, Stephen Hansen wrote:

cut
Wait, what? Why shouldn't I profit repeatedly from the same work 
already done? *I* created, its *mine*. I put blood, sweat and tears 
into it and perhaps huge amounts of resources, risking financial 
security and sanity, and you're arguing I shouldn't have the right to 
sell it after its done?
Of course, but what do you do if you find out that your potential 
customer already has your software without paying you?


Exactly how do you imagine I'm going to make money off of it? How the 
existing system works is that I sell... multiple copies of it. Maybe 
hundreds or thousands before that investment is recouped. At that 
point, do I no longer get to sell multiple copies? Or do I have to 
find someone to retroactively pay me some kind of salary? What does 
pay for work even mean?


As a simple developer I do not think my craft is more special than any 
other craft like carpentry, masonry, plumbing, electrician etc.
And as I see how other crafts get paid I think is reasonable for my 
craft too, I am either employed and paid by the hour or take more risks 
and do projects, commissions, etc. etc.


Of course if I would be in the construction business and I build a house 
I can either sell it or let it, but then I do take the risk that the 
occupant uses my work beyond what I expected and eventually end up with 
a huge repair costs.


I am sure you can imagine the rest of my comparison arguments between 
construction and software development.


What's wrong with software copyrights? Don't lump intellectual 
property issues together, they're not comparable. Copyrights have 
nothing at all to do with patents which have nothing at all to do with 
trademarks. Each is a very different set of law.
Very true and in my opinion they all share the same trait, although they 
are once made to make sure the original author gets credit and profit 
for his/her work they are primarily used now to profit beyond 
reasonableness and actually encumber future development and good use, 
IMHO they actually hinder the intellectual development of the human race.




Sure, there's some nutty corner cases in copyrights, which need to be 
addressed-- including things like fair use and DRM. But on the whole, 
copyrights aren't really all that broken. Its nothing like the 
situation with software patents, which are just sort of crazy.
Okay so what do you actually do if you find out that in another country, 
which do not share the same legislation (about the other 80% of the 
population) brakes your copyright or does not uphold the patent 
restrictions?
If your big like Microsoft you might try to convince that particular 
government that their citizens should pay you, otherwise good luck (even 
for Microsoft as they seem to fail more often than succeed in that notion).


They are broken because by definition restrictions need enforcement to 
uphold them, if there is no enforcement it will not work. Perhaps a 
better solution would be to find a way that does not need any 
enforcement (or limited amount of it), say like the economy worked prior 
to patents and copyrights minus kings and tyrants.


For those who say it can't be done, sure it can, all you have to
do is nothing, it takes effort to enforce policies.


And an entire industry ceases to exist overnight, with countless new 
homeless people showing up on the streets.
I have the opposite opinion but neither of us have given any facts or 
proven research papers on this so shall we call this quits?


You can believe in the Free Software movement (I'm not saying you do, 
this 'you' is impersonal and metaphorical)-- and if you do, good for 
you. You can believe in morality with regards to freedom and the 
essential rights of the users. I find it all nonsensical. But good 
for you if you believe in it. But the Free Software movement exists 
*because* of copyrights. Copyright Law is what makes the GPL even 
possible.



cut
I don't believe in a system which is based on enforcing rules and where 
breaking of this rule at most results in a hypothetical loss of income. 
Some enforced rules are of course necessary, like not going on a 
pillage/killing/raping spree (except of course if this is your job but 
then your still governed by the rules of Geneva -- yeah I know bold 
military statement, but I have been there too, the military that is). I 
rather like to find a way where minimal rule enforcing is necessary to 
make a living.

But I fail to see what's fundamentally wrong with that system.

I hope I have further explained my point of view and hope that you agree 
with me at least from my perspective, I do understand though that your 
point of view is perfectly valid and reasonable. It is just that I am a 
sucker for seeking alternative ways to improve systems even if they only 
show small amounts of defects. So you could argue that I have my sight 
set for an Utopia while you rather remain in the reality, if you can 
find yourself with 

Re: Picking a license

2010-05-09 Thread Martin P. Hellwig

On 05/09/10 21:06, Stephen Hansen wrote:
On Sun, May 9, 2010 at 12:33 PM, Martin P. Hellwig 
martin.hell...@dcuktec.org mailto:martin.hell...@dcuktec.org wrote:


On 05/09/10 18:24, Stephen Hansen wrote:

cut

Wait, what? Why shouldn't I profit repeatedly from the same
work already done? *I* created, its *mine*. I put blood,
sweat and tears into it and perhaps huge amounts of resources,
risking financial security and sanity, and you're arguing I
shouldn't have the right to sell it after its done?

Of course, but what do you do if you find out that your potential
customer already has your software without paying you?


Nothing. There's really very little benefit to me to go after 
potential customers. There will always be warez trading and cracked 
versions of any product out there that someone can pirate. So what? 
The vast majority of the people downloading that aren't actually 
*potential customers*. They'd never have bought the products to begin 
with.


Now, if I find out some other company happens to be selling my 
software, them I'd sue into oblivion and make a killing -- copyright 
lets me do that.
Assuming that you have enough financial resources and that company is 
within the same jurisdiction, granted otherwise it is still possible but 
often seen unfeasible.



Exactly how do you imagine I'm going to make money off of it?
How the existing system works is that I sell... multiple
copies of it. Maybe hundreds or thousands before that
investment is recouped. At that point, do I no longer get to
sell multiple copies? Or do I have to find someone to
retroactively pay me some kind of salary? What does pay for
work even mean?

As a simple developer I do not think my craft is more special than
any other craft like carpentry, masonry, plumbing, electrician etc.
And as I see how other crafts get paid I think is reasonable for
my craft too, I am either employed and paid by the hour or take
more risks and do projects, commissions, etc. etc.

Of course if I would be in the construction business and I build a
house I can either sell it or let it, but then I do take the risk
that the occupant uses my work beyond what I expected and
eventually end up with a huge repair costs.

I am sure you can imagine the rest of my comparison arguments
between construction and software development.


You're comparing apples to rabbits. There's nothing even vaguely alike 
between the two no matter how much you are trying to compare them: 
carpentry, masonry, plumbing, all of that deal with *physical* items, 
that by their very nature create singular, specific, tangible items 
and/or services.


If I create a software product on commission for some private company, 
that's almost-kind of like what happens for other crafts, wherein 
someone pays me some amount of money for some amount of work to 
produce a finished product. But how exactly do you imagine I would 
make money if I have some idea for some great new program and I write 
it on my own?


The only way is to... sell multiple copies. Or try to find someone to 
give me one big lump sum for the privilege of releasing it to the 
universe.
I have seen a couple of times when one organization/user has not the 
financial resources to commission or further develop an (software) idea 
that they through trade or sector organization combine their resources 
to get there, this happen quite often in education institutes for the 
development for administration programs. Personally I think that where 
there is a will there is a way.


Software is intangible, irregardless of the fact that it might show up 
on a physical medium. You can't compare work of the mind with work of 
physical crafts-- one is not more worthy of money then the other, but 
they are *different*.
Like poetry, music and the such, which indeed share much of the same 
problems as software. Still they flourished even before rule 
enforcement. I am sure that Muhammad ibn Mūsā al-Khwārizmī, didn't have 
too much problems in that regard.


What's wrong with software copyrights? Don't lump intellectual
property issues together, they're not comparable. Copyrights have
nothing at all to do with patents which have nothing at all to do
with trademarks. Each is a very different set of law.

Very true and in my opinion they all share the same trait,
although they are once made to make sure the original author gets
credit and profit for his/her work they are primarily used now to
profit beyond reasonableness and actually encumber future
development and good use, IMHO they actually hinder the
intellectual development of the human race.


You say 'very true' but then you lump them all together again. They 
are not at all for the same thing.
I said they share a same trait, I did not say they where the same thing 
and above that I said

Re: Picking a license

2010-05-08 Thread Martin P. Hellwig

On 05/08/10 09:37, Steven D'Aprano wrote:
cut

If encouraging third parties to take open source code and lock it up
behind proprietary, closed licences *isn't* a moral hazard, then I don't
know what one is.

cut
I fail to see what is morally wrong with it. When I ,as the author, 
share my work to the public, I should have made peace with the fact that 
I, for all intends and purposes, lost control over its use. And that is 
rightfully so; who am I to say: Yeah you can use it but only once in a 
blue moon when Jupiter aligns with Mars and a solar eclipse reaches its 
high on Greenwich at noon exactly.


But just for argument sake say that you can put restrictions on the use, 
who is going to enforce these restrictions? The author/Police/special 
interest groups?


Anyway I usually put stuff under the MIT/BSD license, but when I can I 
use the beerware license (http://people.freebsd.org/~phk/) and I fully 
agree with PHK's reasoning.


--
mph


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


Re: Teaching Programming

2010-05-05 Thread Martin P. Hellwig

On 05/04/10 12:59, superpollo wrote:

Martin P. Hellwig ha scritto:

cut

For the corner cases (I can think of a couple) it is good to know you
can use ';' most of the time.



most but not always as i noted (think about loops or function definition)


Well through in some exec magic then, for example:
for number in [1,2,3,4]:
def nprint(number):
print(number)
number += 1
nprint(number

translates to:

 exec('for number in [1,2,3,4]:\n\tdef 
nprint(number):\n\t\tprint(number)\n\tnumber += 1\n\tnprint(number)')

2
3
4
5

But if you have an example why indentation is still a problem please 
give it :-)


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


Re: Teaching Programming

2010-05-04 Thread Martin P. Hellwig

On 05/04/10 11:28, superpollo wrote:

Samuel Williams ha scritto:

I personally like indentation.

I just wonder whether it is an issue that some people will dislike.

cut

there might be problems if for example you
generate code from a one-line template.

cut
Well a one-line template code generator are great and such, but if the 
output should be human readable it is necessary to have at least some 
form of mark-up control on it. Like newlines and indentations.


On the other hand if it is only meant to generate executable code, 
generating an interpreted code might not be the best solution for the 
actual problem.


For the corner cases (I can think of a couple) it is good to know you 
can use ';' most of the time.


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


Re: Linux servers, network and file names

2010-04-23 Thread Martin P. Hellwig

On 04/22/10 15:13, Infinity77 wrote:
cut


For me:  //SERVER/gavana/Folder/FileName.txt
Colleague: //SERVER/Colleague/Folder/FileName.txt

So, no matter what I do, the file name stored in the database is user-
dependent and not universal and common to all of us.

If that user dependent part happens to be equal to the login name, then 
what you could do is replace is with the username variable (I believe 
%USERNAME% on windows) instead.


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


Re: Building a GUI Toolkit

2010-04-20 Thread Martin P. Hellwig

On 04/20/10 19:53, Lie Ryan wrote:
cut


Rather than writing a windowing toolkit from the low-level, I would
rather like to see some wrapper for existing windowing toolkit which
uses more pythonic idioms.

Most popular python GUI toolkit currently in use are only a simple thin
wrapper over the library they're wrapping and exposes a lot of the
design considerations of the language that the toolkit was originally
written in. Yes, even Tkinter that comes with the standard lib is a hack
on top of python and looks much more Tcl-ish than pythonic.

I have always had the idea of writing a windowing toolkit wrapper that
creatively uses python features for maximum expressiveness (e.g.
decorator, with-statement, for-each), but never got the time to write
anything like that.


Well I suppose you could piggyback on tk for that and rewrapping tkinter 
to be more pythonic is probably more doable than rewriting it from scratch.


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


Re: Building a GUI Toolkit

2010-04-20 Thread Martin P. Hellwig

On 04/20/10 21:15, Martin P. Hellwig wrote:

On 04/20/10 19:53, Lie Ryan wrote:
cut


Rather than writing a windowing toolkit from the low-level, I would
rather like to see some wrapper for existing windowing toolkit which
uses more pythonic idioms.

Most popular python GUI toolkit currently in use are only a simple thin
wrapper over the library they're wrapping and exposes a lot of the
design considerations of the language that the toolkit was originally
written in. Yes, even Tkinter that comes with the standard lib is a hack
on top of python and looks much more Tcl-ish than pythonic.

I have always had the idea of writing a windowing toolkit wrapper that
creatively uses python features for maximum expressiveness (e.g.
decorator, with-statement, for-each), but never got the time to write
anything like that.


Well I suppose you could piggyback on tk for that and rewrapping tkinter
to be more pythonic is probably more doable than rewriting it from scratch.



On second thought, if you would like borderless windows (for example to 
implement all widgets from scratch), you run into troubles, as 
overrideredirect also affects the keyboard focus, so you can't use the 
keyboard in any widget created. And also it would be ice to still have 
an iconify option.


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


Re: Building a GUI Toolkit

2010-04-18 Thread Martin P. Hellwig

On 04/18/10 12:49, Tim Diels wrote:

Hi

I was thinking of writing a GUI toolkit from scratch using a basic '2D
library'. I have already come across the Widget Construction Kit.

My main question is: Could I build a GUI toolkit of reasonable
performance with the Widget Construction Kit, would it still feel more
or less lightweight? By reasonable I mean that the user wouldn't think
of the interface as being slow or unresponsive.

I've also thought of using pyglet to build widgets with, but this would
seem to be overkill. As a side question: by using opengl, the work would
be delegated to the GPU rather than the CPU; is this always a good
thing, or does it have downsides as well (performance, power usage, ...)?

Are there any other libraries that may be of interest to me?

Thanks in advance


It probably depends on how low level you want to go, I have pondered 
about the possibility myself to have an all python(ic) gui toolkit, 
capable of writing a (x11) windowing manager itself with.
But I decided that using tkinter and just live with its rough corners is 
more bang for the buck for me than to reimplement tkinter badly.


However as a thought exercise I did spend some energy on it and I had 
the following ideas.

- Need to have direct access to at least x11, cocoa  and win32gui;
  or even lower than that (if possible/reasonable).
- Only need to abstract enough so I can display a borderless window full
  screen or on any position/size.
- Need to provide a wrapper for the input devices too, e.g.: keyboard,
  mouse, joystick, touchscreen, etc.
- Optionally graphical acceleration (OpenGL, DirectX, SDL?)
- It would be good that fonts, windows, decoration and icons are all SVG
  so that all these items can scale independently.

I also had some more questions:
- How about providing an interface for video playback?
- How about audio?
- How about printing?
- How about multiple displays?
- How about odd sized displays (round, triangle, etc)?
- How to handle 'legacy' gui applications?
- Need to remain completely BSD licensed so that it is possible that it
  might some day be incorporated in the standard distribution.

So I gave up on it as it seem to me much to much work for not enough 
ROI, but I still would welcome anyone giving it a shot :-)


--
mph

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


Re: Unit testing errors (testing the platform module)

2010-04-13 Thread Martin P. Hellwig

On 04/13/10 15:01, John Maclean wrote:

I normally use  languages unit testing framework to get a better
understanding of how a language works. Right now I want to grok the
platform module;


  1 #!/usr/bin/env python
   2 '''a pythonic factor'''
   3 import unittest
   4 import platform
   5
   6 class TestPyfactorTestCase(unittest.TestCase):
   7 def setUp(self):
   8 '''setting up stuff'''
  13
  14 def testplatformbuiltins(self): 15
'''platform.__builtins__.blah '''
  16 self.assertEquals(platform.__builtins__.__class__, type 'd
 ict')
  17
  18
  19 def tearDown(self):
  20 print 'cleaning stuff up'
  21
  22 if __name__ == __main__:
  23 unittest.main()


Is there an error in my syntax? Why is my test failing? Line 16.


python stfu/testing/test_pyfactor.py
Fcleaning stuff up

==
FAIL: platform.__builtins__.blah
--
Traceback (most recent call last):
   File stfu/testing/test_pyfactor.py, line 16, in testplatformbuiltins
 self.assertEquals(platform.__builtins__.__class__, type 'dict')
AssertionError:type 'dict'  != type 'dict'

--
Ran 1 test in 0.000s

FAILED (failures=1)



What happens if you change this line:
self.assertEquals(platform.__builtins__.__class__, type 'dict')

To something like:
self.assertEquals(platform.__builtins__.__class__, type(dict()))

or
self.assertEquals(str(platform.__builtins__.__class__), type 'dict')

--
mph

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


Re: 2.7 beta 1

2010-04-12 Thread Martin P. Hellwig

On 04/12/10 06:57, Mensanator wrote:

On Apr 11, 6:08 pm, Steven D'Apranost...@remove-this-
cybersource.com.au  wrote:

On Sun, 11 Apr 2010 11:54:04 -0700, Mensanator wrote:

On Apr 11, 11:53 am, Steven D'Apranost...@remove-this-
cybersource.com.au  wrote:

On Sat, 10 Apr 2010 21:08:44 -0700, Mensanator wrote:

cut

Maybe because I'm a user, not a developer.


You write code. You use an Integrated DEVELOPMENT Environment. That makes
you a developer.


Being a little pedantic here, aren't we? Would it help if I said
professional
developer? After all, just because I dabble in Collatz Conjecture
research as
a hobby, it doesn't give me the right to go around calling myself a
mathematician.


cut
really pedantic state='on'
Well professional in IT context often just means that you do it for a 
living, doesn't necessarly say you are any good in what you are doing.
I am especially wary to certified professionals by biased 'institutes' 
like Cisco and Microsoft. /really pedantic


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


Re: Cleanup guarantees?

2010-04-09 Thread Martin P. Hellwig

On 04/09/10 05:13, Alf P. Steinbach wrote:
cut socket open/close


Second, I'm unable to find documentation of when they're called and what
they do. It seems that (A) when the connection object's stream is
exhausted by reading, its close() method is called automatically, and
(B) that when the text_reader object's close method is called it calls
the close method of the wrapped stream (i.e. on the connection object).
But where is this documented?

If nothing else, my guess would be the source somewhere between the 
urllib and socket module.


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


Re: In disGuiodoise?

2010-04-05 Thread Martin P. Hellwig

On 04/05/10 00:05, r wrote:
knip

However i have also considered that maybe *all* the well knowns are
in fact the many colorful personalities of Guido.


knip

De vraag is dan natuurlijk of al zijn persoonlijkheden nog steeds 
nederlands machtig zijn.


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


Re: off topic but please forgive me me and answer

2010-04-03 Thread Martin P. Hellwig

On 04/03/10 14:38, Steve Holden wrote:
cut


If you think you will persuade a crackpot to drop his lunacy by logical
argument you are clearly an optimist of the first water. But since I
like a challenge (and bearing in mind this is OT so I don't claim to be
an expert) you might try first of all persuading him to agree to the
commutativity of multiplication (i.e. x * y == y * x for any x and y).

If he agrees to that, then get him to agree that x * 1 == x for any x.

If he agrees to that, then set x = 1/2 and see if he'll agree that 1/2 *
1 == 1/2.

If he does, then surely he must also agree that 1 * 1/2 == 1/2, i.e.
multiplication can indeed make things smaller.

Good luck, though. Crackpots aren't generally responsive to appeals to
rational thinking.



I am replying to this post not because I disagree but because it 
postalogically  fits the best (I am by no means an expert either).


IMHO, the crackpot in this regard is actually partially right, 
multiplication does mean that the number must get bigger, however for 
fractions you multiply four numbers, two numerators and two 
denominators. The resulting numerator and denominator by this 
multiplication get indeed bigger.


--
mph

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


Re: off topic but please forgive me me and answer

2010-04-03 Thread Martin P. Hellwig

On 04/03/10 16:17, Steven D'Aprano wrote:

On Sat, 03 Apr 2010 15:43:41 +0100, Martin P. Hellwig wrote:


I am replying to this post not because I disagree but because it
postalogically  fits the best (I am by no means an expert either).

IMHO, the crackpot in this regard is actually partially right,
multiplication does mean that the number must get bigger, however for
fractions you multiply four numbers, two numerators and two
denominators. The resulting numerator and denominator by this
multiplication get indeed bigger.


But you're not multiplying four numbers, you're multiplying two numbers.
One-half is not two numbers, that would be a tuple or a list or
possibly a coordinate pair. One-half is a single number, the number which
if you double it gives one.



I disagree with you there, but I only disagree with you on the 
definition of the syntax, not with the logic nor the explanation.
I am not going to argue about syntax, since I don't think I would make a 
great argument (being the devil's advocate) and also because I believe 
when argued correctly, agreeing on disagreement of syntax allows even 
the greatest untruth be true and false at the same time.


Excuse me please I need to feed Schroedinger's cat :-)

--
mph



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


Re: off topic but please forgive me me and answer

2010-04-03 Thread Martin P. Hellwig

On 04/03/10 16:46, Patrick Maupin wrote:

On Apr 3, 9:43 am, Martin P. Hellwig  IMHO, the crackpot in this
regard is actually partially right,

multiplication does mean that the number must get bigger, however for
fractions you multiply four numbers, two numerators and two
denominators. The resulting numerator and denominator by this
multiplication get indeed bigger.


That argument is great!  Just make sure that you've managed to leave
before the class has to learn about irrational numbers that don't
*have* numerators and denominators ;-)


Yeah but those numbers have their own problems anyway, one of them being 
that you are never sure how big/small they actually are, so by that 
logic you could argue that if you can not give an exact measure for a 
given number, bickering over it size after an operation is pretty 
pointless (pun intended) :-)


Beside the only number that really matters is 42 ;-)

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


Re: Get Eclipse/PyDev to run scripts that don't end in .py

2010-03-31 Thread Martin P. Hellwig

On 03/31/10 22:37, J wrote:

Is there any way to tell PyDev in Eclipse to run a script that doesn't
end in .py?  Even if I have to go and manually set something for each
file...

I've inherited (in a manner of speaking) a dev project that is done in
python2.6... I pulled the latest dev branch and have it opened as a
project in Eclipse, however, none of the python files end in .py, so
PyDev only sees them as text files.  And because of that, I can't run
them in Eclipse to try my changes, debug, etc.

So, is there a way to make them show up as python code without the .py
extension?  Because of this, I also don't get any of the fancy
indenting and highlighting that I'd normally get...

Cheers,

Jeff


You probably need to do that one level higher, i.e. in Eclipse (hint: 
PreferencesGeneralEditorsFile Associations don't forget to also add 
a 'Associated editors' for your new defined file type).


I do have a couple of remarks though.

It sounds to me like you inherited something of more or less a 'shipped' 
product. Perhaps it would be wise to invest some time to restructure the 
project so that it works nicely with all the tools you have (unit 
testing, coverage, refactoring, etc.) and build a script that from your 
source builds the actually release (resembling that what you have 
inherited).


whining_mode status='on'
This question would probably have been more suitable in 
http://sourceforge.net/projects/pydev/forums/forum/293649 (that is the 
PyDev forum), and it is likely that they would have sent you through to 
http://www.eclipse.org/forums/ .

/whining_mode

--
mph



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


Don't understand behavior; instance form a class in another class' instance

2010-03-25 Thread Martin P. Hellwig

Hi all,

When I run the following snippet (drastically simplified, to just show 
what I mean):


import platform, sys

class One(object):
def __init__(self):
self.one = True

def change(self):
self.one = False

class Two(object):
def __init__(self):
self._instance_one = One()
self.one = self._instance_one.one
self.change = self._instance_one.change

if __name__ == '__main__':
print(sys.version)
print(platform.machine())
print(80*'#')
TEST1 = One()
print(TEST1.one)
TEST1.change()
print(TEST1.one)
TEST1 = None
print(80*'#')
TEST2 = Two()
print(TEST2.one)
TEST2.change()
print(TEST2.one


I get the following result:


[GCC 4.2.1 20070719  [FreeBSD]]
amd64

True
False

True
True



What I don't understand why in the second test, the last boolean is True 
instead of (what I expect) False.
Could somebody enlighten me please as this has bitten me before and I am 
confused by this behavior.


Thanks in advance

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


Re: Don't understand behavior; instance form a class in another class' instance

2010-03-25 Thread Martin P. Hellwig

On 03/25/10 23:41, Christian Heimes wrote:

Martin P. Hellwig schrieb:

What I don't understand why in the second test, the last boolean is True
instead of (what I expect) False.
Could somebody enlighten me please as this has bitten me before and I am
confused by this behavior.


Hint: TEST2.one is not a reference to TEST2.__instance_one.one. When you
alter TEST2.__instance_one.one you don't magically change TEST2.one,
too. Python doesn't have variables like C pointers. Python's copy by
object (or share by object) behavior can be understand as labels. The
label TEST2.one references the same object as TEST2.__instance_one.one
until you change where the label TEST2.__instance_one.one points to.

Christian



Ah okay thanks for the explanation, Am I correct in thinking (please 
correct me if I mangle up the terminology and/or totally are in the 
wrong ballpark) that this is more or less because the label of the first 
class is to an object (boolean with value False)
and the label of the second class does not cascade to the first label 
for looking something up but instead during assignment sees that it is a 
label to an object instead of the object itself thus copies the label 
content instead?


I probably expected classes namespaces to behave in about the same way 
as lists and dictionaries do, don't know where I picked that up.


Thanks again,

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


Re: Don't understand behavior; instance form a class in another class' instance

2010-03-25 Thread Martin P. Hellwig

On 03/26/10 01:10, Rhodri James wrote:
cut


Pretty much. In the sense that you're thinking of, every assignment
works that way, even the initial TEST1 = One(). Assignment binds names
to objects, though you have to be aware that names can be such exotic
things as t, a[15] or TEST2.__instance_one.one


I probably expected classes namespaces to behave in about the same way
as lists and dictionaries do, don't know where I picked that up.


They do, in fact, which isn't terribly surprising considering that class
namespaces are implemented with dictionaries. The distinction you're
missing is that lists and dictionaries are mutable, while booleans
aren't; you can change the contents of a dictionary, but you can't
change the 'contents' of a boolean.



All makes sense now, thanks Rhodri  Christian.

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


Re: Pythonic way to trim and keep leading and trailing whitespace

2010-03-23 Thread Martin P. Hellwig

On 03/23/10 23:38, Tim Chase wrote:
cut

Just in case you're okay with a regexp solution, you can use

  s = \t\tabc def 
  import re
  r = re.compile(r'^(\s*)(.*?)(\s*)$')
  m = re.match(s)
  m.groups()
('\t\t', 'abc def', ' ')
  leading, text, trailing = m.groups()

cut
Ahhh regex, the hammer, Swiss Army Knife, cable tie, duct tape, 
superglue and soldering iron, all wrapped in one*. Mastery of it will 
enable you to drive the nails in your coffin at an incomparable speed. :-)


*Yes I was a sysadmin, why do you ask?
--
mph
--
http://mail.python.org/mailman/listinfo/python-list


Re: Need to create subprocess...

2010-03-18 Thread Martin P. Hellwig

On 03/18/10 16:17, drstoka wrote:

Hello,

I have to run a program as a child process inside my python program and
redirect it's output through a pipe to a parent program process.
So, I wrote this:

pipe = Popen('example_program', shell=True, bufsize=0, stdout=PIPE).stdout

and it works great.

Now, in parent program I need to wait for a some time and if a child
(example_program) does not finish in that time, kill the child.

How do I do that? Please help.


Try searching around for threading.thread python it should give you 
some clues, if you can't work through the info (it can be a bit hard to 
digest), just post here an example of your test code along with what you 
expected and what didn't happen.


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


Re: multiprocessing on freebsd

2010-03-17 Thread Martin P. Hellwig

On 03/17/10 13:30, Tim Arnold wrote:

Hi,
I'm checking to see if multiprocessing works on freebsd for any
version of python. My server is about to get upgraded from 6.3 to 8.0
and I'd sure like to be able to use multiprocessing.

I think the minimal test would be:
-
import multiprocessing
q = multiprocessing.Queue()
-

with 6.3, I get

  File /usr/local/lib/python2.6/multiprocessing/__init__.py, line
212, in Queue
 from multiprocessing.queues import Queue
   File /usr/local/lib/python2.6/multiprocessing/queues.py, line 22,
inmodule
 from multiprocessing.synchronize import Lock, BoundedSemaphore,
Semaphore, Condition
   File /usr/local/lib/python2.6/multiprocessing/synchronize.py, line
33, inmodule
  function, see issue 3770.)
ImportError: This platform lacks a functioning sem_open
implementation, therefore, the required synchronization primitives
needed will not function, see issue 3770.



Build mine from ports, with the following options (notice SEM  PTH):
[mar...@aspire8930 /usr/home/martin]$ cat /var/db/ports/python26/options
# This file is auto-generated by 'make config'.
# No user-servicable parts inside!
# Options for python26-2.6.4
_OPTIONS_READ=python26-2.6.4
WITH_THREADS=true
WITHOUT_HUGE_STACK_SIZE=true
WITH_SEM=true
WITH_PTH=true
WITH_UCS4=true
WITH_PYMALLOC=true
WITH_IPV6=true
WITHOUT_FPECTL=true

[mar...@aspire8930 /usr/home/martin]$ uname -a
FreeBSD aspire8930 8.0-STABLE FreeBSD 8.0-STABLE #3: Wed Feb  3 17:01:18 
GMT 2010 mar...@aspire8930:/usr/obj/usr/src/sys/ASPIRE8930  amd64

[mar...@aspire8930 /usr/home/martin]$ python
Python 2.6.4 (r264:75706, Mar 17 2010, 18:44:24)
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd8
Type help, copyright, credits or license for more information.
 import multiprocessing as mp
 queue = mp.Queue()


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


Re: import antigravity

2010-03-16 Thread Martin P. Hellwig

On 03/16/10 19:30, Hans Mulder wrote:

Ulrich Eckhardt wrote:

Chris Rebert wrote:

You're a bit behind the times.
If my calculations are right, that comic is over 2 years old.


import timetravel


I think you mean:

from __future__ import timetravel


-- HansM


Well according to Marty it is:
from __back_to_the_future import DeLorean

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


Re: xml-rpc

2010-03-14 Thread Martin P. Hellwig

On 03/14/10 08:14, ahmet erdinc yilmaz wrote:

Hello,

Recenetly we are developing a senior project and decide to use xmlrpclib.
However I have some questions. In the documentation I could not find any
clue about
handling requests? Does the server handles each request in a separate
thread? Or is
there some queuing mechanism for client calls? Thanks in advance.


--erdinc


How I usually tackle stuff like this:
[mar...@aspire8930 /usr/home/martin]$ python
Python 2.6.4 (r264:75706, Jan 31 2010, 20:52:16)
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd8
Type help, copyright, credits or license for more information.
 import SimpleXMLRPCServer
 help(SimpleXMLRPCServer)
read it and somewhere at CLASSES it says
CLASSES

BaseHTTPServer.BaseHTTPRequestHandler(SocketServer.StreamRequestHandler)
SimpleXMLRPCRequestHandler
SimpleXMLRPCDispatcher
CGIXMLRPCRequestHandler
SimpleXMLRPCServer(SocketServer.TCPServer, SimpleXMLRPCDispatcher)
SocketServer.TCPServer(SocketServer.BaseServer)
SimpleXMLRPCServer(SocketServer.TCPServer, SimpleXMLRPCDispatcher)

Aah so it is based on SocketServer, lets have a look at that:

 import SocketServer
 help(SocketServer)
Help on module SocketServer:
reading it and then it says

There are five classes in an inheritance diagram, four of which 
represent

synchronous servers of four types:

++
| BaseServer |
++
  |
  v
+---++--+
| TCPServer |---| UnixStreamServer |
+---++--+
  |
  v
+---+++
| UDPServer |---| UnixDatagramServer |
+---+++

So the base of all these servers is BaseServer, hmm somebody must have a 
laugh right now :-)


Okay lets have a look at that then:

 import BaseServer
Traceback (most recent call last):
  File stdin, line 1, in module
ImportError: No module named BaseServer

Hmmm okay, lets have a look at the SocketServer source itself then, but 
where is it?

 SocketServer.__file__
'/usr/local/lib/python2.6/SocketServer.pyc'

I bet that the non compiled file is in the same directory, let's have a 
look at it with less.


 quit()
[mar...@aspire8930 /usr/home/martin]$ less 
/usr/local/lib/python2.6/SocketServer.py


And there it says among other interesting stuff:

# The distinction between handling, getting, processing and
# finishing a request is fairly arbitrary.  Remember:
#
# - handle_request() is the top-level call.  It calls
#   select, get_request(), verify_request() and process_request()
# - get_request() is different for stream or datagram sockets
# - process_request() is the place that may fork a new process
#   or create a new thread to finish the request
# - finish_request() instantiates the request handler class;
#   this constructor will handle the request all by itself

def handle_request(self):
Handle one request, possibly blocking.

Respects self.timeout.

# Support people who used socket.settimeout() to escape
# handle_request before self.timeout was available.
timeout = self.socket.gettimeout()
if timeout is None:
timeout = self.timeout
elif self.timeout is not None:
timeout = min(timeout, self.timeout)
fd_sets = select.select([self], [], [], timeout)
if not fd_sets[0]:
self.handle_timeout()
return
self._handle_request_noblock()

def _handle_request_noblock(self):
Handle one request, without blocking.

I assume that select.select has returned that the socket is
readable before this function was called, so there should be
no risk of blocking in get_request().

try:
request, client_address = self.get_request()
except socket.error:
return
if self.verify_request(request, client_address):
try:
self.process_request(request, client_address)
except:
self.handle_error(request, client_address)
self.close_request(request)


I leave the remaining parts of your question as an exercise :-)

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


  1   2   3   4   >