Re: Getting data out of Mozilla Thunderbird with Python?

2015-12-09 Thread Christian Gollwitzer

Am 08.12.15 um 19:21 schrieb Anthony Papillion:

I have a TON of email (years) stored in my Thunderbird. My backup
strategy for the last few years has been to periodically dump it all
in a tar file, encrypt that tar file, and move it up to the cloud.
That way, if my machine ever crashes, I don't lose years of email.

But I've been thinking about bringing Python into the mix to build a
bridge between Thunderbird and SQLite or MySQL (probably sqlite) where
all mail would be backed up to a database where I could run analytics
against it and search it more effectively.

I'm looking for a way to get at the mail stored in Thunderbird using
Python and, so far, I can't find anything. I did find the mozmail
package but it seems to be geared more towards testing and not really
the kind of use I need.


You have several options.

1) As noted before, Thunderbird ususally stores mail in mbox format, 
which you can read and parse. However it keeps an extra index file 
(.msf) to track deleted messages etc. Until you "compact" the folders, 
the messages are not deleted in the mbox file


2) You can configure it to use maildir instead. Maildir is a directory 
where every mail is stored in a single file. That might be easier to 
parse and much faster to access.


3) Are you sure that you want to solve the problem using Python? 
Thunderbird has excellent filters and global full text search (stored in 
sqlite, btw). You can instruct it to archive mails, which means it 
creates a folder for each year - once created for a past year, that 
folder will never change. This is how I do my mail backup, and these 
folders are backed up by my regular backup (TimeMachine). You could also 
try to open the full text index with sqlite and run some query on it.


4) Yet another option using Thunderbird alone is IMAP. If you can either 
use a commercial IMAP server, have your own server in the cloud or even 
write an IMAP server using Python, then Thunderbird can 
access/manipulate the mail there as a usual folder.


5) There are converters like Hypermail or MHonArc to create HTML 
archives of mbox email files for viewing in a browser


Christian

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


tkinter

2015-12-09 Thread Chris Harwood
Hi,

Python » 3.5.0 Documentation » The Python Standard Library » 25. Graphical User 
Interfaces with Tk » states that "You can check that tkinter is properly 
installed on your system by running python -m tkinter from the command line; 
this should open a window demonstrating a simple Tk interface."

Having recently installed Python 3.5.0 I find that python -m tkinter produces:
'python' is not recognised as an  internal or external command, operable 
program or batch file.

Can you help, please?

Thank you,

Chris Harwood.

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


Image download failure from wget.download function.

2015-12-09 Thread ashwath
Hi 
 
 
I am trying to download the image from a URL, I am able to download  a file but 
after downloading if I try to open the image it says file format is corrupted 
or damaged. 
 
I use this function to download the image  -   
wget.download('http:realpython.com//learn//python-first-steps//images//pythonlogo.jpg')
 
 
For all the other URLs also same image format failure is happening.
 
So can you please check and lemme know the reason for failure.
 
 
 
Thank you
 
Ashwath
-- 
https://mail.python.org/mailman/listinfo/python-list


Reading lines of text from 7z compressed files in Python

2015-12-09 Thread Anmol Dalmia
Hello all.

I am trying to read a compressed xml file line by line under the 7z format.
I found an answer to a related question here:

http://stackoverflow.com/questions/20104460/how-to-read-from-a-text-file-compressed-with-7z-in-python

I wish to use the native LZMA library of Python 3.4 for faster performance
than any other third- party packages. Is it possible to do so?

Thanks
-- 
With Regards
ANMOL DALMIA
M Tech (Dual) Information Security, 2017
National Institute of Technology, Rourkela, India
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Python Script - Windows Task Scheduler - Logging

2015-12-09 Thread Raheel Rao
Update: I was able to figure this one out eventually. I had to put path of 
where the script is in "Start in" section of my task. 

Consider this ticket 'closed' :)


> Date: Mon, 7 Dec 2015 23:53:10 +
> From: rr.codeproj...@outlook.com
> To: python-list@python.org
> Subject: Python Script - Windows Task Scheduler - Logging
> 
> Hello there,I created a python script that connects to an ftp and downloads 
> files to a specifed folder and logs each event in a log file. This script 
> works perfectly fine as i want it to however when i put this in a task 
> scheduler, the script runs and downloads the file just fine except that there 
> is no log created. Any suggestions? I remember task scheduler have a bug 
> where you have to put something in "start in". Have been searching froums but 
> so far no luck. Thanks in advance!
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: tkinter

2015-12-09 Thread Chris Angelico
On Wed, Dec 9, 2015 at 4:59 AM, Chris Harwood  wrote:
> Having recently installed Python 3.5.0 I find that python -m tkinter produces:
> 'python' is not recognised as an  internal or external command, operable 
> program or batch file.

Try instead:

python3 -m tkinter

But it might mean that you didn't put Python on yout $PATH.

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


Re: Image download failure from wget.download function.

2015-12-09 Thread Peter Otten
ashw...@nanoheal.com wrote:

> I am trying to download the image from a URL, I am able to download  a
> file but after downloading if I try to open the image it says file format
> is corrupted or damaged.

What version of python are you using? Where did you get the wget libary?
 
> I use this function to download the image  -  
> wget.download('http:realpython.com//learn//python-first-steps//images//pythonlogo.jpg')

The above snippet will not work because all slashes are duplicated.
Please post a small but runnable script.

> For all the other URLs also same image format failure is happening.

How do you "open" the images? Do you mean you try to view them in an image 
viewer or are you reading the contents with Python? If the latter, show us 
your code for that, too.

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


Re: Getting data out of Mozilla Thunderbird with Python?

2015-12-09 Thread Steven D'Aprano
On Wed, 9 Dec 2015 07:03 pm, Christian Gollwitzer wrote:

> 1) As noted before, Thunderbird ususally stores mail in mbox format,
> which you can read and parse. However it keeps an extra index file
> (.msf) to track deleted messages etc. Until you "compact" the folders,
> the messages are not deleted in the mbox file
> 
> 2) You can configure it to use maildir instead. Maildir is a directory
> where every mail is stored in a single file. That might be easier to
> parse and much faster to access.

Maildir is also *much* safer too. With mbox, a single error when writing
email to the mailbox will likely corrupt *all* emails from that point on,
so potentially every email in the mailbox. With maildir, a single error
when writing will, at worst, corrupt one email.

Thanks Mozilla, for picking the *less* efficient and *more* risky format as
the default. Good choice!


> 3) Are you sure that you want to solve the problem using Python?
> Thunderbird has excellent filters and global full text search (stored in
> sqlite, btw).

Sqlite is unsafe on Linux systems if you are using ntfs. I have had no end
of database corruption with Firefox and Thunderbird due to this, although
in fairness I haven't had any problems for a year or so now.



-- 
Steven

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


Re: tkinter

2015-12-09 Thread Zachary Ware
On Dec 9, 2015 3:36 AM, "Chris Harwood"  wrote:
>
> Hi,
>
> Python » 3.5.0 Documentation » The Python Standard Library » 25.
Graphical User Interfaces with Tk » states that "You can check that tkinter
is properly installed on your system by running python -m tkinter from the
command line; this should open a window demonstrating a simple Tk
interface."
>
> Having recently installed Python 3.5.0 I find that python -m tkinter
produces:
> 'python' is not recognised as an  internal or external command, operable
program or batch file.
>
> Can you help, please?

Try "py -3.5 -m tkinter" instead.  On Windows, you have tkinter unless you
deselected it when you installed Python.

For future reference, it's very helpful to provide your OS and OS version
when asking questions like this; I'm just assuming you're on Windows since
that's the default "that's not on PATH" message.

Hope this helps,
--
Zach
(On a phone)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting data out of Mozilla Thunderbird with Python?

2015-12-09 Thread srinivas devaki
On Dec 9, 2015 4:45 PM, "Steven D'Aprano"  wrote:
>
> Maildir is also *much* safer too. With mbox, a single error when writing
> email to the mailbox will likely corrupt *all* emails from that point on,
> so potentially every email in the mailbox. With maildir, a single error
> when writing will, at worst, corrupt one email.
>

may be with frequent backup of mbox file and storing checksum to each email
will be faster and safe too.
I wonder if they already do that.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting data out of Mozilla Thunderbird with Python?

2015-12-09 Thread Chris Angelico
On Thu, Dec 10, 2015 at 1:06 AM, srinivas devaki
 wrote:
> On Dec 9, 2015 4:45 PM, "Steven D'Aprano"  wrote:
>>
>> Maildir is also *much* safer too. With mbox, a single error when writing
>> email to the mailbox will likely corrupt *all* emails from that point on,
>> so potentially every email in the mailbox. With maildir, a single error
>> when writing will, at worst, corrupt one email.
>>
>
> may be with frequent backup of mbox file and storing checksum to each email
> will be faster and safe too.
> I wonder if they already do that.

Yes, because we all know that frequent checking is better than
prevention. That's why MySQL's myisamchk command makes it so much
better than PostgreSQL's transactional DDL.

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


Re: filter a list of strings

2015-12-09 Thread Sivan Greenberg
That might also work:

new_list = [i for i in the_list if i not in targets]
# given you have no special requirements for the selection
# out of 'targets'

-Sivan

On Wed, Dec 9, 2015 at 12:58 AM, Thomas 'PointedEars' Lahn <
pointede...@web.de> wrote:

> Mark Lawrence wrote:
>
> > On 03/12/2015 01:15, c.bu...@posteo.jp wrote:
> >> I would like to know how this could be done more elegant/pythonic.
> >>
> >> I have a big list (over 10.000 items) with strings (each 100 to 300
> >> chars long) and want to filter them.
> >>
> >> list = .
> >> […]
> >
> > targets = ['Banana', 'Car'...]
> > for item in list[:]:
> >  for target in targets:
> >  if target in item:
> >  list.remove(item)
> >
> >> btw: Is it correct to iterate over a copy (list[:]) of that string list
> >> and not the original one?
> >
> > Absolutely :)
>
> However, “list” is a built-in class/constructor that would be overwritten
> this way.  One should choose another identifier than “list” for one’s
> variables.
>
> --
> PointedEars
>
> Twitter: @PointedEars2
> Please do not cc me. / Bitte keine Kopien per E-Mail.
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
Sivan Greenberg
Co founder & CTO
Vitakka Consulting
-- 
https://mail.python.org/mailman/listinfo/python-list


3D numpy array subset

2015-12-09 Thread Heli
Dear all, 

I am reading a dataset from a HDF5 file using h5py. my datasets are 3D. 

Then I will need to check if another 3d numpy array is a subset of this 3D 
array i am reading from the file.

In general, is there any way to check if two 3d numpy arrays have intersections 
and if so, get the indices of the intersection area.

By intersection, I exactly mean the intersection definition used in set theory.


Thanks in Advance for your help, 
-- 
https://mail.python.org/mailman/listinfo/python-list


np.searchSorted over 2D array

2015-12-09 Thread Heli
Dear all, 

I need to check whether two 2d numpy arrays have intersections and if so I will 
need to have the cell indices of the intersection.

By intersection, I exactly mean the intersection definition used in set theory.

I will give an example of what I need to do:

a=[[0,1,2],[3,4,5],[6,7,8]]
b=[[0,1,2],[3,4,5]]

I would like to check whether b is subset of a and then get the indices in a 
where b matches. 

cellindices=[[True,True,True],[True,True,True],[False,False,False]]

What is the best way to do this in numpy? 

 
Thanks in Advance for your help, 

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


Re: np.searchSorted over 2D array

2015-12-09 Thread Peter Otten
Heli wrote:

[Please don't open a new thread for the same problem] 

> I need to check whether two 2d numpy arrays have intersections and if so I
> will need to have the cell indices of the intersection.
> 
> By intersection, I exactly mean the intersection definition used in set
> theory.
> 
> I will give an example of what I need to do:
> 
> a=[[0,1,2],[3,4,5],[6,7,8]]
> b=[[0,1,2],[3,4,5]]
> 
> I would like to check whether b is subset of a and then get the indices in
> a where b matches.
> 
> cellindices=[[True,True,True],[True,True,True],[False,False,False]]
> 
> What is the best way to do this in numpy?

Providing an example is an improvement over your previous post, but to me 
it's still not clear what you want.

>>> functools.reduce(lambda x, y: x | y, (a == i for i in b.flatten()))
array([[ True,  True,  True],
   [ True,  True,  True],
   [False, False, False]], dtype=bool)

produces the desired result for the example input, but how do you want to 
handle repeating numbers as in 

>>> a = numpy.array([[0,1,2],[3,4,5],[3, 2, 1]])
>>> functools.reduce(lambda x, y: x | y, (a == i for i in b.flatten()))
array([[ True,  True,  True],
   [ True,  True,  True],
   [ True,  True,  True]], dtype=bool)

?

Try to be clear about your requirement, describe it in english and provide a 
bit of context. You might even write a solution that doesn't use numpy and 
ask for help in translating it.

At the very least we need more/better examples.

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


Re: Getting data out of Mozilla Thunderbird with Python?

2015-12-09 Thread Grant Edwards
On 2015-12-09, Steven D'Aprano  wrote:

> Thanks Mozilla, for picking the *less* efficient and *more* risky format as
> the default. Good choice!

At least they picked a standard format as the default and gave you the
option to use a different standard format (cf. Microsoft and Outlook).

-- 
Grant Edwards   grant.b.edwardsYow! Are you the
  at   self-frying president?
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Python variable assigning problems...

2015-12-09 Thread ICT Ezy
Pl refer question which attached image here:

link: https://drive.google.com/open?id=0B5L920jMv7T0dFNKQTJ2UUdudW8
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python variable assigning problems...

2015-12-09 Thread Joel Goldstick
On Wed, Dec 9, 2015 at 12:51 PM, Joel Goldstick 
wrote:

>
>
> On Wed, Dec 9, 2015 at 12:49 PM, ICT Ezy  wrote:
>
>> Pl refer question which attached image here:
>>
>> link: https://drive.google.com/open?id=0B5L920jMv7T0dFNKQTJ2UUdudW8
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
>
> You have a link to somewhere that needs permission to view.  Why not just
ask your question here?  Many people won't follow links, and anyway, no one
can follow yours

>
> --
> Joel Goldstick
> http://joelgoldstick.com/stats/birthdays
>



-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python variable assigning problems...

2015-12-09 Thread Joel Goldstick
On Wed, Dec 9, 2015 at 12:49 PM, ICT Ezy  wrote:

> Pl refer question which attached image here:
>
> link: https://drive.google.com/open?id=0B5L920jMv7T0dFNKQTJ2UUdudW8
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


How to connect the MYSQL database to Python program?

2015-12-09 Thread ICT Ezy
Pl explain me how to connect the MYSQL database to Python program?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to connect the MYSQL database to Python program?

2015-12-09 Thread Chris Angelico
On Thu, Dec 10, 2015 at 4:51 AM, ICT Ezy  wrote:
> Pl explain me how to connect the MYSQL database to Python program?

You start by looking for a module that lets you do that. You can use
your favourite web search engine, or go directly to PyPI.

Then you learn how to use that module, including learning SQL if you
don't already know it.

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


Re: Reading lines of text from 7z compressed files in Python

2015-12-09 Thread srinivas devaki
On Dec 9, 2015 3:07 PM, "Anmol Dalmia"  wrote:
>
>
> I wish to use the native LZMA library of Python 3.4 for faster performance
> than any other third- party packages. Is it possible to do so?
>

you can check the source of lzma module main compression and decompression
algorithms were written in c. so obviously you will get faster performance.
In [21]: import _lzma

In [22]: _lzma.__file__
Out[22]:
'/home/eightnoteight/.anaconda3/envs/snakes3.4.3/lib/python3.4/lib-dynload/_
lzma.cpython-34m.so'


and regarding your problem, here's a simple example on how you can read
line by line of your compressed 7z text file.


import lzma
with lzma.open('test.7z', 'w') as lf:
lf.write(b'123\n'*1000)
with lzma.open('test.7z', 'r') as lf:
arr = list(lf)
print(len(arr))
print(set(arr))
print(arr[0])
print(arr[0].decode('utf-8'))

[gist] https://gist.github.com/38681cad88928b089abb

later you can even extract that test.7z with 7z command line client with
(7z x test.7z)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 3D numpy array subset

2015-12-09 Thread Oscar Benjamin
On 9 Dec 2015 14:26, "Heli"  wrote:
>
> Dear all,
>
> I am reading a dataset from a HDF5 file using h5py. my datasets are 3D.
>
> Then I will need to check if another 3d numpy array is a subset of this
3D array i am reading from the file.
>
> In general, is there any way to check if two 3d numpy arrays have
intersections and if so, get the indices of the intersection area.
>
> By intersection, I exactly mean the intersection definition used in set
theory.

Does this help:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.intersect1d.html

I'm not sure how the 3d part is relevant but that function finds the common
elements of two arrays. Use .flat or something to make the 3d arrays be
treated as 1d. Otherwise it's not clear what you mean by intersection.

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


Re: Python variable assigning problems...

2015-12-09 Thread Mark Lawrence

On 09/12/2015 17:49, ICT Ezy wrote:

Pl refer question which attached image here:

link: https://drive.google.com/open?id=0B5L920jMv7T0dFNKQTJ2UUdudW8



Please put your code, query or whatever it is inline here, I'm not going 
off into the great wide world just to suit you.


If it has anything to do with installing 3.5 on Windows asked and 
answered roughly one trillion times.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: How to connect the MYSQL database to Python program?

2015-12-09 Thread Mark Lawrence

On 09/12/2015 17:51, ICT Ezy wrote:

Pl explain me how to connect the MYSQL database to Python program?



Use a search engine.  Then run up an editor, write some code, run said 
code.  If you then have problems state your OS, Python version and 
provide us with the full traceback.


An alternative is to write a cheque for (say) GBP 1000 payable to the 
Python Software Foundation and if you're lucky somebody will do your 
homework for you.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Is there a data type rule on 'x+=' and 'x0=x+'?

2015-12-09 Thread Robert
Hi,

I have a numpy np.array data x:

x= np.array([[157, 185], [169, 195], [162, 179], [145, 195], [159, 199],
 [165, 180], [172, 195], [180, 201], [163, 195], [169, 191]])

Here is the original code snippet:

x+=uniform(-8, 8, x.shape)

x
Out[557]: 
array([[163, 192],
   [163, 187],
   [171, 200],
   [165, 186],
   [162, 185],
   [160, 193],
   [156, 194],
   [168, 197],
   [186, 207],
   [184, 208]])


I am curious about the integer data type of result x.
When I use this code:

x0=x+uniform(-8, 8, x.shape)

x0 is a floating format:

x0
Out[555]: 
array([[ 150.84633535,  188.93254259],
   [ 170.29185044,  197.22753051],
   [ 175.65371771,  190.59168953],
   [ 159.61401655,  175.06364015],
   [ 168.35531363,  180.19243277],
   [ 163.79970077,  206.28600694],
   [ 157.89342616,  203.39444556],
   [ 179.86956647,  192.91265609],
   [ 182.48075601,  208.02397713],
   [ 187.59332123,  207.41482024]])


I would like to know what rule makes these two different result formats.

Could you help me?

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


PyTk cascaded radiobuttons, howto?

2015-12-09 Thread nickgeovanis
Using python 3.4.2.
Tcl/tk example here is from /usr/share/tk8.5/demos/widget and .../menu.tcl.
The way tcl/tk adds cascaded radiobuttons to a menu is like this:
set m $w.menu.cascade
$w.menu add cascade -label "Cascades" -menu $m -underline 0

$m add cascade -label "Radio buttons" -menu $w.menu.cascade.radio...
set m $w.menu.cascade.radio
$m add radio -label "Roman" -variable style...
$m add radio -label "Italic" -variable style...

...and so on.

My difficulty doing the same in PyTk is the following: When creating that 
uppermost cascade, you do something like
menu.add_cascade(label = "Cascades")
...but there is no ability to save a usable reference to that top-level 
cascade. If I do so anyway and add a radiobutton to it, nothing appears, no 
errors either. What is the correct way to cascade radiobuttons from a cascaded 
menu in PyTk? ThanksNick

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


Re: Is there a data type rule on 'x+=' and 'x0=x+'?

2015-12-09 Thread Steven D'Aprano
On Thu, 10 Dec 2015 08:57 am, Robert wrote:

> Hi,
> 
> I have a numpy np.array data x:
> 
> x= np.array([[157, 185], [169, 195], [162, 179], [145, 195], [159, 199],
>  [165, 180], [172, 195], [180, 201], [163, 195], [169, 191]])
> 
> Here is the original code snippet:
> 
> x+=uniform(-8, 8, x.shape)

What is "uniform"? I thought it might be numpy.uniform, but that doesn't
appear to exist. So I will guess that it might be numpy.random.uniform. Is
that right?


[...]
> I am curious about the integer data type of result x.

py> x = np.array([[157, 185], [169, 195], [162, 179], [145, 195], [159,
199],
...  [165, 180], [172, 195], [180, 201], [163, 195], [169, 191]])
py> x.dtype
dtype('int32')

py> y = np.random.uniform(-8, 8, x.shape)
py> y.dtype
dtype('float64')


So the array x is an array of int32 and the array of random numbers is an
array of float64.

When you do an in-place add using += the data type doesn't change, but when
you do an external add using + the result is coerced to the "wider" type,
which is float64.

py> x.dtype
dtype('int32')

py> (x + y).dtype
dtype('float64')


You can read up on numpy types here:

http://docs.scipy.org/doc/numpy/user/basics.types.html

http://docs.scipy.org/doc/numpy/reference/generated/numpy.find_common_type.html

http://docs.scipy.org/doc/numpy/reference/generated/numpy.result_type.html

http://docs.scipy.org/doc/numpy/reference/generated/numpy.promote_types.html


I'm not quite sure if the specific type promotion rules are documented
anywhere, but basically any arithmetic operation between different types
can involve loss of precision. Consider adding an integer 100 and a float
1.1, since they are different types, numpy must coerce the types to a
common format:

100 + int32(1.1) = 101

float64(100) + 1.1 = 101.1

Since the first result loses precision, numpy will choose the second. This
is called "type promotion": float64 can represent every value that int32
can, but int32 cannot represent every float64 without loss of precision.

When Numpy creates a new array as the result of an calculation, it will
promote the types involved to avoid data loss. But an in-place operation
like += has to use the type of the original, because that is fixed.


py> x = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9])
py> x ** 0.5  # creates a new array
array([ 1.,  1.41421356,  1.73205081,  2.,  2.23606798,
2.44948974,  2.64575131,  2.82842712,  3.])
py> x **= 0.5
py> x
array([1, 1, 1, 2, 2, 2, 2, 2, 3])



-- 
Steven

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


Re: PyTk cascaded radiobuttons, howto?

2015-12-09 Thread nickgeovanis
This is of course using tkinter from python, PyTk is a misnomer. Python 3.4.2 
wit tcl/tk 8.5 under CentOS 7.
-- 
https://mail.python.org/mailman/listinfo/python-list


Windows 10 and PYODBC

2015-12-09 Thread William Abdo
Hi All,
I am not sure if anyone has asked this question already or not but I will again.
Hopefully someone else has had and found a fix for this issue.
I'm grateful for any and all assistance.

I have recently upgraded to Windows 10 and I have an issue with PYODBC 
connecting to Oracle 11g.

It was working OK in Windows 7,  till I upgraded to Windows 10, Anyone have any 
IDEAS?
I have tried setting it to Windows 7 compatibility mode .
I have updated the drivers to the latest (Which I think I already had).

The actual error I get is
 Traceback (most recent call last):
  File "oraclecountsDec1.py", line 32, in 
pconnObj =  pyodbc.connect( pconnString )
pyodbc.Error: ('NA000', "[NA000] [Microsoft][ODBC driver for 
Oracle][Oracle]Error while trying to retrieve text for error ORA-01019 (1019) 
(SQLDriverConnect); [01000] [Microsoft][ODBC Driver Manager] The driver doesn't 
support the version of ODBC behavior that the application requested (see 
SQLSetEnvAttr). (0)")

SQL Log file states:
Fatal NI connect error 12560, connecting to:
(DESCRIPTION=(ADDRESS=(PROTOCOL=BEQ)(PROGRAM=oracle)(ARGV0=oracleORCX)(ARGS='(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))'))(CONNECT_DATA=(SID=ORCX)(CID=(PROGRAM=D:\Python26\python.exe)(HOST=xxx-)(USER=xx

  VERSION INFORMATION:
TNS for 32-bit Windows: Version 12.1.0.2.0 - Production
Oracle Bequeath NT Protocol Adapter for 32-bit Windows: Version 
12.1.0.2.0 - Production
Windows NT TCP/IP NT Protocol Adapter for 32-bit Windows: 
Version 12.1.0.2.0 - Production
  Time: 06-AUG-2015 17:12:31
  Tracing not turned on.
  Tns error struct:
ns main err code: 12560
TNS-12560: Message 12560 not found; No message file for product=NETWORK, 
facility=TNS
ns secondary err code: 0
nt main err code: 530
TNS-00530: Message 530 not found; No message file for product=NETWORK, 
facility=TNS
nt secondary err code: 126
nt OS err code: 0


Respectfully,

William Abdo
Software App Engineer II
NTT America, an NTT Communications Company
Office:   +1 561.912.2434
Email:w.a...@ntta.com
[https://rvip.team-center.net/externals/images/email/ntta.png]
[https://rvip.team-center.net/externals/images/email/ntta-twitter.png]
  [https://rvip.team-center.net/externals/images/email/ntta-linkedin.png] 
   
[https://rvip.team-center.net/externals/images/email/ntta-facebook.png] 
   
[https://rvip.team-center.net/externals/images/email/ntta-youtube.png] 










This email message is intended for the use of the person to whom it has been 
sent, and may contain information that is confidential or legally protected. If 
you are not the intended recipient or have received this message in error, you 
are not authorized to copy, distribute, or otherwise use this message or its 
attachments. Please notify the sender immediately by return e-mail and 
permanently delete this message and any attachments. makes no warranty that 
this email is error or virus free. Thank you.

This email message is intended for the use of the person to whom it has been 
sent, and may contain information that is confidential or legally protected. If 
you are not the intended recipient or have received this message in error, you 
are not authorized to copy, distribute, or otherwise use this message or its 
attachments. Please notify the sender immediately by return e-mail and 
permanently delete this message and any attachments. NTT America makes no 
warranty that this email is error or virus free. Thank you.

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


How to use internal python c funtions, from python code

2015-12-09 Thread srinivas devaki
Hi
I'm coming from this link (
https://groups.google.com/forum/#!topic/python-ideas/cBFvxq1LQHM), which
proposes to use long_to_decimal_string(), int_to_decimal_string() functions
for printing integers in different bases.

Now is there anyway i can use such internal functions from pure python
code, passing ctypes when the arguments are c datatypes.

For competitive programming purposes I really want to use those functions
for speed.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to use internal python c funtions, from python code

2015-12-09 Thread Chris Angelico
On Thu, Dec 10, 2015 at 3:44 PM, srinivas devaki
 wrote:
> For competitive programming purposes I really want to use those functions
> for speed.

Recommendation: Write your code the simple and obvious way, and *then*
start thinking about speed. And before you look at calling on C code
manually, try running your code in PyPy, and then try making use of
Cython.

For the specific example of converting an integer into a string using
a particular base, there are quite a few options available; but I
would recommend using the very simplest you can get away with.

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


Re: Python variable assigning problems...

2015-12-09 Thread Steven D'Aprano
On Thursday 10 December 2015 04:49, ICT Ezy wrote:

> Pl refer question which attached image here:
> 
> link: https://drive.google.com/open?id=0B5L920jMv7T0dFNKQTJ2UUdudW8

Do you really expect us to sign in to Google in order to help you?

Let me give you some friendly advice. You are asking us for free support. In 
the commercial world, this sort of support can cost hundreds of dollars an 
hour, and you are getting it for free. Every barrier you add, you lose 50% 
of the potential answers.

You ask us to click a link, instead of including the question direct in your 
message? That's 50% of potential helpers gone.

Link is to an image instead of actual text and code? That's 75% gone.

Link requires a login to Google? That's 87.5% gone.

If you want good quality answers, you need to ask good quality questions. If 
you ask lazy questions and expect us to do all the work, you'll probably be 
disappointed.



-- 
Steve

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


Re: Getting data out of Mozilla Thunderbird with Python?

2015-12-09 Thread Michael Torrie
On 12/09/2015 04:11 AM, Steven D'Aprano wrote:
> Maildir is also *much* safer too. With mbox, a single error when writing
> email to the mailbox will likely corrupt *all* emails from that point on,
> so potentially every email in the mailbox. With maildir, a single error
> when writing will, at worst, corrupt one email.
> 
> Thanks Mozilla, for picking the *less* efficient and *more* risky format as
> the default. Good choice!

Not so long ago, many filesystems were very poor at storing lots of
small files. For disk efficiency, storing them in one big file,
periodically compacting the file, was seen as a better way to go. After
all mbox format has been around for a very long time for certain reasons
(which no longer exist today). Maildir came later.  Back when hard
drives were smaller, it was also not uncommon to run out of inodes in a
file system on a server that had many small files.

Neither of these issues is much of a problem these days.  Ext4 added the
ability to store small files right in the inode, so internal
fragmentation (and wasting of space) isn't a big issue anymore.

It's good to know I can configure Thunderbird to use maildir for local
storage.  I'll have to make the change here.  Will make my backups a lot
easier and faster.

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