How do I run a python program from an internet address?

2012-05-07 Thread Albert
I have a small text based python program that I want to make available
to people who might be behind a firewall or can't install python on
their office computers, but can access the internet.  It is just an
algorithm that makes a handful of straightforward calculations on some
input that the user provides and spits out some text as output that
they might want to print out on a printer.  I can program python on my
local machine, but don't know how to make the code accessible from a
browser.

What would be the best way to figure out how to do this?  I looked at
Google app engine tutorial, but can't figure out how that will help we
get the code into the cloud so I can access it from any browser.
-- 
http://mail.python.org/mailman/listinfo/python-list


Anyone know a donation app codebase?

2016-06-04 Thread Albert
Hello,

Anyone knows a donation app whose code is available on github or similar made 
in python (could be django, flask, or any other web framework).

Thank you very much.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Anyone know a donation app codebase?

2016-06-05 Thread Albert
Thank you for your answer Ben,

That is not exactly what I am looking for. I am interested in knowing if there 
are any python (django, flask, etc) opensource projects for managing donations, 
similar to catarse [1] (ruby) and [2] (ruby).

[1]: https://github.com/catarse/catarse
[2]: https://github.com/danielweinmann/unlock

Any suggestion please?

On Saturday, June 4, 2016 at 6:02:51 PM UTC-3, Ben Finney wrote:
> Albert writes:
> 
> > Anyone knows a donation app whose code is available on github or
> > similar made in python (could be django, flask, or any other web
> > framework).
> 
> Search for Python libraries on the Python Package Index
> https://pypi.python.org/>.
> 
> What you are (I think) looking for can be called a “payment” handler
> https://pypi.python.org/pypi?%3Aaction=search&term=payment&submit=search>.
> If that's not right you can try different search terms.
> 
> -- 
>  \ “My, your, his, hers, ours, theirs, its. I'm, you're, he's, |
>   `\   she's, we're, they're, it's.” —anonymous, alt.sysadmin.recovery |
> _o__)  |
> Ben Finney

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


Re: Anyone know a donation app codebase?

2016-06-15 Thread Albert
On Monday, June 6, 2016 at 10:17:35 AM UTC-3, Michael Selik wrote:
> On Sun, Jun 5, 2016 at 3:26 PM Ben Finney <>
> wrote:
> 
> > Albert <> writes:
> >
> > > Thank you for your answer Ben,
> >
> > You're welcome. Please note that top-posting is poor etiquette for
> > discussions; instead, interleave your response like a written dialogue.
> > See https://en.wikipedia.org/wiki/Posting_style#Interleaved_style>.
> >
> > > That is not exactly what I am looking for. I am interested in knowing
> > > if there are any python (django, flask, etc) opensource projects for
> > > managing donations
> >
> > Again, PyPI is the place to search
> >  > https://pypi.python.org/pypi?:action=search&term=django%20donation&submit=search
> > >.
> >
> 
> I tried the Google search engine. Looking up the phrase "python managing
> donations catarse" the 2nd search result was this a website which appears
> to list several packages in different programming languages.
> http://seedingfactory.com/index.html%3Fp=634.html

Great, this looks very promising!

Thank you very much to both for your time and good will to help me out.

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


Re: [newbie] problem with if then

2013-06-09 Thread Albert Dengg
Jean Dubois  wrote:
...
> checkavailablestring='wget -q -O -
>http://www.deredactie.be/cm/vrtnieuws/videozone/programmas/journaal/EP_'+thisday.strftime("%y%m%d")+'_JO7
>>/dev/null ; echo $?'
The problem schould be the echo:
Since os.system returns the exit code of the shell, when chaining commands with 
; it returns the exit status of the last command,in your case the echo.
So,if you really want to go with wget here,
Either drop the echo or chain with &&

Yours
Albert
Hi,
While i agree that calling wget here is not optimal
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Contact information for Jim Hugunin?

2013-07-24 Thread Albert Hopkins
On Mon, Jul 22, 2013, at 05:33 PM, Larry Hastings wrote:
> 
> 
> Does anybody have an email address (or anything, really) for Jim 
> Hugunin?  He left Google in May and appears to have dropped off the face 
> of the internet.  Please email me privately.
> 
> I swear I will use the information only for good and never for evil,

Is that your definition of "good" and "evil" or mine?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 'indent'ing Python in windows bat

2012-09-19 Thread Albert Hopkins
On Tue, 2012-09-18 at 22:12 -0600, Jason Friedman wrote:
> > I'm converting windows bat files little by little to Python 3 as I find time
> > and learn Python.
> > The most efficient method for some lines is to call Python like:
> > python -c "import sys; sys.exit(3)"
> >
> > How do I "indent" if I have something like:
> > if (sR=='Cope'): sys.exit(1) elif (sR=='Perform') sys.exit(2) else
> > sys.exit(3)
> 
> Some months ago I posted what I think is a similar question in the
> Unix world:  I wanted to call a small portion of Python from within a
> Bash script.
> 
> Someone on this list answered (for Bash):
> 
> #!/bin/bash
> command1
> command2
> python -c "if True:
> import module
> if condition:
> do_this
> else:
> do_that
> "
> command4
> # end code

A better way (in *nix) would be, e.g.:

#!/bin/sh   
 

read -p 'Enter a number ' count

python << EOF
print 'Odd numbers between 0 and ${count}'
for i in range(${count}):
if i % 2:
print i
EOF

Horribly bad example, but you get the idea.

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


Re: Fastest web framework

2012-09-24 Thread Albert Hopkins
On Sun, 2012-09-23 at 12:19 +0300, Andriy Kornatskyy wrote:
> I have run recently a benchmark of a trivial 'hello world' application for 
> various python web frameworks (bottle, django, flask, pyramid, web.py, 
> wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9... you might find 
> it interesting:
> 
> http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html
> 
> Comments or suggestions are welcome.
> 

The thing I don't like about these benchmarks is.. they tell you which
framework is best for writing a trivial 'hello world' application.  But
no one writes trivial 'hello world' applications.  A
framework/programming language/software package/what-have-you.  Can be
really fast for trivial stuff, but perform much less favorably when
performing "real-world" tasks.  It's kind of the same argument that's
used when people say X computer boots faster than Y computer.  That's
nice and all, but I spend much more of my time *using* my computer than
*booting* it, so it doesn't give me a good picture of how the computers
perform.  This is why most "good" benchmarks run a series various tests
based on real-world use cases.

-a


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


Re: who can give me some practical tutorials on django 1.4 or 1.5?

2012-11-04 Thread Albert Hopkins
On Sun, 2012-11-04 at 13:29 +0800, Levi Nie wrote:
> Who can give me some practical tutorials on django 1.4 or 1.5?
> Thank you.

Is the official[1] tutorial not practical enough?

[1] https://docs.djangoproject.com/en/1.4/intro/tutorial01/


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


Re: Help accessing COM .dll from Python

2012-12-01 Thread Albert Dengg
On Sat, Dec 01, 2012 at 12:47:57PM +, Steve Simmons wrote:
> Gunther - Sorry about that, hoping this response comes through as
> plain text.
> 
> Chris - Thanks for the translation and the response.  Unfortunately,
> I don't speak 'C', and I think the learning curve for Python + COM
> should be slightly less steep.
i've had some some expirience using COM from python with pywin32, which
works reasonably well if your interfaces is documented.

as for examples beeing excel centric: it does not really matter, you
just have to look the real interface you want to use in the
documentation of your libary.

there are however some pitfalls, espesially with arguments passed by
reference: there not the parameter will be modified but you will have a
tuple as a return value.

albert


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tarfile and usernames

2012-12-30 Thread Albert Hopkins






On Sun, Dec 30, 2012, at 01:57 PM, Nicholas Cole wrote:

Dear List,

I'm hoping to use the tarfile module in the standard library to move
some files between computers.

I can't see documented anywhere what this library does with userids and
groupids.  I can't guarantee that the computers involved will have the
same users and groups, and would like the archives to be extracted so
that the files are all owned by the extracting user.

Essentially, I do *not* with to preserve the owner and groups specified
in the archives.


Each "member" in the tar file has misc. metadata associated with it,
which can be retrieved with the get_info() method.  You can add/modify
this metadata if creating a TarFile.

However, it should be stated that by default (on *nix anyway) if the
user is not root then user/groups are assigned to the user exctracting
the file (because only root can assign userids/non-member-groups).
The TarFile extract*() methods pretty much inherit the same behavior as
the *nix tar command.  So if you are extracting as a non-root user, you
should expect the same behavoir.  If you are extracting as root but
don't want to change user/groups may have to extract it manually or
create your own class by inheriting TarFile and overriding the .chown()
method.

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


Re: When is overriding __getattr__ is useful?

2013-01-07 Thread Albert Hopkins


On Mon, Jan 7, 2013, at 10:54 AM, Rodrick Brown wrote:
> Can someone provide an example why one would want to override __getattr__
> and __getattribute__ in a class?


They're good for cases when you want to provide an "attribute-like"
quality but you don't know the attribute in advance.

For example, the xmlrpclib uses __getattr__ to "expose" XML-RPC methods
over the wire when it doesn't necessarily know what methods are exposed
by the service.  This allows you do simply do

>>> service.method(*args)

And have the method "seem" like it's just a local method on an object.


There are countless other examples.  But that's just one that can be
found in the standard library.

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


Re: sockobj.connect Errno 13 Permission denied

2013-01-26 Thread Albert Hopkins


On Sat, Jan 26, 2013, at 08:52 AM, Joel Goldstick wrote:
> On Sat, Jan 26, 2013 at 8:47 AM, Joel Goldstick
> wrote:
> 
> >
> >
> >
> > On Sat, Jan 26, 2013 at 6:19 AM, nobody  wrote:
> >
> >> Hi,
> >>
> >> I have a client program Client.py which has a statement of
> >> sockobj.connect(), the port number 6 is used, so no problem from port
> >> permission.
> >>
> >> I am puzzled because I can run Client.py from command line in my user
> >> account or apache user account without any problems.
> >>
> >> But if I run it from a web page http://localhost/client.php, the
> >> client.php called exec("Client.py"),
> >
> >
> >
> > Check the arguments to exec.  I think it has to be an open file object.
> >
> >
> >
> >> then it got an exception of sockobj.connect Errno 13 Permission denied.
> >>
> >> Why it can run from command line, but cannot make connection from a web
> >> file? Appreciate any tips and clues.
> >>
> >> Thank you.
> >>
> >> Kind regards.
> >>
> >>
> >>
> Maybe I spoke too soon.  You should probably be asking in a php forum
> since
> what you are doing is running a php exec.  If you are actually getting a
> python error you should show the code and the traceback so that someone
> can
> look at your code.
> 
> In either case (py and php) it looks like exec needs either a string of
> executable text or (in py case) an open file handle.  So the code you
> describe isn't really what you are running
> 

Also your php/apache config needs to be set up to enable execs (I think
it's off by the default).

Either way it's a PHP question, not a Python question.
-- 
http://mail.python.org/mailman/listinfo/python-list


WatPy: A new Python User Group in Kitchener-Waterloo, Ontario

2012-05-29 Thread Albert O'Connor
We are having our first night of talks on Thursday June 7th, 6:30 at the
Communitech Hub in downtown Kitchener.

More information: http://watpy.ca/blog/post/peer-2-peer-talks/

Albert O'Connor
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subtle error slows code by 10x (builtin sum()) - replace builtin sum without using import?

2011-07-01 Thread Albert Hopkins


On Friday, July 1 at 19:17 (-0700), bdb112 said:

> Question:
> Can I replace the builtin sum function globally for test purposes so
> that my large set of codes uses the replacement?
> 
> The replacement would simply issue warnings.warn() if it detected an
> ndarray argument, then call the original sum
> I could then find the offending code and use the appropriate import to
> get numpy.sum

You shouldn't do this, but you could use the __builtins__ module

e.g.

>>> __builtins__.sum = numpy.sum # bad



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


Making `logging.basicConfig` log to *both* `sys.stderr` and `sys.stdout`?

2011-08-30 Thread Michel Albert
Hi,

I use python oftentimes to write automation scripts on Linux servers.
And there's a big pattern in my scripts:

- I *always* use `logging` instead of `print` statements.
- I *always* create two stream handlers. One for `sys.stdout` with
level `INFO` and one for `sys.stderr` with level `WARN`

Well, the levels may variate occasionally, but that's only the rare
exception.

The reason I do this is simple: Most automation tasks are run via
cron. With this setup, I can redirect `stdout` to `/dev/null` and
still receive e-mails if things go wrong.

And having two handlers gives me more flexibility in my scripts. In
one case, I used a different color for error messages for example as
this script is run primarily from the shell and having errors stand
out has proven to be a good thing.

Unfortunately this setup makes `logging.basicConfig` pretty useless.
However, I believe that this is something that more people could
benefit from. I also believe, that it just "makes sense" to send
warnings (and above) to `stderr`, the rest to `stdout`.

So I was thinking: "Why does `logging.basicConfig` not behave that
way".

Naturally, I was thinking of writing a patch against the python
codebase and submit it as a suggestion. But before doing so, I would
like to hear your thoughts on this. Does it make sense to you too or
am I on the wrong track? Are there any downsides I am missing?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making `logging.basicConfig` log to *both* `sys.stderr` and `sys.stdout`?

2011-08-30 Thread Michel Albert
On Aug 30, 11:45 am, Peter Otten <[email protected]> wrote:
> Michel Albert wrote:
> > I use python oftentimes to write automation scripts on Linux servers.
> > And there's a big pattern in my scripts:
>
> > - I *always* use `logging` instead of `print` statements.
> > - I *always* create two stream handlers. One for `sys.stdout` with
> > level `INFO` and one for `sys.stderr` with level `WARN`
>
> > Well, the levels may variate occasionally, but that's only the rare
> > exception.
>
> How would a call to basicConfig() look like that produces this setup?

I personally see this happen by default (i.e. no additional
parameters). And in case the `stream` parameter is set, /then/ you
would  send all to that stream only.

In my point of view, the call to `basicConfig` is either something
used in only the most mundane usages of the logging package, or it's
mainly used by people that have not yet grokked the logging package
(correct me if I'm wrong). In both cases, I find it useful to redirect
warnings and errors to `stderr` by default.

However, this would also mean that existing code calling this method
would result in different behavior. But only /slightly/ different.
Meaning, you still see the output on the console as expected. But it
gives you the possibility to use standard shell redirection in a way
that "makes sense".
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Restarting a daemon

2011-04-26 Thread Albert Hopkins
On Tue, 2011-04-26 at 06:13 -0600, Jeffrey Barish wrote:
> Not exactly a Python question, but I thought I would start here.
> 
> I have a server that runs as a daemon.  I can restart the server manually 
> with the command 
> 
> myserver restart
> 
> This command starts a new myserver which first looks up the pid for the one 
> that is running and sends it a terminate signal.  The new one then 
> daemonizes itself.
> 
> I want the server to be able to restart itself.  Will it work to have 
> myserver issue "myserver restart" using os.system?  I fear that the new 
> myserver, which will be running in a subshell, will terminate the subshell 
> along with the old myserver when it sends the terminate signal to the old 
> myserver.  If so, what is the correct way to restart the daemon?  Will it 
> work to run the restart command in a subprocess rather than a subshell or 
> will a subprocess also terminate when its parent terminates?

You should look into tools like daemon-tools, or similar.  It already
solves this (and many other) problems.

-a

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


Re: How to concatenate unicode strings ???

2011-04-26 Thread Albert Hopkins
On Tue, 2011-04-26 at 17:58 +0200, Ariel wrote:
> Hi everybody, how could I concatenate unicode strings ??? 
> What I want to do is this:
> 
> unicode('this an example language ') + unicode('español') 
> 
> but I get an:
> Traceback (most recent call last):
>   File "", line 1, in 
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
> 11: ordinal not in range(128)
> 
> How could I concatenate unicode strings ???
> 
Your problem isn't with concationation. Your problem is with:


unicode('español')


That is your are passing a non-unicode string to the unicode type and,
it seems the default encoding on your system is ASCII, but "ñ"
is not valid ASCII encoding.

So you can do one of two things:

* Use a unicode literal, e.g. u'español'
* pass whatever encoding you are actually using in your byte string,
  e.g. unicode('español', 'utf8')

If you are writing this in a module and you want to use unicode
literals, you should put something similar at the top of the file:

# -*- encoding: utf-8 -*-

HTH,
-a


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


Re: PIL: The _imaging C module is not installed

2011-05-05 Thread Albert Hopkins
On Thu, 2011-05-05 at 15:35 +0200, Nico Grubert wrote:
> Hi there
> 
> I am having trouble to install PIL 1.1.7 on CentOS.
> 
> I read and followed the instructions from
> http://effbot.org/zone/pil-imaging-not-installed.htm
> 
> However, I still get the "The _imaging C module is not installed" error 
> if I run the selftest:
> 
> $ python selftest.py
> *** The _imaging C module is not installed
> 
> 
> Here is what I have tested so far:
> 
> 1.)
> 
> $ python -v
> ...
>  >>> import Image
> ...
> dlopen("/usr/local/lib/python2.4/site-packages/PIL/_imaging.so", 2);
> import _imaging # dynamically loaded from 
> /usr/local/lib/python2.4/site-packages/PIL/_imaging.so
> ...

I had this problem earlier this week.

Assuming that you pip-installed or similar.

PIL will compile and install if you don't have some development
libraries and then simply not work or not work up to full steam when
used.

To avoid this, you need to install the appropriate libraries, among
which are:

libjpeg-devel
freetype-devel
libpng-devel

Probably others as well.

HTH,
-a


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


Re: PIL: The _imaging C module is not installed

2011-05-05 Thread Albert Hopkins
Oh I forgot to say, after installing these libraries, you will need to
re-compile (install) PIL.

-a


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


Re: PIL: The _imaging C module is not installed

2011-05-05 Thread Albert Hopkins
On Fri, 2011-05-06 at 01:45 +0200, Michel Claveau - MVP wrote:
> Hi!
> 
> > you need to install the appropriate libraries, among which are:
> > libjpeg-devel
> > freetype-devel
> > libpng-devel
> 
> OK, but where can I find it?  I want use PIL with Python under Windows,
> and I can't compile C's sources.
> Should I replace PIL by ImageMagick?

The OP was about CentOS.  I have no idea about Windows.

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


Re: if statement multiple or

2011-05-06 Thread Albert Hopkins
On Fri, 2011-05-06 at 13:47 +0300, Lutfi Oduncuoglu wrote:
> Hi,
> 
> I am trying to write a script and I realised that I need to use
> something like
> 
> if ('a' or 'b' or 'c')  not in line:
>print line
> 

The expression:
('a' or 'b' or 'c') 

evaluates to True

True not in line

Is probably not what you intended.


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


Re: if statement multiple or

2011-05-06 Thread Albert Hopkins
Correction:

('a' or 'b' or 'c') evaluates to 'a'


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


Re: FW: help please

2011-05-17 Thread Albert Hopkins
On Tue, 2011-05-17 at 10:18 -0600, Littlefield, Tyler wrote:
> Not to be pedantic or anything, and I may not be able to help 
> regardless, but it looks like your space key is fixed, and I don't 
> really care to pick through and try to play hangman with your message.

I actually, at first glance, thought it was spam, ignored it, and was
wondering why people were replying to it :|

-a


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


Re: FW: help please

2011-05-18 Thread Albert Hopkins
On Tue, 2011-05-17 at 21:46 -0300, Gabriel Genellina wrote:
> En Tue, 17 May 2011 16:48:29 -0300, Albert Hopkins
>  escribió:
> > On Tue, 2011-05-17 at 10:18 -0600, Littlefield, Tyler wrote:
> 
> >> Not to be pedantic or anything, and I may not be able to help
> >> regardless, but it looks like your space key is fixed, and I don't
> >> really care to pick through and try to play hangman with your message.
> >
> > I actually, at first glance, thought it was spam, ignored it, and was
> > wondering why people were replying to it :|
> 
> I can't remember exactly in which release 'perfect English skills' were
> added to Python runtime requirements, could you please refresh my memory?

I can't speak for Tyler (I assume your message was meant for him) but as
for myself:  I saw a glob of practically unreadable text and simply
passed it off as spam, concluding that any well-intentioned, moderately
intelligent human being wouldn't have intentionally posted such a
monstrosity and actually expected an intelligent response.

I'm guessing Tyler's message was to help you so that your messages don't
continue to be ignored by people who may otherwise be of assistance.

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


Re: FW: help please

2011-05-18 Thread Albert Hopkins
On Wed, 2011-05-18 at 13:39 +0100, Stuart MacKay wrote:
> If you were required to answer the question then asking the poster to 
> phrase it better is going to help solve the issue faster but for a 
> mailing list like this simply ignore it. 

Which is what I've done.

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


Re: How To Make Fast Money Legally

2011-05-18 Thread Albert Hopkins
On Wed, 2011-05-18 at 15:48 -0400, D'Arcy J.M. Cain wrote:
> On Wed, 18 May 2011 12:06:07 -0700 (PDT)
> "[email protected]"  wrote:
> > HOW TO MAKE EASY MONEY FAST AND LEGALLY
> 
> Wow!  Was this stuck in someone's mail queue since 1992?

Me too!

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


Re: changing current dir and executing a shell script

2011-05-27 Thread Albert Hopkins
On Fri, 2011-05-27 at 14:25 -0700, suresh wrote:
> Hi,
> I want to execute the following command line stuff from inside python. 
> $cd directory
> $./executable
> 
> I tried the following but I get errors
> import subprocess
> subprocess.check_call('cd dir_name;./executable')
> 
> Due to filename path issues, I cannot try this version.
> subprocess.check_call('./dir_name/executable')
> 

You don't want to do this because "cd" is a built-in shell command, and
subprocess does not execute within a shell (by default).

The proper way to do this is to use the "cwd" keyword argument to
subprocess calls, i.e.:

>>> subprocess.check_call(('/path/to/exec',), cwd="/path/to/dir")

-a


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


Re: changing current dir and executing a shell script

2011-05-28 Thread Albert Hopkins
On Sat, 2011-05-28 at 09:41 +0200, Peter Otten wrote:
> > You don't want to do this because "cd" is a built-in shell command,
> and
> > subprocess does not execute within a shell (by default).
> 
> The problem is not that cd is built-in, but that there is no shell at
> all. 
> You can change that with shell=True: 

This is exactly what I said, but using different words.

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


Re: float("nan") in set or as key

2011-05-28 Thread Albert Hopkins
On Sun, 2011-05-29 at 00:41 +0100, MRAB wrote:
> Here's a curiosity. float("nan") can occur multiple times in a set or as 
> a key in a dict:
> 
>  >>> {float("nan"), float("nan")}
> {nan, nan}
> 
These two nans are not equal (they are two different nans)

> except that sometimes it can't:
> 
>  >>> nan = float("nan")
>  >>> {nan, nan}
> {nan}

This is the same nan, so it is equal to itself.

Two "nan"s are not equal in the manner that 1.0 and 1.0 are equal:

>>> 1.0 == 1.0
True
>>> float("nan") == float("nan")
False


I can't cite this in a spec, but it makes sense (to me) that two things
which are nan are not necessarily the same nan.

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


Demo-Mode in IPython broken?

2018-07-29 Thread Albert Brandl
Hi!

The IPython documentation mentions a demo mode that can be used
to execute chunks of a Python file that are separated by special
comments (e.g. "#  stop").

The annotated Python file can be executed by importing `Demo` from
`IPython.lib.demo`, instantiating it using the file name and calling
the `Demo` instance:

from IPython.lib.demo import Demo
d = Demo("some_file.py")
d()

According to the documentation, all names that are defined in such a
chunk are transferred to the global IPython namespace. This would
allow me to interactively inspect the names etc.

It looks like this feature does not work in the version 6.4.0 of
IPython: the global namespace does not change after executing any chunk
of a Python file. The Demo instance has a dictionary called `user_ns`
that _is_ updated when a chunk is executed, but using it to access the
names is quite clumsy ;-).

Is this a known bug? Do you have a suggestion how I could emulate the
behavior of the demo mode by other means (not necessarily with IPython)?

TIA and best regards,

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


Division issue with 3.8.2 on AIX 7.1

2020-06-03 Thread Albert Chin
I've built Python 3.8.2 on AIX 5.2, 5.3, 6.1, and 7.1. I am seeing
different results for the following Python program:
  $ python3 -c "eps = 2.0 ** -53.0; tiny = 2.0 ** -1022.0; \
print ((1.0 - eps) / tiny * 4.0)"

I get the correct result, 1.7976931348623157e+308, on AIX 5.2, 5.3,
and 6.1. But, on 7.1, I get "inf".

Anyone know where can I look in the Python source code to investigate
this?

-- 
albert chin ([email protected])
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Division issue with 3.8.2 on AIX 7.1

2020-06-03 Thread Albert Chin
On Wed, Jun 03, 2020 at 08:11:17PM -0400, Dennis Lee Bieber wrote:
> On Tue, 2 Jun 2020 12:26:16 -0500, Albert Chin
>  declaimed the following:
> 
> >I've built Python 3.8.2 on AIX 5.2, 5.3, 6.1, and 7.1. I am seeing
> >different results for the following Python program:
> >  $ python3 -c "eps = 2.0 ** -53.0; tiny = 2.0 ** -1022.0; \
> >print ((1.0 - eps) / tiny * 4.0)"
> >
> >I get the correct result, 1.7976931348623157e+308, on AIX 5.2, 5.3,
> >and 6.1. But, on 7.1, I get "inf".
> >
> >Anyone know where can I look in the Python source code to investigate
> >this?
> 
> Have you considered that it might be something in an underlying C
> library (especially for the double-precision exponentiation)?

On Wed, Jun 03, 2020 at 08:44:47PM -0700, Miki Tebeka wrote:
> > Anyone know where can I look in the Python source code to investigate
> > this?
>
> Probably around
> https://github.com/python/cpython/blob/master/Objects/floatobject.c

Thanks to both of you. I applied some updated OS patches and the
problem went away.

-- 
albert chin ([email protected])
-- 
https://mail.python.org/mailman/listinfo/python-list


pymssql and bind variables

2005-09-23 Thread Albert Leibbrandt








I need to write a little app that connects to an MS SQL
server and for this I decided on the pymssql module. At this stage I am trying
to find out if MS SQL server can handle bind variables. If anybody can give me
an answer and perhaps a example it will be appreciated

 

Thanks

Albert






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

Re: Overloading __init__ & Function overloading

2005-09-30 Thread Istvan Albert
in python you can provide default values for your parameters:

class BaseClass:
def __init__(self, a=None):
if a is None:
#no parameter
pass
else:
#one parameter
pass

baseclass1=BaseClass()
baseclass2=BaseClass(1)

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


Re: "no variable or argument declarations are necessary."

2005-10-04 Thread Istvan Albert
> What can one do to swiftly detect this type of bug?

While I can only speak from my own experience I can't  remember a
single instance where this type of bug caused any kind of serious
problem.  IMHO these are very trivial errors, that get caught
immediately and I would not  even qualify them as bugs, more like
typos, spelling mistakes, etc.

Real bugs are a lot more insidious than that, and they might even occur
more frequently  if there was type checking ...  since it might even
lead to longer code

just my $0.01

Istvan.

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


Re: Controlling who can run an executable

2005-10-04 Thread Istvan Albert
>was using to track clients and transactions.  He couldn't demonstrate
>the program for one reason or another because it was protected in a way
>that neither could circumvent. (She didn't remember how it was
>protected, she had hired this person a long time ago.)

I'd venture to guess that neither of the people above knew much about
programming. So do the same, create a security measure that protects
against this level of 'threat'.

As others have pointed out the simplest way would be to detect the
presence of a hidden file, or some hardcoded system value, mac address
etc. Obscure this step even more by encrypting some of the information
so that one can't just simply view it in a hex editor.

Istvan.

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


Re: New project coming up...stay with Python, or go with a dot net language??? Your thoughts please!

2005-10-04 Thread Istvan Albert

Disclaimer: this is not a flame against Boo.

It just boggles my mind that a language that describes itself as
"python inspired syntax" keeps being touted as:

> Luis M. Gonzalez wrote:
> Boo (which could be considered almost an static version of Python for .NET)

Boo is *nothing* like a static version of Python. Stop perpetuating
this nonsense.

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


Re: New project coming up...stay with Python, or go with a dot net language??? Your thoughts please!

2005-10-04 Thread Istvan Albert
> It has many similarities, but also some fundamental differences,

> considered "almost" a static python

lol, if  that is your definition of 'almost'  then your statement is
correct

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


Re: Controlling who can run an executable

2005-10-04 Thread Istvan Albert
> I could ask her, "If you can't break it is that good enough security?"

Guess not. Most non-programmers think everyone else who knows some
programming is a some sort of hacker genius.

Instead come up with a simple solution then explain her how it will
works. I think in the ensuing conversation you'll find out more on what
approach would put her mind at ease.

Istvan.

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


Re: How to delete yourself????

2005-10-14 Thread Istvan Albert
> But is this nice code??? Is there another way to delete yourself???

I think you are overcomplicating things.

Don't think of it as deleting 'itself', since what you seem to need is
deleting a reference to the instance.

In your example the parent is a container and  it usually makes more
sense to have the only the container deal with adding and deleting
elements, that way your objects are less coupled.

Istvan.

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


Re: XML Tree Discovery (script, tool, __?)

2005-10-26 Thread Istvan Albert
All I can add to this is:

- don't use SAX unless your document is huge
- don't use DOM unless someone is putting a gun to your head

There's a good selection of nice and simple XML processing libraries in
python. You could start with ElementTree.

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


Re: How best to reference parameters.

2005-10-26 Thread Istvan Albert
Sounds like the Bunch:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308

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


Re: PYTHON LOOSING FOR JAVA???????

2005-11-08 Thread Istvan Albert
> PYTHON LOOSING FOR JAVA???

Yes, Python is already looser than Java.

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


Re: CGI question

2005-11-29 Thread Istvan Albert
See urlparse:

http://www.python.org/doc/current/lib/module-urlparse.html

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


Re: an intriguing wifi http server mystery...please help

2005-11-30 Thread Istvan Albert
> The server is almost entirely based on the server found at:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/259148

Try using a different python based webserver. This recipe might have
some problems that cause the weird behavior.

(The Karigell webframework uses a server based on this recipe. In their
changlog for the latest release they say: "It fixes 2 bugs, one in the
asynchronous HTTP server which would use 100% of the CPU")

Istvan.

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


Re: an intriguing wifi http server mystery...please help

2005-11-30 Thread Istvan Albert
> But if it's a problem with the software,  why does the server work
> great when wired (i.e. not wireless)...that's the weird part.

Don't be  so quick to eliminate software error ... when it comes to
bugs there are few rules. You are using a recipe that is *known* to
produce weird behavior. Make sure to eliminate that source before
moving to more esoteric reasons such as bad routing table. For example
run some other simple webservers that  were written in some other
language and see if you get the same behavior (tinyhttpd or its ilk) .

Istvan.

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


Re: CGI question

2005-12-01 Thread Istvan Albert
> I'm still wondering though, if there's some part of the python standard
> modules that will convert those % escapes to ASCII or similar - and

I believe that functionality is provided by the quote/unquote functions
in the urllib module:

http://www.python.org/doc/current/lib/module-urllib.html

Istvan.

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


Re: Python evolution: Unease

2005-01-04 Thread Istvan Albert
Iwan van der Kleyn wrote:
And I do sense (reading planet python/this newsgroup) a mindset or at 
least a tendency by the people who really matter in these discussion to 
keep on adding features to the syntax; to add "structure" to Python. My 
personal preference would be to leave the language alone for a while and 
to improve its infrastructure.
In all honesty this:
http://www.artima.com/weblogs/viewpost.jsp?thread=86641
scares me too.  Reminds me of Larry Wall's writings on Perl 6
that make me tune out fairly quickly. I don't have the kind of
problems that the these features will solve so I can't relate
to them at all.
But others might do. Especially when using python in an environment
where enforcing a strict contract is important. But if python
were to become overly complicated I'll find something else.
Three years ago I have not not used python at all, now I'm
using it for everything.
Languages should evolve with time, adapt to the needs
of its users. Sometimes that means that in some areas
it might feel worse. But it could also mean that the
problem is with us, so it would be unfair to spend effort
towards holding back this evolution just because
we don't need it.
Istvan.
PS. why can't decorators solve this optional type checking
problem? I clearly remember this as being one of the
selling points for having decorators in the first place...
--
http://mail.python.org/mailman/listinfo/python-list


Re: Parallelization with Python: which, where, how?

2005-01-04 Thread Albert Hofkamp
On Mon, 20 Dec 2004 14:03:09 +0100, Mathias <[EMAIL PROTECTED]> wrote:
> Can someone recommend a parallelization approach? Are there examples or 
> documentation? Has someone got experience with stability and efficiency?

If you think a light-weight approach of distributing work and collecting
the output afterwards (using ssh/rsh) fits your problem, send me an
email.

Albert
-- 
Unlike popular belief, the .doc format is not an open publically available 
format.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python evolution: Unease

2005-01-04 Thread Istvan Albert
Doug Holton wrote:
application is so important that I expect Python 3000 will have
optional type declarations integrated into the argument list."
I think that *optional* part of the "optional type declaration"
is a myth.
It may be optional in the sense that the language will
accept missing declarations but as soon as the feature
is available it will become "mandatory" to use it
(peer pressure, workplace practices).
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Download .jpg from web

2005-01-06 Thread Istvan Albert
GMane Python wrote:
  Using a network camera with built-in webserver
The first thing that might be worth investigating
is this webserver. What kind of throughput is it
capable of? How does it handle repeated
requests etc.
Your program won't be faster than the server
that provides it with the data.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Writing huge Sets() to disk

2005-01-10 Thread Istvan Albert
Martin MOKREJÅ wrote:

But nevertheless, imagine 1E6 words of size 15. That's maybe 1.5GB of raw
data. Will sets be appropriate you think?
You started out with 20E20 then cut back to 1E15 keys
now it is down to one million but you claim that these
will take 1.5 GB.
On my system storing 1 million words of length 15
as keys of a python dictionary is around 75MB.
I.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Writing huge Sets() to disk

2005-01-10 Thread Istvan Albert
Martin MOKREJÅ wrote:
Istvan Albert wrote:

So you say 1 million words is better to store in dictionary than
in a set and use your own function to get out those unique or common
words?
I have said nothing even remotely like that.
Fine, that's what I wanted to hear. How do you improve the algorithm?
Do you delay indexing to the very latest moment or do you let your
computer index 999 999 times just for fun?
I think that you need to first understand how dictionaries work.
The time needed to insert a key is independent of
the number of values in the dictionary.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: distutils linux script installation broken?

2005-01-12 Thread Albert Hofkamp
On Wed, 12 Jan 2005 10:09:03 +, Cory Davis <[EMAIL PROTECTED]> wrote:
> command has been behaving badly.  In the part where it is supposed to 
> adjust the first line of the script it now produces
> 
> #!None
> 
> instead of
> 
> #!/whereverpythonis/python
> 
> Has anyone else encountered this?

I haven't (as I am not using 2.4 :-) )

However, there is an easy way around this, just use

#!/usr/bin env python

instead.


Albert
-- 
Unlike popular belief, the .doc format is not an open publically available 
format.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: shutil.move has a mind of its own

2005-01-12 Thread Istvan Albert
Daniel Bickett wrote:
In my script, rather than a file being moved to the desired location,
it is, rather, moved to the current working directory (in this case,
my desktop -- without any exceptions, mind you). As it happens, the
what is the output generated by the lines:
fdir, fname = randFileInfo.new()
debugMess( "Generated file information: %s, %s" % ( fdir, fname ) )
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: java 5 could like python?

2005-01-12 Thread Istvan Albert
vegetax wrote:
previus two python proyects where relatively big,and python didnt feel 
well suited for the task.
One typical problem that others might talk about in more detail
is that you might be writing java code in python. That means
using Java style class hierarchies, methods and overall
organization. That does not work well in python.
-No naming convention. 
That is result of open source model that evolved over a
long time.
getAttribute,GetAttribute,get_attribute, then i have to go and check the
doc, every time,which is a waste of time.
Create a simple wrapper that does exactly what you want. For
example it would take just a few minutes to create a URL class
that you wanted. Then you have to figure it out only once.
-Is python library half object oriented? half functional oriented? 
Yes. As should most solutions be.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Integration with java

2005-01-14 Thread Istvan Albert
Joachim Boomberschloss wrote:
 the code is already written in Python, using the
 standard libraries and several extension modules
One thing to keep in mind is that Jython does not
integrate CPython, instead it "understands" python code
directly. So if you have a C extension that works with python
it won't work with Jython.
My feeling is that if you had a lot of Java code written and
wanted to build on that with python Jython would be a better
fit than vice versa.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: [perl-python] 20050113 looking up syntax

2005-01-14 Thread Istvan Albert
Jürgen Exner wrote:
Why don't you just stop posting this nonsense?
He will, fairly soon. I'm suspecting that the original
intent behind these posts was to stir up a perl vs python
flamewar. That is unlikely to materialize since the
poster does not seem to understand neither of these
languages.
I.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Integration with java (Jpype vs. JPE)

2005-01-17 Thread Istvan Albert
Cameron Laird wrote:
Someone really ought to include a couple of sentences to that effect
on the front page of http://jpype.sf.net/ >.
Now I remember visiting this site, but never understood how it
actually worked. Examples such as:
from jpype import *
startJVM("d:/tools/j2sdk/jre/bin/client/jvm.dll", "-ea")
java.lang.System.out.println("hello world")
shutdownJVM()
in three different versions are the only code examples
that to show "complete" working snippets. I'm still
clueless as to how would one say share a list between
python and java.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


pychecker - sets.Set need to be overridden

2005-01-17 Thread Istvan Albert
Hello all,
if I have this code:
import sets
class Foo:
x = sets.Set()
then pychecker says:
test.py:4: Methods (__cmp__, __hash__) in sets.Set need to be overridden in a 
subclass
I don't get this message. What is it trying to say, and why?
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: pychecker - sets.Set need to be overridden

2005-01-17 Thread Istvan Albert
[EMAIL PROTECTED] wrote:
<__main__.Foo instance at 0x00C578A0> Set([])
on 2.4. on WinXP. What environment do you run in?
I'm running it on cygwin,
but still don't get it, why the warning?
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: pychecker - sets.Set need to be overridden

2005-01-17 Thread Istvan Albert
Peter Otten wrote:
The Set class has implementations for __cmp__() and __hash__() that
unconditionally raise an exception. pychecker assumes that these methods
are "abstract", i. e. meant to be overriden by a subclass, and warns that
you are instantiating an abstract base class, while the intention of the
I see. Thanks!
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Integration with java (Jpype vs. JPE)

2005-01-18 Thread Istvan Albert
Steve Menard wrote:
To asnwer your question more fully, the jpype-specific cide is only for 
looking up the Classes and startting/stopping the environment. For 
everything else, Java objects and classes are used as regular Python 
objects.
Thanks for the response. Currently I don't need to use java but
in the past when I explored such a possibility I looked at jpype
and I was unable to understand from the documentation what it
actually does.
There is a lot of text there, but it is all concerning catching
errors or other subtleties. For a new visitor the most important
question is about how it works, what does it do, and how can it be
applied for the given problem.
> everything else, Java objects and classes are used as regular Python
> objects.
This is too generic. My question was a little more specific,
how would I pass a python list as an argument of a java class/method or
transform a java list into a python one? You don't have to
answer it here, I'm just pointing out the kind of
questions that I was unable to get an answer for on the jpype
website.
best,
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: What YAML engine do you use?

2005-01-20 Thread Istvan Albert
Reinhold Birkenfeld wrote:
You will be amazed, and never think of XML again.
XML with elementtree is what makes me never have think about XML again.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] XML design intent ... further musings

2005-01-24 Thread Istvan Albert
Paul Rubin wrote:

I love this old rant about XML:
http://groups-beta.google.com/group/comp.lang.lisp/msg/9a30c508201627ee
This is my favorite:
http://weblog.burningbird.net/archives/2002/10/08/the-parable-of-the-languages
"I’m considered the savior, the ultimate solution, the final word.
Odes are written to me, flowers strewn at my feet, virgins sacrificed at
my altar. Programmers speak my name with awe. Companies insist on using
me in all their projects, though they’re not sure why. And whenever a
problem occurs, someone somewhere says, “Let’s use XML", and miracles
occur and my very name has become a talisman against evil. And yet, all
I am is a simple little markup, from humble origins.
It’s a burden, being XML."
--
http://mail.python.org/mailman/listinfo/python-list


Re: What YAML engine do you use?

2005-01-24 Thread Istvan Albert
rm wrote:
http://www.theinquirer.net/?article=20868 :-)
There's a lot of nonsense out there propagated by people who do not
understand XML. You can't possibly blame that on XML...
For me XSLT transformations are the main reason for using XML.
If I have an XML document I can turn it into other
formats with a few lines of code. Most importantly these
are much safer to run than a program.
I think of an XML document as a "mini-database" where one
can easily and efficiently access content via XPath. So there
is a lot more to XML than just markup and that's
why YAML vs XML comparisons make very little sense.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Question about reading a big binary file and write it into several text (ascii) files

2005-01-24 Thread Albert Tu
Hi,

I am learning and pretty new to Python and I hope your guys can give me
a quick start.

I have an about 1G-byte binary file from a flat panel x-ray detector; I
know at the beggining there is a 128-byte header and the rest of the
file is integers in 2-byte format.

What I want to do is to save the binary data into several smaller files
in integer format and each smaller file has the size of 2*1024*768
bytes.

I know I can do something like
>>>f=open("xray.seq", 'rb')
>>>header=f.read(128)
>>>file1=f.read(2*1024*768)
>>>file2=f.read(2*1024*768)
>>>..
>>>f.close()

Bur I don't them how to save files in integer format (converting from
binary to ascii files) and how to do this in an elegant and snappy way.


Please reply when you guyes can get a chance.
Thanks,
Warm regards,
Albert

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


Re: 4suite XSLT thread safe ?

2005-01-26 Thread Istvan Albert
Diez B. Roggisch wrote:
What do you mean by that? You can of course transform xml using xslt in as
many threads as you like 
It is not unthinkable that some parts of the library would not be
threadsafe. They could have some internal shared global variable
that keeps track of an intermediate state.
Some C string processing functions are not thread safe either.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: python memory blow out

2005-01-27 Thread Istvan Albert
Simon Wittber wrote:

Does anyone have ideas on why this is occuring, or how I might
otherwise prevent memory blow out?
I don't know it this is a decent enough solution but
if I were you I would try running the SQL service
in  a subshell. Within this subshell I would
terminate then restart the program after a large
query and keep it going after small ones.
The clients then would need to have some tolerance
for the service being offline for short periods.
Just a guess.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


RE: cursor positioning

2005-07-11 Thread Albert Leibbrandt
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Mage
Sent: 11 July 2005 04:28 PM
To: [email protected]
Subject: Re: cursor positioning

Larry Bates wrote:

>While not "curses" based this class will update screen as you
>want.  You could use it as a basis upon which to do a curses
>version with your cursor positioning.
>
>http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/299207
>
>  
>
Thank you. This is good for displaying the percentage.
However it fails to display this:
100 files read
200 files read
300 files read


of course all in the same line and not under the last line.

   Mage


-- 
Why not use something like this?

counter = 0

while 1:
if (counter % 100) == 0:
print'%s files read '%counter
counter += 1

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


RE: difficulty connecting to networked oracle database

2005-07-22 Thread Albert Leibbrandt
>> As the other posters already mentioned, cx_Oracle is the way to go. I'm
>> using it to connect to Oracle not only on Windows, but also on Solaris,
>> Linux and AIX.

>> Grig

I can second that, I have been using python and cx_oracle for more than 3
years now


Albert

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


RE: trying to access Oracle

2005-07-27 Thread Albert Leibbrandt








>> I am trying to
access Oracle using the cx_Oracle module. I can login to Oracle OK, but I >> am at a loss as to
how I should then access the specific table I need so that I can join it to >> our county parcel
layer using the “make table view” tool. I have scoured the internet
looking >> for
any examples and have found little that makes sense (to me). Can anyone help?
The >> table I
need is called ASR.TEMP_OWNERSHIP. The password, username, and TNS is all >> “asr”. 

>> I’m not quite
to the point where I can think for myself and improvise with python.  

 

 

Import cx_Oracle

 

conn = cx_Oracle.connect(‘username’,’password’,’tns’)

cursor = conn.cursor()

 

cursor.execute(“whatever you feel
like executing”)

 

 

Hope it helps

 

cheers

Albert

 






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

Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread Istvan Albert
There are plenty of webhosts that offer python,  do a little research.

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


error when parsing xml

2005-09-05 Thread Albert Leibbrandt
>> I use xml.dom.minidom to parse some xml, but when input
>> contains some specific caracters(æ, ø and å), I get an
>> UnicodeEncodeError, like this:
>>
>> UnicodeEncodeError: 'ascii' codec can't encode character
>> u'\xe6' in position 604: ordinal not in range(128).
>>
>> How can I avoid this error?
>>
>>
>> All help much appreciated!

I have found that some people refuse to stick to standards, so whenever I
parse XML files I remove any characters that fall in the range 
<= 0x1f
>= 0xf0

Hope it helps.

Regards
Albert


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


Download Mail Via Python

2005-09-12 Thread Albert Leibbrandt








I am busy writing a little prog to download mail and put the
contents of the emails into a database. The problem that I am currently facing
is that I can view the message body only if it was sent with a mail client
other than MS outlook or outlook express. What am I missing, any reading material
I can have a look at? Examples perhaps?

 

Thanks in advance.

Albert

 

 






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

How can I Read/Write multiple sequential Binary/Text data files

2005-03-10 Thread Albert Tu
Dear there,

We have an x-ray CT system. The acquisition computer acquires x-ray
projections and outputs multiple data files in binary format (2-byte
unsigned integer) such as projection0.raw, projection1.raw,
projection2.raw ... up to projection500.raw. Each file is
2*1024*768-byte big.

I would like to read those files and convert to ascii files in %5.0f/n
format as projection0.data ... projection500.data so that our
visualization software can undersatnd the projection images. I was
trying to do this conversion using Python. However, I had troubles
declaring the file names using the do-loop index. Anyone had previous
experience?   

Thanks,
Albert

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


Re: Lisp-likeness

2005-03-15 Thread Albert Reiner
[EMAIL PROTECTED], Tue, 15 Mar 2005 13:10:52 +0100]:
> It's indeed correct CL syntax, but I don't see much macro usage in there.

defun?

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


Re: Database connection caching

2005-03-18 Thread Istvan Albert
[EMAIL PROTECTED] wrote:
Hi all,
is there an alternative way of:
- create a connection object
- open the connection
- close the connection
psycopg, a Postgresql database adapter does connection pooling
automatically
http://initd.org/projects/psycopg1
Most Zope database adapters also have implicit
connection pooling.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: module imports and memory usage

2004-11-30 Thread Istvan Albert
Brad Tilley wrote:

Also, is there a way to load and unload modules as they are needed. I 
have some scripts that sleep for extended periods during a while loop 
and I need to be as memory friendly as possible. I can post a detailed 
script that currently uses ~ 10MB of memory if anyone is interested.
I believe that the rule of thumb for Python, C, Java
and probably most other portable languages is that
freed memory cannot be released back to the
operating system. The best you can expect (usually true)
is  that allocating the same amount later will not
increase the memory footprint.
So the only way to write memory efficient programs
might be to:
 1. either not load all the data
 2. run the data intensive routines as a separate process
that terminates and exists
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: pre-PEP generic objects

2004-12-02 Thread Istvan Albert
Steven Bethard wrote:
I promised I'd put together a PEP for a 'generic object' data type for 
Python 2.5 that allows one to replace __getitem__ style access with 
dotted-attribute style access (without declaring another class).  Any 
comments would be appreciated!
IMHO this too easy to accomplish right now to warrant
an "official" implementation:
class Bunch:
pass
b = Bunch()
b.one, b.two, b.three = 1,2,3
works just fine, depending on the problem I might add a few special
operators. For anything more complicated I'd rather write a real class.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: pre-PEP generic objects

2004-12-03 Thread Istvan Albert
Steven Bethard wrote:
> The question is not how easy it is to write,
> but how many times it's going to get written.
but with that logic we could  create a standard
"looping" construct called loop(x) that would stand in for
for i in range(x):
or a file_reader('whatever') generator that would be
a shortcut for:
for line in file('whatever'):
   line  = line.strip()
   elems = line.split()
> and more than one of them had rewritten the class a few times.
Two observations regarding that:
1. Probably not entirely true. They might have used something like a Bunch
but it is a bit too optimistic to believe that they could have directly used
your Bunch. My Bunches turn out to be just a ever so slightly different.
Either have an update operation or an equality, or can be hashed etc.
So in the end it might save a lot less work.
2. Even if it was, no big deal. It takes too little time to do it.
On the other hand, it would be nice to have a module that
implements various design patterns. The Bunch, the Borg, the Null,
the Proxy all nicely documented tucked away in their separate
module. That would feel a lot less like littering the standard name space
with an class that just "seems"  to be useful.
just an opinion.
Istvan
--
http://mail.python.org/mailman/listinfo/python-list


Re: pre-PEP generic objects

2004-12-03 Thread Istvan Albert
Steven Bethard wrote:
module) not to the __builtins__.  I don't see how this "litters the 
standard namespace".
Maybe then it doesn't.
but what are you saying? that a man cannot exaggerate and
fudge the facts in order to embellish his argument? :-)
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: xmlrpclib or twisted?

2004-12-06 Thread Istvan Albert
flupke wrote:

I am planning to build a web GUI for the client so if i
If you are planning to build a browser based interface
then use an available webserver and don't build
your own.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Webapp servers & security

2004-12-07 Thread Istvan Albert
Anakim Border wrote:
few) offer a clean environment to develop Python webapps. I have some
problems, however, understanding their security model.

Did I miss anything?
They don't have a security model. AFAIK only Zope has.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: ElementTree and XPATH

2004-12-09 Thread Istvan Albert
[EMAIL PROTECTED] wrote:
it seems to be invalid syntax if I give "/a/b[0]" to the findall()
method. Does anyone know the correct syntax?
I think the proper mindset going in should be that
elementtree does not support xpath but that
there are some handy constructs that resemble
the location steps of xpath.
Sometimes it takes very little work to achieve what
you want directly with python. In your case you could
probably use:
findall("/a/b")[0]
to the same effect.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Calling a C program from a Python Script

2004-12-09 Thread Istvan Albert
Brad Tilley wrote:
If possible, how much faster would this be over a pure Python solution?
It is like the difference between Batman and Ever.
batman is faster than ever
--
http://mail.python.org/mailman/listinfo/python-list


Re: Suggestion for "syntax error": ++i, --i

2004-12-13 Thread Istvan Albert
Petr Prikryl wrote:
Summary: In my opinion, the C-like prefix
increment and decrement operators (++i and --i)
should be marked as "syntax error".
My guess is that the impact of it would be nil.
This is python, there are no prefix or postfix
operators. That is very easy to remember. Just because
one might get burned by it when learning python
it cannot become a recurring problem that needs fixing.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Performance (pystone) of python 2.4 lower then python 2.3 ???

2004-12-13 Thread Istvan Albert
Lucas Hofman wrote:
Anyone who understands what is going on?
It is difficult to measure a speedup that might be
well within your measurement error.
Run the same pystone benchmark repeatedly and
see what variation you get.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Boo who? (was Re: newbie question)

2004-12-20 Thread Istvan Albert
Doug Holton wrote:
the syntax of boo is indeed virtually identical to python.  
All that boo does is borrows a few syntactical constructs
from python. Calling it virtually identical
is *very* misleading.
I've downloaded and tried it when you first made this claim
and it turned out that boo couldn't directly run even
the simplest python programs, on top of that execution
speed was slower than that of the corresponding python program.
I think this entitles me to be irked by your post above.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Boo who? (was Re: newbie question)

2004-12-21 Thread Istvan Albert
Doug Holton wrote:

The syntax is indeed virtually identical to python.  You are yet another 
person who has trolled before. 
> Do you have financial conflict of interest too like Fredrik?
You'll easily get away by calling me a troll, but trying to make
it look like that the effbot is one, that's just hilarious.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: My first real request for help

2013-11-19 Thread Albert Dengg
On Tue, Nov 19, 2013 at 04:31:15AM -0500, Gene Heskett wrote:
...
> But when I switch in, as one of the plugins a new .py version of camview-
> emc, I get this when I attempt to run linuxcnc -l, where the -l is "use the 
> same config as last time" option.
> 
> Starting LinuxCNC...
> Traceback (most recent call last):
>   File "/usr/bin/axis", line 3326, in 
> _dynamic_tabs(inifile)
>   File "/usr/bin/axis", line 3182, in _dynamic_tabs
> child = Popen(cmd)
>   File "/usr/lib/python2.6/subprocess.py", line 633, in __init__
> errread, errwrite)
>   File "/usr/lib/python2.6/subprocess.py", line 1139, in _execute_child
> raise child_exception
> OSError: [Errno 2] No such file or directory
> 
> No clue, even when straced, as to what file might be missing.
> 
> So, how do I find out?
have you tried strace -e open -ff -ofile.log ?
(it is easy to miss something in the strace output & and with -ff you
also get subprocesses (in their own files, file.log.pid1,
file.log.pid2,...)

this however, does not really look like a python problem, as from the
look of it it misses some external executable it tries to Popen()

so, you should probably on some linuxcnc/camview-emc related mailling
list/forum.

regards,
albert

ps: a more descriptive subject line would be helpfull for people to
recognize what your post is about and then can quickly decide if they
want to look at it or not.


signature.asc
Description: Digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter widgets into classes.

2014-02-01 Thread albert visser
On Sun, 02 Feb 2014 00:07:00 +0100, Lewis Wood   
wrote:



On Saturday, 1 February 2014 22:26:17 UTC, Dave Angel  wrote:

Lewis Wood  Wrote in message:

(snip)


DaveA


It does, this is the whole code:

from tkinter import *

root=Tk()
root.title("Second Root Testing")



def secondwindow():
root2=Tk()
root2.mainloop()

this may seem to work, but you're starting a new event loop here instead  
of using the current one. I think you want to create another TopLevel()  
window here, not a new Tk instance.


button1=Button(root,text="Root2",command=secondwindow).grid(row=0,column=0)

Note that if you want to be able to actually use the button1 symbol, you  
have to break this statement up:


button1=Button(root,text="Root2",command=secondwindow)
button1.grid(row=0,column=0)

You can't shortcut this because grid() returns None.


root.mainloop()




--
Vriendelijke groeten / Kind regards,

Albert Visser

Using Opera's mail client: http://www.opera.com/mail/
--
https://mail.python.org/mailman/listinfo/python-list


Re: Is vars() the most useless Python built-in ever?

2015-12-02 Thread Albert Visser
On Tue, 01 Dec 2015 22:15:08 +0100, Rick Johnson  
 wrote:



On Tuesday, December 1, 2015 at 10:56:27 AM UTC-6, John Gordon wrote:

Rick Johnson writes:
> Your lament does remind me of a pet peeve i have concerning Python,  
and

> that is, the lie about: "THERE SHOULD BE ONE (AND PREFERABLY ONLY ONE)
> WAY TO DO IT!". In fact, in python there is almost always *MANY* ways  
to

> achieve the same output.=20

The koan reads:

There should be one-- and preferably only one --obvious way to do  
it.


You left out the rather important word "obvious".


Indeed you are correct about the wording, but your interpretation is  
wrong.


Mm, not so much. What you're describing is a statement like "There should  
be one way and it should be obvious".


--
Vriendelijke groeten / Kind regards,

Albert Visser

Using Opera's mail client: http://www.opera.com/mail/
--
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-03-05 Thread Albert Visser

On Sat, 05 Mar 2016 08:41:39 +0100,  wrote:


On Saturday, December 12, 2015 at 1:05:29 AM UTC-8, Harbey Leke wrote:

Create a class called BankAccount

.Create a constructor that takes in an integer and assigns this to a  
`balance` property.


.Create a method called `deposit` that takes in cash deposit amount and  
updates the balance accordingly.


.Create a method called `withdraw` that takes in cash withdrawal amount  
and updates the balance accordingly. if amount is greater than balance  
return `"invalid transaction"`


.Create a subclass MinimumBalanceAccount of the BankAccount class

Please i need help on this i am a beginer into python programming.


Also below is a test case given for this project


import unittest
class AccountBalanceTestCases(unittest.TestCase):
  def setUp(self):
self.my_account = BankAccount(90)

  def test_balance(self):
self.assertEqual(self.my_account.balance, 90, msg='Account Balance  
Invalid')


  def test_deposit(self):
self.my_account.deposit(90)
self.assertEqual(self.my_account.balance, 180, msg='Deposit method  
inaccurate')


  def test_withdraw(self):
self.my_account.withdraw(40)
self.assertEqual(self.my_account.balance, 50, msg='Withdraw method  
inaccurate')


  def test_invalid_operation(self):
self.assertEqual(self.my_account.withdraw(1000), "invalid  
transaction", msg='Invalid transaction')


  def test_sub_class(self):
self.assertTrue(issubclass(MinimumBalanceAccount, BankAccount),  
msg='No true subclass of BankAccount')


my solution is:

class BankAccount(object):
def __init__(self, initial_balance):
self.balance = initial_balance
def deposit(self, amount):
self.balance +=amount
def withdraw(self, amount):
  if self.balance>= amount:
  self.balance  -=  amount
  else:
return invalid transaction
a1 = BankAccount (90)
a1.deposit(90)
a1.withdraw(40)
a1.withdraw(1000)
class MinimumBalanceAccount(BankAccount):
  def __init__(self):
BankAccount.__init__(self,minimum_balance)
self.minimum_balance = minimum_balance
my_account = BankAccount(90)
my_account.withdraw(40)
print my_account.balance


It keeps alerting me that,"Error running your script".Where might I have  
gone wrong?Please help..


Most probably there's extra information available on the "Error running  
your script" message. You should examine that.

Meanwhile, I think the line "return invalid transaction" provides a clue.

--
Vriendelijke groeten / Kind regards,

Albert Visser

Using Opera's mail client: http://www.opera.com/mail/
--
https://mail.python.org/mailman/listinfo/python-list


Re: I am out of trial and error again Lists

2014-10-24 Thread Albert Visser
On Fri, 24 Oct 2014 19:03:47 +0200, Seymore4Head  
 wrote:




http://i.imgur.com/DTc5zoL.jpg

The interpreter.   I don't know how to use that either.



It's what's on the left hand side of your screenshot. You can simply type  
Python statements following the >>> prompt and hit enter to examine the  
result, instead of pushing F5 to run your code


--
Vriendelijke groeten / Kind regards,

Albert Visser

Using Opera's mail client: http://www.opera.com/mail/
--
https://mail.python.org/mailman/listinfo/python-list


Re: Where is inspect() located?

2014-11-16 Thread Albert Visser

On Sun, 16 Nov 2014 05:12:36 +0100, Igor Korot  wrote:


import lib

Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named lib




In the https://docs.python.org/2/library/inspect.html, it says it is
located in Lib/inspect.py.

What am I missing? Or its only for 3.x?

Thank you.


Windows may not be case-sensitive, but Python is iirc

--
Vriendelijke groeten / Kind regards,

Albert Visser

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


Re: Tuples and immutability

2014-03-02 Thread albert visser
On Sun, 02 Mar 2014 15:17:11 +0100, Eric Jacoboni  
 wrote:



Le 02/03/2014 15:05, Mark Lawrence a écrit :


The behaviour is consistent except when you try to modify a tuple.



Not in my opinion...

li = [10, 30]
li = li + "spam"   --> TypeError: can only concatenate list (not "str")
li += "spam"   --> Ok



possibly because you expect += to take "spam" as a string, but have you  
looked at the result?


In [1]: mylist = ['1', '2']

In [2]: mylist += 'spam'

In [3]: mylist
Out[3]: ['1', '2', 's', 'p', 'a', 'm']

consequently, try adding something that can not be interpreted as a  
sequence:


In [4]: mylist += 3
---
TypeError Traceback (most recent call last)
 in ()
> 1 mylist += 3

TypeError: 'int' object is not iterable


--
Vriendelijke groeten / Kind regards,

Albert Visser

Using Opera's mail client: http://www.opera.com/mail/
--
https://mail.python.org/mailman/listinfo/python-list


Re: trailing underscores naming convention_

2014-05-09 Thread Albert Visser
On Fri, 09 May 2014 12:22:56 +0200, Metallicow   
wrote:



On Friday, May 9, 2014 3:10:26 AM UTC-6, Peter Otten wrote:

Metallicow wrote:

> I guess to be more clear here is a small code snippet that shows what  
is

> happening more readably. Hence the underscores question.

Working with multiple names with small differences is error-prone.


Definitely.



Anyway, the small snippet just shows that this can be done, but the  
actual
question you replied to you left unanswered. It is about the trailing  
underscores.




It's not an "official" convention I think, but a (single) trailing  
underscore is mainly meant to create something that is close to an  
original definition without shadowing it.
If you subclass an object and bind a thusly underscored method to an event  
to which the original is already bound in the superclass's __init__  
method, they are both getting called on the event unless you do not call  
the superclass's __init__() in your own __init__().


--
Vriendelijk groeten / Kind regards,

Albert Visser

Using Opera's mail client: http://www.opera.com/mail/
--
https://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   7   8   9   10   >