Install Universal Encoding Detector

2006-03-15 Thread Jacob
How do I install Universal Encoding Detector
(http://chardet.feedparser.org/)?

Thanks,
Jacob

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


Re: Install Universal Encoding Detector

2006-03-15 Thread Jacob
Thanks :)

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


Re: Install Universal Encoding Detector

2006-03-16 Thread Jacob
How do I uninstall?

/Jacob

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


Re: How do you refer to an iterator in docs?

2012-04-19 Thread Jacob MacDonald
On Thursday, April 19, 2012 5:21:20 AM UTC-7, Roy Smith wrote:
> Let's say I have a function which takes a list of words.  I might write 
> the docstring for it something like:
> 
> def foo(words):
>"Foo-ify words (which must be a list)"
> 
> What if I want words to be the more general case of something you can 
> iterate over?  How do people talk about that in docstrings?  Do you say 
> "something which can be iterated over to yield words", "an iterable over 
> words", or what?
> 
> I can think of lots of ways to describe the concept, but most of them 
> seem rather verbose and awkward compared to "a list of words", "a 
> dictionary whose keys are words", etc.

When I talk about an iterable, I say "iterable". Based on my recent readings of 
the style guide PEPs I would write something like:

"""Foo-ify some words.

Arguments:
words -- an iterable of words

"""

Just remember that types don't matter (until you get down to the C, really), 
just the methods associated with an object.

Have fun and happy coding!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: with statement

2012-04-19 Thread Jacob MacDonald
On Thursday, April 19, 2012 10:15:23 AM UTC-7, Kiuhnm wrote:
> A with statement is not at the module level only if it appears inside a 
> function definition or a class definition.
> Am I forgetting something?
> 
> Kiuhnm

That sounds about right to me. However, I haven't really used with's very much. 
So why would it matter where the statement is? (The only possibility that 
occurs to me is if your __enter__ or __exit__ methods reference a variable at 
some arbitrary level.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.system()

2012-04-19 Thread Jacob MacDonald
On Thursday, April 19, 2012 11:09:22 AM UTC-7, Yigit Turgut wrote:
> When I use os.system() function, script waits for termination of the
> windows that is opened by os.system() to continue thus throwing errors
> and etc. How can i tell Python to let it go and keep on with the next
> execution after os.system() ?

You have to use threads. As in most programming languages (I believe), the 
program waits for a line to finish before moving on. So you'll have to create a 
new thread to deal with the windows, then move on to other stuff. Read the docs 
on the threading modules.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can I overload operators like "=>", "->" or something like that?

2012-04-19 Thread Jacob MacDonald
On Thursday, April 19, 2012 12:28:50 PM UTC-7, dmitrey wrote:
> hi all,
> can I somehow overload operators like "=>", "->" or something like
> that? (I'm searching for appropriate overload for logical implication
> "if a then b")
> Thank you in advance, D.

I don't believe that you could overload those particular operators, since to my 
knowledge they do not exist in Python to begin with.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can I overload operators like "=>", "->" or something like that?

2012-04-20 Thread Jacob MacDonald
On Thursday, April 19, 2012 11:09:52 PM UTC-7, Ben Finney wrote:
> alex23  writes:
> 
> > On Apr 20, 5:54 am, Jacob MacDonald  wrote:
> >
> > > On Thursday, April 19, 2012 12:28:50 PM UTC-7, dmitrey wrote:
> > > > can I somehow overload operators like "=>", "->" or something like
> > > > that?
> > > I don't believe that you could overload those particular operators,
> > > since to my knowledge they do not exist in Python to begin with.
> 
> There is no ‘=>’ operator, and no ‘->’ operator, in Python
> http://docs.python.org/reference/lexical_analysis.html#operators>.
> >
> > It all depends on if the operators use special methods on objects:
> > http://docs.python.org/reference/datamodel.html#special-method-names
> >
> > You can overload => via object.__le__, for example.
> 
> No, ‘<=’ is the less-than-or-equal operator. There is no ‘=>’ operator
> in Python.
> 
> -- 
>  \  “I knew things were changing when my Fraternity Brothers threw |
>   `\   a guy out of the house for mocking me because I'm gay.” |
> _o__)  —postsecret.com, 2010-01-19 |
> Ben Finney

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


Re: How do you refer to an iterator in docs?

2012-04-20 Thread Jacob MacDonald
On Friday, April 20, 2012 6:41:25 AM UTC-7, Roy Smith wrote:
> In article <[email protected]>,
>  Steven D'Aprano  wrote:
> 
> > I refer you to your subject line:
> > 
> > "How do you refer to an iterator in docs?"
> > 
> > In documentation, I refer to an iterator as an iterator, just as I would 
> > refer to a list as a list, a dict as a dict, or a string as a string.
> 
> Except that "list of foos" and "sequence of foos" make sense from a 
> grammar standpoint, but "iterator of foos" does not.  Or maybe it does?

Unless you're writing the docstring for end users, I think you should be fine 
using Python words. After all, this is Python :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Initial introduction

2022-12-07 Thread jacob kruger

Hi there


I might shortly be posting about a specific issue with imaplib/poplib, 
but, thought would first introduce myself.



I am 100% blind, but, among other forms of assistive technology 
software, I use windows PC's with the NVDA screenreader, which itself is 
written in python, but, besides that, i generally work with either VS 
code or other programmer-specific text editors when it comes to python 
coding, etc., and, while have been a web application developer for over 
25 years, working with different programming/scripting languages and 
platforms, I am more-or-less a full-time python developer nowadays, and, 
when it comes to web development in this context, I work with either 
flask or django, but anyway.



Regards

--

Jacob Kruger
+2782 413 4791
"Resistance is futile...but, acceptance is versatile..."


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


Recommendations in terms of threading, multi-threading and/or asynchronous processes/programming? - Sent Mail - Mozilla Thunderbird

2023-01-06 Thread jacob kruger
I am just trying to make up my mind with regards to what I should look 
into working with/making use of in terms of what have put in subject line?



As in, if want to be able to trigger multiple/various threads/processes 
to run in the background, possibly monitoring their states, either via 
interface, or via global variables, but, possibly while processing other 
forms of user interaction via the normal/main process, what would be 
recommended?


As in, for example, the following page mentions some possibilities, like 
threading, asyncio, etc., but, without going into too much detail:

https://itnext.io/practical-guide-to-async-threading-multiprocessing-958e57d7bbb8

And, have played around with threading in the past, and, was looking 
into asyncio now, but, thought would rather first ask for 
recommendations/suggestions here?



For reference, am currently working with python 3.11, or might roll back 
to 3.10 if relevant, but, main thing is just want to get an idea of 
what's simplest to make use of in this context?


Thanks in advance

--

Jacob Kruger
+2782 413 4791
"Resistance is futile...but, acceptance is versatile..."


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


Re: Recommendations in terms of threading, multi-threading and/or asynchronous processes/programming? - Sent Mail - Mozilla Thunderbird

2023-01-08 Thread jacob kruger
Ok, the specific usage case right now is that I need to set up a process 
pulling contents of e-mail messages from an IMAP protocol mail server, 
which I then populate into a postgresql database, and, since this is the 
inbox of a relatively large-scale CRM/support system, there are 
currently over 2.5 million e-mails in the inbox, but, it can grow by 
over 5 per day.



I already have the basic process operating, using imap_tools, but, 
wanted to enable you to query the process during run-time, without 
needing to either check logs, or query the database itself while it is 
on-the-go - even if this is just for initial population time-period, 
since later on I will just set up code to run under a form of cron job, 
or handling time-based repeats itself on a separate machine.



Also wanted to offer the ability to either pause, or terminate processes 
while it's busy batch processing large chunks of e-mail messages - 
either send a message to the thread, or set a global variable to tell it 
to end the run after the current process item has finished off, just in 
case.



So, I think that for now, threading is probably the simplest to look into.


Later on, was also considering forms of low-level monitoring for UI 
elements, but, this is not really related to initial task, but, could 
almost relate to forms of non-visual gaming interfaces, for blind/VI 
individuals - I am myself 100% blind, but, that's not really relevant in 
this context.



Stay well


Jacob Kruger
+2782 413 4791
"Resistance is futile...but, acceptance is versatile..."


On 2023/01/06 21:19, Chris Angelico wrote:

On Sat, 7 Jan 2023 at 04:54, jacob kruger  wrote:

I am just trying to make up my mind with regards to what I should look
into working with/making use of in terms of what have put in subject line?


As in, if want to be able to trigger multiple/various threads/processes
to run in the background, possibly monitoring their states, either via
interface, or via global variables, but, possibly while processing other
forms of user interaction via the normal/main process, what would be
recommended?


Any. All. Whatever suits your purpose.

They all have different goals, different tradeoffs. Threads are great
for I/O bound operations; they're easy to work with (especially in
Python), behave pretty much like just having multiple things running
concurrently, and generally are the easiest to use. But you'll run
into limits as your thread count climbs (with a simple test, I started
seeing delays at about 10,000 threads, with more serious problems at
100,000), so it's not well-suited for huge scaling. Also, only one
thread at a time can run Python code, which limits them to I/O-bound
tasks like networking.

Multiple processes take a lot more management. You have to carefully
define your communication channels (for instance, a
multiprocessing.Queue() to collect results), but they can do CPU-bound
tasks in parallel. So multiprocessing is a good way to saturate all of
your CPU cores. Big downsides include it being much harder to share
information between the processes, and much MUCH higher resource usage
than threads (with the same test as the above, I ran into limitations
at just over 500 processes - way fewer than the 10,000 threads!).

Asynchronous I/O runs a single thread in a single process. So like
multithreading, it's only good for I/O bound tasks like networking.
It's harder to work with, though, since you have to be very careful to
include proper await points, and you can stall out the entire event
loop with one mistake (common culprits being synchronous disk I/O, and
gethostbyname). But the upside is that you get near-infinite tasks,
basically just limited by available memory (or other resources).

Use whichever one is right for your needs.

ChrisA

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


Re: Android APK

2023-01-25 Thread jacob kruger

Beeware is the only one I have tried out:

https://beeware.org/


Jacob Kruger
+2782 413 4791
"Resistance is futile...but, acceptance is versatile..."


On 2023/01/25 22:55, Jules Tillinghast wrote:

Is there a good python library for converting python3 to android APK


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


zpifile.py error - no crc 32 attribute

2018-08-22 Thread jacob m
 Hi guys,
I have a problem with zipfile and zlib module, and hope to get some help.

That's my error:
"import zipfile
  File "/home/lib/python3.7/lib/python3.7/zipfile.py", line 19, in 
crc32 = zlib.crc32
AttributeError: module 'zlib' has no attribute 'crc32' "

I have no idea what to do with that :/ I use this version of zipfile:
https://github.com/python/cpython/blob/3.7/Lib/zipfile.py

Somebody knows how to solve it?
Regards
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: zpifile.py error - no crc 32 attribute

2018-08-22 Thread jacob m
 Hi,
" Is there perhaps a different zlib on
your path, hiding the real zlib?" - I'm unsure of that.

"sudo apt-get install zlib1g-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
zlib1g-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded."
Regards


On 22 August 2018 at 13:12, jacob m  wrote:

> Hi guys,
> I have a problem with zipfile and zlib module, and hope to get some help.
>
> That's my error:
> "import zipfile
>   File "/home/lib/python3.7/lib/python3.7/zipfile.py", line 19, in
> 
> crc32 = zlib.crc32
> AttributeError: module 'zlib' has no attribute 'crc32' "
>
> I have no idea what to do with that :/ I use this version of zipfile:
> https://github.com/python/cpython/blob/3.7/Lib/zipfile.py
>
> Somebody knows how to solve it?
> Regards
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: zpifile.py error - no crc 32 attribute

2018-08-22 Thread jacob m
" import zlib
print(zlib.__file__)"

When I don't have the zlib uploaded to my Python3.7 library, I have the
following error:
"Traceback (most recent call last):
  File "./testx.py", line 2, in 
import zlib
ModuleNotFoundError: No module named 'zlib'"

When I download the zlib 1.2.11 from http://www.zlib.net/, rename the
"zlib-1.2.11" folder into "zlib" (after unpacking) and upload it into
Python library, the result is:
"# ./testx.py
None
"
In the second case I still have the AttributeError with crc32.



On 22 August 2018 at 23:09, Ashok Arora  wrote:

> Test this in the interpreter:-
>
> import zlib
> zlib.__file__
>
> It will return the location of zlib module.
>
> On 8/22/18, jacob m  wrote:
> >  Hi,
> > " Is there perhaps a different zlib on
> > your path, hiding the real zlib?" - I'm unsure of that.
> >
> > "sudo apt-get install zlib1g-dev
> > Reading package lists... Done
> > Building dependency tree
> > Reading state information... Done
> > zlib1g-dev is already the newest version.
> > 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded."
> > Regards
> >
> >
> > On 22 August 2018 at 13:12, jacob m  wrote:
> >
> >> Hi guys,
> >> I have a problem with zipfile and zlib module, and hope to get some
> help.
> >>
> >> That's my error:
> >> "import zipfile
> >>   File "/home/lib/python3.7/lib/python3.7/zipfile.py", line 19, in
> >> 
> >> crc32 = zlib.crc32
> >> AttributeError: module 'zlib' has no attribute 'crc32' "
> >>
> >> I have no idea what to do with that :/ I use this version of zipfile:
> >> https://github.com/python/cpython/blob/3.7/Lib/zipfile.py
> >>
> >> Somebody knows how to solve it?
> >> Regards
> >>
> >>
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: zpifile.py error - no crc 32 attribute

2018-08-24 Thread jacob m
Hi all,
Thanks for your help, I reinstalled my Python and now it seems to be
working :)
Before building Python3 i uncommented:
#zlib zlibmodule.c -I$(prefix)/include
in Modules/Setup.dist and then I enabled ipv6 during the configuration.
Regards

On Thu, 23 Aug 2018 at 01:59, MRAB  wrote:

> On 2018-08-22 23:43, jacob m wrote:
> > " import zlib
> > print(zlib.__file__)"
> >
> > When I don't have the zlib uploaded to my Python3.7 library, I have the
> > following error:
> > "Traceback (most recent call last):
> >File "./testx.py", line 2, in 
> >  import zlib
> > ModuleNotFoundError: No module named 'zlib'"
> >
> > When I download the zlib 1.2.11 from http://www.zlib.net/, rename the
> > "zlib-1.2.11" folder into "zlib" (after unpacking) and upload it into
> > Python library, the result is:
> > "# ./testx.py
> > None
> > "
> > In the second case I still have the AttributeError with crc32.
> >
> In the first case, without the downloaded zlip, can you import zipfile?
>
> If yes, try:
>
> zipfile.zlib
>
>  From what I've seen, zlib is a built-in.
> >
> >
> > On 22 August 2018 at 23:09, Ashok Arora 
> wrote:
> >
> >> Test this in the interpreter:-
> >>
> >> import zlib
> >> zlib.__file__
> >>
> >> It will return the location of zlib module.
> >>
> >> On 8/22/18, jacob m  wrote:
> >> >  Hi,
> >> > " Is there perhaps a different zlib on
> >> > your path, hiding the real zlib?" - I'm unsure of that.
> >> >
> >> > "sudo apt-get install zlib1g-dev
> >> > Reading package lists... Done
> >> > Building dependency tree
> >> > Reading state information... Done
> >> > zlib1g-dev is already the newest version.
> >> > 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded."
> >> > Regards
> >> >
> >> >
> >> > On 22 August 2018 at 13:12, jacob m  wrote:
> >> >
> >> >> Hi guys,
> >> >> I have a problem with zipfile and zlib module, and hope to get some
> >> help.
> >> >>
> >> >> That's my error:
> >> >> "import zipfile
> >> >>   File "/home/lib/python3.7/lib/python3.7/zipfile.py", line 19, in
> >> >> 
> >> >> crc32 = zlib.crc32
> >> >> AttributeError: module 'zlib' has no attribute 'crc32' "
> >> >>
> >> >> I have no idea what to do with that :/ I use this version of zipfile:
> >> >> https://github.com/python/cpython/blob/3.7/Lib/zipfile.py
> >> >>
> >> >> Somebody knows how to solve it?
> >> >> Regards
> >> >>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


gmpy2 problem

2018-11-01 Thread jacob m
Hi guys
I have some problems with gmpy2 module installation - pip install gmpy2
doesn't work for me
[image: image.png]

How to fix it?
Regards
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: gmpy2 problem

2018-11-05 Thread jacob m
Sorry Rhodri, my gmail set your email as default recipient when I was
responding, I forgot to change that. Sorry for that
Regards

On Mon, 5 Nov 2018 at 13:06, Rhodri James  wrote:

> Jacob, please reply to the list, not to me personally.  As I said, I
> have no idea about gmpy2 or pip, I just know how to google.
>
> On 01/11/2018 23:28, jacob m wrote:
> > I tried to install libgmp3-dev, but it didn't solved my problem
> >
> > On Thu, 1 Nov 2018 at 18:44, Rhodri James  wrote:
> >
> >> Replying to the list since I have absolutely no idea about gmpy2 or
> pip...
> >>
> >> On 01/11/2018 16:56, jacob m wrote:
> >>> Hi Rodhri, of course I can paste the text :)
> >>> "
> >>> creating build
> >>>   creating build/temp.linux-x86_64-3.7
> >>>   creating build/temp.linux-x86_64-3.7/src
> >>>   gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g
> -fwrapv
> >> -O3
> >>> -Wall -fPIC -DWITHMPFR -DWITHMPC
> -I/home/lib/python3.7/include/python3.7m
> >>> -c src/gmpy2.c -o build/temp.linux-x86_64-3.7/src/gmpy2.o
> >>>   In file included from src/gmpy2.c:426:0:
> >>>   src/gmpy.h:106:12: fatal error: gmp.h: No such file or directory
> >>>#  include "gmp.h"
> >>>   ^~~
> >>>   compilation terminated.
> >>>   error: command 'gcc' failed with exit status 1
> >>>
> >>>   
> >>> Command "/home/lib/python3.7/bin/python3.7 -u -c "import setuptools,
> >>>
> >>
> tokenize;__file__='/tmp/pip-install-kiqba_j_/gmpy2/setup.py';f=getattr(tokenize,
> >>> 'open', open)(__file__);code=f.read().replace('\r\n',
> >>> '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
> >>> /tmp/pip-record-2jatj1mi/install-record.txt
> >>> --single-version-externally-managed --compile" failed with error code 1
> >> in
> >>> /tmp/pip-install-kiqba_j_/gmpy2/
> >>> "
> >>
> >> A little googling suggests that you need to install the libgmp3-dev
> >> package:
> >>
> >> $ sudo apt install libgmp3-dev
> >>
> >>> On Thu, 1 Nov 2018 at 16:46, Rhodri James 
> wrote:
> >>>
> >>>> On 01/11/2018 14:40, jacob m wrote:
> >>>>> Hi guys
> >>>>> I have some problems with gmpy2 module installation - pip install
> gmpy2
> >>>>> doesn't work for me
> >>>>> [image: image.png]
> >>>>>
> >>>>> How to fix it?
> >>>>
> >>>> Hi Jacob,
> >>>>
> >>>> I'm afraid the screen-shot that you sent was automatically stripped
> off
> >>>> by the mailing list.  Could you copy the error text (preferably
> >>>> cut-and-paste the whole thing rather than retyping!)?  The more
> >>>> information you can give us, the better the advice will be from the
> >>>> people who actually understand pip :-)
> >>
> >>
> >> --
> >> Rhodri James *-* Kynesim Ltd
> >> --
> >> https://mail.python.org/mailman/listinfo/python-list
> >>
> >
>
>
> --
> Rhodri James *-* Kynesim Ltd
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Resources/pointers for writing maintable, testable Python

2016-05-18 Thread Jacob Scott
Many years ago, when I was primarily writing Java, I found Misko
Hevery's Guide:
Writing Testable Code
<http://misko.hevery.com/attachments/Guide-Writing%20Testable%20Code.pdf> to
be incredibly helpful in guiding the design and structure of my codebase,
and as reference for checking if my code was smelly.

Today, I'm happily writing primarily Python (unfortunately, 2.7 -- but I'm
not sure it makes that much of a difference), but I haven't found anything
that speaks to me in the same way. Some of the best resources I've found,
but which don't quite cover all of what I'm looking for, include

   - PEP-8 and PEP-20
   - The Hitchhiker's Guide to Python
   <http://docs.python-guide.org/en/latest/>
   - Effective Python <http://www.effectivepython.com/>

I'd appreciate any pointers to resources I might have missed, general
thoughts on the topic, etc.

Thanks,

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


Re: Resources/pointers for writing maintable, testable Python

2016-05-18 Thread Jacob Scott
Ah, what I should have done is note that I am writing Python 2.7 (and this
is at work, with all that entails...), but am happy to take advice that
applies only to Python 3 (even 3.5 or 3.6.0a1!) and work backwards to apply
it to Python 2.7.

I think I would be (perhaps pleasantly) surprised if there was a wide gulf
between Python 2.7 and Python 3 *in terms of advice/resources applicable to
my original question*. Based on my (admittedly shallow) understanding of
overall Python 2.7/3 differences, the biggest changes (from e.g.
http://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html) tend to
be a bit lower level (utf-8 str) than what I'm focused on (maintainable and
testable classes, functions, modules, etc).

Thanks for the pointer to Code Like A Pythonista and the feedback on 2.7 vs
3!

Jacob

On Wed, May 18, 2016 at 5:55 PM, Ben Finney 
wrote:

> Jacob Scott  writes:
>
> > Today, I'm happily writing primarily Python (unfortunately, 2.7 -- but
> I'm
> > not sure it makes that much of a difference)
>
> Python 2.7 is still viable, but is certainly a dead end. The difference
> increases month by month, and the advantage is only going to increase to
> Python 3.
>
> Any new code base should not be written in Python 2. Any libraries you
> need which don't work yet on Python 3 should be seriously reconsidered.
>
> > I'd appreciate any pointers to resources I might have missed, general
> > thoughts on the topic, etc.
>
> Code Like A Pythonista was written in the Python 2 era
> <http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html>
> but is still excellent advice today.
>
> --
>  \ “I have the simplest tastes. I am always satisfied with the |
>   `\best.” —Oscar Wilde, quoted in _Chicago Brothers of the Book_, |
> _o__) 1917 |
> Ben Finney
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Resources/pointers for writing maintable, testable Python

2016-05-19 Thread Jacob Scott
Indeed, I skimmed the TOC for Test-Driven Development with Python and it
does look to be rather Django-centric (which makes it a bit less helpful to
me). I will take a look at "Testing Python: Applying Unit Testing, TDD, BDD
and Acceptance Testing"!

Thanks,

Jacob

On Thu, May 19, 2016 at 8:33 AM, Mike Driscoll  wrote:

> On Wednesday, May 18, 2016 at 4:48:28 PM UTC-5, Andrew Farrell wrote:
> > Hi Jacob,
> >
> > You are probably looking for the book Test-Driven Development with Python
> > <http://chimera.labs.oreilly.com/books/123400754/index.html>.
> > You'll also want to look at py.test <http://pytest.org/latest/>
> >
> > Cheers!
> > Andrew Farrell
>
> I was under the impression that this book is primarily aimed at
> Python/Django web testing. I saw "Testing Python: Applying Unit Testing,
> TDD, BDD and Acceptance Testing" is getting good reviews too though.
>
> Mike
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to programming and asking about accessibility with jaws screen reader.

2016-07-24 Thread Jacob Kruger

What part is not accessible?

Ask since while haven't really gone past 3.4 and 3.5.1, at times, I 
generally work with specific text/code editors, and the command line 
window, and this works fine for me with both NVDA, and jaws 17 at times.


Stay well


Jacob Kruger
Blind Biker
Skype: BlindZA
"Resistance is futile, but, acceptance is versatile..."

On 2016-07-24 10:04 PM, josphine said wrote:

Hello,
I have downloaded python3.6 and found it is not accessible with jaws 17.
So, is there any  skripts for jaws for that?
Or any suggestions?
Every guidance will highly appreciated.
Thanks.


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


Re: New to programming and asking about accessibility with jaws screen reader.

2016-07-24 Thread Jacob Kruger

Presume you're talking about python idle IDE?


Forget it, and, like said, I use edSharp programmers text editor, and 
work from command line/console when want to test/run my code.



Stay well


Jacob Kruger
Blind Biker
Skype: BlindZA
"Resistance is futile, but, acceptance is versatile..."

On 2016-07-25 12:14 AM, josphine said wrote:

Thanks for your care,
Downloaded it from the python download page, (86-64 bit).
It reads only the menus, when i try to write anything , readable only with the 
curser,,.

Maybe i don't know exactly how to use it,
So if possible that anyone walk with me step by step??
Sorry for that.
Thanks, god bless you all.

Sent from my iPhone


On Jul 24, 2016, at 11:52 PM, Jacob Kruger  wrote:

What part is not accessible?


Ask since while haven't really gone past 3.4 and 3.5.1, at times, I generally 
work with specific text/code editors, and the command line window, and this 
works fine for me with both NVDA, and jaws 17 at times.


Stay well


Jacob Kruger
Blind Biker
Skype: BlindZA
"Resistance is futile, but, acceptance is versatile..."


On 2016-07-24 10:04 PM, josphine said wrote:
Hello,
I have downloaded python3.6 and found it is not accessible with jaws 17.
So, is there any  skripts for jaws for that?
Or any suggestions?
Every guidance will highly appreciated.
Thanks.




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


Dynamical loading of modules

2005-10-03 Thread Jacob Kroon
Hi, I'm having some problems with implementing dynamical module loading. 
First let me
describe the scenario with an example:

modules/
fruit/
__init__.py
apple.py
banana.py

apple.py defines a class 'Apple', banana defines a class 'Banana'. The 
problem lies in the
fact that I want to be able to just drop a new .py-file, for instance 
peach.py, and not change
__init__.py, and it should automatically pickup the new file in 
__init__.py. I've come halfway
by using some imp module magic in __init__.py, but the problem I have is 
that the instantiated
objects class-names becomes fruit.apple.Apple/fruit.banana.Banana, whild 
I want it to be
fruit.Apple/fruit.Banana.

Is there a smarter way of accomplishing what I am trying to do ?
If someone could give me a small example of how to achieve this I would 
be very grateful.

Regards Jacob Kroon

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


Re: where to download md5.py?

2005-11-04 Thread Jacob Hallen
In article <[EMAIL PROTECTED]>,
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
>"Bell, Kevin" wrote:
>
>> I've been looking around, but haven't found a place to download the
>> md5.py module.  I need it to run the dupinator.py
>
>md5 is a standard Python module (written in C).  it's been in Python since
>the early ages, so if you don't have it, your install is most likely
>broken (per-
>haps intentionally, based on this: http://eprint.iacr.org/2004/199 )

A pure python implementation of md5 is included in the pypy project.
It is naturally a lot slower than the C module, but it does the job.

Jacob Hallén

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

SQLObject transaction rollback not working

2005-11-28 Thread jacob . miles
Hello.  I'm trying to wrap a function call in a transaction, but when I
intentionally throw an exception in the middle of the function it
doesn't actually roll back the transaction.  The debug output says
1/ROLLBACK, without any 1/COMMITs in there, but when I view the data in
the command-line mysql utility the changes have been made.

This is the code I'm using to connect to the mysql database and to wrap
the function call in a transaction.  After that I've invluded the
testUpdate method I'm using, and after that the python conversation
that ensued.  Does anyone see what I'm doing wrong?

--- sqlutil.py:

from sqlobject import *

def connect():
""" Connects SQLObject to the dev database on localhost.
"""
connectionString =
"mysql://[EMAIL PROTECTED]/mc_image_library_dev?debug=1"
connection = connectionForURI (connectionString)
sqlhub.processConnection = connection


def wrapInTransaction (func, *args, **kw):
""" Got this from the SQLObject mailing list.
Calls the given func with the given args and keyword assignments
within a db transaction.  Rolls back if an exception is thrown,
otherwise commits.
"""
old_conn = sqlhub.getConnection()
conn = old_conn.transaction()
sqlhub.processConnection = conn
try:
try:
value = func(*args, **kw)
except:
conn.rollback()
raise
else:
conn.commit()
return value
finally:
sqlhub.processConnection = old_conn

--
- test.py:

from ImageCategory import *

def testUpdate (newName, username, fail):
category = ImageCategory.get(1)
category.name = newName
category.updateLastChanged (username)
if fail:
raise Exception ('spam', 'eggs')

-
-- The python conversation:

>>> import sqlutil
>>> sqlutil.connect()
>>> import test
>>> sqlutil.wrapInTransaction (test.testUpdate, 'Animals', 'jake', True)
 1/QueryOne:  SELECT last_changed_by, last_changed_date, name FROM
image_category WHERE id = 1
 1/Query   :  UPDATE image_category SET name = 'Animals' WHERE id = 1
 1/Query   :  UPDATE image_category SET last_changed_by = 'jake' WHERE
id = 1
 1/Query   :  UPDATE image_category SET last_changed_date = '2005-11-29
00:36:22' WHERE id = 1
 1/ROLLBACK:
Traceback (most recent call last):
  File "", line 1, in ?
  File "sqlutil.py", line 22, in wrapInTransaction
value = func(*args, **kw)
  File "test.py", line 8, in testUpdate
raise Exception ('spam', 'eggs')
Exception: ('spam', 'eggs')



After all this, the mysql utility shows that the update did take
effect.

Any thoughts?

- Jake

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


Help with saving and restoring program state

2005-01-24 Thread Jacob H
Hello list...

I'm developing an adventure game in Python (which of course is lots of
fun). One of the features is the ability to save games and restore the
saves later. I'm using the pickle module to implement this. Capturing
current program state and neatly replacing it later is proving to be
trickier than I first imagined, so I'm here to ask for a little
direction from wiser minds than mine!

When my program initializes, each game object is stored in two places
-- the defining module, and in a list in another module. The following
example is not from my actual code, but what happens is the same.

(code contained in "globalstate" module)
all_fruit = []

(code contained in "world" module)
class Apple(object): # the class hierarchy goes back to object, anyway
def __init__(self):
self.foo = 23
self.bar = "something"
globalstate.all_fruit.append(self)  
apple = Apple()

I enjoy the convenience of being able to refer to the same apple
instance through world.apple or globalstate.all_fruit, the latter
coming into play when I write for loops and so on. When I update the
instance attributes in one place, the changes are reflected in the
other place. But now comes the save and restore game functions, which
again are simplified from my real code:

(code contained in "saveload" module)
import pickle
import world
def savegame(path_to_name):
world_data = {}
for attr, value in world.__dict__.items():
# actual code is selective about which attributes 
# from world it takes -- I'm just keeping this 
# example simple
world_data[attr] = value
fp = open(path_to_name, "w")
pickle.dump(world_data, fp)
fp.close()

def loadgame(path_to_name):
fp = open(path_to_name, "r")
world_data = pickle.load(fp)
for attr, value in world_data.items():
setattr(world, attr, value)
fp.close()

The problem is that the game objects only get overwritten in the world
module. The instances in the globalstate.all_fruit list remain
unchanged, which is not the behaviour I want. I started to write code
to get around this. I figured that with each loadgame call, I could
reset all the lists in globalstate to empty, then reappend each game
object to the appropriate list. But this possibility got complicated
fast, because all game objects belong to more than one list. My apple
instance alone would belong to globalstate.all_things,
globalstate.all_fruit, globalstate.all_items, and perhaps others. Some
of the game objects contained in these lists don't need to be a part
of capturing program state in the first place! But I'm stuck, because
unpickling (so far as I understand it) creates a brand new instance
that doesn't know it used to have references to itself in the
globalstate lists.

Any advice out there? I'm looking for a clean, elegant way to
overwrite the same class instance in two arbitrary places at once.
Perhaps the example code I've provided isn't even the best way of
saving and restoring program state. Perhaps I can easily update my
globalstate lists and I'm just overlooking the simple way. Or perhaps
the solution lies in abandoning the concepts of referencing my game
objects through module attributes and lists. I'm open to any
suggestions.

Thanks in advance for any help!

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


Re: what's OOP's jargons and complexities?

2005-01-28 Thread jacob navia
Good post.
First article that demistifies this OO centered approach
in quite a long time.
This approach has its strength, but also has it weakness,
it is not the solution for every problem appearing in
data processing.
--
http://mail.python.org/mailman/listinfo/python-list


Europython 2005 - last call

2005-06-21 Thread Jacob Hallen

Europython 2005 will start on Monday 27 June!

If you haven't preregistered for Europython 2005, you still have
a few hours to do so. You can register and pay by credit card
until 21 June 18.00 CEST. Payment by SWIFT/IBAN is closed, since
we would not receive your payment before the conference starts.

On-site registration is also possible, though at a somewhat higher
cost. Pyment on-site is in cash, SEK or Euro. Please bring even money
since we can't have a big pile of change at the conference.

All details are found at http://www.europython.org.


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


use a regex or not?

2005-06-21 Thread Joost Jacob
I am looking for a function that takes an input string
and a pattern, and outputs a dictionary.

# @param s str, lowercase letters
# @param p str, lowercase and uppercase letters
# @return dict
def fill(s, p):
d = {}

return d

String s has characters from the lowercase letters.
String p is a pattern, a string of characters from the
lowercase and uppercase letters.  The idea is to match
s with p, where lowercase letters have to match
exactly, and to fill variables (with an uppercase
letter name) with the rest of s.  The variables are
collected in a dictionary with the resulting bindings.
A variable that occurs in more than one place in p must
bind to the same substring of s.

Tests:

>>> fill('ab', p='aA')
{'A': 'b'}
>>> fill('ab', p='Ab')
{'A': 'a'}
>>> fill('bb', p='Ab')  # no match
{}
>>> fill('aa', p='Aa')
{'A': 'a'}
>>> fill('aa', p='Ab')  # no match
{}
>>> fill('abb', p='aA')
{'A': 'bb'}
>>> fill('aba', p='aAa')
{'A': 'b'}
>>> fill('abb', p='aAa')# no match
{}
>>> fill('abab', p='aAaA')  # A-matches must be equal
{'A': 'b'}
>>> fill('abac', p='aAaA')  # no match
{}
>>> fill('abac', p='aAaB')
{'A': 'b', 'B': 'c'}

Can you do it?  Is trying a solution with a regex a
good idea?

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


Re: use a regex or not?

2005-06-21 Thread Joost Jacob
Oops, the 3rd test should be

fill('bb', p='Aa')

resulting in the empty dict {} because no binding for A can be found.

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


Host resolution problems with socket module

2005-07-03 Thread Jacob Lee
I'm getting a rather bizarre error while using the socket module. If I
start out disconnected from the net and then connect while the program or
interpreter session is open, I do not always gain the ability to resolve
or connect to hosts by name. Here is the problematic scenario:



>>> from socket import *
>>> gethostbyname('google.com') # Fails as expected
Traceback (most recent call last):
  File "", line 1, in ?
  File "", line 1, in connect
socket.gaierror: (-3, 'Temporary failure in name resolution')



>>> gethostbyname('google.com') # Should succeed
Traceback (most recent call last):
  File "", line 1, in ?
  File "", line 1, in connect
socket.gaierror: (-3, 'Temporary failure in name resolution')

After some testing, I believe that this behavior is dependent on whether
the first call to gethostbyname() succeeded or not. If the first call
succeeded, subsequent calls will either resolve the host or raise an
exception depending on the status of the internet connection. If the first
call failed (i.e. raised the above exception), subsequent ones will always
raise the same exception no matter if the connection has been restored.

I should also add that getaddrinfo() and .connect() on socket objects
both fail in the same way as gethostbyname(). Deleting the socket module
and then importing it again does not help, nor does calling
reload(socket). I've been testing this on Linux with both python 2.3 and
python 2.4. As far as I can tell, the only variable that affects this
behavior is the status of the connection at the time gethostbyname() is
first called.

Is there anything else I can do to fix this problem? Is it maybe a python
bug, or is it representative of some lower-level subtlety (e.g. in the C
libraries) that I'm unaware of? Has anyone else run into this before?

-- 
Jacob Lee
[EMAIL PROTECTED] | www.nearestneighbor.net

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


Re: Lisp development with macros faster than Python development?..

2005-07-05 Thread Joost Jacob
Very hard to say.

LISP has OOP too, Google for CLOS.

Operator overloading is something to avoid anyway, IMHO, just like
static typing is something to avoid if you need fast development, on
schedule and the like.

LISP has one thing that Python does not have: LISP code is LISP data.
A thorough study comparing LISP and Python in this respect would be
welcome.

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


Python Module Exposure

2005-07-07 Thread Jacob Page
I have created what I think may be a useful Python module, but I'd like 
to share it with the Python community to get feedback, i.e. if it's 
Pythonic.  If it's considered useful by Pythonistas, I'll see about 
hosting it on Sourceforge or something like that.  Is this a good forum 
for exposing modules to the public, or is there somewhere 
more-acceptable?  Does this newsgroup find attachments acceptable?

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


Re: Python Module Exposure

2005-07-07 Thread Jacob Page
Robert Kern wrote:

> Jacob Page wrote:
> 
>> I have created what I think may be a useful Python module, but I'd 
>> like to share it with the Python community to get feedback, i.e. if 
>> it's Pythonic.  If it's considered useful by Pythonistas, I'll see 
>> about hosting it on Sourceforge or something like that.  Is this a 
>> good forum for exposing modules to the public, or is there somewhere 
>> more-acceptable?  Does this newsgroup find attachments acceptable?
> 
> No. Please put files somewhere on the web and post a URL. This would be 
> a good forum to informally announce and discuss your module. Formal 
> announcements once you, e.g. put it on SF should go to c.l.py.announce .

Thanks for the information, Robert.  Anyway, here's my informal 
announcement:

The iset module is a pure Python module that provides the ISet class and 
some helper functions for creating them. Unlike Python sets, which are 
sets of discrete values, an ISet is a set of intervals. An ISet could, 
for example, stand for all values less than 0, all values from 2 up to, 
but not including 62, or all values not equal to zero. ISets can also 
pertain to non-numeric values.

ISets can be used in much the same way as sets. They can be or'ed, 
and'ed, xor'ed, added, subtracted, and inversed. Membership testing is 
done the same as with a set. The documentation has some examples of how 
to create and use ISets.

The iset module is for Python 2.4 or later.

I am seeking feedback from programmers and mathematicians on how to 
possibly make this module more user-friendly, better-named, 
better-documented, better-tested, and more Pythonic.  Then, if this 
module is considered acceptable by the community, I'll create a more 
permanent home for this project.

To download the iset module and view its pydoc-generated documentation, 
please visit http://members.cox.net/apoco/iset/.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Polling, Fifos, and Linux

2005-07-07 Thread Jacob Page
Jeremy Moles wrote:
> This is my first time working with some of the more lower-level python
> "stuff." I was wondering if someone could tell me what I'm doing wrong
> with my simple test here?
> 
> Basically, what I need is an easy way for application in userspace to
> simply echo values "down" to this fifo similar to the way proc files are
> used. Is my understanding of fifo's and their capabilities just totally
> off base?

You shouldn't need to use select.poll(), unless I'm missing something. 
I was able to get the following to work:

-=-=-

import os

fifo = os.open("fifo", os.O_RDONLY | os.O_NONBLOCK)

while True:
 string = os.read(fifo, 1)
 if len(string):
 print string
 # Perhaps add a delay under an else

-=-=-

The Python script, when run, does nothing until you put data into the 
fifo from another process.  Then it immediately spits the data out, 
character by character.

I'm assuming that you've already created the fifo and that it's in the 
current working directory.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Module Exposure

2005-07-08 Thread Jacob Page
Thomas Lotze wrote:
> Jacob Page wrote:
> 
>>better-named,
> 
> Just a quick remark, without even having looked at it yet: the name is not
> really descriptive and runs a chance of misleading people. The example I'm
> thinking of is using zope.interface in the same project: it's customary to
> name interfaces ISomething.

I've thought of IntervalSet (which is a very long name), IntSet (might 
be mistaken for integers), ItvlSet (doesn't roll off the fingers), 
ConSet, and many others.  Perhaps IntervalSet is the best choice out of 
these.  I'd love any suggestions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Module Exposure

2005-07-09 Thread Jacob Page
George Sakkis wrote:
> 1. As already noted, ISet is not really descriptive of what the class
> does. How about RangeSet ? It's not that long and I find it pretty
> descriptive. In this case, it would be a good idea to change Interval
> to Range to make the association easier.

The reason I decided not to use the term Range was because that could be 
confused with the range function, which produces a discrete set of 
integers.  Interval isn't a term used in the standard/built-in library, 
AFAIK, so I may stick with it.  Is this sound reasoning?

> 2. The module's "helper functions" -- which are usually called factory
> functions/methods because they are essentially alternative constructors
> of ISets -- would perhaps better be defined as classmethods of ISet;
> that's a common way to define instance factories in python. Except for
> 'eq' and 'ne', the rest define an ISet of a single Interval, so they
> would rather be classmethods of Interval. Also the function names could
> take some improvement; at the very least they should not be 2-letter
> abbreviations. Finally I would omit 'eq', an "interval" of a single
> value; single values can be given in ISet's constructor anyway. Here's
> a different layout:

First, as far as having the factory functions create Interval instances 
(Range instances in your examples), I was hoping to avoid Intervals 
being publically "exposed."  I think it's cleaner if the end-programmer 
only has to deal with one object interface.

I like the idea of lengthening the factory function names, but I'm not 
sure that the factory methods would be better as class methods. 
Consider a use-case:

 >>> import iset
 >>> interval = iset.ISet.lowerThan(4)

as opposed to:

 >>> import iset
 >>> interval = iset.lowerThan(4)

This is less typing and probably eliminates some run-time overhead.  Can 
you list any advantages of making the factory functions class methods?

> class Range(object): # Interval
> 
> @classmethod
> def lowerThan(cls, value, closed=False):
> # lt, for closed==False
> # le, for closed==True
> return cls(None, False, value, closed)
> 
> @classmethod
> def greaterThan(cls, value, closed=False):
> # gt, for closed==False
> # ge, for closed==True
> return cls(value, closed, None, False)
> 
> @classmethod
> def between(cls, min, max, closed=False):
> # exInterval, for closed==False
> # incInterval, for closed==True
> return cls(min, closed, max, closed)

I like the function names, but in my dialect, lessThan would be more proper.

> class RangeSet(object):  # ISet
> 
> @classmethod
> def allExcept(cls, value): # ne
> return cls(Range.lowerThan(value), Range.greaterThan(value))
> 
> 3. Having more than one names for the same thing is good to be avoided
> in general. So keep either "none" or "empty" (preferably "empty" to
> avoid confusion with None) and remove ISet.__add__ since it is synonym
> to ISet.__or__.

I agree that "none" should be removed.  However, some programmers may 
prefer to use +, some |, so I'd like to provide both.

> 4. Intervals shouldn't be comparable; the way __cmp__ works is
> arbitrary and not obvious.

I agree that __cmp__ is being used arbitrarily.  I wanted sorting to be 
easy, but there's other ways of doing that.  I'll take your suggestion.

> 5. Interval.adjacentTo() could take an optional argument to control
> whether an endpoint is allowed to be in both ranges or not (e.g.
> whether (1,3], [3, 7] are adjacent or not).

Interval objects weren't meant to be public; adjacentTo is used by ISet 
for combinatory functions.  I could look into ways to hide the class 
from the public, but hiding things never seemed Pythonic to me; someone 
may want to use them for some reason.  Maybe pydoc can be made to not 
document certain objects.

> 6. Possible ideas in your TODO list:
> - Implement the whole interface of sets for ISet's so that a client
> can use either or them transparently.

That was my intention.  I'll have to see which interface functions I'm 
missing.

> - Add an ISet.remove() for removing elements, Intervals, ISets as
> complementary to ISet.append().
> - More generally, think about mutable vs immutable Intervals and
> ISets. The sets module in the standard library will give you a good
> idea of  the relevant design and implementation issues.

Both good ideas.

> After I look into the module's internals, I'll try to make some changes
> and send it back to you for feedback.

Thanks for your feedback, George.  I look forward to any additional 
comments you come up with.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Module Exposure

2005-07-09 Thread Jacob Page
George Sakkis wrote:
> "Jacob Page" <[EMAIL PROTECTED]> wrote:
> 
>>George Sakkis wrote:
>>
>>>1. As already noted, ISet is not really descriptive of what the class
>>>does. How about RangeSet ? It's not that long and I find it pretty
>>>descriptive. In this case, it would be a good idea to change Interval
>>>to Range to make the association easier.
>>
>>The reason I decided not to use the term Range was because that could be
>>confused with the range function, which produces a discrete set of
>>integers.  Interval isn't a term used in the standard/built-in library,
>>AFAIK, so I may stick with it.  Is this sound reasoning?
> 
> Yes, it is not unreasonable; I can't argue strongly against Interval.
> Still I'm a bit more in favor of Range and I don't think it is
> particularly confusing with range() because:
> 1. Range has to be either qualified with the name of the package (e.g.
> rangesets.Range) or imported as "from rangesets import Range", so one
> cannot mistake it for the range builtin.
> 2. Most popular naming conventions use lower first letter for functions
> and capital for classes.
> 3. If you insist that only RangeSet should be exposed from the module's
> interface and Range (Interval) should be hidden, the potential conflict
> between range() and RangeSet is even less.

Those are pretty good arguments, but after doing some poking around on 
planetmath.org and reading 
http://planetmath.org/encyclopedia/Interval.html, I've now settled on 
Interval, since that seems to be the proper use of the term.

>>>2. The module's "helper functions" -- which are usually called factory
>>>functions/methods because they are essentially alternative constructors
>>>of ISets -- would perhaps better be defined as classmethods of ISet;
>>>that's a common way to define instance factories in python. Except for
>>>'eq' and 'ne', the rest define an ISet of a single Interval, so they
>>>would rather be classmethods of Interval. Also the function names could
>>>take some improvement; at the very least they should not be 2-letter
>>>abbreviations.
>>
>>First, as far as having the factory functions create Interval instances
>>(Range instances in your examples), I was hoping to avoid Intervals
>>being publically "exposed."  I think it's cleaner if the end-programmer
>>only has to deal with one object interface.
> 
> First off, the python convention for names you intend to be 'private'
> is to prefix them with a single underscore, i.e. _Interval, so it was
> not obvious at all by reading the documentation that this was your
> intention. Assuming that Interval is to be exposed, I  found
> Interval.lowerThan(5) a bit more intuitive than
> IntervalSet.lowerThan(5). The only slight problem is the 'ne'/
> allExcept factory which doesn't return a continuous interval and
> therefore cannot be a classmethod in Interval.

If the factories resided in separate classes, it seems like they might 
be less convenient to use.  I wanted these things to be easily 
constructed.  Maybe a good compromise is to implement lessThan and 
greaterThan in both Interval and IntervalSet.

> On whether Interval should be exposed or not: I believe that interval
> is a useful abstraction by itself and has the important property of
> being continuous, which IntervalSet doesn't. 

Perhaps I should add a boolean function for IntervalSet called 
continuous (isContinuous?).

Having a simple
> single-class interface is a valid argument, but it may turn out to be
> restricted later. For example, I was thinking that a useful method of
> IntervalSet would be an iterator over its Intervals:
> for interval in myIntervalSet:
> print interval.min, interval.max

I like the idea of allowing iteration over the Intervals.

> There are several possible use cases where dealing directly with
> intervals would be appropriate or necessary, so it's good to have them
> supported directly by the module.

I think I will keep Interval exposed.  It sort of raises a bunch of 
hard-to-answer design questions having two class interfaces, though. 
For example, would Interval.between(2, 3) + Interval.between(5, 7) raise 
an error (as it currently does) because the intervals are disjoint or 
yield an IntervalSet, or should it not even be implemented?  How about 
subtraction, xoring, and anding?  An exposed class should have a more 
complete interface.

I think that IntervalSet.between(5, 7) | IntervalSet.between(2, 3) is 
more intuitive than IntervalSet(Interval.between(5, 7), 
Interval.between(2, 3)), but I can understand the reverse.  I think I'll

Re: Python Module Exposure

2005-07-09 Thread Jacob Page
George Sakkis wrote:
> "Jacob Page" <[EMAIL PROTECTED]> wrote:
> 
>>I think I will keep Interval exposed.  It sort of raises a bunch of
>>hard-to-answer design questions having two class interfaces, though.
>>For example, would Interval.between(2, 3) + Interval.between(5, 7) raise
>>an error (as it currently does) because the intervals are disjoint or
>>yield an IntervalSet, or should it not even be implemented?  How about
>>subtraction, xoring, and anding?  An exposed class should have a more
>>complete interface.
>>
>>I think that IntervalSet.between(5, 7) | IntervalSet.between(2, 3) is
>>more intuitive than IntervalSet(Interval.between(5, 7),
>>Interval.between(2, 3)), but I can understand the reverse.  I think I'll
>>just support both.
> 
> As I see it, there are two main options you have:
> 
> 1. Keep Intervals immutable and pass all the responsibility of
> combining them to IntervalSet. In this case Interval.__add__ would have
> to go. This is simple to implement, but it's probably not the most
> convenient to the user.
> 
> 2. Give Interval the same interface with IntervalSet, at least as far
> as interval combinations are concerned, so that Interval.between(2,3) |
> Interval.greaterThan(7) returns an IntervalSet. Apart from being user
> friendlier, an extra benefit is that you don't have to support
> factories for IntervalSets, so I am more in favor of this option.

I selected option one; Intervals are immutable.  However, this doesn't 
mean that __add__ has to go, as that function has no side-effects.  The 
reason I chose option one was because it's uncommon for a mathematical 
operation on two objects to return a different type altogether.

> Another hard design problem is how to combine intervals when
> inheritance comes to play. Say that you have FrozenInterval and
> FrozenIntervalSet subclasses. What should "Interval.between(2,3) |
> FrozenInterval.greaterThan(7)" return ?

For now, operations will return mutable instances.  They can always be 
frozen later if needs be.
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: interval module 0.2.0 (alpha)

2005-07-09 Thread Jacob Page
After some feedback from this newsgroup, I've updated and renamed the 
iset module to the interval module.  Many of the names within the module 
have also changed, and I've refactored a lot of the code.  The updated 
version can be found at http://members.cox.net/apoco/interval/, as well 
as a change log.

Again, any suggestions would be greatly appreciated.  I especially want 
to sort out big design-level changes first.  Then I can upgrade the 
project status to beta and try to keep interface compatibility intact.

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


Re: Python Module Exposure

2005-07-09 Thread Jacob Page
George Sakkis wrote:
> "Jacob Page" <[EMAIL PROTECTED]> wrote:
> 
>>I selected option one; Intervals are immutable.  However, this doesn't
>>mean that __add__ has to go, as that function has no side-effects.  The
>>reason I chose option one was because it's uncommon for a mathematical
>>operation on two objects to return a different type altogether.
> 
> Mathematically what you described corresponds to sets that are not
> closed under some operation and it's not uncommon at all; a few
> examples are:
> - The set of integers is not closed under division: int / int ->
> rational
> - The set of real numbers is not closed under square root: sqrt(real)
> -> complex
> - The set of positive number is not closed under subtraction:
> pos_number - pos_number -> number
> - And yes, the set of intervals is not closed under union.

Yes, but I wasn't talking about mathematical operations in general; I 
was talking about mathematical operations in Python.  Example: 6 / 5 
doesn't yield a float (though I heard that might change in future 
versions).  If the union of two integers yielded a set of integers, then 
it'd make more since for the union of two Intervals to yield an 
IntervalSet.  But it doesn't.  Just as set([2, 6]) creates a set of two 
integers, IntervalSet(Interval(...), Interval(...)) creates a set of two 
intervals.

> On another note, I noticed you use __contains__ both for membership and
> is-subset queries. This is problematic in case of Intervals that have
> other Intervals as members. The set builtin type uses __contains__  for
> membership checks and issubset for subset checks (with __le__ as
> synonym); it's good to keep the same interface.

Good catch.  I think I've made similar mistakes for a few of the other 
functions, too.

Thanks for your help.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Module Exposure

2005-07-10 Thread Jacob Page
George Sakkis wrote:
> "Jacob Page" <[EMAIL PROTECTED]> wrote:
> 
>>If the union of two integers yielded a set of integers, then
>>it'd make more since for the union of two Intervals to yield an
>>IntervalSet.
> 
> AFAIK union is defined over sets, not numbers, so I'm not sure what you
> mean by the "union of two integers". What I'm saying is that while the
> union of two intervals is always defined (since intervals are sets),
> the result set is not guaranteed to be an interval. More specifically,
> the result is an interval if and only if the intervals overlap, e.g.
> (2,4] | [3,7] = (2,7]
> but
> (2,4] | [5,7] = { (2,4], [5,7] }
> That is, the set of intervals is not closed under union. OTOH, the set
> of intervals _is_ closed under intersection; intersecting two
> non-overlapping intervals gives the empty interval.

OK, you've convinced me now to support and, or, and xor between every 
combination of Intervals and IntervalSets, Intervals and IntervalSets, 
and IntervalSets and Intervals.  However, I'm not sure I  like the idea 
of an operation generating either one type or another.  Thus, I'll have 
| and ^ operations between Intervals always return an IntervalSet 
instead of returning either an IntervalSet or an Interval.  & will 
return an Interval.  I suppose that means I should just have + do a 
union and - return an IntervalSet.  It will just have to be documented 
which types are to be expected for the return values depending on the 
operands.
-- 
http://mail.python.org/mailman/listinfo/python-list


set and frozenset unit tests?

2005-07-11 Thread Jacob Page
I have released interval-0.2.1 at 
http://members.cox.net/apoco/interval/.  IntervalSet and 
FrozenIntervalSet objects are now (as far as I can tell) functionality 
equivalent to set and frozenset objects, except they can contain 
intervals as well as discrete values.

Though I have my own unit tests for verifying this claim, I'd like to 
run my code through actual set and frozenset unit tests.  Does any such 
code exist?  Is it in pure Python?  If so, where can it be obtained?

Oh, and again, I'd really appreciate additional feedback on the module, 
especially related to design, if you've got any.  My goal for this 
project is to make the classes built-in-data-type quality.

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


Re: set and frozenset unit tests?

2005-07-12 Thread Jacob Page
Reinhold Birkenfeld wrote:
> Jacob Page wrote:
> 
>>I'd like to 
>>run my code through actual set and frozenset unit tests.  Does any such 
>>code exist?  Is it in pure Python?  If so, where can it be obtained?
> 
> Look at /usr/lib/python2.x/test/ (on unix platforms).

Thanks for pointing that to me.  For some reason, the Debian package for 
python 2.4 doesn't include those tests, but I acquired them from an 
alternative source.

Oye, there's quite a number of set and frozenset features that aren't 
well-documented that I now need to implement.  What a fun chore!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: set and frozenset unit tests?

2005-07-14 Thread Jacob Page
Steven Bethard wrote:
> Jacob Page wrote:
> 
>> Oye, there's quite a number of set and frozenset features that aren't 
>> well-documented that I now need to implement.  What a fun chore!
> 
> It would be a great help if you could submit appropriate documentation 
> patches for the areas you don't think are well-documented:

Hmm, after closer scrutiny, I'm not sure if the documentation really 
does need modification.  The largest incompatibility between IntervalSet 
and set was that my code wasn't enforcing hashability, and that property 
of sets actually IS documented.  However, there are two minor things I 
don't see documented that caught me by surprise:

* Since the <=, <, >, and >= operators raise an exception if the 
right-hand operand is not a set or frozenset,  it seemed reasonable to 
me to assume that == and != should, too.  However, the test suite for 
sets expect the comparisons to be allowed; == between a set and non-set 
return False, != returns True.  Seems inconsistent with the rest of the 
operators, but then again, the odd use of > and < for purposes other 
than ordering also seems strange.

* Apparently, if fs is a frozenset instance, fs.copy() returns a 
reference to fs instead of a copy of fs, and frozenset(fs) does the 
same.  The unit tests also ensure that subclasses of frozenset don't do 
this.  It makes sense that it's done that way to save on storage space, 
but it's not documented that this happens.

Both issues seem to be pretty minor unless you're making functionally 
equivalent classes.  I'm sure neither one will confuse someone into 
using them improperly, so I think it's fine to leave the docs alone.

By the way, IntervalSet and FrozenIntervalSet, when used in place of set 
and frozenset, now pass most of the tests.  One notable difference 
between them is that whereas sets can contain any hashable object, 
IntervalSet elements must be both hashable and orderable (implement 
__cmp__).  Thus, commands like IntervalSet([FrozenIntervalSet(...)]) 
fail, unlike set([frozenset(...)]).

I've also changed the methods with mixedCase capitalization to 
lower_case_with_underscores, as recommended by PEP 8.

Version 0.2.2 of the module can now be downloaded from 
http://members.cox.net/apoco/interval/.  I'm about to freeze the 
interfaces and transition the module to beta, so if you have any 
interest in the project or design change ideas, please send feedback soon.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compiling a Python File on Mac OS X Tiger

2005-07-26 Thread Jacob Page
Asad Habib wrote:
> Hello. I am working on Tiger and wanted to find out how to compile a
> Python (.py) file into a .pyc file and then into a .pyo file. Can the
> compilation be achieved within the interpreter? Also, I am
> new to Python and wanted to know the difference between .pyc and .pyo
> files. Is this comparison similar to C? Any help would be appreciated.
> Thanks.

http://www.network-theory.co.uk/docs/pytut/tut_48.html has some good 
explanations.  To generate the .pyo files from the interpreter, add the 
-O option.

The difference between .pyc and .pyo files is that .pyo files are 
optimized a bit; for example docstrings are removed (which will break 
pydoc tests).  According to the above link, .pyo files don't run any 
faster; they just load faster.
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] PyDO-2.0b1 Released

2005-07-27 Thread Jacob Smullyan
I'm pleased to announce the release of PyDO-2.0b1, the second beta
release of the 2.0 series.

What's New
--

* more tests and corresponding bug fixes.
  
What it is
--

PyDO is Drew Csillag's ORM (Object-Relational Mapper) database access
library for Python that facilitates writing a Python database access
layer.  PyDO attempts to be simple, flexible, extensible, and
unconstraining. 

PyDO 2 is a rewrite of the 1.x series distributed with SkunkWeb.
It has several enhancements:

   * PyDO can now be used in multi-threaded or twisted-style
 asynchronous sitations, with or without a customizable connection
 pool.

   * PyDO objects are now dict subclasses, but also support attribute
 access to fields.

   * Projections -- subsets of the field list of a super-class -- are
 now supported by the PyDO.project() method.

   * Table attributes are now declared in a more concise way.

   * PyDO2 supports runtime table introspection.

   * Overall, the API has been tightened and the code restructured.

PyDO 2 requires Python 2.4 or later.  It currently supports
PostgreSQL, MySQL, Sqlite, MSSQL, and Oracle, and support for other
databases is planned.

PyDO is dual GPL/BSD licensed.

The source tarball is available at SkunkWeb's berlios site:

   https://developer.berlios.de/projects/skunkweb/

or, more directly:

   http://download.berlios.de/skunkweb/PyDO-2.0b1.tar.gz

Questions pertaining to PyDO can be addressed to the SkunkWeb mailing
list at sourceforge:

   http://lists.sourceforge.net/lists/listinfo/skunkweb-list

Cheers,

js

-- 
Jacob Smullyan 



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


Re: Django Vs Rails

2005-09-15 Thread Jacob Smullyan
On 2005-09-15, Jonathan Ellis <[EMAIL PROTECTED]> wrote:
> James wrote:
>> I actually like the framework to reflect on my database. I am more of a
>> visual person. I have tools for all my favorite databases that allow me
>> to get a glance of ER diagrams and I would rather develop my data
>> models in these tools rather than in code. Further more I rather like
>> the idea of parsimonious use of code (which is probably why I use
>> Python in the first place) and do not really like manually specifying
>> data schemas in code as much as possible.
>>
>> Is some familiar with a Python Framework that builds by reflection.
>
> PyDO (http://skunkweb.sourceforge.net/pydo2.html) is a Python ORM tool
> that does this well (*cough* better than sqlobject *cough*).

As the current PyDO dev, I won't make the same comparative value
judgement as Jonathan here, not out of reticence, but lack of
conviction -- SQLObject is quite excellent, and for all I know better
than PyDO in execution -- but a comparison I would make is that PyDO
is different from ORMs like SQLObject (and even more so, from
ActiveRecord) in that it assumes that the database precedes the object
layer, chronologically and/or in significance, and that the database
schema shouldn't need to conform much to a particular ORM's
expectations, reasonable as they may or not be.  The most obvious
differences are that SQLObject expects tables to have an "id" integer
column, and doesn't support multi-column candidate keys; PyDO doesn't
make such demands.  So, similar as they are, in orientation these
libraries are somewhat different beasts.

I have mixed feelings about automagical schema introspection.  PyDO
supports it, and will probably do so increasingly robustly if people
use it.  But part of me feels that "explicit is better than implicit"
may win out over DRY here, because the ORM layer and the db layer
exist in different realms, and if the ORM layer adapts silently to
changes in the db layer, other code is likely to fail in unpredictable
ways, including silently, whereas an explicit declaration of what
fields are in a table, for instance, will fail with a hard error.  But
maybe this is anal retentiveness, akin to a need for strong typing.

js


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


Re: Django Vs Rails

2005-09-15 Thread Jacob Smullyan
On 2005-09-15, Jorge Godoy <[EMAIL PROTECTED]> wrote:
> I just wonder when it becomes bad having to declare everything.  For example,
> we have databases with 600 tables.  
[snip]
> Having the introspection is great in this case (even though it is boring
> having to declare all those classes and tell them to fetch their structure
> from the database it is better than having to "recreate" all of them).

Granted.  Also, if the tables share structure, another option would be
to simplify their description with inheritance.

> With regards to failures, this is one of the reasons for unit tests :-)  They
> can help finding out where is the problem and they should never fail
> silently. 

You are right.  I am consoled.  

js

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


code for Computer Language Shootout

2005-03-15 Thread Jacob Lee
There are a bunch of new tests up at shootout.alioth.debian.org for which
Python does not yet have code. I've taken a crack at one of them, a task
to print the reverse complement of a gene transcription. Since there are a
lot of minds on this newsgroup that are much better at optimization than
I, I'm posting the code I came up with to see if anyone sees any
opportunities for substantial improvement. Without further ado:

table = string.maketrans('ACBDGHK\nMNSRUTWVY', 'TGVHCDM\nKNSYAAWBR')

def show(s):
i = 0
for char in s.upper().translate(table)[::-1]:
if i == 60:
print
i = 0
sys.stdout.write(char)
i += 1
print

def main():
seq = ''
for line in sys.stdin:
if line[0] == '>' or line[0] == ';':
if seq != '':
show(seq)
seq = ''
print line,
else:
seq += line[:-1]
show(seq)

main()


Making seq into a list instead of a string (and using .extend instead of
the + operator) didn't give any speed improvements. Neither did using a
dictionary instead of the translate function, or using reversed() instead
of s[::-1]. The latter surprised me, since I would have guessed using an
iterator to be more efficient. Since the shootout also tests memory usage,
should I be using reversed for that reason? Does anyone have any other
ideas to optimize this code?

By the way - is there a good way to find out the maximum memory a program
used (in the manner of the "time" command)? Other than downloading and
running the shootout benchmark scripts, of course.

-- 
Jacob Lee
[EMAIL PROTECTED] | www.nearestneighbor.net

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


Re: code for Computer Language Shootout

2005-03-15 Thread Jacob Lee
On Tue, 15 Mar 2005 21:38:48 -0800, Michael Spencer wrote:

> string.translate is a good idea.  Note you can handle upper-casing and
> translation in one operation by adding a mapping from lower case to the
> complement i.e.,
> 
> table = string.maketrans('ACBDGHK\nMNSRUTWVYacbdghkmnsrutwvy',
>   'TGVHCDM\nKNSYAAWBRTGVHCDMKNSYAAWBR')
> 
Good call.

> This looks unwieldy - especially writing to sys.stdout oe character at a
> time. I may not have understood the spec exactly, but isn't this the
> same as:
> 
> for line in sys.stdin:
>  if line and (line[0] == ">" or line[0] == ";"):
>  print line
>  else:
>  print line.translate(table)
> 
> 
That's the immediately obvious solution, but it doesn't actually fulfill
the problem requirements. What if your last line is less than 60
characters long? You no longer will be displaying the input in reverse
order. Otherwise you'd be right - my solution would be unnecessarily
unwieldy (and the problem would be much simpler...) .

-- 
Jacob Lee
[EMAIL PROTECTED] | www.nearestneighbor.net

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


Re: code for Computer Language Shootout

2005-03-15 Thread Jacob Lee
On Tue, 15 Mar 2005 22:45:48 -0700, Steven Bethard wrote:

> # table as default argument value so you don't have to do
> # a global lookup each time it's used
> 
> def show(seq, table=string.maketrans('ACBDGHK\nMNSRUTWVY',
>   'TGVHCDM\nKNSYAAWBR')
>  seq = seq.upper().translate(table)[::-1]
>  # print string in slices of length 60
>  for i in range(0, len(seq), 60):
>  print seq[i:i+60]
> 
> def main():
>  seq = []
>  # alias methods to avoid repeated lookup
>  join = ''.join
>  append = seq.append
>  for line in sys.stdin:
>  # note only one "line[0]" by using "in" test
>  if line[0] in ';>':
>  # note no need to check if seq is empty; show now prints
>  # nothing for an empty string
>  show(join(seq))
>  print line,
>  del seq[:]
>  else:
>  append(line[:-1])
> 

Wow - that ran about 10 times faster on a 10MB input file. The significant
change was the for loop inside the show function: your method avoids the
increment and if statement and of course has 60x fewer iterations total.

> reversed() won't save you any memory -- you're already loading the 
> entire string into memory anyway.
> 
> 
> Interesting tidbit:
>  del seq[:]
> tests faster than
>  seq = []
> 
> $ python -m timeit -s "lst = range(1000)" "lst = []"
> 1000 loops, best of 3: 0.159 usec per loop
> 
> $ python -m timeit -s "lst = range(1000)" "del lst[:]"
> 1000 loops, best of 3: 0.134 usec per loop
> 
> It's probably the right way to go in this case anyway -- no need to 
> create a new empty list each time.

Fascinating - I hadn't thought about that.

Besides redoing that loop, the remaining optimizations produce less than a
10% speed-up; in particular, adding the function aliases increases the
number of lines of code (another benchmark in the shootout), and I would
imagine that the organizers don't really want that type of special
optimization (no developer is going to write that in their programs
unless they have really time-critical code, so this is the sort of hit
that Python really should take in the contest as penalty for being so
dynamically nifty ;)). So here's a tentative contest version of the code:

import sys
import string

def show(seq, table=string.maketrans('ACBDGHK\nMNSRUTWVYacbdghkmnsrutwvy',
 'TGVHCDM\nKNSYAAWBRTGVHCDMKNSYAAWBR')):
 seq = seq.translate(table)[::-1]
 for i in range(0, len(seq), 60):
 print seq[i:i+60]

def main():
 seq = []
 for line in sys.stdin:
 if line[0] in ';>':
 show(''.join(seq))
 print line,
 del seq[:]
 else:
 seq.append(line[:-1])
 show(''.join(seq))

main()

-- 
Jacob Lee
[EMAIL PROTECTED] | www.nearestneighbor.net

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


Re: code for Computer Language Shootout

2005-03-16 Thread Jacob Lee
On Wed, 16 Mar 2005 16:45:53 -0800, bearophileHUGS wrote:

> Michael Spencer's version is nice, this is a bit shortened version. The
> main() isn't useful for this very short loop, and you can use shorter
> variable names to make lines shorter (this code isn't much readable,
> it's just for the Shootout, "production quality" code has probably to
> be more readable. Code produced by lot of people of a newsgroup isn't
> the normal code usually produced by a single programmer in a limited
> amount of time).
> I've used file(sys.argv[1]) instead of sys.stdin.
> 

I don't see what advantage having smaller variable names gives you. IIRC,
they measure lines of code in logical rather than physical lines.

> 
> . import string, itertools, sys
> .
> . t = string.maketrans('ACBDGHKMNSRUTWVYacbdghkmnsrutwvy',
> .  'TGVHCDMKNSYAAWBRTGVHCDMKNSYAAWBR')
> .
> . for h,b in itertools.groupby( file(sys.argv[1]), lambda x: x[0] in
> ">;" ):
> . if h:
> . print "".join(b),
> . else:
> . b = "".join(b).translate(t, "\n\r")
> . print "\n".join( b[-i:-i-60:-1] for i in xrange(1, len(b),
> 60) )
> 

I benchmarked this, btw - it ran in the same amount of time as the other
solution. It does have the advantage of being significantly fewer lines of
code; I suppose that itertools.groupby, while unexpected to someone from a
language without such niceties in the standard library =), is a better
solution than duplicating the code (or the function call) to translate,
reverse, and format the string.

> --
> 
> The Python Mandelbrot program seems to produce a wrong image:
> 
> http://shootout.alioth.debian.org/benchmark.php?test=mandelbrot&lang=python&id=0&sort=fullcpu
> 

It's my understanding that they use an automated diff with the outputs. So
presumably it's generating correct output or it would be listed as
"Error". I haven't actually checked this, so who knows.

> --
> 
> This is a shorter and faster version of wordfreq:
> http://shootout.alioth.debian.org/benchmark.php?test=wordfreq&lang=python&id=0&sort=fullcpu
> 
> . import string, sys
> .
> . def main():
> . f = {}
> . t = " "*65+ string.ascii_lowercase+ " "*6+
> string.ascii_lowercase+ " "*133
> .
> . afilerl = file(sys.argv[1]).readlines
> . lines = afilerl(4095)
> . while lines:
> . for line in lines:
> . for w in line.translate(t).split():
> . if w in f: f[w] += 1
> . else: f[w] = 1
> . lines = afilerl(4095)
> .
> . l = sorted( zip(f.itervalues(), f.iterkeys()), reverse=True)
> . print "\n".join("%7s %s" % (f,w) for f,w in l)
> .
> . main()
> 

Cool. I haven't looked at this one, but why don't you test it against
their sample data, diff it to make sure the output is identical, and send
it to their mailing list :-).

> --
> 
> This is my shorter and faster version of Harmonic (I hope the use of
> sum instead of the for is okay for the Shootout rules):
> http://shootout.alioth.debian.org/benchmark.php?test=harmonic&lang=python&id=0&sort=fullcpu
> 
> import sys
> print sum( 1.0/i for i in xrange(1, 1+int(sys.argv[1]) ) )
> 

Yes, the current Python version is an embarrassment. I was already
planning to send in the one-character patch (s/range/xrange/) when
submitting the reverse-complement code. This version is probably more
efficient than an explicit loop, although I doubt the difference is by
much. I suppose an ounce of profiling is worth a pound of speculation...

-- 
Jacob Lee
[EMAIL PROTECTED] | www.nearestneighbor.net

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


how to force HTTP 1.1 when using urllib2?

2004-12-21 Thread jacob c.
When I request a URL using urllib2, it appears that urllib2 always
makes the request using HTTP 1.0, and not HTTP 1.1.  I'm trying to use
the "If-None-Match"/"ETag" HTTP headers to conserve bandwidth, but if
I'm not mistaken, these are HTTP 1.1 headers, so I can't reasonably
expect a web server to respond correctly to my requests.  (In my
limited testing, it looks like some servers respond correctly with an
HTTP 304 status, while some respond with an HTTP 200 and a full
response body.)

My specific issue notwithstanding, is there any way to force HTTP 1.1
to be used?  Or am I doing something wrong?

I've condensed my code into the following example, which produces
similar results on two different setups, Python 2.3.2 on Windows and
Python 2.2.1 on Debian Linux.  With this particular URL, the server
responds to my HTTP 1.0 request with an HTTP 1.1 response and an HTTP
304 status code, which suits my purposes, but I'd feel more comfortable
if my outgoing response also declared itself to be an HTTP 1.1 request.


Example code:

import httplib
httplib.HTTPConnection.debuglevel = 1
import urllib2

url = 'http://www.mozilla.org/images/firefox-oneoh-top.png'
etag = '"788054-2d18-3b21a80"'

request = urllib2.Request(url)
request.add_header('If-None-Match', etag)
opener = urllib2.build_opener()
response = opener.open(request)


Example output:

connect: (www.mozilla.org, 80)
send: 'GET /images/firefox-oneoh-top.png HTTP/1.0\r\nHost:
www.mozilla.org\r\nUser-agent: Python-urllib/2.0a1\r\nIf-none-match:
"788054-2d18-3b21a80"\r\n\r\n'
reply: 'HTTP/1.1 304 Not Modified\r\n'
header: Date: Tue, 21 Dec 2004 21:56:27 GMT
header: Server: Apache/2.0.46 (Red Hat)
header: Connection: close
header: ETag: "788054-2d18-3b21a80"
Traceback (most recent call last):
File "urllib2-test.py", line 11, in ?
response = opener.open(request)
File "D:\Python\lib\urllib2.py", line 333, in open
'_open', req)
File "D:\Python\lib\urllib2.py", line 313, in _call_chain
result = func(*args)
File "D:\Python\lib\urllib2.py", line 849, in http_open
return self.do_open(httplib.HTTP, req)
File "D:\Python\lib\urllib2.py", line 843, in do_open
return self.parent.error('http', req, fp, code, msg, hdrs)
File "D:\Python\lib\urllib2.py", line 359, in error
return self._call_chain(*args)
File "D:\Python\lib\urllib2.py", line 313, in _call_chain
result = func(*args)
File "D:\Python\lib\urllib2.py", line 419, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 304: Not Modified

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


Re: Grouping code by indentation - feature or ******?

2005-03-26 Thread Jacob Lee
On Sat, 26 Mar 2005 10:02:13 +0100, Javier Bezos wrote:

> 
> "Tim Tyler" <[EMAIL PROTECTED]> escribió en el mensaje
> news:[EMAIL PROTECTED]
>> What do you guys think about Python's grouping of code via indentation?
>>
>> Is it good - perhaps because it saves space and eliminates keypresses?
>>
>> Or is it bad - perhaps because it makes program flow dependent on
>> invisible, and unpronouncable characters - and results in more
>> manual alignment issues by preventing code formatters from managing
>> indentation?
> 
> I particularly hate it, but Python has lots of good
> things which compesate that (another annoying point
> of Python are slices -- mine are always off by 1).
> I always write explicitly ends as #end, so that I
> can reorganice the code easily if necessary. Maybe
> in the future, when Ruby matures, I could change
> my mind, but currently Python is still my favourite
> scripting language (as formerly was Tcl).
> 

About slices:

I agree that Python's slice boundaries (some_list[a:b] being all elements
with a <= index < b) are counterintuitive at first. But this method does
satisfy some handy properties, the first of which being:
  l[:n] + l[n:] = l
Secondly, the range() function behaves identically to slices, meaning that
  for i in range(10):
will iterate 10 times, and
  for i in range(len(l)):
will iterate over the indices of the sequence l.

If you had l[a:b] be inclusive on both a and b (instead of inclusive on a
and exclusive on b), you would have to be adding and subtracting one in
all of these examples, leading that much more easily to off-by-one errors.

A digression: my data structures teacher (in c++) has a vector class that
allows you to set upper and lower bounds, and he combines this with for
loops that usually start at one but don't always. I doubt he was trying to
get this point across, but the lesson I've learned is to always start at
zero and count to less than the length of the list (in c, the idiom is
for (i = 0; i < length; i++)). Believe me that any other way will only
lead to trouble! :-)

-- 
Jacob Lee
[EMAIL PROTECTED] | www.nearestneighbor.net

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


Europython 2005 is now accepting talk submissions

2005-04-04 Thread Jacob Hallen

Europython 2005 is now accepting talk submissions!

Find out more at http://www.europython.org

Just as last year, we have a Refereed Paper Track. Last day for
proposing a refereed paper is 22 April 2005.

For regular talks, we have the following tracks:
Business
Education
Python Frameworks
Python Language
Science
Social skills and General Topics
Zope/Plone

We also have a special track for "Misfits" this year. It is
for any topic that is Python related but doesn't fit in
any of the above categories.

Last day for submitting talks to the regular tracks is
1 May 2005.

On top of this, we will have two tracks of Lightning Talks;
one for Zope/plone and one for other topics. You can register
talks for these all the time until the Lightning Talk
sessions end, or the schedule is filled, whichever comes first.

Europython 2005 will be held 27-29 June at the Chalmers University
of Techchnology, Göteborg, Sweden. Registration will open in
mid-April.

We hope this will become the best Europython Conference ever!
With your help it can. We are still seeking volunteers to help
us with a number of things. We have a recent vacancy as track
chair for Python Frameworks, and it is not too late to revive
the Applications Track. We also need people to help out in the
reception during the conference. Send an email to 
[EMAIL PROTECTED]

Jacob Hallén
Head organiser

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


Europython 2005 registration open

2005-04-26 Thread Jacob Hallen
EuroPython is held -for the second time- in Göteborg, Sweden, during
the week of June 27-29, 2005.  Registration is open and now is your
chance to submit a proposal (or more).

Several topics are handled in parallel tracks at EuroPython2005, these
include: Business, Education, Lightning talks, Python Frameworks,
Python Language, Refereed papers, Science, Social skills/General
topics, Tutorials/Neopythes, Zope and Zope Related, Zope Lightning
talks. If you would like to tell the community something about your
work, interest or experience, then then submit button is your way to
go.

The Refereed Track is intended for prestigious peer-reviewed talks for
presenting technical and scientific papers. To our knowledge,
EuroPython is the only Python conference, with peer-reviewed
talks. Everybody can submit a paper for the Refereed Track, as long as
it follows the Refereed paper instructions. For detailed information
concerning this subject, please have a look at the Tracks & Talks
webpage of EuroPython. To give you yet another opportunity to submit a
refereed paper, we have extended the deadline to coincide with the
deadline for regular talks. Lat day for submission is 1 May 2005!

If you don't want to participate as a speaker, you might be interested
in hearing the talks. Registration for EuroPython2005 is now
open. Several registration alternatives are possible. Pre-Registration
will be available until 17th of June, but Early Bird registration will
end on May the 15th. Everybody is welcome: from novice to advanced.

Our keynote speakers will be Guido van Rossum and Steve Pemberton.
You may not have heard of Steve, since his focus is in an area that is
not directly connected to Python. However, we expect him to give you
an interesting perspective on what is going on in the industry.
Find out more at http://homepages.cwi.nl/~steven/.
If you don't know who Guido van Rossum is, you really need to come to
Europython to find out.

Feel free to spread the word about EuroPython2005 to your friends, family,
colleagues, ...

For all conference details, go to:
http://www.europython.org

See you at Göteborg.

EuroPython Team.

About EuroPython: Europython is an annual conference for the Python
and Zope communities. It circulates between different sites in
Europe. Having started in Charleroi, Belgium, it is now in Göteborg,
Sweden and will move to CERN in Swizerland next year. Europython is a
community conference run by volunteers.

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


ipython and pyglet

2014-01-01 Thread Jacob Goodson
Hello!

Has anyone here tried to get ipython to interact with the event loop for 
pyglet?  If so, would you be willing to share come example code?  I would like 
to be able to interactively code in pyglet, creating and updating objects while 
the program is running.  Thanks!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyFladesk :: create GUI apps by Python and HTML, CSS and Javascript.

2016-01-07 Thread jacob Kruger
I would definitely like to try out something like this - I am primarily 
a web developer, and, partly since am 100% blind, any form of GUI design 
is at times an issue for me, whereas I have been working with HTML 
markup layouts for almost 20 years now, but, which versions of python 
should this work with, and, what does it actually then use to 
generate/handle GUI interface? Ask since, some of the GUI frameworks are 
not too accessible themselves.


Also, downloaded both the main master, and the RSS reader master images, 
but, both python 2.7 and python 3.4 tell me that they have no urllib2, 
and under 3.4, pip install can't find it either..?


TIA

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

On 2016-01-08 1:08 AM, Saeed Moqadam wrote:

create multi platform desktop application by using Python, HTML, CSS and 
Javascript.
source code is https://github.com/smoqadam/PyFladesk

you can find RSS Reader app that made by PyFladesk in the following url :

https://github.com/smoqadam/PyFladesk-rss-reader

I'll waiting for your feedback.

thanks


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


Re: PyFladesk :: create GUI apps by Python and HTML, CSS and Javascript.

2016-01-07 Thread jacob Kruger
Ok, double-checked again, and if force it to run under 2.7, then it 
complains about lack of pyQT4 - that's one of the issues was asking 
about relating to GUI frameworks - pyQT hasn't always worked too well 
under 2.7 in terms of accessibility API's in past, but, will 'see' if 
can get hold of that module for 2.7, and take it from there.


Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

On 2016-01-08 7:07 AM, Bernardo Sulzbach wrote:

On Fri, Jan 8, 2016 at 1:54 AM, jacob Kruger  wrote:

Also, downloaded both the main master, and the RSS reader master images,
but, both python 2.7 and python 3.4 tell me that they have no urllib2, and
under 3.4, pip install can't find it either..?

TIA


Python 3 does not have urllib2. It is a Python 2 module that has been
split across several modules in Python 3.

However, are you sure you tried it with Python 2.7?



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


Re: Hello.

2016-01-17 Thread jacob Kruger

Environment variables pointing to c:\python..?
(needs to point to actual installation directory)

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

On 2016-01-16 11:41 PM, Hmood Js wrote:

cmd won't recognize python at all I've checked several times , and I don't 
understand what's wrong

Sent from Mail for Windows 10



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


Re: Installing pygame

2016-01-21 Thread jacob Kruger
I literally just installed pyGame under 3.5.1, using following .whl file 
that pulled off a site offering collections of .whl files:

http://www.lfd.uci.edu/~gohlke/pythonlibs/

And, according to following page, the command of pi3p install 
...followed by name of .whl file... handled installing pyGame under 3.5.1:

https://skellykiernan.wordpress.com/2015/01/04/python-pygame-install/

That was after copying the .whl file into the./scripts directory under 
python 3.5.1 installation path.


HTH

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

On 2016-01-21 12:10 PM, John Mycroft wrote:

Hi!
I have now spent several hours trying to install Pygame with Python 
3.5.  I have installed from a msi file "successfully" but "import 
pygame" fails either because Python can't find pygame or because "%1  
is not a valid .DLL".  I have followed the instructions at 
https://www.webucator.com/blog/2015/03/installing-the-windows-64-bit-version-of-pygame/ 
to install from a wheel which works just fine until I get to

***
C:\Python>c:\python\scripts\pip install pygame-1.9.2a0-cp35-none-win32
c:\python\lib\site-packages\pip\pep425tags.py:89: RuntimeWarning: 
Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect

  warn=(impl == 'cp')):
c:\python\lib\site-packages\pip\pep425tags.py:93: RuntimeWarning: 
Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect

  warn=(impl == 'cp')):
Collecting pygame-1.9.2a0-cp35-none-win32
  Could not find a version that satisfies the requirement 
pygame-1.9.2a0-cp35-none-win32 (from versions: )

No matching distribution found for pygame-1.9.2a0-cp35-none-win32
**
which tells me nothing.


Please, someone - how do I install pygame?  It appears to be installed 
on my PC - maybe I have it in the wrong folder?  When I download the 
install packages, I copy them into my c:\Python folder (where my 
Python lives) and install from there so I would think they'd get 
installed in the right place.


Many thanks - John Mycroft


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


Re: Help

2016-02-28 Thread jacob Kruger

On 2016-02-28 9:58 PM, [email protected] wrote:

I need to write a program that allows the user to enter a sentence then asks 
them which word they wish to find- and then tell them the position that word 
was within the sentence.

E.g. Please help with this code
Then they enter help it would return that it appears in the 2nd position in the 
sentence.


From what I gather it appears to be a list function but I am struggling to come 
up with a solution.


Thanks.

Something along lines of loading the sentence into a string, using the 
str.split() function to split it into a list object, then cycling 
through to strip all the spaces and/or punctuation out of the 
elements/items, and then the list.index() function can return the index 
of a word in the list, which is the zero-based position of the item in 
that list.


#something along lines of
s = input("enter sentence")
s.replace(",", "") #do this for all common punctuation characters
l = s.split(" ") #space is actually default
s2 = input("enter word")
i = l.index(s2)
print("Your word is at position " + str(i+1) + " in the sentence")
#end code

That's just typed here in message - HTH

HTH

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."
--
https://mail.python.org/mailman/listinfo/python-list


New member - 'odd' question

2014-12-11 Thread Jacob Kruger
Firstly, python is one of my two current focus areas, and while I still work 
with python 2.7, sort of for backward compatibility, my other focus area is web 
development, making use of PHP, javascript, jQuery, MySQL, etc.

And, I develop on windows7 64 bit machines, in conjunction with screen reader 
software - either jaws, or NVDA, if that means much...

Now, one of the current pieces of work am busy with involves sort of automating 
the process of converting some MS access databases to MySQL, and 
manipulating/rearranging the data during the conversion process.

I am implementing this using a python app, making use of wxPython to implement 
the GUI, and am using pyodbc to pull in the data structures, and read the data 
from .mdb files, and then am trying to use either pyodbc, or MySQLdb modules to 
then handle interaction with the MySQL side of things, and the MySQL database 
engine is part of the WAMP installation on my dev machine, FWIW.

Now, on my primary, desktop machine, it seems like if I implement pyodbc 
connections and cursors to handle the input data/structures from an .mdb file, 
and then write out the relevant SQL queries to text files, and then try to read 
them in, split them into separate statements, and execute them against the 
MySQL database, that part of it runs fine, but, the odd issue seems to be that 
if I did in fact first create/open a pyodbc connection object, along with it's 
relevant cursor object, and even if make sure close both of them, then on my 
one machine, after then initiating the direct MySQLdb connection object, I am 
still unable to actually close the whole app down - the main class is a sort of 
inheritor of wx.Frame, and before closing it down, I destroy both the Frame and 
all it's children, but, the main oddity is that while this works fine on my 
other laptop, on my desktop machine it always just ends up telling me 
python.exe is not responding, and would I like to force it to close?

And, it's definitely got something to do with the combination of having created 
and/or destroyed the pyodbc objects first, and then creating MySQLdb objects, 
since either half works fine by itself, but not together - on one machine 
anyway.

Just wondering what can be causing this to occur on one machine, but not the 
other, relatively similar, but maybe cleaner machine, and how to try track down 
something like this?

That's also why am posting this here - trying to figure out how to track down 
what's causing this odd behaviour.

TIA

Jacob Kruger
Blind Biker
Skype: BlindZA
...Roger Wilco wants to welcome you, to the space janitor's closet...
-- 
https://mail.python.org/mailman/listinfo/python-list


Simple background sound effect playback

2014-12-16 Thread Jacob Kruger
Would prefer to use something free, that could work somewhat cross-platform, 
but, my primary target is for windows OS, and would primarily just want to be 
able to easily trigger playback of either .wav or .mp3 background sound 
effects, but, yes, would also be nice to be able to control them a little bit 
in terms of volume, possibly stereo panning as well as playback 
rate/frequency/pitch?

I have used something called sound_lib, as well as another one relating to a 
sort of windows directSound effect, but, both of them had issues when working 
with either py2exe or cx_freeze when it came to compiling into executable, and 
main thing is would like to keep it simple...

Suggestions?

TIA

Jacob Kruger
Blind Biker
Skype: BlindZA
...Roger Wilco wants to welcome you, to the space janitor's closet...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple background sound effect playback

2014-12-17 Thread Jacob Kruger
Ok, trying simple code from a pygame tutorial snippet - nothing happens - just 
silent, but with no errors being returned:

# play a sound to the left, to the right and to the center

# import the time standard module
import time

# import the pygame module
import pygame


# start pygame
pygame.init()

# load a sound file into memory
sound = pygame.mixer.Sound("bird.ogg")

# start playing the sound
# and remember on which channel it is being played
channel = sound.play()
# set the volume of the channel
# so the sound is only heard to the left
channel.set_volume(1, 0)
# wait for 1 second
time.sleep(1)

# do the same to the right
channel = sound.play()
channel.set_volume(0, 1)
time.sleep(1)

# do the same to the center
channel = sound.play()
channel.set_volume(1, 1)
time.sleep(1)
#end code

Think this is why ignored pygame in past... - think it actually needs 
more than itself to be installed, or something.

Jacob Kruger
Blind Biker
Skype: BlindZA
...Roger Wilco wants to welcome you, to the space janitor's closet...

  - Original Message - 
  From: Ian Kelly 
  To: Python 
  Sent: Wednesday, December 17, 2014 3:49 AM
  Subject: Re: Simple background sound effect playback


  On Tue, Dec 16, 2014 at 9:57 AM, Jacob Kruger  wrote:
  >
  > Would prefer to use something free, that could work somewhat 
cross-platform, but, my primary target is for windows OS, and would primarily 
just want to be able to easily trigger playback of either .wav or .mp3 
background sound effects, but, yes, would also be nice to be able to control 
them a little bit in terms of volume, possibly stereo panning as well as 
playback rate/frequency/pitch?
  >  
  > I have used something called sound_lib, as well as another one relating to 
a sort of windows directSound effect, but, both of them had issues when working 
with either py2exe or cx_freeze when it came to compiling into executable, and 
main thing is would like to keep it simple...
  >  
  > Suggestions?


  https://wiki.python.org/moin/Audio/


--


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


RE: Simple background sound effect playback

2014-12-20 Thread Jacob Kruger
Ok, thanks - the following seemed to work perfectly:

#start code
import pygame, time
pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096)
song = pygame.mixer.Sound("bird.ogg")
channel = pygame.mixer.Sound.play(song)
channel.set_volume(0, 1)
time.sleep(1)
channel.set_volume(1, 0)
channel = pygame.mixer.Sound.play(song)
time.sleep(1)
#end code

Will now just have to double-check/test compilation of something including 
something like this, using something like cx_freeze, etc., but, thanks again.

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
...Roger Wilco wants to welcome you, to the space janitor's closet...
---original message---
 wrote in message 
news:[email protected]...
> See this :
> 
>>>> pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096)
>>>> song = pygame.mixer.Sound("bird.ogg")
>>>> pygame.mixer.Sound.play(song)
> and then use the 
>>>> channel.set_volume(0, 1)
>>>> time.sleep(1)
> 
> 
> On Wednesday, December 17, 2014 10:02:30 PM UTC+2, Jacob Kruger wrote:
>> 
>> 
>> Ok, trying simple code from a pygame tutorial 
>> snippet - nothing happens - just silent, but with no errors being 
>> returned:
>> # import the pygame module
>> import  pygame
>> # start pygame
>> pygame.init()
>> # load a sound file into memory
>> sound = pygame.mixer.Sound("bird.ogg")
>> channel = sound.play()
> -- 
> https://mail.python.org/mailman/listinfo/python-list
>-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple background sound effect playback

2014-12-21 Thread Jacob Kruger
Will have a look at it as well, but, also already tested generating a 
console/command line app using the pygame code to play an .ogg file, panning 
it left and right, and the compilation worked alright, and am now still busy 
reloading primary machine, so haven't taken it too much further, but let's 
see...


Am not sure of redistribution licence either, and will need/want to test it 
on a couple of other types of machines.


Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "Akira Li" <[email protected]>

To: 
Sent: Monday, December 22, 2014 12:11 AM
Subject: Re: Simple background sound effect playback



"Jacob Kruger"  writes:


Would prefer to use something free, that could work somewhat
cross-platform, but, my primary target is for windows OS, and would
primarily just want to be able to easily trigger playback of either
.wav or .mp3 background sound effects, but, yes, would also be nice to
be able to control them a little bit in terms of volume, possibly
stereo panning as well as playback rate/frequency/pitch?

I have used something called sound_lib, as well as another one
relating to a sort of windows directSound effect, but, both of them
had issues when working with either py2exe or cx_freeze when it came
to compiling into executable, and main thing is would like to keep it
simple...

Suggestions?



You could try GStreamer: it is free, cross-platform, it allows you to
play media files in the background, to control volume, stereo panning
(e.g., GstAudioPanorama), to change the playback rate while preserving
pitch, it can use DirectShow on Windows, etc -- see
http://gstreamer.freedesktop.org/features/

The downside is that it may be complex to install and use e.g., it
probably works with py2exe but it won't be simple to configure.

If you know other library that provides similar feature list while being
less complex; do tell.


--
Akira.

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



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


Re: If One Line

2014-12-25 Thread Jacob Kruger

One line assignment is ok, but, seems like you can't perform actions.

#the following will work:
I = 1 if True else 2

#but the following will generate an error:
if I == 1: print("one")

And, not sure if/how to work around that second one myself.

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "JC" 

Newsgroups: comp.lang.python
To: 
Sent: Thursday, December 25, 2014 5:18 PM
Subject: If One Line



Hello,

Is it possible in python:

if ((x = a(b,c)) == 'TRUE'):
print x

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


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


Re: If One Line

2014-12-25 Thread Jacob Kruger

One line assignment is ok, but, seems like you can't perform actions.

#the following will work:
I = 1 if True else 2

#but the following will generate an error:
if I == 1: print("one")

And, not sure if/how to work around that second one myself.

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "JC" 

Newsgroups: comp.lang.python
To: 
Sent: Thursday, December 25, 2014 5:18 PM
Subject: If One Line



Hello,

Is it possible in python:

if ((x = a(b,c)) == 'TRUE'):
print x

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


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


Re: If One Line

2014-12-25 Thread Jacob Kruger
Actually more that in the interpreter, it's prompting me with ... as if I had 
left out a closing ) or something, but, suppose it could work fine in an actual 
imported bit of code?

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

  - Original Message - 
  From: Skip Montanaro 
  To: Jacob Kruger 
  Cc: Python 
  Sent: Thursday, December 25, 2014 6:26 PM
  Subject: Re: If One Line


  I don't get an error.


  >>> I = 1 if True else 2
  >>> if I == 1: print("one")
  ... 
  one
  >>> 


  What error did you get?


  Skip



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


Re: If One Line

2014-12-25 Thread Jacob Kruger
Ok, makes sense - just slipped same one line if: action bit of code inside a 
function, and worked fine.

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

  - Original Message - 
  From: Skip Montanaro 
  To: Jacob Kruger 
  Cc: Python 
  Sent: Thursday, December 25, 2014 7:45 PM
  Subject: Re: If One Line



  > Actually more that in the interpreter, it's prompting me with ... as if I 
had left out a closing ) or something, but, suppose it could work fine in an 
actual imported bit of code?

  That's how it's supposed to work. Given that Python block structure is 
determined by indentation, you need some way to tell the interactive 
interpreter that the block is ended.

  Skip

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


Re: If One Line

2014-12-25 Thread Jacob Kruger
Ok, makes sense - just slipped same one line if: action bit of code inside a 
function, and worked fine.

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

  - Original Message - 
  From: Skip Montanaro 
  To: Jacob Kruger 
  Cc: Python 
  Sent: Thursday, December 25, 2014 7:45 PM
  Subject: Re: If One Line



  > Actually more that in the interpreter, it's prompting me with ... as if I 
had left out a closing ) or something, but, suppose it could work fine in an 
actual imported bit of code?

  That's how it's supposed to work. Given that Python block structure is 
determined by indentation, you need some way to tell the interactive 
interpreter that the block is ended.

  Skip

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


Re: Why For Loop Skips the Last element?

2015-01-01 Thread Jacob Kruger
Not sure after quick skim/scan, but, I would generally use either for I in 
range(len(inlist)): or just for it in inlist, instead of using while, etc.

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

  - Original Message - 
  From: Thuruv V 
  To: [email protected] 
  Sent: Wednesday, December 31, 2014 11:25 PM
  Subject: Why For Loop Skips the Last element?


  Hi all,


  Here's the list. .


  inlist = ["Fossil Women's Natalie Stainless Steel Watch Brown (JR1385)",
  'Balmer Swiss Made Veyron Mens Watch: Black Band/ Black Dial (62625241)',
  'Fortune NYC Ladies Quilted Dial Watch: Brown',
  'Jeanne Collection w/ Swarovski Elements Watch: Dark Purple Band (62623659)',
  'Swiss Legend Commander Chronograph: Watch Orange/Black (SL-10067-01-ORS)',
  'Debussy Ladies Watch: Brown/Gray/Silver 14070 - 62625292',
  '#2 Swiss Legend Commander Chronograph: Green (SL-10067-BB-017)',
  'Auguste Jaccard 3 Timezone Watch: Black Band/ Gray & Black Dial (62625184)'
  ]


  My code :
  i = 0
  while i <= len(inlist):
  if 'watch' in str(inlist[i]).lower() or 'watches' in 
str(inlist[i]).lower():
  if 'women' in str(inlist[i]).lower() or 'female' in 
str(inlist[i]).lower() or 'ladies' in str(inlist[i]).lower():
  print 'FEMale Watch', inlist.index(i),str(i)
  elif 'men' in str(inlist[i]).lower() or 'male' in 
str(inlist[i]).lower() or 'chronograph' in str(inlist[i]).lower():
  print 'Male Watch',inlist.index(i),str(i)
  i = next(inlist)


  When on executing python skips the last element('Auguste Jaccard 3 Timezone 
Watch: Black Band/ Gray & Black Dial (62625184)') in the list.


  But when accessing through 'print inlist[0]' is possible,i.e it shows the 
e;lement. but the list skips it. .
  Please enlighten me. .
  Thanks.


--


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


Re: need some guidance on Python syntax smart editor for use with speech recognition

2015-01-05 Thread Jacob Kruger
Eric, not really related, but, from the blind perspective, some of the 
end-users would also love to be able to define their own sets of voice 
commands, and have something like a personal assistant app handle that for 
them, instead of having to necessarily work with PC in normal ways all the 
time, and I played around with something relating to implementing the bare 
basics in a python command line app a little while ago, but, it only really 
used the windows voice recognition system/service, which meant it wasn't 
really useful from my side since the training interface for that is also 
pretty much useless to me, but anyway.


Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "Eric S. Johansson" 

To: 
Sent: Monday, January 05, 2015 8:18 PM
Subject: Re: need some guidance on Python syntax smart editor for use with 
speech recognition





On 1/5/2015 7:24 AM, Chris Angelico wrote:
On Mon, Jan 5, 2015 at 8:34 PM, Jonas Wielicki  
wrote:

As a first iteration, I would try with any editor written in Python.
Are you familiar with the ast[1] module? It could be worth trying to
use this module and perform some kind of pattern matching on the
results to recover the information.

An AST parse throws away a lot of information. You can't easily
reconstruct the original code from that; at best, you can decompile
the AST back into functionally-equivalent source code, but it's not
something you want to do as part of editing code.


Chris is right. I looked at this and came up with the same conclusion. 
Here's a use case that I haven't talked about yet but is part of the 
problem of speech driven programming. I have a chunk of code that I 
created that is exactly right but it's in the wrong place or wrong method 
or even just the wrong environment. I need to capture it and then move it 
to the right place.


At first glance, this would look like a simple cut-and-paste and, 
sometimes it is but more often it's not. Let's take the example of a 
simple file generator. Opening the file, iterating over the input until 
the input data transformation process runs out of data.


This is a real common pattern and what changes are certain elements of the 
code, variables, strings whatever but also the indentation. So putting the 
old chunk of code into the new place requires transformation that most of 
you guys do by hand without thinking twice. Me it's, #()@!&#$, and I use a 
whole bunch of kill words to strip out the old data and put in the new.


Imagine being able to rip out a piece of code, identify the substitution 
points and the indentation adjustment levels and then being able to put in 
that piece of code in other places and just fill in the blanks as a part 
of the insertion dialogue.  Now this gets us to the same point I was first 
talking about which is the ability to identify the idiom and code to 
operate on it as an idiom. some of the stuff I've seen with snippets is 
partly there, again it is a one-way transform.


It seems to me that those of us with hands and those of us with broken 
hands could use this same functionality given the right supportive user 
interface.


Now I've been living with this kind of idea for a while and I realize that 
may not make sense in this abstract written description. What do I need to 
fill in?



However, back when I was doing my PEP 463 research, someone suggested
looking into the 2to3 parser. I regretfully admit that I have yet to
actually do so, but it ought in theory allow source-level
transformations with a measure of intelligence. It's not a ready-made
solution by any means, but it could be a useful tool. [2]


Good idea.

Hope this helps. I find that topic pretty interesting. Is there
anything I can follow to see progress on this?

Likewise!

ChrisA


Is there any problem with keeping the conversation going here or would you 
prefer some other way of talking about it? I've been hesitant to put my 
work up on github because it's flailing about with also the bloody loose 
ends because I'm trying to solve up number of problems all at the same 
time.   The problem first being a framework where I can add speech driven 
UI elements to an editor so I can start experimenting with a bunch of 
these pieces.


Another way you can help is be my hands. sometimes I just run out of hand 
time and it takes a while for me build up enough energy so I can spend the 
day working for money and a day working on this.


--- eric

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



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


String character encoding when converting data from one type/format to another

2015-01-07 Thread Jacob Kruger
I'm busy using something like pyodbc to pull data out of MS access .mdb files, 
and then generate .sql script files to execute against MySQL databases using 
MySQLdb module, but, issue is forms of characters in string values that don't 
fit inside the 0-127 range - current one seems to be something like \xa3, and 
if I pass it through ord() function, it comes out as character number 163.

Now issue is, yes, could just run through the hundreds of thousands of 
characters in these resulting strings, and strip out any that are not within 
the basic 0-127 range, but, that could result in corrupting data - think so 
anyway.

Anyway, issue is, for example, if I try something like 
str('\xa3').encode('utf-8') or str('\xa3').encode('ascii'), or 
str('\xa3').encode('latin7') - that last one is actually our preferred encoding 
for the MySQL database - they all just tell me they can't work with a character 
out of range.

Any thoughts on a sort of generic method/means to handle any/all characters 
that might be out of range when having pulled them out of something like these 
MS access databases?

Another side note is for binary values that might store binary values, I use 
something like the following to generate hex-based strings that work alright 
when then inserting said same binary values into longblob fields, but, don't 
think this would really help for what are really just most likely badly chosen 
copy/pasted strings from documents, with strange encoding, or something:
#sample code line for binary encoding into string output
s_values += "0x" + str(l_data[J][I]).encode("hex").replace("\\", "") + ", "

TIA

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: String character encoding when converting data from one type/format to another

2015-01-07 Thread Jacob Kruger

Thanks.

Yes, using python 2.7, and all you said makes sense, so will check out the 
talk, and the byte'ing, etc. (yes, bad joke, I know)


Issue with knowing encoding could just be that am pretty sure at least some 
of the data capture is done via copy/paste from one MS app to another, which 
could possibly result in a whole bunch of different character sets, etc. 
being copied across, so it comes down to that while can't control sources of 
data, need to manipulate/work with it to make it useful on our side now.


Thanks again

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "Ned Batchelder" 

To: 
Sent: Wednesday, January 07, 2015 2:02 PM
Subject: Re: String character encoding when converting data from one 
type/format to another




On 1/7/15 6:04 AM, Jacob Kruger wrote:

I'm busy using something like pyodbc to pull data out of MS access .mdb
files, and then generate .sql script files to execute against MySQL
databases using MySQLdb module, but, issue is forms of characters in
string values that don't fit inside the 0-127 range - current one seems
to be something like \xa3, and if I pass it through ord() function, it
comes out as character number 163.
Now issue is, yes, could just run through the hundreds of thousands of
characters in these resulting strings, and strip out any that are not
within the basic 0-127 range, but, that could result in corrupting data
- think so anyway.


That will definitely corrupt your data, since you will be discarding data.


Anyway, issue is, for example, if I try something like
str('\xa3').encode('utf-8') or str('\xa3').encode('ascii'), or
str('\xa3').encode('latin7') - that last one is actually our preferred
encoding for the MySQL database - they all just tell me they can't work
with a character out of range.


Are you using Python 2 or Python 3? This is one area where the two are 
very different.  I suspect you are on Python 2, in which case these all 
fail the same way because you are calling encode on a bytestring.  You 
can't encode a bytestring, you can only encode a Unicode string, so encode 
is helpfully trying to decode your bytestring first, using the default 
encoding (ascii), and '\xa3' is not an ascii character.


If that was confusing, this talk covers these fundamentals: 
http://bit.ly/unipain .



Any thoughts on a sort of generic method/means to handle any/all
characters that might be out of range when having pulled them out of
something like these MS access databases?


The best thing is to know what encoding was used to produce these byte 
values.  Then you can manipulate them as Unicode if you need to.  The 
second best thing is to simply pass them through as bytes.



Another side note is for binary values that might store binary values, I
use something like the following to generate hex-based strings that work
alright when then inserting said same binary values into longblob
fields, but, don't think this would really help for what are really just
most likely badly chosen copy/pasted strings from documents, with
strange encoding, or something:
#sample code line for binary encoding into string output
s_values += "0x" + str(l_data[J][I]).encode("hex").replace("\\", "")
+ ", "
TIA

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."





--
Ned Batchelder, http://nedbatchelder.com

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



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


Re: String character encoding when converting data from one type/format to another

2015-01-07 Thread Jacob Kruger

Thanks.

Makes more sense now, and yes, using 2.7 here.

Unfortunately, while could pass the binary values into blob fields well 
enough, using forms of parameterised statements, the actual generation of 
sql script text files is a step they want to work with at times, if someone 
is handling this on site, so had to work first with generating string 
values, and then handle executing those statements against a MySQL server 
later on using MySQLdb.


Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "Peter Otten" <[email protected]>

To: 
Sent: Wednesday, January 07, 2015 2:11 PM
Subject: Re: String character encoding when converting data from one 
type/format to another




Jacob Kruger wrote:


I'm busy using something like pyodbc to pull data out of MS access .mdb
files, and then generate .sql script files to execute against MySQL
databases using MySQLdb module, but, issue is forms of characters in
string values that don't fit inside the 0-127 range - current one seems 
to

be something like \xa3, and if I pass it through ord() function, it comes
out as character number 163.

Now issue is, yes, could just run through the hundreds of thousands of
characters in these resulting strings, and strip out any that are not
within the basic 0-127 range, but, that could result in corrupting data -
think so anyway.

Anyway, issue is, for example, if I try something like
str('\xa3').encode('utf-8') or str('\xa3').encode('ascii'), or


"\xa3" already is a str; str("\xa3") is as redundant as
str(str(str("\xa3"))) ;)


str('\xa3').encode('latin7') - that last one is actually our preferred
encoding for the MySQL database - they all just tell me they can't work
with a character out of range.


encode() goes from unicode to byte; you want to convert bytes to unicode 
and

thus need decode().

In this context it is important that you tell us the Python version. In
Python 2 str.encode(encoding) is basically

str.decode("ascii").encode(encoding)

which is why you probably got a UnicodeDecodeError in the traceback:


"\xa3".encode("latin7")

Traceback (most recent call last):
 File "", line 1, in 
 File "/usr/lib/python2.7/encodings/iso8859_13.py", line 12, in encode
   return codecs.charmap_encode(input,errors,encoding_table)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xa3 in position 0:
ordinal not in range(128)


"\xa3".decode("latin7")

u'\xa3'

print "\xa3".decode("latin7")

£

Aside: always include the traceback in your posts -- and always read it
carefully. The fact that "latin7" is not mentioned might have given you a
hint that the problem was not what you thought it was.


Any thoughts on a sort of generic method/means to handle any/all
characters that might be out of range when having pulled them out of
something like these MS access databases?


Assuming the data in Access is not broken and that you know the encoding
decode() will work.


Another side note is for binary values that might store binary values, I
use something like the following to generate hex-based strings that work
alright when then inserting said same binary values into longblob fields,
but, don't think this would really help for what are really just most
likely badly chosen copy/pasted strings from documents, with strange
encoding, or something:
#sample code line for binary encoding into string output
s_values += "0x" + str(l_data[J][I]).encode("hex").replace("\\", "") 
+

", "


I would expect that you can feed bytestrings directly into blobs, without
any preparatory step. Try it, and if you get failures show us the failing
code and the corresponding traceback.

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



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


Re: String character encoding when converting data from one type/format to another

2015-01-07 Thread Jacob Kruger

Thanks.

Yes, sorry didn't mention 2.7, and, unfortunately in this sense, all of this 
will be running on windows machines.


Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "Dave Angel" 

To: 
Sent: Wednesday, January 07, 2015 2:22 PM
Subject: Re: String character encoding when converting data from one 
type/format to another




On 01/07/2015 06:04 AM, Jacob Kruger wrote:
I'm busy using something like pyodbc to pull data out of MS access .mdb 
files, and then generate .sql script files to execute


 against MySQL databases using MySQLdb module, but, issue is forms of 
characters in string values that don't fit inside


 the 0-127 range - current one seems to be something like \xa3, and if I 
pass it through ord() function,


 it comes out as character number 163.

First question, of course is what version of Python.  Clearly, you're not 
using Python 3.x, so I'll assume 2.7.  But you really should specify it in 
your query.


Next question is what OS you're using.  You're reading .mdb files, which 
are most likely created in Windows, but that doesn't guarantee you're 
actually using Windows to do this conversion.





Now issue is, yes, could just run through the hundreds of thousands of 
characters in these resulting strings, and strip out any that are not 
within the basic 0-127 range, but, that could result in corrupting data - 
think so anyway.


Anyway, issue is, for example, if I try something like 
str('\xa3').encode('utf-8') or str('\xa3').encode('ascii'), or 
str('\xa3').encode('latin7') - that last one is actually our preferred 
encoding for the MySQL database - they all just tell me they can't work 
with a character out of range.




That's because your input data isn't ASCII.  So before you encode it, you 
have to decode it.  Any idea what encoding it's already in?  Maybe it's in 
latin1, which permits all 256 values.  Or utf-8, which permits a few 
hundred thousand values, but uses multiple bytes for any of those over 
127.  Or any of hundreds of other encodings.


Does an .mdb file have a field specifying what encoding was used?  Or do 
you have some other external knowledge?


If you don't know what encoding it's currently in, you'll have to guess, 
and the guess you're using so far is ASCII, which you know is false.


As for the encoding you should actually use in the database, that almost 
certainly ought to be utf-8, which supports far more international 
characters than latin1.  And make sure the database has a way to tell the 
future user what encoding you picked.


Any thoughts on a sort of generic method/means to handle any/all 
characters that might be out of range when having pulled them out of 
something like these MS access databases?


The only invalid characters are those which aren't valid in the encoding 
used.  Those can probably be safely converted to "?" or something similar.




Another side note is for binary values that might store binary values, I 
use something like the following to generate hex-based strings that work 
alright when then inserting said same binary values into longblob fields, 
but, don't think this would really help for what are really just most 
likely badly chosen copy/pasted strings from documents, with strange 
encoding, or something:

#sample code line for binary encoding into string output
s_values += "0x" + str(l_data[J][I]).encode("hex").replace("\\", "") 
+ ", "




Best to not pretend they're text at all.  But if your db doesn't support 
binary blobs, then use an encoding which supports all 256 values 
unambiguously, while producing printable characters.  Like uuencod, using 
module uu


You might also look into mime, where you store the encoding of the data 
with the data.  See for example mimetypes.




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



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


unidecode

2015-01-12 Thread Jacob Kruger
Along lines of recent queries/questions, which had mostly sorted out, but, 
which was still trying to fine tune with regards to text file formats, in terms 
of writing as strings, or as binary files, and where was still trying to decide 
if wanted to worry about maybe specifically just handling forms of 
manual/hard-coded translations of certain accented characters which might 
relate to some of them that might get used quite often in names, etc., I just 
came across the following unidecode module:
https://pypi.python.org/pypi/Unidecode/

Seems to just take any unicode value, and 'translate' it into a string value, 
and will apparently try handle some forms of character substitution - but will 
play around with it a bit more, and let's see...

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: Jacob Kruger 
To: Jacob Kruger 
Sent: Monday, January 12, 2015 2:15 PM
Subject: unidecode


https://pypi.python.org/pypi/Unidecode/

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."
-- 
https://mail.python.org/mailman/listinfo/python-list


Python 2.7, on windows7 64 bit development machine, inconsistent issue on similar machines

2015-01-13 Thread Jacob Kruger
issue - There was a problem connecting to MySQL 
server")
sys.exit()
except Exception as exc:
  s_exc = str(exc.args)
  #lbc.DialogShow(title="errorMessage", message=s_exc)
  print(s_exc)
  exc_type, exc_obj, tb = sys.exc_info()
  print(str(exc_obj))
  print("line number: " + str(tb.tb_lineno))
  #end of convertExport function

#---end code---



If this is operating system specific, sorry, and will maybe also try debugging 
code via VS.Net 2013 shortly, but, thought someone might have an off-hand 
thought regarding something could try use to figure out this issue in 
meantime...?



TIA


Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

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


Re: Python 2.7, on windows7 64 bit development machine, inconsistent issue on similar machines

2015-01-13 Thread Jacob Kruger

See answers below.

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "Dennis Lee Bieber" 




The very first hit /I/ get is:
https://social.technet.microsoft.com/Forums/windows/en-US/3932e3eb-c034-4eb7-aa06-4a0a8e6ea493/fault-module-namestackhash0a9e



Played around with data expraction policy changes/settings now, and didn't 
make it change behaviour.







 s_host = str(d_mysql["host"])
 s_user = str(d_mysql["user"])
 s_pass = str(d_mysql["password"])
 s_db = self.s_target_value


ONE: Have you confirmed all of these are coming in correctly

Yes - that mysql.set pickle dump is just a way of storing some string values 
relating to mysql server connection to sort of hide it from an end-user, 
but, yes, the values work fine in that sense.



 cn = MySQLdb.connect(s_host, s_user, s_pass, s_db)
 if cn:
   cn.autocommit = True


TWO-A: you've turned on autocommit here, yet...


Sorry - that was sort of left-over from when was trying to make sure that 
other parts were happening/working - along with trying out specific commit 
call lower down - have tried taking eitehr of them out one by one, to see if 
made a difference, but, no-go.





   cur = cn.cursor()
   i_struct = 0
   i_data = 0
   f = open(self.s_sql_struct_file, "rb")
   s = f.read()
   f.close()
   l_struct = s.split(";")


THREE-A: here you split some string on semicolons, just to...


   f = open(self.s_sql_data_file, "rb")
   s = f.read()
   f.close()
   l_data = unidecode(s).split(";")
   l_struct_errors = []
   l_data_errors = []
   i_start_time = int(time.time())
   s_status = "/{0} structs".format(str(len(l_struct)))
   for I in range(len(l_struct)):


Very UN-Pythonic...


I know - that was also since originally used this code in a sort of GUI 
version, and meant to use one by one counter to update status bar text at 
sort of intervals of 10 records, to let guys track progress - but, FWIW, it 
seemed to overload my screen reader with too many changes, partly since some 
of these collections of insert statements are processing over 4 record 
insertions - not currently with test data, but, some of the other test 
database files I used were operating in that region of the number of data 
record numbers. Have taken that part out again now.




for a_struct in l_struct:
# do stuff with a_struct directly, no indexing into l_struct


 try:
   i_struct = I
   if str(l_struct[I]).strip() != "": res = 
cur.execute(l_struct[I] + ";")


THREE-B: ... reappend the semicolon here... which probably isn't needed
-- cur.execute() assumes, as I recall, that the provided argument is a
complete statement; unlike a command line interface where the semicolon is
needed to tell the CLI that the statement is complete and can be sent to
the DBMS for processing.

And very confusing names... l_struct and i_struct, where the latter is
an index into the former (and I don't see it used anywhere).


Have taken out counter now, and, yes, cursor seems happy to execute 
statements without ; character at end.





   print(l_struct[I])
 #except Warning as wrn:
 #  print("warning: " + str(wrn.args))
 except Exception as exc:
   l_struct_errors.append([l_struct[I], copy.copy(exc)])
 finally:
   pass
   cn.commit()


TWO-B: ... here you attempt to force a commit.


That was also during test phase when was just trying to make sure parts of 
this were being executed/committed - taken out additional commits now.





   time.sleep(2.0)
   sNada = raw_input("hit enter to continue with data")
   s_status = "/{0} data".format(str(len(l_data)))
   for I in range(len(l_data)):
 try:
   #self.SetStatusText(str(I) + s_status)
   i_data = I
   if str(l_data[I]).strip() != "": res = 
cur.execute(l_data[I][l_data[I].index("INSERT"):] + ";")

   print(l_data[I][l_data[I].index("INSERT"):] + ";")
 except Exception as exc:
   l_data_errors.append([l_data[I], copy.copy(exc)])
 finally:
   pass
   i_end_time = int(time.time())
   s_time_taken = sTimeDiffFormat(i_start_time, i_end_time)
   cn.commit()


TWO-C: ... and here too.


   cur.close()
   cn.close()
   print("cn and cur closed")
   fPickle = open("testDataErrors.pickle", "wb")
   pickle.dump(l_struct_errors, fPickle, 2)
   pickle.dump(l_data_errors, fPickle, 2)
   fPickle.close()
   print("pickled")
   print("MySQL Results - {0} structure queries, and {1} data

Re: Python 2.7, on windows7 64 bit development machine, inconsistent issue on similar machines

2015-01-13 Thread Jacob Kruger
Ok, and just tested MySQLdb connection to both XAMPP server instance on same 
machine, as well as slightly remote connection to other machine over wifi, 
and same error - so, seems issue is invoked/caused by MySQLdb connection 
closing - if just put process to sleep for 30 seconds, nothing happens, but, 
the moment I in fact try to then just close the connection, that's when 
error dialogue immediately pops up.


Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "Jacob Kruger" 

To: "Dennis Lee Bieber" 
Cc: 
Sent: Tuesday, January 13, 2015 8:37 PM
Subject: Re: Python 2.7, on windows7 64 bit development machine, 
inconsistent issue on similar machines




See answers below.

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "Dennis Lee Bieber" 




The very first hit /I/ get is:
https://social.technet.microsoft.com/Forums/windows/en-US/3932e3eb-c034-4eb7-aa06-4a0a8e6ea493/fault-module-namestackhash0a9e



Played around with data expraction policy changes/settings now, and didn't 
make it change behaviour.







 s_host = str(d_mysql["host"])
 s_user = str(d_mysql["user"])
 s_pass = str(d_mysql["password"])
 s_db = self.s_target_value


ONE: Have you confirmed all of these are coming in correctly

Yes - that mysql.set pickle dump is just a way of storing some string 
values relating to mysql server connection to sort of hide it from an 
end-user, but, yes, the values work fine in that sense.



 cn = MySQLdb.connect(s_host, s_user, s_pass, s_db)
 if cn:
   cn.autocommit = True


TWO-A: you've turned on autocommit here, yet...


Sorry - that was sort of left-over from when was trying to make sure that 
other parts were happening/working - along with trying out specific commit 
call lower down - have tried taking eitehr of them out one by one, to see 
if made a difference, but, no-go.





   cur = cn.cursor()
   i_struct = 0
   i_data = 0
   f = open(self.s_sql_struct_file, "rb")
   s = f.read()
   f.close()
   l_struct = s.split(";")


THREE-A: here you split some string on semicolons, just to...


   f = open(self.s_sql_data_file, "rb")
   s = f.read()
   f.close()
   l_data = unidecode(s).split(";")
   l_struct_errors = []
   l_data_errors = []
   i_start_time = int(time.time())
   s_status = "/{0} structs".format(str(len(l_struct)))
   for I in range(len(l_struct)):


Very UN-Pythonic...


I know - that was also since originally used this code in a sort of GUI 
version, and meant to use one by one counter to update status bar text at 
sort of intervals of 10 records, to let guys track progress - but, FWIW, 
it seemed to overload my screen reader with too many changes, partly since 
some of these collections of insert statements are processing over 4 
record insertions - not currently with test data, but, some of the other 
test database files I used were operating in that region of the number of 
data record numbers. Have taken that part out again now.




for a_struct in l_struct:
# do stuff with a_struct directly, no indexing into l_struct


 try:
   i_struct = I
   if str(l_struct[I]).strip() != "": res = 
cur.execute(l_struct[I] + ";")


THREE-B: ... reappend the semicolon here... which probably isn't needed
-- cur.execute() assumes, as I recall, that the provided argument is a
complete statement; unlike a command line interface where the semicolon 
is

needed to tell the CLI that the statement is complete and can be sent to
the DBMS for processing.

And very confusing names... l_struct and i_struct, where the latter is
an index into the former (and I don't see it used anywhere).


Have taken out counter now, and, yes, cursor seems happy to execute 
statements without ; character at end.





   print(l_struct[I])
 #except Warning as wrn:
 #  print("warning: " + str(wrn.args))
 except Exception as exc:
   l_struct_errors.append([l_struct[I], copy.copy(exc)])
 finally:
   pass
   cn.commit()


TWO-B: ... here you attempt to force a commit.


That was also during test phase when was just trying to make sure parts of 
this were being executed/committed - taken out additional commits now.





   time.sleep(2.0)
   sNada = raw_input("hit enter to continue with data")
   s_status = "/{0} data".format(str(len(l_data)))
   for I in range(len(l_data)):
 try:
   #self.SetStatusText(str(I) + s_status)
   i_data = I
   if str(l_data[I]).strip() != "": res = 
cur.ex

Re: Python 2.7, on windows7 64 bit development machine, inconsistent issue on similar machines

2015-01-13 Thread Jacob Kruger
Ok, and just tested MySQLdb connection to both XAMPP server instance on 
same machine, as well as slightly remote connection to other machine over 
wifi, and same error - so, seems issue is invoked/caused by MySQLdb 
connection closing - if just put process to sleep for 30 seconds, nothing 
happens, but, the moment I in fact try to then just close the connection, 
that's when error dialogue immediately pops up.


Sorry - should also have mentioned the connection, cursor, etc. ec. all work 
fine under normal python interpreter, but anyway.


Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."


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


MySQL connections

2015-01-15 Thread Jacob Kruger
Development machine is windows7 64 bit machine, now working with either/both 
python 2.7 or 3.4 - test purposes, trying to figure out if this was something 
like a version incompatibility issue, and tried using both XAMPP and WAMP MySQL 
server version 5.0.11 instances thus far.

Now, aside from all other issues relating to character encoding, etc., now down 
to, hopefully, final issue.

Side note is under python 2.7, I use pyodbc to gather data from .mdb file am 
using to test, but under python 3.4, I use pypyodbc for same functionality.

Now, current/actual issue is something can sort of duplicate using both MySQLdb 
version of mysqlclient, as well as pymysql using both python 2.7 and python 
3.4, but, strange thing am trying to figure out is that even if just implement 
a connection object in interpreter of either version, retrieve an instance of a 
cursor object, and do various types of statement executions, no issues, and can 
then close connection, or cursor, or both, and all good/fine/well.

However, if implement similar code - down to just trying to open a connection, 
wait a few seconds, and then close it again, inside a function called from a 
prior function, in the class am implementing in a file called/executed from 
command line, then, the moment I try to close the connection, whether or not 
have done anything with it, that's when I get that python.exe has stopped 
working/responding error message popping up, and python bombs out.

Have no idea how to try track down actual source/cause of issue, since haven't 
found anything obvious in system event logs, nothing appearing in MySQL server 
logs that makes sense/appears relevant, and no matter if I try enclosing the 
connection open/close code inside try except code blocks, nothing happens there 
except that python just stops cooperating at all, and stops working.

Now did try making sure data execution prevention was turned on/off, and that 
if set to second mode then told it to ignore specific applications - added both 
python.exe, and the compiled version of my code to it's exemption list, but, no 
changes there.

This still operates fine on my other dev machine, but, would like to know why 
it's not operating on one specific machine.

Otherwise, will just have to tell guys that, sorry, will only be able to 
generate SQL script text files, and they'll have to stick to the final step of 
then executing those via MySQL console interface, or something, but, would 
really prefer to at the very least, figure/find out what's causing this 
mis-behaviour.

Thoughts/suggestions with regards to how to find out what is happening/what I'm 
doing/handling wrong/incorrectly?

The two current versions of the code - which work fine under interpreter of 
both versions of python are basically the following:

#pymysql version
import pymysql
cn = pymysql.connect("localhost", "root", "", "import_test")
time.sleep(5)
cn.close()

#MySQLdb version
import MySQLdb
cn = MySQLdb.connect("localhost", "root", "", "import_test")
time.sleep(5)
cn.close()
#end code

Stay well (away from this machine ;) )

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: MySQL connections

2015-01-15 Thread Jacob Kruger
And, FWIW, if I compile the 2.7 version on the other machine where it works, in 
both code and compiled forms, and then copy .exe back to the main machine, same 
error message pops up, so must be something to do with machine's configuration, 
etc.

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

  - Original Message - 
  From: Jacob Kruger 
  To: [email protected] 
  Sent: Thursday, January 15, 2015 10:13 AM
  Subject: MySQL connections


  Development machine is windows7 64 bit machine, now working with either/both 
python 2.7 or 3.4 - test purposes, trying to figure out if this was something 
like a version incompatibility issue, and tried using both XAMPP and WAMP MySQL 
server version 5.0.11 instances thus far.

  Now, aside from all other issues relating to character encoding, etc., now 
down to, hopefully, final issue.

  Side note is under python 2.7, I use pyodbc to gather data from .mdb file am 
using to test, but under python 3.4, I use pypyodbc for same functionality.

  Now, current/actual issue is something can sort of duplicate using both 
MySQLdb version of mysqlclient, as well as pymysql using both python 2.7 and 
python 3.4, but, strange thing am trying to figure out is that even if just 
implement a connection object in interpreter of either version, retrieve an 
instance of a cursor object, and do various types of statement executions, no 
issues, and can then close connection, or cursor, or both, and all 
good/fine/well.

  However, if implement similar code - down to just trying to open a 
connection, wait a few seconds, and then close it again, inside a function 
called from a prior function, in the class am implementing in a file 
called/executed from command line, then, the moment I try to close the 
connection, whether or not have done anything with it, that's when I get that 
python.exe has stopped working/responding error message popping up, and python 
bombs out.

  Have no idea how to try track down actual source/cause of issue, since 
haven't found anything obvious in system event logs, nothing appearing in MySQL 
server logs that makes sense/appears relevant, and no matter if I try enclosing 
the connection open/close code inside try except code blocks, nothing happens 
there except that python just stops cooperating at all, and stops working.

  Now did try making sure data execution prevention was turned on/off, and that 
if set to second mode then told it to ignore specific applications - added both 
python.exe, and the compiled version of my code to it's exemption list, but, no 
changes there.

  This still operates fine on my other dev machine, but, would like to know why 
it's not operating on one specific machine.

  Otherwise, will just have to tell guys that, sorry, will only be able to 
generate SQL script text files, and they'll have to stick to the final step of 
then executing those via MySQL console interface, or something, but, would 
really prefer to at the very least, figure/find out what's causing this 
mis-behaviour.

  Thoughts/suggestions with regards to how to find out what is happening/what 
I'm doing/handling wrong/incorrectly?

  The two current versions of the code - which work fine under interpreter of 
both versions of python are basically the following:

  #pymysql version
  import pymysql
  cn = pymysql.connect("localhost", "root", "", "import_test")
  time.sleep(5)
  cn.close()

  #MySQLdb version
  import MySQLdb
  cn = MySQLdb.connect("localhost", "root", "", "import_test")
  time.sleep(5)
  cn.close()
  #end code

  Stay well (away from this machine ;) )

  Jacob Kruger
  Blind Biker
  Skype: BlindZA
  "Roger Wilco wants to welcome you...to the space janitor's closet..."



--


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


Re: [OT] Re: MySQL connections

2015-01-15 Thread Jacob Kruger
- Original Message - 
From: "Peter Otten" <[email protected]>

To: 
Sent: Thursday, January 15, 2015 12:40 PM
Subject: [OT] Re: MySQL connections



Jacob Kruger wrote:


However, if implement similar code - down to just trying to open a
connection, wait a few seconds, and then close it again, inside a 
function

called from a prior function, in the class am implementing in a file
called/executed from command line, then, the moment I try to close the
connection, whether or not have done anything with it, that's when I get
that python.exe has stopped working/responding error message popping up,
and python bombs out.


Jacob, your writing style is incredibly long-winded and hard to follow.
Try to build shorter sentences instead of this stream of consciousness, 
and

focus on the actual problem.



Was just trying to make sure included all relevant details ;)


"python bombs out"

is not a meaningful problem description. A traceback might be.



Agree with that, but, like said in prior e-mail, just get windows error 
message popping up, mentioning - no track trace, since it's python 
terminating:


---error details---
 Problem Event Name: BEX
 Application Name: python.exe
 Fault Module Name: StackHash_0a9e
---end error details---

That term BEX equates to buffer overflow exception, but not sure why this is 
happening - previous suggestion was to do with data execution prevention on 
windows, but, bex apparently also relates to winsock, or something, and 
tried different types of applying DEP - think so anyway.
That said, I probably cannot help with your particular problem, so feel 
free

to ignore me...



No worries - thanks for reply.

Just found following bit of summary of possible combination of 
bex/stackhash - but, still doesn't make sense when at this test stage I'm 
literally just opening and closing connection - might make sense if was 
executing thousands of queries against database before committing them:

---quote---
Buffer overflow is a condition when some process tries to store data beyond 
the capacity of the fixed/available buffer so it tries to overwrite some 
other memory locations, too. And in Windows we have some security feature 
called Data Execution Prevention that is intended to prevent similar 
processes to prevent buffer overflow attacks (that can introduce some 
malicious codes). But in some cases DEP can prevent some legitimate software 
from executing, too. And then you can get a BEX error.

---end quote---

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

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


Re: MySQL connections

2015-01-15 Thread Jacob Kruger
- Original Message - 
From: "Chris Angelico" 




You've posted your working versions; can you post a non-working version?


Problem is that works fine in interpreter, but, not when executing it as 
part of code in file.




Also, I'm seeing a very small hint here that might indicate a huge
factor that you haven't mentioned. You speak of "compiling" your
Python code. Do you mean you're turning it into an exe file? If so,
with which tool? Does the code still have problems if you run the
actual Python file?


Tried generating .exe with both cx_freeze, and pyInstaller, and the code 
itself, and both versions of executable generate errors, same as running it 
from command line - only difference is the source of the error mentioned in 
error message then varies from a2m.exe and python.exe , and even if compile 
it on machine where all works, and then copy .exe back to this primary 
machine, then get same error - think it must relate to something else on 
this machine, but can't track it down.


Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

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


Re: MySQL connections

2015-01-15 Thread Jacob Kruger
- Original Message - 
From: "Chris Angelico" 

Cc: 
Sent: Thursday, January 15, 2015 2:33 PM
Subject: Re: MySQL connections


On Thu, Jan 15, 2015 at 10:59 PM, Jacob Kruger  
wrote:

Tried generating .exe with both cx_freeze, and pyInstaller, and the code
itself, and both versions of executable generate errors, same as running 
it
from command line - only difference is the source of the error mentioned 
in
error message then varies from a2m.exe and python.exe , and even if 
compile

it on machine where all works, and then copy .exe back to this primary
machine, then get same error - think it must relate to something else on
this machine, but can't track it down.


Okay. Ignore the .exe versions, and just work with what happens when
you run the .py files. If it fails as part of a .py file, post the
failing file.


If you want to check it out, have attached the full code file - might be a 
bit messy/large - but, effectively, right at bottom, launch an instance of 
the class a2m, passing through arguments, and then from within __init__ call 
convertProcess function, which then initiates process, harvesting sort of 
rendition/version of structure out of MS access database file, makes call to 
convertSQL to generate structural SQL script, and save it to a file, which 
then calls convertData function to generate insert statements to populate 
database, and then that makes a call to convertExport, if you passed a 
command line argument in requesting mysql, and that's the current issue 
function - have stripped most of actual functionality out of it, since am 
just testing, so the first 16 lines of that function are what's relevant at 
moment - think shouldn't rely on any other self. objects/attributes as such 
either, unless step-through process is an issue.


And, tried cleaning it up a bit - replaced tab indentation character with 
double spaces, but, code might not look perfect/be perfectly clean as of 
yet.


Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..." 

import pypyodbc, os, sys
import copy, warnings
import pymysql, time, pickle
from unidecode import unidecode

def sTimeDiffFormat(i_time1, i_time2):
 i_total_time = i_time2 - i_time1 if i_time2 > i_time1 else i_time1 - i_time2
 i_total_time = int(i_total_time)
 #time.strftime("%H:%M:%S", time.gmtime(i_total_time))
 i_hours = 0
 i_minutes = 0
 if i_total_time >= 3600:
   i_hours = int(i_total_time / 3600)
   i_total_time = i_total_time - (i_hours * 3600)
 if i_total_time > 60:
   i_minutes = int(i_total_time/60)
   i_total_time = i_total_time - (i_minutes * 60)
 s_out = ""
 if i_hours > 0: s_out = "{0} hours ".format(i_hours)
 if i_minutes > 0: s_out = s_out + "{0} minutes ".format(i_minutes)
 s_out = s_out + "{0} seconds".format(i_total_time)
 return s_out
 #end of sTimeDiffFormat

class a2m():
 s_mdb = ""
 s_mdb_pass = ""
 s_mdb_conn = ""
 bl_mdb_conn = False
 d_db_tables = {}
 cn_mdb = None
 s_structure_sql = ""
 d_db_data = {}
 l_field_types = []
 s_target = ""
 s_target_value = ""
 s_sql_struct_file = ""
 s_sql_data_file = ""
 
 def __init__(self, s_mdb, s_mdb_pass, s_target, s_target_value):

   self.s_mdb = str(s_mdb) if len(str(s_mdb)) > 0 else ""
   self.s_mdb_pass = str(s_mdb_pass) if len(str(s_mdb_pass)) > 0 else ""
   if self.s_mdb_pass == "#": self.s_mdb_pass = ""
   self.s_target = str(s_target) if len(str(s_target))>0 else ""
   self.s_target_value = str(s_target_value) if len(str(s_target_value))>0 else 
""
   self.s_mdb_conn = ""
   self.bl_mdb_conn = False
   if self.s_mdb != "" and self.s_target != "" and self.s_target_value != "":
 self.convertProcess()
 #end of __init__
 
 def shiftID(self, l_columns):

   if l_columns.count("ID")>0:
 l_columns.remove("ID")
 l_columns.insert(0, "ID")
   return l_columns
 #end of shiftID

 def dictDBStructure(self, cur):
   d_out = {}
   cur_tables = cur.tables(tableType="table").fetchall()
   s_tables = ""
   for l_table in cur_tables:
 s_tables += str(l_table[2]) + "|"
   l_tables = s_tables.split("|")
   if len(l_tables) > 1: l_tables.pop(len(l_tables)-1)
   for s_table in l_tables:
 d_out[s_table] = {}
 #s_columns = ""
 #INTEGER, SMALLINT, VARCHAR, LONGCHAR, CURRENCY, BIT, DATETIME, COUNTER?
 for col in cur.columns(table=s_table):
   s_col_name = str(col.get("column_name"))
   s_col_type = str(col.get("type_name"))
   i_col_size = int(col.get("column_size"))
   if list(d_out[s_table].keys()).count(s_col_name) < 1:
 d_out[s_table][s_col_name] = {"column_nam

Re: [OT] Re: MySQL connections

2015-01-15 Thread Jacob Kruger
- Original Message - 
From: "Dennis Lee Bieber" 

To: 
Sent: Thursday, January 15, 2015 4:22 PM
Subject: Re: [OT] Re: MySQL connections



On Thu, 15 Jan 2015 13:48:34 +0200, "Jacob Kruger" 
declaimed the following:


Agree with that, but, like said in prior e-mail, just get windows error
message popping up, mentioning - no track trace, since it's python
terminating:


Python is fairly good about dumping a stack trace when the error is
something detectable by Python.

Issue is it just kills python, so no error message from python being 
rendered/displayed.


Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

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


Re: [OT] Re: MySQL connections

2015-01-15 Thread Jacob Kruger
- Original Message - > functions. When was the last time those 
systems had Windows Update and

reboots performed?


Daily basis.

Think, in line with your other message, will just try rewrite code - and, 
issue relating to structure etc. is left over from when pulled it out of 
wxPython implementation - you're right that should have just redone that 
part of it ;)


Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

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


help() function screen output

2015-01-31 Thread Jacob Kruger
Using python 3.4 32 bit on windows 7 64 bit machine, and when, for example, 
type in something like the following in interpreter window:
help(str)

It will populate the screen with one full screen of information, with a prompt 
of --more-- to hit enter, or something to continue displaying information, but, 
when, for example, hit enter key, it merely populates one more line of info, 
each time - under pythn 2.7, it seemed to render one full screen of info each 
time.

Is there rather a different keystroke should use to invoke that, or is this a 
python 3.4 feature/issue?

TIA

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: help() function screen output

2015-01-31 Thread Jacob Kruger
- Original Message - 
From: "Steven D'Aprano" 

Newsgroups: comp.lang.python
To: 
Sent: Saturday, January 31, 2015 11:13 AM
Subject: Re: help() function screen output



Jacob Kruger wrote:


Using python 3.4 32 bit on windows 7 64 bit machine, and when, for
example, type in something like the following in interpreter window:
help(str)

It will populate the screen with one full screen of information, with a
prompt of --more-- to hit enter, or something to continue displaying
information, but, when, for example, hit enter key, it merely populates
one more line of info, each time - under pythn 2.7, it seemed to render
one full screen of info each time.


Are you sure?

I don't have Windows to try, but in Linux using both Python 2.7 and 3.3,
pressing Enter advances by a single line.


Is there rather a different keystroke should use to invoke that, or is
this a python 3.4 feature/issue?


Try using the Space key to advance an entire page.

You can also try Page Up and Page Down keys.
Ok, strangely, while am relatively sure 2.7 rendered a screen at a time 
before when hitting enter key, it now also seems to advance one line at a 
time, but, yes, seems like space bar does advance a whole screen in both 
versions, and page up/down doesn't react, but, space bar will do for 
now...


And, I generally let it render a screen full, and then review the screen 
contents using screen-reader screen review functionality, but, in this case 
it pretty much matches what people see.


Thanks

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..." 


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


Re: help() function screen output

2015-01-31 Thread Jacob Kruger

- Original Message - > Specifically, the last two lines show:


 Display next page
   Display next line

which is, I suspect, what you're after here.

(If you're interested, the code for all this is in the pydoc module 
(Lib\pydoc.py) in the getpager() function.


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

Yes, that makes sense/works - wonder what changed recently in my overall 
configuration/setup - suppose might have something to do with screen 
reader's system wide interference - maybe it was passing a different 
effective keystroke through to command line prompt before, or something, 
since am 99.9% sure always just used  key to advance one screen at a 
time before - who knows, but, main thing is, yes, space bar does what I want 
it to.


Thanks

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

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


Re: Accessible tools

2015-02-19 Thread Jacob Kruger
Brian, I am also a fully bind python/PHP developer, and all I really bother 
with, aside from python interpreter itself is the text editor called 
edSharp:

http://www.empowermentzone.com/edsetup.exe

That's been developed by another blind guy who's name you might have heard 
in other circles, Jamal Mazrui, and it's just a programmers text editor that 
has a bit of extra functionality built in for use along with screen readers 
like jaws and NVDA, etc.


And, there are also some other general blind programmer mailing lists - I am 
on both [email protected] as well as a couple of other topic specific 
ones, but anyway.


Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "Bryan Duarte" 

To: 
Sent: Wednesday, February 18, 2015 7:43 PM
Subject: Accessible tools



Hello all,

I have been posting to another group which directed me to this group. I am 
a blind software engineering student at Arizona State University. I am 
currently doing research and have decided to use Python as my developing 
language. I am in search of an accessible IDE or other tool set which will 
allow me to use the features with a screen reader. I have tried a number 
of tools but so far have been unsuccessful in finding one that allows me 
to use the tools and features of the IDE with my screen reader.


I understand that I do not need an IDE to use Python, I am looking for an 
IDE to allow me to explore the classes and methods easily and quickly. I 
have tried the following tools.

• pyCharm
• iPy
• iPy Notebook
• Idle
• and Eclipse

So far only Eclipse was accessible but I did still incounter some 
difficulties like the IDE freezing up when tool tips would pop up. Finally 
I am using a Mac mostly but can use Windows, or Linux if need be. Thank 
you and I appreciate any and all suggestions.

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



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


Re: Accessible tools

2015-02-19 Thread Jacob Kruger

I use edSharp as my primary code/text editor, and just save code from there,
and while it doesn't offer too many things like design tools, it's pretty
much perfect in terms of code block selection, code snippets, code
navigation - to a certain extent, even in python, with regards to jumping
from block to block, etc.

Text based IDE would be nice at times, as long as you could review code
nicely enough, etc., and in terms of GUI design I generally just make use
of/work with scrollable grids via wxPython, since that cooperates well
enough in end result with both sighted, and accessibility API users, etc.,
but anyway.

It just means my interface design is done via a form of layout-by-code,
dropping controls in a flexGridSizer as well, but anyway.

My one primary thing I would like to be able to handle in terms of
development process is better means of working with debugging code
execution, etc. - at moment, primarily either print out information to
console, during dev process, or at times invoke sound effects/TTS output to
keep track, or even, occasionally use pickle to store images of objects for
later review, etc., but anyway...

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "Bryan Duarte" 

To: "Jonas Wielicki" 
Cc: 
Sent: Thursday, February 19, 2015 5:33 PM
Subject: Re: Accessible tools



Thank you jwi, and Jacob,

I took a look at that posting and it seems pretty unique. I am not much 
interested in the speech driven development, but I am very interested in 
developing an accessible IDE. A professor and I have been throwing around 
the idea of developing a completely text based IDE. There are a lot of 
reasons this could be beneficial to a blind developer and maybe even some 
sighted developers who are comfortable in the terminal. The idea would be 
really just to provide a way of easily navigating blocks of code using 
some kind of tabular formatting, and being able to collapse blocks of code 
and hearing from a high level information about the code within. All tools 
and features would obviously be spoken or output in some kind of audio 
manor.


Jacob, I know your name and I do know Jamal's name as well. I think I 
recall your names from either back in the "Mobile Speak" days, or maybe 
from the jaws mailing list. Either way thank you for the feedback and I 
will take a look at edSharp today. The Python interpreter is great for 
small tests or scripts but for lengthy programs there is no easy way to 
save your code other than capturing the entire history with extra code and 
all. How do you typically handle that issue? Thank you both.


Oh and before I forget does anyone know how to contact Eric who was 
developing that accessible speech driven IDE? Thanks

On Feb 19, 2015, at 3:08 AM, Jonas Wielicki  wrote:

Dear Bryan,

I don’t have a finished solution for you, but I would like to link you
to a previous thread on this list:
<https://mail.python.org/pipermail/python-list/2015-January/696276.html>

The poster seems to be researching into the direction of developing a
speech-friendly IDE. You may want to follow his work.

regards,
jwi


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


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



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


Re: Accessible tools

2015-02-20 Thread Jacob Kruger

Eric, issue is that with screenreaders, we're generally way more into
navigating code and interface character by character/by keyboard, so , yes,
keeping interface relatively simple is a good thing, but, we also would
prefer to primarily keep all interface elements to make use of standard UI
controls, and make sure tab index/order is suitable/relevant at times, etc.
etc.

As in, I think we'd primarily want to avoid having to use a mouse at all if
possible, but anyway.

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "Eric S. Johansson" 

To: 
Sent: Friday, February 20, 2015 7:22 PM
Subject: Re: Accessible tools




On 2/19/2015 10:33 AM, Bryan Duarte wrote:

Thank you jwi, and Jacob,

I took a look at that posting and it seems pretty unique. I am not much 
interested in the speech driven development, but I am very interested in 
developing an accessible IDE.


Well you should be because it looks like an aural interface (uses speech 
instead of keyboards) uses the same kinds of data to present to either a 
text to speech or speech recognition driven environment.
A professor and I have been throwing around the idea of developing a 
completely text based IDE. There are a lot of reasons this could be 
beneficial to a blind developer and maybe even some sighted developers 
who are comfortable in the terminal. The idea would be really just to 
provide a way of easily navigating blocks of code using some kind of 
tabular formatting, and being able to collapse blocks of code and hearing 
from a high level information about the code within. All tools and 
features would obviously be spoken or output in some kind of audio manor.
I've been working with another professor working on some of these issues 
as well. His focus has been mostly blind young adults in India.  come up 
with some pretty cool concepts that looks very usable. The challenge now 
is to make them work and, quite frankly monetize the effort to pay for the 
development.


Again, this shows the similarities in functionality used by both speech 
recognition and text-to-speech. All I care about is text and what I can 
say. We're now working with constructs such as with-open, argument by 
number, plaintext symbol names (with bidirectional transform to and from 
code form), guided construct generation for things like classes, methods, 
comprehensions etc.


All of these things would be useful to handed programmers as well as a way 
of accelerating co-creation and editing. Unfortunately, like with disabled 
people stove piping text-to-speech versus speech recognition, handed 
developers stovepipe keyboard interfaces and don't really think about what 
they are trying to do, only how they are doing it.


Yes yes, it's a broadbrush that you can probably slap me with. :-)


Oh and before I forget does anyone know how to contact Eric who was 
developing that accessible speech driven IDE? Thanks


Well, you could try looking in a mirror and speaking my name three times 
at midnight But you would get better results if you used my non-mailing 
list email address. [email protected].


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



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


Re: Accessible tools

2015-02-22 Thread Jacob Kruger
- Original Message - 
From: "Tim Chase" 

Subject: Re: Accessible tools




While my experience has shown most of your items to be true, I'd
contend that


• Do not, have access to debugging tools.


is mistaken or at least misinformed.  For Python, I use the "pdb"
module all the time, and it's command-line driven.  Combined with a
multi-terminal (whether multiple windows, virtual consoles, or a
tmux/screen session), I can easily bounce back and forth between a
"pdb" debugging session and the source code to make edits.  Just to
check, I fired up the "yasr" terminal screen-reader, launched tmux
(using my quiet config, since it updates information on the screen
like the time on a regular basis, making it chatty), and stepped
through some Python code, checked variables, and walked up/down the
call-stack.  I know most other languages have similar functionality
such as gdb for C code.
Will check out PDB a bit more, but, honestly, my windows screenreader that 
use most of the time, jaws, doesn't always cooperate perfectly with command 
line/console interface - can be worked around, but, not all that easily at 
times - but, this page seems to offer enough detail relating to PDB, to 
start off with anyway:

https://docs.python.org/3/library/pdb.html

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."


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


  1   2   3   >