Oblique Strategies

2005-09-14 Thread robin
The Oblique Strategies were originally a set of one-hundred cards,
each bearing a short phrase. They were devised by Brian Eno and Peter
Schmidt as ways of working through creative problems. When a blockage
occurs, draw a card, and see if it can direct you in a tangential way
that helps solve the problem.

I have created a Python implementation that includes two different
decks. Since one of these is my own, I can be sure this is an original
contribution for all of you Python coders stuck on a problem!

Surf:
http://noisetheatre.blogspot.com/2005/09/oblique-strategies.html

-
robin
noisetheatre.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Oblique Strategies

2005-09-15 Thread robin
Tom Anderson <[EMAIL PROTECTED]> wrote:

>On Wed, 14 Sep 2005, robin wrote:
>
>> The Oblique Strategies were originally a set of one-hundred cards, each 
>> bearing a short phrase. They were devised by Brian Eno and Peter Schmidt 
>> as ways of working through creative problems. When a blockage occurs, 
>> draw a card, and see if it can direct you in a tangential way that helps 
>> solve the problem.
>
>Neat!
>
>I can't help but feel that putting the strategies in a file and using 
>'fortune' to pick them would have been slightly simpler, but since i don't 
>actually seem to have fortune on my machine, i'm actually rather happy 
>that you've done this.

The best things about this approach are that code and data are in one
file and you don't need to be on a machine with fortune. (My machines
seem to mostly have misfortune, aka Windows.)

I'm happy how Python reduces most small problems down to the most
trivial of exercises. This is less a program than a list of text
strings.

-
robin
noisetheatre.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Britney Spears nude

2005-09-17 Thread robin
"Ian Osgood" <[EMAIL PROTECTED]> wrote:

>Wouldn't Natasha Kinski be more apropos for this newsgroup?  (In case
>Python needs a poster girl...)
>
>http://snakeskins0.tripod.com/eden.html

That would be Nastassja Kinski.

But you are correct, it is a python. Photo by Richard Avedon.

-
robin
noisetheatre.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


wanted: visual report templating system

2005-03-22 Thread robin
I am looking for a client/server reporting tool to use with a web
application built in Python. 

It would consist of three parts:

1. a data definition & retrieval engine that interfaces to RDBMS or
other data files

2. a visual designer in which a nontechnical person can create a
report layout template (supporting charts, text, graphics, etc.)

3. a server engine to merge the two and create on-the-fly reports when
requested programmatically.

A similar application would be the ReportMill product for Java:
http://www.reportmill.com/product/

Price should not exceed 4 figures (in US$).

Seems like a reasonable expectation, but all I am readily aware of in
this market is ReportLab. Any suggestions?

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


Re: SimpleRPCServer

2005-04-03 Thread robin
Skip Montanaro <[EMAIL PROTECTED]> wrote:

>First, from my reading of SimpleXMLRPCServer, I don't think _dispatch()
>belongs at that level.  It belongs in the request handler class or in a
>separate dispatcher class, depending on what version of Python you're using.

Quite so. As a variant I just use verify_request() to persist the
client IP address, and then wait until _dispatch() to do everything
else.

class RPCServer(SimpleXMLRPCServer):
def verify_request(self, handler, address):
self.client_ip, self.client_port = address
return True

def _dispatch(self, method, args):
do_something(self.client_ip)

Though using a firewall would not be remiss. :-)

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


Re: Python Cookbook, 2'nd. Edition is published

2005-04-04 Thread robin
Cameron Laird wrote:

>IT'S IN THERE.  The answer to all questions--well, to 
>surprisingly many questions--is in the Second Edition.
>Even questions about the Second Edition itself are
>answered therein.  So, the summary:  if in doubt, as-
>sume that the Second Edition has what you want.

It even has been known to answer questions about the Third Edition,
using the "from future" construct publishers have wanted for years.
:-)

This is a fantastic book and my single favourite Python paper
reference. It examines problems, even those which at first seem
trivial, with an unexpected rigour and invigorating sense of
adventure. Alex Martelli and the others should be congratulated.

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


Re: TOC of Python Cookbook now online (was Re: author index for Python Cookbook 2?)

2005-04-04 Thread robin
[EMAIL PROTECTED] wrote:

>I emailed the O'Reilly webmaster, and the table of contents are now
>online at http://www.oreilly.com/catalog/pythoncook2/toc.html and also
>listed below.

Unfortunately there is no list of authors for the sections in the
book. This is likely its only shortcoming!

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


html 2 plain text

2006-05-28 Thread robin
hi,
i remember seeing this simple python function which would take raw html
and output the content (body?) of the page as plain text (no <..> tags
etc)
i have been looking at htmllib and htmlparser but this all seems to
complicated for what i'm looking for. i just need the main text in the
body of some arbitrary webbpage to then do some natural-language
processing with it...
thanks for pointing me to some helpful resources!

robin

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


Re: html 2 plain text

2006-05-28 Thread robin
lucks yummy. merci beaucoup.

robin

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


summarize text

2006-05-29 Thread robin
hello list,

does anyone know of a library which permits to summarise text? i've
been looking at nltk but haven't found anything yet. any help would be
very welcome.
thank you all in advance,

robin

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


problem with google api / xml

2006-05-31 Thread robin
hello,

i installed SOAPpy 0.12.0 and pyXML 0.8.4 in order to try out the
google-search example in diveintopython
http://diveintopython.org/soap_web_services/index.html
however, i'v been trying and trying and won't get it to work :-(
whenever i run this code, i get the attached exception...

from SOAPpy import WSDL
WSDLFILE = '/pathtomy/googleapi/GoogleSearch.wsdl'
APIKEY = ''
_server = WSDL.Proxy(WSDLFILE)

any help would be very much appreciated!
thanks in advance,
robin

Traceback (most recent call last):
  File "", line 1, in ?
  File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/SOAPpy/WSDL.py",
line 67, in __init__
self.wsdl = reader.loadFromString(str(wsdlsource))
  File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/SOAPpy/wstools/WSDLTools.py",
line 47, in loadFromString
return self.loadFromStream(StringIO(data))
  File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/SOAPpy/wstools/WSDLTools.py",
line 28, in loadFromStream
document = DOM.loadDocument(stream)
  File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/SOAPpy/wstools/Utility.py",
line 602, in loadDocument
return xml.dom.minidom.parse(data)
  File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/_xmlplus/dom/minidom.py",
line 1915, in parse
return expatbuilder.parse(file)
  File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/_xmlplus/dom/expatbuilder.py",
line 930, in parse
result = builder.parseFile(file)
  File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/_xmlplus/dom/expatbuilder.py",
line 207, in parseFile
parser.Parse(buffer, 0)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1,
column 0

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


Re: summarize text

2006-05-31 Thread robin
thanks for all your replies. lemur looks pretty interesting!
robin

gene tani wrote:
> robin wrote:
> > hello list,
> >
> > does anyone know of a library which permits to summarise text? i've
> > been looking at nltk but haven't found anything yet. any help would be
>
> unclear what you're asking, maybe look at:
> http://www.cs.waikato.ac.nz/~ml/weka/index.html
>
> http://www.kdnuggets.com/software/suites.html
> http://www.ailab.si/orange
>
> http://mallet.cs.umass.edu/index.php/Main_Page
> http://minorthird.sourceforge.net/
> http://www.dia.uniroma3.it/db/roadRunner/
> 
> http://www.lemurproject.org/

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


Re: problem with google api / xml

2006-05-31 Thread robin
hi kent,

thanks for your reply. in fact it was me who put "pathtomy" into the
path and exchanged my apikey with ""
i prefer not everyone to know the name of my directories and even less
my apikey. so the problem isn't there :-(
hope to find some other solution
thanks!!

robin


Mike Kent wrote:
> robin wrote:
>
> > from SOAPpy import WSDL
> > WSDLFILE = '/pathtomy/googleapi/GoogleSearch.wsdl'
> > APIKEY = ''
> > _server = WSDL.Proxy(WSDLFILE)
>
> Robin, note this part of the URI set in WSDLFILE:
> '/pathtomy/googleapi'.  Get it?  'path to my google api'.  You must set
> this part to the actual path where the file 'GoogleSearch.wsdl' is
> found.  In addition, doesn't APIKEY = '' look a bit odd to you?
> Hmm, what could this mean.  APIKEY.  Perhaps you need to get an API key
> from Google in order to use their search API, and fill it in there?
> 
> ;-)

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


Re: ANN: Pocoo (bulletin board software) 0.1 beta released

2006-09-21 Thread robin
Georg Brandl <[EMAIL PROTECTED]> wrote:
>The 0.1 release is not meant to be feature complete. It's more like a preview
>to show off what's already there. If you like the idea, *feel free to join us!*

Looks very nice so far. Will fill an important gap in Python apps.

Oh, and you've been blogged:
http://diagrammes-modernes.blogspot.com/

-
robin
noisetheatre.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using Beautiful Soup to entangle bookmarks.html

2006-09-21 Thread robin
"George Sakkis" <[EMAIL PROTECTED]> wrote:

>Here's what I came up with:
>http://rafb.net/paste/results/G91EAo70.html. Tested only on my
>bookmarks; see if it works for you.

That URL is dead. Got another?

-
robin
noisetheatre.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: beta.python.org content

2006-01-30 Thread robin
Steve Holden <[EMAIL PROTECTED]> wrote:

>How does
>
>   http://beta.python.org/about/beginners/
>
>look?

There are several things wrong with the interface.

First, I count seven ways of formatting a link. This is approximately
five too many and can be fixed as follows.

"For Beginners" is italicised, supposedly to indicate it is the page
we are currently on. This overloads the normal expected meaning of
italics with something unexpected. And what is the point of a link to
the current page? This should be plain text.

"About" is a top-level menu which has been expanded; to indicate this
there is a yellow bar. This is not necessary since the viewer can see
the menu is expanded. :-)

The menu items underneath an expanded heading should be in the same
format, but offset. Same format says "menu"; offset says "child."

The last menu items are in different formats yet again (typeface and
size). I see no reason for this.

Once this has been done there will be but two different ways of
formatting a link: a menu and a link in the page body.

In terms of page space, the horizontal bar at the top seems wasted.
Perhaps the vertical bar is all that is needed? The other elements
could be relocated.

The menu is structured with a list and formatted with CSS. Good!

Given that there is already a hierarchical organisation of the content
voa the collapsing menu bar, I do not think that another
representation of this is required above the main page text. I would
ditch the link trail.

Overall, the look is very "safe corporate". I myself would have gone
for a funkier (though still elegant) look. The energy of the Python
community is not being communicated. The vim of the language is
diluted. This is not playing to Python's strengths.

Yes, i have been known to do this for a living. Had I been aware
earlier, I would have been happy to help with the redesign. How can I
now?

P.S. I am not averse to the new logo. It is professional, clean, and
symbolic. Maybe there are more ideal choices but we have to get beyond
little green cartoon snakes eventually.
-
robin
noisetheatre.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How many web framework for python ?

2006-02-27 Thread robin
Steve Holden <[EMAIL PROTECTED]> wrote:

>Damn. More reading ...

Even more reading as of tomorrow, when I get my Web Application
Framework article up on my blog.

Even listing the vast number of frameworks & toolkits out there is
daunting, so I figured I may as well share my own outlook.

And FWIW, I have abandoned my own contribution, so that's one less out
in the wild!

-
robin
noisetheatre.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: new wooden door step - fixing and finishing

2006-02-27 Thread robin
Jeffrey Schwab <[EMAIL PROTECTED]> wrote:

>> I was wondering about treating it
>> wilth liberal amounts of Teak Oil or similar...
>
>Some people, when confronted with a problem, think "I know, I?ll use 
>Teak Oil."  Now they have two problems.

+1 QOTW

BTW, I integrated a similar line into one of my readings (I sideline
as a poet), a piece entitled "Advice For Modern Living". Goes like
this:

"When confronted with a conflict some people go to a solicitor for
advice. Now they have two problems."

-
robin
noisetheatre.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


changing params in while loop

2006-02-27 Thread robin
hi,

i'm a newbie, but please bear with me for a second.
i have this function inside a while-loop, which i'd like to loop
forever, but i'm not sure about how to change the parameters of my
function once it is running.
what is the best way to do that? do i have to use threading or is there
some simpler way?
here's some code to show the structure of the problem:

from time import *

b = 44

def printStuff(a):
print a
sleep(1)
print b
sleep(1)

while 1:
printStuff("bibi")

now how can i make printStuff() print "fifi" instead of "bibi" or 88
instead of 44 once it is running?

thank y'all for your help
do the snake!

robin

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


module webbrowser - open link in same window - osx

2006-05-18 Thread robin
hi,

i'm using the webbrowser module to open url's in safari or firefox.
specifically i'm using the
webbrowser.open('http://...', new=0)
command.

however, even though i say new=0 my url is always opened in a new
browser window.
what can i do, so my link is opened in an already open browser window?

thank you for your help,

robin

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


webbrowser module bug on os x?

2006-05-25 Thread robin
hi

it seems to me like the webbrowser command

webbrowser.open('http://www...', new=0)

does not work as advertised: all the urls open in seperate windows
regardless of the default browser (safari, firefox, mozilla). i do not
have this problem on windows...

can anyone help?
thank you in advance.

robin

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


best way to serve wsgi with multiple processes

2009-02-11 Thread Robin
Hi,

I am building some computational web services using soaplib. This
creates a WSGI application.

However, since some of these services are computationally intensive,
and may be long running, I was looking for a way to use multiple
processes. I thought about using multiprocessing.Process manually in
the service, but I was a bit worried about how that might interact
with a threaded server (I was hoping the thread serving that request
could just wait until the child is finished). Also it would be good to
keep the services as simple as possible so it's easier for people to
write them.

I have at the moment the following WSGI structure:
TransLogger(URLMap(URLParser(soaplib objects)))
although presumably, due to the beauty of WSGI, this shouldn't matter.

As I've found with all web-related Python stuff, I'm overwhelmed by
the choice and number of alternatives. I've so far been using cherrypy
and ajp-wsgi for my testing, but am aware of Spawning, twisted etc.
What would be the simplest [quickest to setup and fewest details of
the server required - ideally with a simple example] and most reliable
[this will eventually be 'in production' as part of a large scientific
project] way to host this sort of WSGI with a process-per-request
style?

Thanks!

Robin

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


Re: best way to serve wsgi with multiple processes

2009-02-11 Thread Robin
On Feb 11, 12:10 pm, Robin Becker  wrote:
> We've used forked fastcgi (flup) with success as that decouples the wsgi 
> process
> (in our case django) from the main server (in our case apache). Our reasons 
> for
> doing that were to allow the backend to use modern pythons without having to
> upgrade the server (which is required if using say mod_python). The wsgi 
> process
> runs as an ordinary user which eases some tasks.

Yes - I've done something very similar with ajp-wsgi (from the author
of flup; and which incidently performs very well works really nicely)
to go from apache -> wsgi. But the issue I'm asking about here is to
have multiple WSGI processes - ie to allow concurrent execution of
more than one web service at the time (since these are long running
computational soap web services). ajp-wsgi embeds a single python
interpreter so multiple running services would be effected by the GIL
- I imagine flup is similar (a single process on the python side).

So I'm not worried about decoupling from the web server - I'm happy to
use pure python server (which I guess is easier to setup) - but I want
the web server to dispatch requests to different processes running the
wsgi app. I've looked at Spawning, but couldn't get it to work and it
seems a little bit 'beta' for my taste (doesn't exit cleanly, leaves
worker processes running etc.)

Cheers

Robin



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


Re: best way to serve wsgi with multiple processes

2009-02-11 Thread Robin
On Feb 11, 1:28 pm, Robin  wrote:
> On Feb 11, 12:10 pm, Robin Becker  wrote:
>
> > We've used forked fastcgi (flup) with success as that decouples the wsgi 
> > process
> > (in our case django) from the main server (in our case apache). Our reasons 
> > for
> > doing that were to allow the backend to use modern pythons without having to
> > upgrade the server (which is required if using say mod_python). The wsgi 
> > process
> > runs as an ordinary user which eases some tasks.

I'm sorry - I originally missed the worked 'forked' and hence the
whole point of your message I think.

I looked at flup before but had forgotten about the forked version.
Having revisited it I think the forked version does keep a process
pool so each request is processed by a seperate process, which is
exactly what I wanted.

Cheers

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


Re: best way to serve wsgi with multiple processes

2009-02-11 Thread Robin
On Feb 11, 3:46 pm, Robin Becker  wrote:
> well the flup server for fast cgi supports forking if the server is declared 
> as
> an external process in apache. Then the top level of the flup process handles
> each request and passes it off to a forked worker. I cannot recall exactly, 
> but
> I believe that apache mod_fastcgi does the right thing when it comes to
> internally declared fastcgi handlers. For apache at least I think the 
> threading
> issues are handled properly.
>
> I think the preforkserver.py code handles all the threading issues for you
> (assuming it's not win32).

Thanks - I think if I go the flup route I would use AJP though - since
its very easy to setup with apache (1 proxy line) and mod_ajp comes as
standard. And then everything is very much seperated from the apache
process.

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


Re: SOAP client

2009-02-11 Thread Robin
On Feb 11, 3:33 pm, mk  wrote:
> Hi,
>
> I'm trying to consume a SOAP web service using Python.  So far I have
> found two libraries: SOAPpy and ZSI.  Both of them rely on PyXML which
> is no longer maintained (and there is no build for 64bit Windows and
> the setup.py doesn't seem to know how to build it on Windows).  Is
> there a live SOAP library for Python?  I'm sort of surprised that a
> common standard like SOAP is not more actively supported in Python.
> I'm probably missing something?
>
> Thanks,
> m

For consuming services, I've found suds to be the best client:
https://fedorahosted.org/suds/

For creating them, I've been using soaplib:
http://trac.optio.webfactional.com/

HTH,

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


Re: best way to serve wsgi with multiple processes

2009-02-11 Thread Robin
On Feb 11, 7:59 pm, Graham Dumpleton 
wrote:
> On Feb 11, 8:50 pm, Robin  wrote:
>
>
>
> > Hi,
>
> > I am building some computational web services using soaplib. This
> > creates a WSGI application.
>
> > However, since some of these services are computationally intensive,
> > and may be long running, I was looking for a way to use multiple
> > processes. I thought about using multiprocessing.Process manually in
> > the service, but I was a bit worried about how that might interact
> > with a threaded server (I was hoping the thread serving that request
> > could just wait until the child is finished). Also it would be good to
> > keep the services as simple as possible so it's easier for people to
> > write them.
>
> > I have at the moment the following WSGI structure:
> > TransLogger(URLMap(URLParser(soaplib objects)))
> > although presumably, due to the beauty of WSGI, this shouldn't matter.
>
> > As I've found with all web-related Python stuff, I'm overwhelmed by
> > the choice and number of alternatives. I've so far been using cherrypy
> > and ajp-wsgi for my testing, but am aware of Spawning, twisted etc.
> > What would be the simplest [quickest to setup and fewest details of
> > the server required - ideally with a simple example] and most reliable
> > [this will eventually be 'in production' as part of a large scientific
> > project] way to host this sort of WSGI with a process-per-request
> > style?
>
> In this sort of situation one wouldn't normally do the work in the
> main web server, but have a separarte long running daemon process
> embedding mini web server that understands XML-RPC. The main web
> server would then make XML-RPC requests against the backend daemon
> process, which would use threading and or queueing to handle the
> requests.
>
> If the work is indeed long running, the backend process would normally
> just acknowledge the request and not wait. The web page would return
> and it would be up to user to then somehow occassionally poll web
> server, manually or by AJAX, to see how progres is going. That is,
> further XML-RPC requests from main server to backend daemon process
> asking about progress.
>
> I do't believe the suggestions about fastcgi/scgi/ajp/flup or mod_wsgi
> are really appropriate as you don't want this done in web server
> processes as then you are at mercy of web server processes being
> killed or dying when part way through something. Some of these systems
> will do this if requests take too long. Thus better to offload real
> work to another process.

Thanks - in this case I am contrained to use SOAP (I am providing SOAP
services using soaplib so they run as a WSGI app). I choose soaplib
becuase it seems the simplest way to get soap services running in
Python (I was hoping to get this setup quickly).
So I am not really able to get into anything more complex as you
suggest... I have my nice easy WSGI app soap service, I would just
like it to run in a process pool to avoid GIL. Turns out I can do that
with apache+mod_wsgi and daemon mode, or flup forked server (I would
probably use ajp - so flup is in a seperate process to apache and
listens on some local port, and apache proxies to that using the ajp
protocol). I'm not sure which one is best... for now I'm continuing to
just develop on cherrypy on my own machine.

I suspect I will use ajp forked flup, since that only requires
mod_proxy and mod_proxy_ajp which I understand come with standard
apache and the system administrators will probably be happier with.

Cheers

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


Re: best way to serve wsgi with multiple processes

2009-02-11 Thread Robin
On Feb 11, 9:32 pm, Graham Dumpleton 
wrote:
> 2009/2/12 alex goretoy :
>
> > GAE (Google App Engine) uses WSGI for webapps. You don't have to overhead of
> > managing a server and all it's services this way as well. Just manage dns
> > entries. Although, there are limitations depending on your project needs of
> > what libs you need to use.
>
> GAE is not suitable as they kill off any requests that take more than
> a set time. That time isn't that long, so can't support long running
> requests.

GAE is definitely not suitable in this case... The servers are
provided and maintained as part of a large scientific project for
which I am providing just a few services... Other groups are running
services in other platforms on tomcat through soaplab/instantsoap -
but I was hoping to use native python services since I thought it
would be easier.

Cheers

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


About upgrade my graphics memory

2008-10-09 Thread robin
PROBLEM

i need to upgrade my graphics memory to enjoy the features of windows
vista aero theme.. i am intel D915GLVG motherboard. what type of
graphics card is supported on my motherboard and how much it cost??

fiend solution here http://pc-solution4u.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Error code MP170

2008-10-11 Thread robin
PROBLEM

hi i'm Pauline Revelli'v just brought a canon pixma mp180/mp160. i
have installed the software and everything. the printer works fine but
the scanner dose not. it trys to scan but a thing comes up that says
its not plug in or cable not connected with numbers. the canon is
pluged in of cours becasue the printer works.

find solution here
http://pc-solution4u.blogspot.com/search/label/Canon%20PIXMA%20MP160%20All-In-One%20InkJet%20Printer
--
http://mail.python.org/mailman/listinfo/python-list


Ink level monitor on Canon Prixma...

2008-10-11 Thread robin
After the ink cartridge for the Canon Prixma MP 160 have been refilled
and test then I press the button Stop / Reset several times but
unfortunately the problem low ink indicator is still remaining as
before although I have done as some user online suggested. Please tell
me what to do the correct steps to resolve this issue.

find solution here
http://pc-solution4u.blogspot.com/search/label/Canon%20PIXMA%20MP160%20All-In-One%20InkJet%20Printer
--
http://mail.python.org/mailman/listinfo/python-list


I can't get the scanner to work on my mp160.

2008-10-11 Thread robin
PROBLEM

I have tried everything but I am unable to get the scanner to work . I
have reinstalled drivers checked connections I have windows 2000 and
all other requirements. There is a windows error code 31 that pops up.
This says check connections and make sure scanner is turned on.

find solution here

http://pc-solution4u.blogspot.com/search/label/Canon%20PIXMA%20MP160%20All-In-One%20InkJet%20Printer
--
http://mail.python.org/mailman/listinfo/python-list


sceanner connection to the pc

2008-10-11 Thread robin
PROBLEM

i have already installed the software canon mp 160..the machine can
print out the paper andn copy something perfectly..BUT, when i tried
to scan a paper to the PC,It can't work..there's is a message 'CANNOT
COMMUNICATE TO THE SCANNER. PLEASE TURN ON OR CONNECT THE MACHINE'
whereas i have turned it on..is there any body wants to help me with
this problem??

find solution here

http://pc-solution4u.blogspot.com/search/label/Canon%20PIXMA%20MP160%20All-In-One%20InkJet%20Printer
--
http://mail.python.org/mailman/listinfo/python-list


Scanning error

2008-10-11 Thread robin
PROBLEM

I connect to my laptop to scan pictures, and each time, each single
time the scanner will start scanning an inch but it stops and I get
the message Cannot communicate with scanner. Cable may be disconnected
or scanner may be turned off. Check status. Scanner driver will be
closed. Code: 2,155,0"The closest I get is it will scan one or two,
but same problem persists. Today I totally cannot scan one thing! What
is wrong?

find solution here
http://pc-solution4u.blogspot.com/search/label/Canon%20PIXMA%20MP160%20All-In-One%20InkJet%20Printer
--
http://mail.python.org/mailman/listinfo/python-list


Canon mp160 drivers

2008-10-11 Thread robin
PROBLEM
i lost my canon mp160 drivers for the printer and scanner. how to i
download from the drivers for the printerI lost my start up disk for
my canon mp180 all in one printer.How can I download another oneNeed
to find the drivers to downloadmy computer has much viruses and i
installed it. after finishedinstalling, i cannot print more because
the software is lost

visit in this 
sitehttp://www.usa.canon.com/consumer/controller?act=DownloadDetailAct&fcategoryid=238&modelid=13368
MP160 driver 1.01 Win98SE/ME/2000/XPhttp://www.driversdown.com/drivers/
Canon-PIXMA-MP160-driver_74508.shtmlMP160 driver 1.10 Windows Vista/
Vista-64http://www.driversdown.com/drivers/Canon-PIXMA-MP160-
driver_74507.shtml

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


Canon PIXMA MP160 All-In-One InkJet Printer

2008-10-11 Thread robin
PROBLEM

I have a very basic question... how to take black and white print? I
am getting colored print even if I press black button on the printer.
Please advice.I'll be thankful if you please let me know the steps to
make sure that how can I make sure that my printer settings at
computer level are correct to take black and print.

find solution here
http://pc-solution4u.blogspot.com/search/label/Canon%20PIXMA%20MP160%20All-In-One%20InkJet%20Printer
--
http://mail.python.org/mailman/listinfo/python-list


E5 and 2,114,0 errors

2008-10-11 Thread robin
PROBLEM

I've just bought a second hand MP160,which I only intended to used as
a scanner.I can't get the scanner to operate due to an E5 error on the
display,and a 2,114,0 error which appears as a pop-up when I attempt
to scan.Although empty,the cartridges are of the correct type and are
seated properly.When I remove the cartridges completely the error
codes do not change.Is an empty cartridge enough to cause this issue?

find solution here
http://pc-solution4u.blogspot.com/search/label/Canon%20PIXMA%20MP160%20All-In-One%20InkJet%20Printer
--
http://mail.python.org/mailman/listinfo/python-list


ink level reset

2008-10-11 Thread robin
PROBLEM

I need to know how to reset the ink level counter of the Canon MP160.
It says " Low ink" when I just refilled the ink tanks. Please help. I
need the tricks or software that resets the counter.

find solution here

http://pc-solution4u.blogspot.com/search/label/Canon%20PIXMA%20MP160%20All-In-One%20InkJet%20Printer
--
http://mail.python.org/mailman/listinfo/python-list


Re: New python.org website

2006-03-13 Thread robin
"Michael Tobis" <[EMAIL PROTECTED]> wrote:

>While the new one is much better than the old website, the logo strikes
>me as awful.

I personally believe the new logo is miles better than the old one.
Whether you see snakes or a plus-sign or a yin-yang, it has a nice
harmonious look that still captures some playfulness. 

Besides, why is everyone fixated on snakes? Python the language has
nothing to do with python the constrictor.

As far as the layout goes, I still find it too busy. Specifically
there are too many fonts on the one page. But I have already made that
point, and did an entire version of the homepage, which the team have
taken as input.

Anyone who has the time can do the same, rather than simply comment
from the sidelines. The best websites never stay still, but are
constantly evolving. I hope python.org can do the same, and go from
strength to strength.

Congratulations to all involved!
-
robin
noisetheatre.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


New Python Logo Revealed

2006-04-01 Thread robin
I have an entry on my blog discussing the new Python logo, which is
apparently due to replace the current one within the month. I'd be
interested in what people think of it.

Surf:
http://diagrammes-modernes.blogspot.com

-
robin
noisetheatre.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Python Logo Revealed

2006-04-03 Thread robin
"Giovanni Bajo" <[EMAIL PROTECTED]> wrote:

>robin wrote:
>
>> I have an entry on my blog discussing the new Python logo, which is
>> apparently due to replace the current one within the month. I'd be
>> interested in what people think of it.
>>
>> Surf:
>> http://diagrammes-modernes.blogspot.com
>
>Tell me tell me it's an april's joke, please? :)

yes :-)
-
robin
noisetheatre.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


converting lists to strings to lists

2006-04-12 Thread robin
hi,

i'm doing some udp stuff and receive strings of the form '0.87
0.25 0.79;\n'
what i'd need though is a list of the form [0.87 0.25 0.79]
i got to the [0:-3] part to obtain a string '0.87 0.25
0.79' but i can't find a way to convert this into a list. i tried
eval() but this gives me the following error:

Traceback (most recent call last):
  File "", line 1, in ?
  File "", line 1
.87 0.25 0.79000

and i have the same problem the other way round. e.g. i have a list
which i need to convert to a string in order to send it via udp.
btw: i cannot use pickle, since i'm sending stuff to a LISP programme.

thank you in advance for your help!
best,

robin

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


Re: converting lists to strings to lists

2006-04-12 Thread robin
thanks for your answer. split gives me a list of strings, but i found a
way to do what i want:

input='0.1, 0.2, 0.3;\n'
input = list(eval(input[0:-2]))
print input
> [0.10001, 0.20001, 0.2]

this does fine... but now, how do i convert this list to a string?

my_new_string = ' '.join(input)

gives me:

Traceback (most recent call last):
  File "", line 1, in ?
TypeError: sequence item 0: expected string, float found

thanks,

robin

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


Re: converting lists to strings to lists

2006-04-12 Thread robin
yo!

thank you everone! here's how i finally did it:
converting the string into a list:

input = net.receiveUDPData()
input = list(eval(input[0:-2]))

converting the list into a string:

sendout = "%.6f %.6f %.6f;\n" % tuple(winningvector)

maybe i'll even find a way to generalize the list2string bit, so it
accepts arbitrary sized lists...
thanks,

robin

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


Re: bus error in Py_Finalize with ctypes imported

2009-11-13 Thread Robin
On Nov 13, 2:14 pm, Robin  wrote:
> I am trying to embed Python in a MATLAB mex function. This is loaded
> into the MATLAB interpreter - I would like the Python interpreter to
> be initialized once and stay there for future calls. I added a call to
> Py_Finalize as a mexAtExit handler which is called when the library is
> unloaded in MATLAB (with clear funcname) or when MATLAB shuts down. So
> far, things were working well, but I get a random but easily
> repeatable bus error in Py_Finalize if I have imported ctypes.

Looks like I've run into this bug:
http://bugs.python.org/issue6869

I will try the attached patch - hopefully it will make into a
forthcoming release.

Cheers

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


bus error in Py_Finalize with ctypes imported

2009-11-13 Thread Robin
Hi,

I am trying to embed Python in a MATLAB mex function. This is loaded
into the MATLAB interpreter - I would like the Python interpreter to
be initialized once and stay there for future calls. I added a call to
Py_Finalize as a mexAtExit handler which is called when the library is
unloaded in MATLAB (with clear funcname) or when MATLAB shuts down. So
far, things were working well, but I get a random but easily
repeatable bus error in Py_Finalize if I have imported ctypes.

Here is my code:

#include 
#include 

static int PYRUNNING = 0;

static void Cleanup(void)
{
mexPrintf("Finalising Python...\n");
Py_Finalize();
}

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const
mxArray*prhs[])
{
mexPrintf("hello from mex\n");

if (!PYRUNNING) {
Py_Initialize();
PYRUNNING = 1;
mexAtExit(Cleanup);
PyRun_SimpleString("import ctypes");
}

PyRun_SimpleString("print 'hello from python'");

}

If I load, run the function, and unload many times eventually I get
the following stack trace (whcih i don't get if I'm not import
ctypes). Does anyone have any idea what might be up? Could it be a bug
in Py_Finalize or ctypes? Is there a problem with my approach (ie is
it bad to leave the interpreter initialized between mex function calls
- it seems to work provided ctypes is not imported - but I need ctypes
to access other mex functions from python).


 Bus error detected at Fri Nov 13 14:06:12 2009


Configuration:
  MATLAB Version:   7.8.0.347 (R2009a)
  MATLAB License:   161051
  Operating System: Darwin 10.0.0 Darwin Kernel Version 10.0.0: Fri
Jul 31 22:47:34 PDT 2009; root:xnu-1456.1.25~1/RELEASE_I386 i386
  Window System:The X.Org Foundation (10402000), display /tmp/
launch-2p1ZWg/:0
  Current Visual:   0x24 (class 4, depth 24)
  Processor ID: x86 Family 6 Model 15 Stepping 10, GenuineIntel
  Virtual Machine:  Java 1.6.0_15-b03-219 with Apple Inc. Java HotSpot
(TM) Client VM mixed mode
  Default Encoding:  ISO-8859-1

Fault Count: 1

Register State:
  eax =   ebx = 3483d9be
  ecx = 33ff7620  edx = 
  esi = 32fb4dc0  edi = 001a
  ebp = b0b69938  esp = b0b69920
  eip = 3485559f  flg = 00010282

Stack Trace:
  [0] Python:type_dealloc~(0x32fb4dc0, 0x33f70818, 0x34854f0b,
0x34844410) + 26 bytes
  [1] Python:dict_dealloc~(0x33fef930, 0x348e4b40 "__builtin__",
0xb0b699bc, 0xb0b699b8) + 142 bytes
  [2] Python:dict_dealloc~(0x33f429c0, 0x348ee58c "exitfunc",
0xb0b699d8, 0x348b96b0) + 142 bytes
  [3] Python:_PyImport_Fini~(0x348ee58c "exitfunc", 0, 0, 0) + 82
bytes
  [4] Python:Py_Finalize~(673024, 1, 0, 0x00ab4700) + 207 bytes
  [5] libmex.dylib:SafeExitFunctionCall(void (*)())(0x30365df0,
0xb0b69ab8, 0xb0b69a80, 0x0073d01b) + 66 bytes
  [6] libmex.dylib:mexClearMexFileDefault(impl_info_tag*)(0x33e0dce0,
1, 0, 0x015fa3d8 "7Mfh_mex") + 80 bytes
  [7] libmex.dylib:safeMexClearMexFile(impl_info_tag*&)(0xb0b69bec
"‡‹‡3", 1, 0x015fc080, 0) + 76 bytes
  [8] libmex.dylib:Mlm_mex::unload_file()(0x32b01290, 0, 0, 0) + 250
bytes
  [9] libmwm_dispatcher.dylib:Mlm_file::unload_mf()(0x32b01290, 0, 0,
0) + 18 bytes
  [10] libmwm_dispatcher.dylib:Mlm_MATLAB_fn::clear()(0x32b01290, 0,
0xb0b69c9c, 236) + 82 bytes
  [11] libmwm_dispatcher.dylib:void clear
(Mlmmf_string_matcher, int)(0x05319c00, 0x33e24b8c "pytest",
0x30476300, 0x03f3b531 "pytest") + 296 bytes
  [12] libmwm_dispatcher.dylib:mdClearFunctionsByName(0x33e24b8c
"pytest", 42, 0xb0b6adf8, 10) + 650 bytes
  [13] libmwm_interpreter.dylib:InterpBridge::FullClearFcn(int,
mxArray_tag**, int, mxArray_tag**)(0x036225e0, 0, 0xb0b6af6c, 1) +
1234 bytes
  [14] libmwm_interpreter.dylib:inFullClearFcn(int, mxArray_tag**,
int, mxArray_tag**)(0, 0xb0b6af6c, 1, 0xb0b6afcc) + 50 bytes
  [15] libmwm_dispatcher.dylib:Mfh_builtin::dispatch_mf(int,
mxArray_tag**, int, mxArray_tag**)(0x2dd025a0, 0, 0xb0b6af6c, 1) + 95
bytes
  [16] libmwm_dispatcher.dylib:Mfh_MATLAB_fn::dispatch_fh(int,
mxArray_tag**, int, mxArray_tag**)(0x2dd025a0, 0, 0xb0b6af6c, 1) + 192
bytes
  [17] libmwm_interpreter.dylib:inDispatchFromStack(int, char const*,
int, int)(0, 0x304fa51c "clear", 0, 1) + 998 bytes
  [18] libmwm_interpreter.dylib:inDispatchCall(char const*, int, int,
int, int*, int*)(1, 0xb0b6b298, 0x33e11a28, 0x9322e76b) + 152 bytes
  [19] libmwm_interpreter.dylib:inInterp(inDebugCheck, int, int,
opcodes, inPcodeNest_tag volatile*, int*)(1, 0, 1, 0) + 5167 bytes
  [20] libmwm_interpreter.dylib:protected_inInterp(inDebugCheck, int,
int, opcodes, inPcodeNest_tag*, int*)(1, 0, 1, 0) + 112 bytes
  [21] libmwm_interpreter.dylib:inInterPcodeSJ(inDebugCheck, int, int,
opcodes, inPcodeNest_tag*, int*)(0, 0x33e007d0, 0xb0b6b460,
0xb0b6b460) + 266 bytes
  [22] libmwm_interpreter.dylib:inExecuteMFunctionOrScript(Mfh_mp*,
bool)(0x33e263c0, 1, 0xb0b6b99c, 0) + 932 bytes
  [23] libmwm_interpreter

python to exe

2010-03-12 Thread Robin
Does anyone know of a good python to stand alone exe compiler?

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


python question

2011-02-02 Thread Robin
how do you acccess a hash element in python 3? It completely changed
from version 2 and earlier, I think.

stop war straight up, direct or indectly,
-- 
http://mail.python.org/mailman/listinfo/python-list


repeat tkinter

2010-05-03 Thread Robin
How can I make a command within a tkinter application repeat itself
over and over in intervals of a certain time.
Thanks,
-Robin
-- 
http://mail.python.org/mailman/listinfo/python-list


scrolledtext download location

2010-05-04 Thread Robin
Does anyone know where I can download the ScrolledText tkintewr
widget, looked all over for it and had no luck,
Thanks,
-Robin
-- 
http://mail.python.org/mailman/listinfo/python-list


the solution to your current problems........join this: http://www.thevoid1.net/para

2010-05-05 Thread Robin
the solution to your current problemsjoin this: 
http://www.thevoid1.net/para
-- 
http://mail.python.org/mailman/listinfo/python-list


python to exe

2010-05-09 Thread Robin
Does anyone know of a way I can make a python script into an exe that
runs on windows7, I don't care if it is a python to c++ or python to c
translator or anything like it. The version of python I am using is
python 3.1. Thanks,
-Robin
-- 
http://mail.python.org/mailman/listinfo/python-list


what are some good python modules?

2010-06-14 Thread Robin
What are some good python modules that can be downloaded for any
purpose that is recomended?
-Robin
-- 
http://mail.python.org/mailman/listinfo/python-list


do

2010-07-09 Thread Robin
please, please post a link to my site, http://offlame.thevoid1.net/

also, post free for all links at www.thevoid1.net/ffa

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


Re: Numeric literals in other than base 10

2009-08-27 Thread robin
"James Harris"  wrote in message
news:bc3607b3-7fdd-43fd-8ede-66ac3f597...@32g2000yqj.googlegroups.com...
On 22 Aug, 10:27, David <71da...@libero.it> wrote:

>They look good - which is important. The trouble (for me) is that I
>want the notation for a new programming language and already use these
>characters. I have underscore as an optional separator for groups of
>digits - 123000 and 123_000 mean the same. The semicolon terminates a
>statement. Based on your second idea, though, maybe a colon could be
>used instead as in

XPL uses "(2)1011" for base 4,
"(3)03212" for octal,
"(4)0741" for base 16.

PL/I uses 8FXN for numeric hex and X suffix for a hex character constant.




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


unexpected syntax errors

2013-05-07 Thread Robin Becker

A user is getting this error



New issue 8: bad raise syntax
https://bitbucket.org/rptlab/reportlab/issue/8/bad-raise-syntax



  File "/usr/lib/python2.7/site-packages/svg2rlg.py", line 16, in 
from reportlab.graphics import renderPDF
  File "/usr/lib64/python2.7/site-packages/reportlab/graphics/renderPDF.py", 
line 168
raise ValueError, 'bad value for textAnchor '+str(text_anchor)
^
SyntaxError: invalid syntax




however, I believe that this older syntax is allowed in python 2.7. We've had 
other issues like this raised from various distros which are apparently making 
changes to 2.7 which change the external behaviour eg spelling corrections to 
attribute names. Could this be one of those?

--
Robin Becker

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


Re: Writing Extensions for Python 3 in C

2013-06-19 Thread Robin Becker

On 18/06/2013 11:24, Aditya Avinash wrote:

Hi. This is the last place where I want to ask a question. I have searched
for lots of tutorials and documentation on the web but, didn't find a
decent one to develop extensions for Python 3 using a custom compiler
(mingw32, nvcc). Please help me.
PS: Don't point me to Python Documentation. It is not good for beginners.
It doesn't elaborate about calls and implementation.



Try getting the source code for the Python you intend to build for. Then look in 
the Modules directory for the sample extensions xxlimited.c, xxmodule.c & 
xxsubtype.c. They may give you some idea of how to proceed. Of course all the 
other .c codes in there are the actual extensions that Python uses so they are 
also good examples.


I started with "Extending and Embedding the Python Interpreter" from the python 
documentation though.

--
Robin Becker

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


substituting proxy

2013-07-29 Thread Robin Becker
Before attempting to reinvent the wheel has anyone created an http(s) proxy that 
can replace the content for specific requests.


Context: I have access to the client's test site, but a lot of the  requests are 
dynamic and save html complete etc etc doesn't work properly. In addition lots 
of the content comes from a cloud server which seems to object unless I take 
great care over spoofing of host names & referrers etc.


I would like to debug stuff we supply, but that's hard unless I have the whole 
kit & kaboodle. I thought a proxy that could substitute for our javascript 
file(s) might work.


Has anyone done this in twisted pymiproxy etc etc?
--
Robin Becker

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


Executing untrusted scripts in a sandboxed environment

2012-10-05 Thread Robin Krahl
Hi all,

I need to execute untrusted scripts in my Python application. To avoid security 
issues, I want to use a sandboxed environment. This means that the script 
authors have no access to the file system. They may only access objects, 
modules and classes that are "flagged" or "approved" for scripting.

I read that I will not be able to do this with Python scripts. (See 
SandboxedPython page in the Python wiki [0] and several SE.com questions, e. g. 
[1].) So my question is: What is the best way to "embed" a script engine in a 
sandboxed environment that has access to the Python modules and classes that I 
provide?

Thanks for your help.

Best regards,
Robin

[0] http://wiki.python.org/moin/SandboxedPython
[1] 
http://stackoverflow.com/questions/3068139/how-can-i-sandbox-python-in-pure-python
-- 
http://mail.python.org/mailman/listinfo/python-list


looping versus comprehension

2013-01-30 Thread Robin Becker
An email in reportlab-us...@reportlab.com claimed that the following loop in a 
charting module was taking a long time



I use ReportLab 2.6 but I also found the problem in ReportLab daily from 
01/29/2013 in /src/reportlab/graphics/charts/lineplots.py:
276  # Iterate over data columns.
277  if self.joinedLines:
278  points = []
279  for xy in row:
280  points += [xy[0], xy[1]]

If I use a list comprehension instead, the plot is generated within seconds or 
minutes:
278  points = [[xy[0], xy[1]] for xy in row]


however, when I tried an experiment in python 2.7 using the script below I find 
that the looping algorithms perform better. A naive loop using list += list 
would appear to be an O(n**2) operation, but python seems to be doing better 
than that. Also why does the append version fail so dismally. Is my test coded 
wrongly or is pre-allocation of the list making this better than expected?


C:\code\tests>tpoints 86000 86
 START n=86000 
existing algorithm took 0.08 seconds
existing algorithm using list took 0.12 seconds
existing algorithm using list assuming length 2 took 0.12 seconds
map(list,row) took 0.16 seconds
[list(xy) for xy in row] took 0.28 seconds
[[xy[0],xy[1]] for xy in row] took 0.22 seconds
append algorithm took 0.19 seconds
 END   n=86000 


 START n=86 
existing algorithm took 0.86 seconds
existing algorithm using list took 1.33 seconds
existing algorithm using list assuming length 2 took 1.25 seconds
map(list,row) took 3.44 seconds
[list(xy) for xy in row] took 3.03 seconds
[[xy[0],xy[1]] for xy in row] took 2.70 seconds
append algorithm took 2.48 seconds
 END   n=86 

#
import sys, time
def main(n):
print 20*'#','START n=%s'%n,20*'#'
row = [(i,i+1) for i in xrange(2*n)]
print 'existing algorithm',
t0 = time.time()
points = []
for xy in row:
points += [xy[0],xy[1]]
t1 = time.time()
print 'took %.2f seconds' % (t1-t0)

print 'existing algorithm using list',
t0 = time.time()
points = []
for xy in row:
points += list(xy[:2])
t1 = time.time()
print 'took %.2f seconds' % (t1-t0)

print 'existing algorithm using list assuming length 2',
t0 = time.time()
points = []
for xy in row:
points += list(xy)
t1 = time.time()
print 'took %.2f seconds' % (t1-t0)

print 'map(list,row)',
t0 = time.time()
points = map(list,row)
t1 = time.time()
print 'took %.2f seconds' % (t1-t0)

print '[list(xy) for xy in row]',
t0 = time.time()
points = [list(xy) for xy in row]
t1 = time.time()
print 'took %.2f seconds' % (t1-t0)

print '[[xy[0],xy[1]] for xy in row]',
t0 = time.time()
points = [[xy[0],xy[1]] for xy in row]
t1 = time.time()
print 'took %.2f seconds' % (t1-t0)

print 'append algorithm',
t0 = time.time()
points = [].append
for xy in row:
points([xy[0],xy[1]])
points = points.__self__
t1 = time.time()
print 'took %.2f seconds' % (t1-t0)

print 20*'#','END   n=%s'%n,20*'#','\n\n'

if __name__=='__main__':
if len(sys.argv)==1:
N = [86000]
else:
N = map(int,sys.argv[1:])
for n in N:
main(n)
#
--
Robin Becker

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


Re: looping versus comprehension

2013-01-30 Thread Robin Becker

On 30/01/2013 15:49, Chris Angelico wrote:

On Thu, Jan 31, 2013 at 1:58 AM, Robin Becker  wrote:

however, when I tried an experiment in python 2.7 using the script below I
find that the looping algorithms perform better. A naive loop using list +=
list would appear to be an O(n**2) operation, but python seems to be doing
better than that. Also why does the append version fail so dismally. Is my
test coded wrongly or is pre-allocation of the list making this better than
expected?


First off, are you aware that your first three blocks of code and your
last four produce different results? The first ones flatten the list,
the others simply convert tuples to lists. With n = 3:


points = []
for xy in row:

 points += [xy[0],xy[1]]

points

[0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6]

map(list,row)

[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]

Once that's sorted out, then timings can be played with. But it's
worth noting that list appending is not going to be O(N*N), because
it's going to allow room for expansion.

ChrisA



No I missed that :( the list is a flattened one.

That'll teach me not to copy the code from the users without checking. Now you 
point it out it's clear that his code is doing something different. Presumably 
it's not drawing the same thing at all :) no wonder it got much faster.

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


client ssl verification

2012-03-15 Thread Robin Becker
I'm trying to do client ssl verification with code that looks like the sample 
below. I am able to reach and read urls that are secure and have no client 
certificate requirement OK. If I set explicit_check to True then verbose output 
indicates that the server certs are being checked fine ie I see the correct cert 
details and am able to check them.


However, when I try to reach an apache location like


sslverifyclient require
sslverifydepth 10


I am getting an error from  urllib2 that goes like this

urllib2.py", line 1148, in do_open
raise URLError(err)
URLError: routines:SSL3_READ_BYTES:tlsv1 alert unknown ca


I am using the server.crt and server.key (both in PEM format) from the target 
server itself; I reasoned that should be the easiest combo for the client & 
server to match, but I am obviously wrong. Any obvious stupidities to be pointed 
out? I suppose I could create a new cert/key based on a self signed ca, but that 
would not work properly for the other parts of the server.



import socket, ssl, fnmatch, datetime, urllib2, httplib
verbose=False

# wraps https connections with ssl certificate verification
class SecuredHTTPSHandler(urllib2.HTTPSHandler):
  def 
__init__(self,key_file=None,cert_file=None,ca_certs=None,explicit_check=False):
class SecuredHTTPSConnection(httplib.HTTPSConnection):
  def connect(self):
# overrides the version in httplib so that we do
#  certificate verification
sock = socket.create_connection((self.host, self.port), self.timeout)
if self._tunnel_host:
  self.sock = sock
  self._tunnel()
# wrap the socket using verification with the root
#  certs in ca_certs
if verbose:
  print ca_certs, key_file, cert_file
self.sock = ssl.wrap_socket(sock,
  cert_reqs=ssl.CERT_REQUIRED,
  ca_certs=ca_certs,
  keyfile=key_file,
  certfile=cert_file,
  )
if explicit_check:
  cert = self.sock.getpeercert()
  if verbose:
import pprint
pprint.pprint(cert)
  for key,field in cert.iteritems():
if key=='subject':
  sd = dict([x[0] for x in field])
  certhost = sd.get('commonName')
  if not fnmatch.fnmatch(self.host,certhost):
raise ssl.SSLError("Host name '%s' doesn't match certificate host 
'%s'"
 % (self.host, certhost))
  if verbose:
print 'matched "%s" to "%s"'  % (self.host,certhost)
elif key=='notAfter':
  now = datetime.datetime.now()
  crttime = datetime.datetime.strptime(field,'%b %d %H:%M:%S %Y %Z')
  if verbose:
print 'crttime=%s now=%s' % (crttime,now)
  if now>=crttime:
raise ssl.SSLError("Host '%s' certificate expired on %s"
   % (self.host, field))
self.specialized_conn_class = SecuredHTTPSConnection
urllib2.HTTPSHandler.__init__(self)

  def https_open(self, req):
return self.do_open(self.specialized_conn_class, req)

def secureDataGet(uri,ca_certs='cacert.pem',key_file=None,cert_file=None, 
explicit_check=False):
  https_handler = SecuredHTTPSHandler(key_file=key_file,cert_file=cert_file,
ca_certs=ca_certs,explicit_check=explicit_check)
  url_opener = urllib2.build_opener(https_handler)
  handle = url_opener.open(uri)
  response = handle.readlines()
  handle.close()
  return response



--
Robin Becker

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


How good is security via hashing

2011-06-07 Thread Robin Becker

A python web process is producing files that are given randomized names of the 
form

hh-MMDDhhmmss-.pdf

where rrr.. is a 128bit random number (encoded as base62). The intent of the 
random part is to prevent recipients of one file from being able to guess the 
names of others.


The process was originally a cgi script which meant each random number was 
produced thusly



pid is process id, dur is 4 bytes from /dev/urandom.

random.seed(long(time.time()*someprimeint)|(pid<<64)|(dur<<32))
rrr = random.getrandbits(128)


is this algorithm safe? Is it safe if the process is switched to fastcgi and the 
initialization is only carried out once and then say 50 rrr values are generated.

--
Robin Becker

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


Re: How good is security via hashing

2011-06-07 Thread Robin Becker

On 07/06/2011 11:26, Nitin Pawar wrote:

Have you tried using UUID module?

Its pretty handy and comes with base64 encoding function which gives
extremely high quality randon strings

ref:
http://stackoverflow.com/questions/621649/python-and-random-keys-of-21-char-max

..
I didn't actually ask for a suitable method for doing this; I assumed that Tim 
Peters' algorithm (at least I think he's behind most of the python random 
support) is pretty good so that the bits produced are indeed fairly good 
approximations to random.


I guess what I'm asking is whether any sequence that's using random to generate 
random numbers is predictable if enough samples are drawn. In this case assuming 
that fastcgi is being used can I observe a sequence of generated numbers and 
work out the state of the generator. If that is possible then the sequence 
becomes deterministic and such a scheme is useless. If I use cgi then we're 
re-initializing the sequence hopefully using some other unrelated randomness for 
each number.


Uuid apparently uses machine internals etc etc to try and produce randomness, 
but urandom and similar can block so are probably not entirely suitable.

--
Robin Becker

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


Re: How good is security via hashing

2011-06-07 Thread Robin Becker




/dev/urandom does not block, that's the point of it as compared to /
dev/random.

Jean-Paul


my mistake, I thought it was the other way round, on FreeBSD they're the same 
anyway which is what we test on.

--
Robin Becker

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


Re: How good is security via hashing

2011-06-07 Thread Robin Becker

On 07/06/2011 12:40, Jean-Paul Calderone wrote:
astcgi and the

initialization is only carried out once and then say 50 rrr values are 
generated.


How much randomness do you actually have in this scheme?  The PID is
probably difficult
for an attacker to know, but it's allocated roughly monotonically with
a known
wrap-around value.  The time is probably roughly known, so it also
contributes less
than its full bits to the randomness.  Only dur is really
unpredictable.  So you have
something somewhat above 4 bytes of randomness in your seed - perhaps
8 or 10.  That's
much less than even the fairly small 16 bytes of "randomness" you
expose in the
filename.


I'm sure you're right about the limited amount of entropy in the initial state, 
but how much state can be in the prng?




The random module is entirely deterministic, so once the seed is known
the value you
produce is known too.

Is 10 bytes enough to thwart your attackers?  Hard to say, what does
an attack look like?
An attacker could try to gain information from seeing others' results by 
guessing the filename.


an attack would consist of generating a sample file via a web query which might 
take 1 or 2 seconds; the sequence number could then be seen and if the state 
established future filenames could be guessed if fastcgi is in operation.


In a cgi type scheme that requires searching over the pid space, the time space 
and some random bits from the OS.


I'm not sure such an attack is realistic given the size of the space even in the 
initial seed.




If you want the full 16 bytes of unpredictability, why don't you just
read 16 bytes from
/dev/urandom and forget about all the other stuff?

Jean-Paul
I have a vague memory that the original author felt that entropy might run out 
or something like that so reading from /dev/urandom always was not a good idea.


FreeBSD re-uses the entropy, but the end target is Solaris so I'm not really 
sure about the details of /dev/urandom.

--
Robin Becker

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


Re: How good is security via hashing

2011-06-08 Thread Robin Becker

On 07/06/2011 21:42, Paul Rubin wrote:

geremy condra  writes:

# adds random junk to the filename- should make it hard to guess
rrr = os.urandom(16)
fname += base64.b64encode(rrr)


Don't use b64 output in a filename -- it can have slashes in it!  :-(

Simplest is to use old fashioned hexadeimal for stuff like that, unless
the number of chars is a significant problem.  Go for a more complicated
encoding if you must.

we have been using base62 ie 0-9A-Za-z just to reduce the name length.
--
Robin Becker

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


Re: How to read barcoded value from PDF

2011-06-28 Thread Robin Becker

On 28/06/2011 06:59, Asif Jamadar wrote:

Hi,


...


In Reportlab I can do the following code to generate barcode and to get the 
value of that barcode



 barcode=code39.Extended39("123456789",barWidth=0.2*mm,barHeight=8*mm)



 bc = Paragraph("Barcode value: %s" % barcode.value, STYLES['Normal'])



 document.append(bc)

But how can I achieve this from the existing PDF document??

.

you might consider asking on the reportlab list as there is considerable 
experience there about pdf in general.


It's unlikely that you will be able to easily discern which string/text in the 
pdf corresponds to the barcode values that you are interested in.


PDF does allow things called annotations which reportlab can generate.

Alternatively you can generate an invisible string which may make more sense 
than the simple barcode value. So when you draw the barcode you also need to add 
the magic string using some prefix/postfix that allows easy extraction with 
pypdf or similar eg


"===radamajfisa===123456789===radamajfisa===". Your text extractor should be 
able to find this without too much trouble.

--
Robin Becker

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


Re: Implicit initialization is EVIL!

2011-07-05 Thread Robin Becker

On 03/07/2011 23:21, Chris Angelico wrote:
.


var(0x14205359) x   # Don't forget to provide an address where the
object will be located
x=42


did you forget to specify the memory bank and computer (and presumably planet 
etc etc)

-molly-coddled-ly yrs-
Robin Becker
--
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit initialization is EVIL!

2011-07-05 Thread Robin Becker

On 05/07/2011 16:33, nn wrote:
..

Ah, I see we have a mainframe programmer among us ... :-)

so long since I manipulated the switches of that old pdp-8
-anciently yrs-
Robin Becker

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


Re: reportlab import error after dundled using py2exe

2011-07-25 Thread Robin Becker

On 22/07/2011 03:55, SANKAR . wrote:

Hi all,





C:\Python26\dist>DELchek.exe
Traceback (most recent call last):
File "DELchek.py", line 12, in
File "reportlab\pdfgen\canvas.pyc", line 25, in<
File "reportlab\pdfbase\pdfdoc.pyc", line 22, in
File "reportlab\pdfbase\pdfmetrics.pyc", line 23,
File "reportlab\pdfbase\_fontdata.pyc", line 158,
ImportError: No module named _fontdata_enc_winansi

But I could see the '_fontdata_enc_winansi' module in reportlab folder.
Could someone help me to fix this.


.
You can try asking this in the reportlab list

reportlab-us...@lists2.reportlab.com

but perhaps this is more about py2exe than reportlab. The modules 
_fontdata_enc_* & _fontdata_widths_* are imported dynamically in _fontdata.py 
rather than explicitly. I suspect that py2exe needs to be given a hint that this 
is going on. However, I'm uncertain as to why this should be required since even 
if the imports are being dynamically imported that is done as soon as _fontdata 
is imported (ie it's part of the module code) so those modules should be seen by 
the setup.py.


If you don't have reportlab explicitly imported as part of the packages try 
adding this to the packages list


packages=[




'reportlab',
'reportlab.graphics.charts',
'reportlab.graphics.samples',
'reportlab.graphics.widgets',
'reportlab.graphics.barcode',
'reportlab.graphics',
'reportlab.lib',
'reportlab.pdfbase',
'reportlab.pdfgen',
'reportlab.platypus',
],


that's what we use to make the distributions and seems to work.
--
Robin Becker

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


Re: arbitrary precision linear algebra

2011-03-02 Thread Robin Becker

On 02/03/2011 16:39, Ben123 wrote:
...

Languages can't support infinitely large or small numbers, so try to
multiply the inner variables by 10^n to increase their values if this
will not involve on the method. For example, I did this when was
calculating geometric means of computer benchmarks.


Currently I have values between 1 and 1E-300 (not infinitely small). I
don't see how scaling by powers of 10 will increase precision.


In such way you will be storing the number of zeros as n.


Are you saying python cares whether I express a number as 0.001 or
scaled by 10^5 to read 100? If this is the case, I'm still stuck. I
need the full range of eigenvalues from 1 to 1E-300, so the entire
range could be scaled by 1E300 but I would still need better precision
than 1E19


...

If you enter a number as 1e-19 then python will treat as a float; by default I 
think that float is IEEE double precision so you're getting a 48 bit mantissa 
(others may have better details). That means you've already lost any idea of 
arbitrary precision.


When you say you have numbers like 1E-300 are those actually numerically zero or 
have you some valid inputs that vary over a huge range. It should be possible to 
compute determinants/inverses etc to arbitrary precision as those are known to 
be polynomial functions of the input elements. However, eigenvalues are not.


eg

[0 2]
[1 0]

has eigenvalues +/- sqrt(2) so even though you can represent the matrix in 
finite precision the eigenvalues require infinite precision.


Eigenvalues are roots of a polynomial in the elements and root solving may 
require an infinite number of steps so it will be difficult with arbitrary 
matrices to keep arbitrary precision.

--
Robin Becker

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


Re: Generate PDF with Tamil font problem

2011-03-08 Thread Robin Becker

On 05/03/2011 05:20, sathe...@e-ndicus.com wrote:

Hi All,

I am using python's reportlab to print some unicode Tamil characters
'பே'. I added necessary unicode font to reportlab. But It
prints the output as 'ேப' (in reverse order). This issue
happens for multi-byte characters, whereas for character 'ப' is
printed as it is.
I am struggling to figure out the issue. Any help would see me on track.

...

you can ask at the reportlab mailing list reportlab-us...@reportlab.com; the use 
of numeric entities is supported in paragraph text, but not in canvas.drawString 
and similar. There you need to use either  unicode or a utf8 encoded byte string.

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


full reload of fastcgi

2011-04-12 Thread Robin Becker
A recent problem with a fastcgi script leads me to ask if there's any well 
defined way to fully reload a python fastcgi process. I know that people do 
tricks like unloading/reloading all modules, but it seems there's no obvious way 
to get python to restart itself. I believe that the server is apache based with 
mod_fcgid.


The script in question suffers from two problems

1) it runs out of a zip file and the software can be upgraded by moving a new 
zip file into place.


2) A cron job pulls new data into place which the script should notice.

The last is easy we can just re-read the data files before acting on the 
request, but it seems much harder to reload all modules from the zipfile.


An easy way out is to just halt the running script when a software change is 
detected. That means we must run with the old software for at least one request 
and could be dangerous if an import is required during the last request.


Normally the upgrade process is supposed to move software into place and then 
new data and then restart the fastcgi scripts; for whatever reason the error 
seems to have been that the process was restarted with old data around.


Any ideas?
--
Robin Becker

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


ANNOUNCE: wxPython 2.8.12.0

2011-04-19 Thread Robin Dunn

Announcing
--

The 2.8.12.0 release of wxPython is now available for download at
http://wxpython.org/download.php. This release has no major new
features or enhancements, but there have been plenty of bug fixes
since the last stable release.

Source code is available as a tarball, and binaries are also available
for Python 2.6 and 2.7, for Windows and Mac, as well some packages for
various Linux distributions in the wx apt repository.  Binaries for
Python 2.5 have been discontinued.



What is wxPython?
-

wxPython is a GUI toolkit for the Python programming language. It
allows Python programmers to create programs with a robust, highly
functional graphical user interface, simply and easily. It is
implemented as a Python extension module that wraps the GUI components
of the popular wxWidgets cross platform library, which is written in
C++.

wxPython is a cross-platform toolkit. This means that the same program
will usually run on multiple platforms without modifications.
Currently supported platforms are 32-bit and 64-bit Microsoft Windows,
most Linux or other Unix-like systems using GTK2, and Mac OS X 10.4+.
In most cases the native widgets are used on each platform to provide
a 100% native look and feel for the application.


--
Robin Dunn
Software Craftsman
http://wxPython.org

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


Re: Abandoning Python

2011-05-23 Thread Robin Becker

On 21/05/2011 16:49, John J Lee wrote:



I still like Python after using it for over a decade, but there are
things I don't like.

..
a relatively new one that's going about is cobra, http://cobra-language.com/, it 
appears to have some of the features you indicate eg speed, some kind of 
interfaces (contracts I think), but it needs net or mono.

--
Robin Becker

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


windows 8 versus urllib2 certificate verify

2017-09-11 Thread Robin Becker

I have an application built on 32 bit windows 7 with python 2.7.10.
The application runs fine on windows 7 and older windows machines, but it is 
failing to connect properly using urllib2 when run on windows 8.


The error CERTIFICATE_VERIFY_FAILED indcates this is some issue with urllib2 not 
being able to verify the remote certificate.


This is pyinstaller so the python and python library seem to be constant. I 
thought I understood that python uses its own cert path, but obviously I am wrong.


Googling sort of implies I might need certifi to be installed, but is that true?

Why does this fail only on windows 8?
--
Robin Becker

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


Re: windows 8 versus urllib2 certificate verify

2017-09-12 Thread Robin Becker

On 12/09/2017 08:35, dieter wrote:

Robin Becker  writes:
Certificate verification generally depends on local configuration:
specifically, the set of installed trusted root certificates.

I do not know about Windows, but often the root certificates installed
for other packages, e.g. the browser, are used. And different
versions of the same package may install different sets of trusted
certificates. It might also be that your new environment lacks
one of the packages from your old environment - and it has provided
the required root certificate.


Of course, the problem might also be caused by a general problem.
Try to access a "common" https site via urllib2, one you do not have
any problems to connect with a browser (or another "http" utility
like "wget" or "curl") from the same machines.
If this works, the problem is assiciated with the specific certificate.


The certs are fine at least in all the browsers I have access to.

It's pretty hard to use the python that's built in to a pyinstaller exe so I 
have used the certifi method and passed certifi.where() into the urlopen calls.


That seems to work, but obviously if the compiled in root certs become too old 
problems will recur.

--
Robin Becker

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


Re: How do I check all variables returned buy the functions exists

2017-09-20 Thread Robin Becker

On 16/09/2017 01:58, Steve D'Aprano wrote:



If you want to test for None specifically:

if any(v is None for v in values):
 print "at least one value was None"


...

for some reason that seems slow on my machine when compared with

if None in values:
   .



C:\usr\share\robin\pythonDoc>python -m timeit -s"values=(1,2,None)" "any(v is None 
for v in values)"
100 loops, best of 3: 0.62 usec per loop

C:\usr\share\robin\pythonDoc>python -m timeit -s"values=(None,2,None)" "any(v is 
None for v in values)"
1000000 loops, best of 3: 0.504 usec per loop

C:\usr\share\robin\pythonDoc>python -m timeit -s"values=(None,2,None)" "None in 
values"
1000 loops, best of 3: 0.0309 usec per loop

C:\usr\share\robin\pythonDoc>python -m timeit -s"values=(1,2,None)" "None in 
values"
1000 loops, best of 3: 0.097 usec per loop


it also seems a bit less obvious
--
Robin Becker

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


Re: Even Older Man Yells At Whippersnappers

2017-09-27 Thread Robin Becker

On 20/09/2017 10:54, Chris Angelico wrote:



What, you take silicon that someone else created?!

ChrisA

well I had germanium for flipflops and dekatron tubes with neon for counters 
never built anything digital with valves though

--
Robin Becker

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


Re: The "loop and a half"

2017-10-04 Thread Robin Becker
Given the prevalence of the loop and a half idea in python I wonder why we don't 
have a "do" or "loop" statement to start loops without a test.




C:\Python27\Lib>grep "while True" *.py | wc -l
 99

C:\Python27\Lib>grep "while 1" *.py | wc -l
117



C:\Python36\Lib>grep "while True" *.py | wc -l
131

C:\Python36\Lib>grep "while 1" *.py | wc -l
 44


How much does the while True actually cost compared to nothing?
--
Robin Becker

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


Re: The "loop and a half"

2017-10-04 Thread Robin Becker

On 04/10/2017 11:57, Rhodri James wrote:

On 04/10/17 10:01, Robin Becker wrote:
Given the prevalence of the loop and a half idea in python I wonder why we 
don't have a "do" or "loop" statement to start loops without a test.


See PEP 315.  Guido's rejection note is here:
https://mail.python.org/pipermail/python-ideas/2013-June/021610.html

seems fair enough; I suppose the cost is negligible or perhaps there's peephole 
optimization for this common case.

--
Robin Becker

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


Re: why del is not a function or method?

2017-10-18 Thread Robin Becker

On 16/10/2017 16:37, Xue Feng via Python-list wrote:

Hi,
    I wonder why 'del' is not a function or method. Most operations can be used 
as follows

     len(team)
or
     team.append("tom")
But, I think
     del team[2]
is somewhat uncommon. Why does not it take a syntax we are famillar with?

It can look like a function


x = 3
del(x)
x

Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'x' is not defined





--
Robin Becker

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


efficient way to get a sufficient set of identifying attributes

2017-10-19 Thread Robin Becker
Given a list of objects with attributes a0, a1, a2,an-1 is there an 
efficient way to find sets of attributes which can be used to distinguish 
members of the list?


As example a list of people might have

firstName, lastName, nationality, postcode, phonenumber,

as attributes. The probe items may have some of these attributes, but which 
should be used to test. Presumably the information in any attribute is highest 
if the number of distinct occurrences is the the same as the list length and 
pairs of attributes are more likely to be unique, but is there some proper way 
to go about determining what tests to use?


A particular problem might be dynamic in that the list may be being constructed 
from the probes.

--
Robin Becker

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


Re: efficient way to get a sufficient set of identifying attributes

2017-10-19 Thread Robin Becker

On 19/10/2017 16:42, Stefan Ram wrote:

Robin Becker  writes:

Presumably the information in any attribute is highest
if the number of distinct occurrences is the the same as the list length and
pairs of attributes are more likely to be unique, but is there some proper way
to go about determining what tests to use?


   When there is a list

|>>> list = [ 'b', 'b', 'c', 'd', 'c', 'b' ]
|>>> l = len( list )

   , the length of its set can be obtained:

|>>> s = len( set( list ))

   . The entries are unique if the length of the set is the
   length of the list

|>>> l == s
|False

   And the ratio between the length of the set and the length
   of the list can be used to quantify the amount of repetiton.

|>>> s / l
|0.5

...
this sort of makes sense for single attributes, but ignores the possibility of 
combining the attributes to make the checks more discerning.

--
Robin Becker

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


Re: efficient way to get a sufficient set of identifying attributes

2017-10-20 Thread Robin Becker

On 19/10/2017 17:50, Stefan Ram wrote:

Robin Becker  writes:

...
this sort of makes sense for single attributes, but ignores the possibility of
combining the attributes to make the checks more discerning.


   What I wrote also applies to compound attributes
   (sets of base attributes).

   When there are n base attributes, one can form 2^n-1
   compound attributes from them, or 2^n-1-n proper compound
   attributes. Therefore, a combinatoric explosion might impede
   the brute-force approach. A heuristics might start to
   explore combinations of keys with the best s/l ratio first
   and/or use preferences for certain fields set by a human.



all good


   In database design, the keys are usually chosen by a
   human database designer using world knowledge. It sounds
   as if you want to have the computer make such a choice
   using only the information in the table as knowledge.


I think I am tending towards the chosen by real world knowledge approach :(



   Your "identifying attributes" are called "super keys"
   in database science. You probably want minimal
   identifying attribute sets (without unneeded attributes),
   which are called "candidate keys".



thanks for this and the reference below.



   So, now you can find and read literature, such as:

Journal of Al-Nahrain University
Vol.13 (2), June, 2010, pp.247-255
Science
247
Automatic Discovery Of Candidate In The Relational
 Databases Keys By Using Attributes Sets Closure
Yasmeen F. Al-ward
Department of Computer Science, College of Science,
Al-Nahrain University.

   (The title was copied by me as found, the contents is
   in the web and makes more sense than the title.)




--
Robin Becker

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


Re: Let's talk about debuggers!

2017-10-27 Thread Robin Becker

On 25/10/2017 15:08, Michele Simionato wrote:

pdb plus plus: https://pypi.python.org/pypi/pdbpp

I like the idea, but in putty at least changing the terminal size causes pdb++ 
to detach immediately from the process and mess up the screen. I think this is 
caused by (5, 'Input/output error') here


/home/rptlab/devel/otr/local/lib/python2.7/site-packages/pyrepl/fancy_termios.py 
in tcsetattr




def copy(self):
return self.__class__(self.as_list())
def tcgetattr(fd):
return TermState(termios.tcgetattr(fd))
def tcsetattr(fd, when, attrs):
termios.tcsetattr(fd, when, attrs.as_list())

 error is here

class Term(TermState):
TS__init__ = TermState.__init__
def __init__(self, fd=0):
self.TS__init__(termios.tcgetattr(fd))
self.fd = fd



--
Robin Becker

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


headless python app for android/ios

2017-10-27 Thread Robin Becker
In the past we have developed reportlab applications for use on android/ios 
devices. We used Kivy for the gui and the kivy setup did allow us to create a 
working reportlab pdf producer under the kivy gui. It was not exactly easy, but 
in the end we had a working PDF producer.


A possible requirement is for pdf production using reportlab, but with others 
providing the gui using possible something called electron.


I know very little about what is actually possible to provide api's in python 
under ios/android. Can the front end spawn a python process or must we run some 
kind of background app with  listening sockets etc etc? Can applications call 
out to the world to download updated templates and so on?


Any pointers would be useful.
--
Robin Becker

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


Re: Python Templating Language

2017-12-20 Thread Robin Becker

On 17/12/2017 06:41, Abdur-Rahmaan Janhangeer wrote:

Hi all,

Can somebody point out to me some py-based template languages interpreters
resources?

Thank you !


https://bitbucket.org/rptlab/preppy
--
Robin Becker

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


unicode direction control characters

2018-01-02 Thread Robin Becker

I'm seeing some strange characters in web responses eg

u'\u200e28\u200e/\u200e09\u200e/\u200e1962'

for a date of birth. The code \u200e is LEFT-TO-RIGHT MARK according to 
unicodedata.name.  I tried unicodedata.normalize, but it leaves those characters 
there. Is there any standard way to deal with these?


I assume that some browser+settings combination is putting these in eg perhaps 
the language is normally right to left but numbers are not.

--
Robin Becker

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


Re: unicode direction control characters

2018-01-02 Thread Robin Becker

On 02/01/2018 15:18, Chris Angelico wrote:

On Wed, Jan 3, 2018 at 1:30 AM, Robin Becker  wrote:

I'm seeing some strange characters in web responses eg

u'\u200e28\u200e/\u200e09\u200e/\u200e1962'

for a date of birth. The code \u200e is LEFT-TO-RIGHT MARK according to
unicodedata.name.  I tried unicodedata.normalize, but it leaves those
characters there. Is there any standard way to deal with these?

I assume that some browser+settings combination is putting these in eg
perhaps the language is normally right to left but numbers are not.


Unicode normalization is a different beast altogether. You could
probably just remove the LTR marks and run with the rest, though, as
they don't seem to be important in this string.

ChrisA

I guess I'm really wondering whether the BIDI control characters have any 
semantic meaning. Most numbers seem to be LTR.


If I saw u'\u200f12' it seems to imply that the characters should be displayed 
'21', but I don't know whether the number is 12 or 21.

--
Robin Becker

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


Re: Tips or strategies to understanding how CPython works under the hood

2018-01-10 Thread Robin Becker

http://aosabook.org/en/500L/a-python-interpreter-written-in-python.html
--
Robin Becker

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


py2exe output flagged as malware

2018-02-28 Thread Robin Becker
I see this has happened to others in the past. I'm using 32 bit python 2.7.10 with py2exe 3.3 on windows 7. The exes work fine, 
but when I try to download into windows 10 I'm getting the exes immediately removed as malware.


Is there any way to prevent this. It's very bad for python programs to get this 
kind of reputation.

Anyone know if the same happens with PyInstaller etc etc?
--
Robin Becker

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


Re: py2exe output flagged as malware

2018-02-28 Thread Robin Becker

On 28/02/2018 11:46, alister via Python-list wrote:

On Wed, 28 Feb 2018 09:53:09 +, Robin Becker wrote:


I see this has happened to others in the past. I'm using 32 bit python
2.7.10 with py2exe 3.3 on windows 7. The exes work fine,
but when I try to download into windows 10 I'm getting the exes
immediately removed as malware.

Is there any way to prevent this. It's very bad for python programs to
get this kind of reputation.

Anyone know if the same happens with PyInstaller etc etc?


I would suggest you contact the Anti-virus vendor,
Are you sure you have download a clean copy of py2exe.



The anti-virus vendor is Microsoft; I imagine I will get short shrift from them 
regarding this issue.

Turns out my py2exe script was just pyinstaller under the hood. Apologies to 
py2exe.

I guess someone changed the build script script to use a different python 
packager.

I upgraded pyinstaller using the very latest pip and now the version of pyinstaller at least is 3.3.1. I don't actually know how 
to check the validity of the installed code or the binary stubs.


After rebuilding with 3.3.1 the new exe is 10 bytes shorter and is not 
recognized as malware by windows 10.
--
Robin Becker

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


Re: py2exe output flagged as malware

2018-02-28 Thread Robin Becker

On 28/02/2018 16:25, Hartmut Goebel wrote:

Am 28.02.2018 um 16:47 schrieb Robin Becker:

I upgraded pyinstaller using the very latest pip and now the version
of pyinstaller at least is 3.3.1. I don't actually know how to check
the validity of the installed code or the binary stubs.


The current archives are PyPI are PGP/GnuPG-signed, as the ones at github.


so presumably I can locate the downloaded tar zip and hash it to check. Of 
course if pip is already busted it can out fox me anyhow.
--
Robin Becker

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


is mypy failing here

2022-11-24 Thread Robin Becker

I haven't used dataclasses or typing very much, but while playing about I found 
this didn't give me an expected error

(.py312) robin@minikat:~/devel/reportlab
$ cat tmp/examples/tdc.py && python tmp/examples/tdc.py && mypy 
tmp/examples/tdc.py
##
from dataclasses import dataclass

@dataclass
class DC:
a: str
b: str

def main():
dc = DC(DC, "B")
print(dc)

if __name__ == "__main__":
main()
##
DC(a=, b='B')
Success: no issues found in 1 source file
(.py312) robin@minikat:~/devel/reportlab

DC.a is supposed to be a str and I expected mypy to indicate a type error

should typing work for this case?
--
Robin Becker
--
https://mail.python.org/mailman/listinfo/python-list


Re: is mypy failing here

2022-11-25 Thread Robin Becker

On 24/11/2022 14:10, Thomas Passin wrote:
.


C:\temp\python>py -V
Python 3.10.4

C:\temp\python>py tdc.py
DC(a=, b='B')

C:\temp\python>mypy tdc.py
tdc.py:10: error: Argument 1 to "DC" has incompatible type "Type[DC]"; expected 
"str"  [arg-type]
Found 1 error in 1 file (checked 1 source file)


Forgot the mypy version:

C:\Users\tom>mypy --version
mypy 0.910

interesting; I'm on archlinux and neither the system python 3.10.8 / mypy 0.982 gives an error. I did try running in my 
self build 3.10.8 with latest mypy 0.991 and mypy 0.910 and I still don't get an error.


I'll break out the windows 10 laptop and see what happens there.

You ran with the py runner. I wonder if that does something special.
--
Robin Becker
--
https://mail.python.org/mailman/listinfo/python-list


Re: is mypy failing here

2022-11-25 Thread Robin Becker

On 24/11/2022 13:50, Kirill Ratkin via Python-list wrote:

mypy --strict gives you detail info.

Thanks Kirill,

it seems --strict does find the errors. One of those is that on line 9 I have 
to add a return type ie

def main() -> None:
.

if that is added then mypy without --strict also finds the real typing error.

So it seems the tool fails in the simplest cases if you forget some typing.

Interesting that it works in windows without --strict though.
--
Robin Becker
--
https://mail.python.org/mailman/listinfo/python-list


C extension custom types in abi3 module

2022-12-08 Thread Robin Becker

I am trying to split off reportlab C extensions to simplify installations and 
make use of more advanced packages.

A simple extension is easily converted to being an abi3 module. However, another has a custom type which uses the old 
style mechanisms here


  https://docs.python.org/3.7/extending/newtypes_tutorial.html#the-basics

I made a simple setup based on this abi3 example modified to allow switching 
between abi3 and normal build

  https://github.com/joerick/python-abi3-package-sample

I made a tiny change to the code example in the newtypes tutorial page the code 
is here

https://github.com/MrBitBucket/custom-type

In a python 3.7 - 3.12a3 environment I find I can build the wheel OK with

  ABI3_WHEEL=0 pip wheel -w dist .


but I get lots of compile errors if I switch to an abi3 build with

  ABI3_WHEEL=1 pip wheel -w dist .

looking at the errors


 src/_custom.c:10:1: error: variable ‘CustomType’ has initializer but 
incomplete type
 10 | static PyTypeObject CustomType = {
| ^~
  In file included from 
/home/robin/LOCAL/3.7.16/include/python3.7m/Python.h:90,
   from src/_custom.c:2:
  /home/robin/LOCAL/3.7.16/include/python3.7m/object.h:90:5: error: extra 
brace group at end of initializer
 90 | { PyObject_HEAD_INIT(type) size },
| ^
  src/_custom.c:11:9: note: in expansion of macro ‘PyVarObject_HEAD_INIT’
 11 | PyVarObject_HEAD_INIT(NULL, 0)


it looks like I have to use a different mechanism to setup custom types in the 
abi3 world.

I looked in Modules/xxlimited_35.c, but that seems much more complex and 
provides for a type which supports GC.

Are there any ABI3 examples using the old style strategy?
--
Robin Becker
--
https://mail.python.org/mailman/listinfo/python-list


Re: C extension custom types in abi3 module

2022-12-08 Thread Robin Becker

On 08/12/2022 12:52, Robin Becker wrote:

I am trying to split off reportlab C extensions to simplify installations and 
make use of more advanced packages.

A simple extension is easily converted to being an abi3 module. However, another has a custom type which uses the old 
style mechanisms here




it looks like I have to use a different mechanism to setup custom types in the 
abi3 world.


In the docs I see this

"Also, since PyTypeObject is only part of the Limited API as an opaque struct, any extension modules using static types 
must be compiled for a specific Python minor version."


So it seems I must switch to using a heap allocated type or keep compiling in 
the old way.



I looked in Modules/xxlimited_35.c, but that seems much more complex and 
provides for a type which supports GC.

Are there any ABI3 examples using the old style strategy?
--
Robin Becker


--
Robin Becker

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


  1   2   3   4   5   6   7   8   9   >