Instance method for converting int to str - str() and __str__()

2015-10-02 Thread neubyr
I was wondering if there is any resource that explains why certain methods
like str() and type() were implemented the way they are, rather than
.to_string() or .type() instance/object methods.

I find instance/object methods more intuitive for this cases, but I am
wondering why it wasn't implemented it like that.

I know there are equivalents like  __str__() and __class__ , but passing
object to str() or type() seems more popular.

Any resources for reading or some background information would be helpful.

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


Re: IDLE = 'Integrated Development and Learning Environment'

2015-10-02 Thread Chris Angelico
On Sat, Oct 3, 2015 at 1:57 PM, Terry Reedy  wrote:
> Today, we agreed on the idle-dev list (Guido included) that 'IDLE' should be
> interpreted as 'Integrated Development and Learning Environment' rather than
> as 'Integrated DeveLopment Environment' (note the 'L' in 'DeveLopment').
> The new long form better reflects the current practice and goal of IDLE
> development.  For instance, a menu entry to run turtledemo was added a year
> ago to help learning, rather than development.  Of course, 'IDLE' remains an
> intentional reference to Eric Idle of Monty Python.

Oh, I thought it was already called that. Definitely prefer the
four-word expansion to the middle-of-word version.

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


IDLE = 'Integrated Development and Learning Environment'

2015-10-02 Thread Terry Reedy
Today, we agreed on the idle-dev list (Guido included) that 'IDLE' 
should be interpreted as 'Integrated Development and Learning 
Environment' rather than as 'Integrated DeveLopment Environment' (note 
the 'L' in 'DeveLopment').  The new long form better reflects the 
current practice and goal of IDLE development.  For instance, a menu 
entry to run turtledemo was added a year ago to help learning, rather 
than development.  Of course, 'IDLE' remains an intentional reference to 
Eric Idle of Monty Python.


--
Terry Jan Reedy

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


Re: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-02 Thread Grant Edwards
On 2015-10-02, Rob Gaddi  wrote:

> Also, who do I try to report this one to?

I'd try here:

https://github.com/pyserial/pyserial/issues


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


Re: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread paul.hermeneutic
On Oct 2, 2015 12:31 PM, "Kenneth L"  wrote:

> I'm not sure about the plugin route. I'm not looking to build a plug,
lol. Just a finger to point me where to go/start.

Writing a plug-in for an existing open source project would be a good
starting point to see how others have approached graphics applications. You
probably have something good to contribute to the community.

You might start by searching pypi.python.org for "graphics" to see if
something there  catches your interest.
-- 
https://mail.python.org/mailman/listinfo/python-list


Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-02 Thread Rob Gaddi
So, this is odd.  I'm running Ubuntu 14.04, and my system did a kernel 
upgrade from the repository from 3.13.0-63-generic to 3.13.0-65-generic.  
And pyserial (2.7, installed through pip) stopped working.

Specifically, when I make read() calls on a Serial object, I get the error

serial.serialutil.SerialException: device reports readiness to read but 
returned no data (device disconnected?)

This comes from the PosixSerial.read() method in serialposix.py, and 
seems to be a result of the select.select call screwing up.

I reboot under 3.13.0-63-generic.  My code works.  I reboot under 
3.13.0-65-generic.  My code doesn't.  Implication would seem to be that 
somehow between these kernel versions, the select() logic in the serial 
driver changed.  This happens regardless of whether the serial port is 
real, FTDI USB-UART, or Prolific USB-UART.

Can anyone else confirm?  Also, who do I try to report this one to?

Thanks,
Rob

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Terry Reedy

On 10/2/2015 12:41 PM, Kenneth L wrote:

I'm a graphic designer. I'm new to Python. I know html, css, alittle
actioscript and little javascript. I actually build an iOS using
Flash. I understand programming concepts I believe.

I'd like to build a Illustrator/Photoshop like program. Why, there
are some features that I'd like to personally have. Example,
randomizing the rotation, line height and sizing of text. You have to
do this manually. It would be cool have a little program that is
dedicated building logos. Not trying to reinvent the wheel. Just
basic featuring of vector graphics program plus my enhancements.
Maybe this program could be base and it can export vector and bring
into Photoshop to add finishing touches.

I heard Python is easy to learn. So my question is Python able to do
this or connect with libraries? Plus where do I start? I watched
python tutorials but they don't really show you how to build an
application. How does one build a graphics program? LOL where do you
start? How do you draw graphics on the screen?


Python comes with the tkinter package, which interfaces to the tcl/tk 
GUI framework.  Tk has a canvas widget that is, I believe, at least 
partly vector-based.  In any case, it can output .ps or .eps postscript 
files* and with an extension# .svg scalable vector graphics files.


* They may or may not be readable by any other particular app.
# I do not know how to install this, but have read that it exists.

To get an intro to using tkinter, I would start with the beginning 
example in the tkinter doc or

http://www.tkdocs.com/  or
http://effbot.org/tkinterbook/

There are other GUI packages you can download and install.  And the 
other suggestions people have given.


--
Terry Jan Reedy

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


Re: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Mark Lawrence

On 02/10/2015 19:25, Kenneth L wrote:

Well 15 years ago when I was 15 I wanted to model cars in 3D. It took me 100 
hours and 5-10 years but I can modeling a realistic vehicle and other objects 
in 3d. It was time consuming and challenging but it was worth it. And honestly 
I've used my 3d modeling skills to build displays and products. It has helped 
me land jobs and keep jobs. It was a hobby.

I'm not afraid of the hard work. I just didn't know were to begin. If this 
takes me a few years that's fine, lol. I have 20-40 years on earth, hopefully.

I'm not sure about the plugin route. I'm not looking to build a plug, lol. Just 
a finger to point me where to go/start.

1&2 sound good to me.



Please quote some context, you'll get a lot more help here if you do. 
Following threads can get tricky when there are sometimes hundreds of 
replies.


That said with existing programming skills I'd recommend starting out 
with Python 3, with this http://www.diveintopython3.net/ as good a place 
as any.  If that doesn't suit you feel free to come back, stating why 
and we'll find you an alternative.


--
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: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Mark Lawrence

On 02/10/2015 18:39, Grant Edwards wrote:

On 2015-10-02, Kenneth L  wrote:


I'm a graphic designer. I'm new to Python. I know html, css, alittle
actioscript and little javascript. I actually build an iOS using
Flash. I understand programming concepts I believe.



I'd like to build a Illustrator/Photoshop like program.


Holy Cow.

I'd like to build something just like the Brooklyn Bridge, only with
more lanes.

I've got a shovel.

And some bricks and wire.

I know how to stack the two bricks one on top of another.

What do I do next?

I'm just confused.



Make allowance for the number of guys who will die of the bends?

--
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: DistutilsPlatformError

2015-10-02 Thread Mark Lawrence

On 02/10/2015 20:35, garyr wrote:

I'm trying to build an extension for Python 3. I'm using the example code in
the
book "Python Essential Reference", 4ed. I have it working for Python 2. But
when
I try to build it for Python 3 I get the following error:

distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 10.0 is
required (
Unable to find vcvarsall.bat).

How can this be fixed?

I'm using Python 3.4.3, obtained from Anaconda, on Win XP

Thanks in advance
garyr



https://docs.python.org/devguide/setup.html#windows

--
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: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Ian Kelly
On Fri, Oct 2, 2015 at 12:27 PM, Kenneth L  wrote:
> I tried to use gimp but as a photoshop user it was horrible. I was trying to 
> like it. That is a great idea tearing down gimp. that is how I learn html and 
> css. Breakin down websites.

What about Inkscape? It's a lot friendlier than GIMP, and it sounds
like you're only really interested in vector graphics anyway. Inkscape
is also open source and also extensible with Python.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Bartc

On 02/10/2015 21:23, Kenneth L wrote:


And I didn't get that by going basic. Keep your advice Bartc.


OK, I will. Although I'm now curious as to what advice you /do/ want.

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


Re: Python 3.5.0 (32-bit) Setup error

2015-10-02 Thread Denis McMahon
On Fri, 02 Oct 2015 12:32:14 +1000, Hadassah Harland wrote:

> The python for windows setup program is constantly opening on my
> computer,
> every couple seconds. Nothing I can do will make it stop. Please, make
> it stop.

Based on the comprehensive and thorough information that you have given, 
I have waved my magic wand. If this didn't work, the information you 
supplied was insufficient.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Kenneth L
No don't tell me what to do. I joined the military 3 years ago. You wouldn't 
believe the stuff I wasn't able to do before but now I am. You can keep your 
advice to yourself. I wasn't asking for something simple. I was asking for a 
starting point. The 3d was to show you I've learned hard stuff and it didn't 
scare me. I was building web pages when I was in grade school late 90s. I had 
no idea how to build an iPhone app but I created one, lol.

I want to build a graphics program or even a prototype. Maybe I can pass it 
over to a expert and hire then to build it. I have a dozen degree and 
certificates on my wall. And I didn't get that by going basic. Keep your advice 
Bartc.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Bartc

On 02/10/2015 17:41, Kenneth L wrote:

I actually build an iOS using Flash.


What does that mean? That you built an Apple-like operating system using 
Flash?



I'd like to build a Illustrator/Photoshop like program.


You've probably got the message by now that that is not trivial.


Maybe this program could be base and it can export vector and bring into 
Photoshop to add finishing touches.


Yes, I did something like that (but many years ago with not so many 
libraries). Users took my 3D vector output and used 3D Studio to render it.


Still, even an application that does the basic stuff will be a long, 
hard slog to do, and most of it is going to be concerned with a million 
uninteresting details, probably GUI-related.



I heard Python is easy to learn. So my question is Python able to do this or 
connect with libraries? Plus where do I start? I watched python tutorials but 
they don't really show you how to build an application. How does one build a 
graphics program? LOL where do you start? How do you draw graphics on the 
screen?


In that case you're probably being over-ambitious. One problem with 
Python is that it can be quite slow when it needs to do detailed things 
itself, and it has to rely on libraries written in other, faster 
languages. If what you want to do can't be directly done by calling a 
series of such library functions, then you would really need to code in 
another language.



I'm just confused.


Try something much simpler first.

--
Bartc

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


DistutilsPlatformError

2015-10-02 Thread garyr
I'm trying to build an extension for Python 3. I'm using the example code in 
the
book "Python Essential Reference", 4ed. I have it working for Python 2. But 
when
I try to build it for Python 3 I get the following error:

distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 10.0 is 
required (
Unable to find vcvarsall.bat).

How can this be fixed?

I'm using Python 3.4.3, obtained from Anaconda, on Win XP

Thanks in advance
garyr

-
# setup.py
from setuptools import setup, Extension

setup(name="example",
version = "1.0",
ext_modules = [ Extension("_example", ["pyexample.c", "example.c"])
]
)


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


Re: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Random832
And right after I posted this I found all the stuff mentioning someone
had hijacked the name and added spyware... sorry...

On Fri, Oct 2, 2015, at 14:57, Random832 wrote:
> On Fri, Oct 2, 2015, at 14:27, Kenneth L wrote:
> > I tried to use gimp but as a photoshop user it was horrible.
> 
> This is off-topic, but have you tried Gimpshop?
> -- 
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Random832
On Fri, Oct 2, 2015, at 14:27, Kenneth L wrote:
> I tried to use gimp but as a photoshop user it was horrible.

This is off-topic, but have you tried Gimpshop?
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: I'm using Sphinx, but is there a UML auto generator

2015-10-02 Thread Albert-Jan Roskam
(Sorry for top-posting, mobile hotmail sie sucks). This is cool, although it's 
not a Sphinx directive. You use insert the resulting graph in the .rst of 
course:
http://furius.ca/snakefood/

Date: Fri, 2 Oct 2015 11:14:59 -0300
Subject: I'm using Sphinx, but is there a UML auto generator
From: gilcanmach...@gmail.com
To: python-list@python.org

Hi,

I'm using Sphinx as a doc tool.

Amazing.

But I need a way to describe, for example, that, inside a Person class, there's 
a method called changePassword which depends of the execution of the method 
checkPermissions, and checkPermissions depends on the execution of two other 
methods.

I'm using a graphic tool like OpenDraw to do the job, but I guess there's a 
better way of doing this.

Is there any UML auto generator for python that do that?

If not, any suggestion?

By the way, I don't know UML (only the very basic stuff), I'm only trying to 
find a good way to describe the methods relations inside my class.

[]
Gil



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


Re: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Kenneth L
I tried to use gimp but as a photoshop user it was horrible. I was trying to 
like it. That is a great idea tearing down gimp. that is how I learn html and 
css. Breakin down websites.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Kenneth L
Well 15 years ago when I was 15 I wanted to model cars in 3D. It took me 100 
hours and 5-10 years but I can modeling a realistic vehicle and other objects 
in 3d. It was time consuming and challenging but it was worth it. And honestly 
I've used my 3d modeling skills to build displays and products. It has helped 
me land jobs and keep jobs. It was a hobby.

I'm not afraid of the hard work. I just didn't know were to begin. If this 
takes me a few years that's fine, lol. I have 20-40 years on earth, hopefully.

I'm not sure about the plugin route. I'm not looking to build a plug, lol. Just 
a finger to point me where to go/start.

1&2 sound good to me.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about regular expression

2015-10-02 Thread Denis McMahon
On Wed, 30 Sep 2015 23:30:47 +, Denis McMahon wrote:

> On Wed, 30 Sep 2015 11:34:04 -0700, massi_srb wrote:
> 
>> firstly the description of my problem. I have a string in the following
>> form: .
> 
> The way I solved this was to:
> 
> 1) replace all the punctuation in the string with spaces
> 
> 2) split the string on space
> 
> 3) process each thing in the list to test if it was a number or word
> 
> 4a) add words to the dictionary as keys with value of a default list, or
> 4b) add numbers to the dictionary in the list at the appropriate
> position
> 
> 5) convert the list values of the dictionary to tuples
> 
> It seems to work on my test case:
> 
> s = "fred jim(1) alice tom (1, 4) peter (2) andrew(3,4) janet( 7,6 )
> james ( 7 ) mike ( 9 )"
> 
> d = {'mike': (9, 0), 'janet': (7, 6), 'james': (7, 0), 'jim': (1, 0),
> 'andrew': (3, 4), 'alice': (0, 0), 'tom': (1, 4), 'peter': (2, 0),
> 'fred':
> (0, 0)}

Oh yeah, the code:

#!/usr/bin/python

import re

s = 'fred jim(1) alice tom (1, 4) peter (2) andrew(3,4) janet( 7,6 ) james
( 7 ) mike ( 9 ) jon  (  6  ,  3  )   charles(0,12)'

bits = s.replace('(', ' ').replace(',', ' ').replace(')', ' ').split(' ')

d = {}

namep = re.compile('^[A-Za-z]+$')
numbp = re.compile('^[0-9]+$')

for bit in bits:
if namep.match(bit):
d[bit] = [0,0]
w = bit
nums = 0
if numbp.match(bit):
n = int(bit)
d[w][nums] = n
nums += 1

d = {x:tuple(d[x]) for x in d}

print s
print d

It uses regex to determine if the list element being processed is a name 
or a number, which makes for 2 very simple patterns.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Grant Edwards
On 2015-10-02, Kenneth L  wrote:

> I'm a graphic designer. I'm new to Python. I know html, css, alittle
> actioscript and little javascript. I actually build an iOS using
> Flash. I understand programming concepts I believe.

> I'd like to build a Illustrator/Photoshop like program.

Holy Cow.

I'd like to build something just like the Brooklyn Bridge, only with
more lanes.

I've got a shovel.

And some bricks and wire.

I know how to stack the two bricks one on top of another.

What do I do next?

I'm just confused.

-- 
Grant Edwards   grant.b.edwardsYow! PUNK ROCK!!  DISCO
  at   DUCK!!  BIRTH CONTROL!!
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Laura Creighton
In a message of Fri, 02 Oct 2015 09:41:16 -0700, Kenneth L writes:

>I'd like to build a Illustrator/Photoshop like program. Why, there
 are some features that I'd like to personally have. Example,
 randomizing the rotation, line height and sizing of text. You have to
 do this manually. It would be cool have a little program that is
 dedicated building logos. Not trying to reinvent the wheel. Just
 basic featuring of vector graphics program plus my enhancements.


Do you know about GIMP?
http://www.gimp.org/

You can script it with Python.
http://www.gimp.org/docs/python/

Note: Play with GIMP first.  A whole lot.  Then learn Python -- a bit
with a tutorial here:
https://wiki.python.org/moin/BeginnersGuide/Programmers
or maybe here:
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers

or -- well, these days there are plenty more that aren't on either of
those lists.

Then try to script gimp using python.
It's not the ideal place to learn how to program in Python, as
the Python in the examples there is fairly atypical for normal
Python programs, but it works ...

Welcome, welcome!

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


Re: Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Chris Angelico
On Sat, Oct 3, 2015 at 2:41 AM, Kenneth L  wrote:
> I'm a graphic designer. I'm new to Python. I know html, css, alittle 
> actioscript and little javascript. I actually build an iOS using Flash. I 
> understand programming concepts I believe.
>
> I'd like to build a Illustrator/Photoshop like program. Why, there are some 
> features that I'd like to personally have. Example, randomizing the rotation, 
> line height and sizing of text. You have to do this manually. It would be 
> cool have a little program that is dedicated building logos. Not trying to 
> reinvent the wheel. Just basic featuring of vector graphics program plus my 
> enhancements.
> Maybe this program could be base and it can export vector and bring into 
> Photoshop to add finishing touches.
>
> I heard Python is easy to learn. So my question is Python able to do this or 
> connect with libraries? Plus where do I start? I watched python tutorials but 
> they don't really show you how to build an application. How does one build a 
> graphics program? LOL where do you start? How do you draw graphics on the 
> screen?
>
> I'm just confused.

You basically have three options here.

1) Completely write a Photoshop-like program from scratch. There are
libraries that can do the heavy lifting for you (Pillow comes to
mind), but you'd be writing a big and complex UI. This is a huge job.
I recommend not doing this.

2) Find an existing open-source program that does what you want, and
hack on it; or find an existing program that has a plugin/extension
system, and write a plugin. This is a great option if one exists, but
bear in mind that you might have your choices restricted somewhat (eg
you might have to use a specific programming language, or you might
have to fit everything into a single menu item, etc).

3) Build a preprocessor or postprocessor for your images. You'd do
most of your work in a well-known program, and then when you get to
the very last step, you run your output file through a post-processor
(or you run your input files through a preprocessor prior to importing
them). This can work really well in some situations, but it isn't so
great for interactive work. But it's fairly straight-forward; you can
define your program purely in terms of its inputs and outputs, and you
can write it in any language you like.

Have a look into those options, and see what kind of job you're taking
on. (Hint: Options 2 and 3 are *much* smaller jobs than option 1 will
be.) Then decide whether it's within your time budget (don't forget
that you might have to learn some new technologies), and whether it'll
be worth the effort (and it's always more effort than you first think
it will be). And maybe, even if it's not really worth the effort,
it'll be enough fun that you barge ahead and do it anyway :)

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


Newbie: Designer Looking to Build Graphics Editor (PS/AI)

2015-10-02 Thread Kenneth L
I'm a graphic designer. I'm new to Python. I know html, css, alittle 
actioscript and little javascript. I actually build an iOS using Flash. I 
understand programming concepts I believe.

I'd like to build a Illustrator/Photoshop like program. Why, there are some 
features that I'd like to personally have. Example, randomizing the rotation, 
line height and sizing of text. You have to do this manually. It would be cool 
have a little program that is dedicated building logos. Not trying to reinvent 
the wheel. Just basic featuring of vector graphics program plus my enhancements.
Maybe this program could be base and it can export vector and bring into 
Photoshop to add finishing touches.

I heard Python is easy to learn. So my question is Python able to do this or 
connect with libraries? Plus where do I start? I watched python tutorials but 
they don't really show you how to build an application. How does one build a 
graphics program? LOL where do you start? How do you draw graphics on the 
screen?

I'm just confused.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I'm using Sphinx, but is there a UML auto generator

2015-10-02 Thread Littlefield, Tyler
> You can use Graphvix and Plant UML from inside Sphinx.
> http://build-me-the-docs-please.readthedocs.org/en/latest/Using_Sphinx/UsingGraphicsAndDiagramsInSphinx.html
> 
> Laura
> 

Keep this in mind: However you write your docs, they should be
accessible for everyone to use. That is to say, screen readers should be
able to use them as well--perhaps try explaining this dependency in a
format across all the docs in text as well?
HTH,
-- 
Take care,
Ty
twitter: @sorressean
web:http://tysdomain.com
pubkey: http://tysdomain.com/files/pubkey.asc
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pandas Left Merge with xlsx with CSV producing null value columns in output

2015-10-02 Thread kbtyo
On Thursday, October 1, 2015 at 7:47:18 PM UTC-4, Mark Lawrence wrote:
> On 01/10/2015 16:03, kbtyo wrote:
> > I would appreciate any feedback on the following question that I have 
> > raised here:
> >
> > http://stackoverflow.com/questions/32889129/pandas-left-merge-with-xlsx-with-csv-producing-null-value-columns-in-output
> >
> > Thank you for your feedback and support.
> >
> 
> I was going to suggest that you ask on the pandas mailing list/google 
> group, but as you've all ready done so, is there anywhere that you 
> haven't asked?  Is there a subreddit for pandas you could also try just 
> in case?

I appreciate the suggestion. I was able to solve the issue. Thank you again. 

> 
> -- 
> 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: I'm using Sphinx, but is there a UML auto generator

2015-10-02 Thread Laura Creighton
In a message of Fri, 02 Oct 2015 11:14:59 -0300, Gilcan Machado writes:
>Hi,
>
>I'm using Sphinx as a doc tool.
>
>Amazing.
>
>But I need a way to describe, for example, that, inside a Person class,
>there's a method called changePassword which depends of the execution of
>the method checkPermissions, and checkPermissions depends on the execution
>of two other methods.
>
>I'm using a graphic tool like OpenDraw to do the job, but I guess there's a
>better way of doing this.
>
>Is there any UML auto generator for python that do that?
>
>If not, any suggestion?
>
>By the way, I don't know UML (only the very basic stuff), I'm only trying
>to find a good way to describe the methods relations inside my class.
>
>[]
>Gil
>
>-- 
>https://mail.python.org/mailman/listinfo/python-list

You can use Graphvix and Plant UML from inside Sphinx.
http://build-me-the-docs-please.readthedocs.org/en/latest/Using_Sphinx/UsingGraphicsAndDiagramsInSphinx.html

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


I'm using Sphinx, but is there a UML auto generator

2015-10-02 Thread Gilcan Machado
Hi,

I'm using Sphinx as a doc tool.

Amazing.

But I need a way to describe, for example, that, inside a Person class,
there's a method called changePassword which depends of the execution of
the method checkPermissions, and checkPermissions depends on the execution
of two other methods.

I'm using a graphic tool like OpenDraw to do the job, but I guess there's a
better way of doing this.

Is there any UML auto generator for python that do that?

If not, any suggestion?

By the way, I don't know UML (only the very basic stuff), I'm only trying
to find a good way to describe the methods relations inside my class.

[]
Gil
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PySide window does not resize to fit screen

2015-10-02 Thread Chris Warrick
On 2 October 2015 at 15:10, Hedieh Ebrahimi  wrote:
> Thanks Laura,
>
> In my user interface I have many group boxes that are located inside the main 
> widget. All the group boxes and their child widgets have fixed sizes.
>
> How can I use the width and height I get from availableGeometry or 
> ScreenGeometry to multiply
>
> screenGeometry = QApplication.instance().desktop().screenGeometry()
> availGeometry = QApplication.instance().desktop().availableGeometry()
> width, height = availGeometry.width(), availGeometry.height()
>
> to resize my geometry by a ratio? Is this a good approach?
> --
> https://mail.python.org/mailman/listinfo/python-list

This is NOT a good approach.  A good approach involves using a layout.
See my previous e-mail for details.

Geometry is not going to help you here, especially since you would
need a ton of code to resize everything on **any** window size change
event.  And you especially do not need the screen size, because it
would still hinder changing window sizes.

-- 
Chris Warrick 
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PySide window does not resize to fit screen

2015-10-02 Thread Hedieh Ebrahimi
Thanks Laura, 

In my user interface I have many group boxes that are located inside the main 
widget. All the group boxes and their child widgets have fixed sizes. 

How can I use the width and height I get from availableGeometry or 
ScreenGeometry to multiply 

screenGeometry = QApplication.instance().desktop().screenGeometry() 
availGeometry = QApplication.instance().desktop().availableGeometry() 
width, height = availGeometry.width(), availGeometry.height() 

to resize my geometry by a ratio? Is this a good approach?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results)

2015-10-02 Thread Chris Warrick
On 2 October 2015 at 01:59, Terry Reedy  wrote:
> On 10/1/2015 12:26 PM, Chris Warrick wrote:
>>
>> The Nikola developers decided to deprecate Python 2.7 support.
>> Starting with v7.7.2, Nikola will display a warning if Python 2.7 is
>> used (but it will still be fully supported). In early 2016, Nikola
>> v8.0.0 will come out, and that release will not support Python 2.7
>> officially.
>
>
> How sane ;-)
>
>> The decision was made on the basis of a user survey, with 138
>> participants. The vast majority of them claimed that they either use
>> Python 3 already, or can switch really easily.
>
>
> From the survey and description below, 'using Python 3' means having Python
> 3 installed, not writing Python 3 code.  Correct?

Correct. We asked about Nikola users, who don’t really have to write
any Python code.  This is, however, an useful information for OSS
developers, who want to know if they can/should target Python 3
instead of Python 2.

-- 
Chris Warrick 
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.5.0 (32-bit) Setup error

2015-10-02 Thread Laura Creighton
In a message of Fri, 02 Oct 2015 20:59:58 +1000, Hadassah Harland writes:
>[image: Inline image 1]
>For further clarification, this pop-up keeps appearing every time i use
>pycharm, it will restart every couple of seconds. If I choose repair, it
>will start a repair and while the repair is going it will open again, and
>without another response, after about a second will close itself and
>reopen, centre page every time. The program has rendered my computer
>unusable while pycharm is open.
>
>Regards, Hadassah

PyCharm is made by JetBrains, an independent company.  You will
have to talk to them about your problem.
https://intellij-support.jetbrains.com/hc/en-us

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


Re: Create a .lua fle from Python

2015-10-02 Thread Stefan Behnel
jmp schrieb am 02.10.2015 um 11:03:
> Safety is like speed optimization, you care about it only when it can be a
> problem. And the vast majority (there's a recent trolling thread about the
> equivalent percentage of vast majority if you want to have fun) of python
> code may run on trusted networks. Meaning it's probable you are wrong when
> assuming security of a python snippet is a concern.

Writing code "for internal use only" is ok, but there is never a guarantee
that some of that code won't be reused elsewhere, in an entirely different
context. Or that someone comes up with the idea of adding a REST API
frontend, now that there is a command line interface [1]. If that happens,
I assure you that at least in some cases (be it the "vast majority" or not)
there will be no thorough security audit up-front. Because, you know - it's
code that works and is production proven already. Possibly for years and
years, and through generations of employees, all experienced and trusted.
What can possibly be wrong with such code?

So, it's acceptable to write such code under certain conditions, but at
least someone should leave a visible comment somewhere (as Peter rightfully
did in this case) that the input is not safely validated, so that future
generations of programmers can see immediately that a) security hasn't been
a concern when writing it and b) the author was in fact not a complete
moron, not knowing a bit about the basics of input validation.

It really helps in trust building to find such comments from time to time.

Stefan



[1] mainframes on the Internet, anyone?


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


Re: Only getting the first 6 lines

2015-10-02 Thread Cecil Westerhof
On Friday  2 Oct 2015 09:37 CEST, Peter Otten wrote:

> Cecil Westerhof wrote:
>
>> I want to get the first 6 lines of ps output. For this I use:
>> 
>> from subprocess import check_output
>>
>> ps_command = ('ps', '-eo',
>> 'user,pid,pcpu,pmem,stat,start,time,cmd', '--sort') message =
>> '\n'.join(check_output(ps_command +
>> ('-%cpu',)).decode("utf-8").splitlines()[0:6])
>> 
>>
>> It works, but does not look very efficient. Is there a better way
>> to do this?
>
> Efficiency be damned, readability counts ;)

The second is more important as the first, but if you can have both …
:-)

I already made a function for it. See my other response.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Only getting the first 6 lines

2015-10-02 Thread Cecil Westerhof
On Friday  2 Oct 2015 00:50 CEST, Cameron Simpson wrote:

> On 01Oct2015 23:58, Cecil Westerhof  wrote:
>> I want to get the first 6 lines of ps output. For this I use:
>> 
>> from subprocess import check_output
>>
>> ps_command = ('ps', '-eo',
>> 'user,pid,pcpu,pmem,stat,start,time,cmd', '--sort') message =
>> '\n'.join(check_output(ps_command +
>> ('-%cpu',)).decode("utf-8").splitlines()[0:6])
>> 
>>
>> It works, but does not look very efficient. Is there a better way
>> to do this?
>
> It depends what you mean by inefficient. I'm presuming you mean that
> this:
>
> - sucks in all the output of ps instead of just the first 6 lines
>
> - sucks all the output into memory instead of just some of it
>
> - does more in-memory work in splitlines()

Yes.


> - needs ps to run to completion instead of just long enough to print
>   6 lines

No, because of the sort, ps has to generate all lines.
>
> You could just read six lines of output from ps. Something like this
> (untested):
>
>
> lines = []
> for lineno, line in \
> enumerate(Popen(ps_command + ('-%cpu',),
> stdin=NULL, stdout=PIPE).stdout,
> 1):
> lines.append(line.decode("utf-8"))
> if lineno >= 6:
> break


I wrote the following general function for it:

def log_resource_usage(command, resource_type, nr_of_lines):
lines   = []
process = Popen(command, stdin = None, stdout = PIPE, stderr = None)
for lineno, line in enumerate(process.stdout, 1):
lines.append(line.decode('utf-8').strip())
if lineno >= nr_of_lines:
break
message = '\n'.join(lines)
cursor.execute(insert_message, (resource_type, message))
process.wait()



> This approach is important if the output of your command is large or
> slow, as it does not need to suck the whole thing into memory or to
> wait for it to finish a long procedure. With "ps" these issues are
> pretty minor; with some other programs it can be significant,
> especially if the other program _doesn't_ terminate (consider "tail
> -f" of an active log file).

Well ps generates more as 400 lines. Not a real problem, but I like to
solve problems before they become a problem. ;-)

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: compiling matplotlib in virtual env

2015-10-02 Thread bayang
I ran into the same issue.
Check here
http://stackoverflow.com/questions/27024731/matplotlib-compilation-error-typeerror-unorderable-types-str-int
It worked for me on python 3 with virtualenv in ubuntu .  Libfreetype was
missing.
Le 2 oct. 2015 10:43, "Laura Creighton"  a écrit :

> Lots of egg problems can be fixed if you pip install this
> package first.
>
> https://pypi.python.org/pypi/ez_setup
>
> However, you are trying to install matplotlib.
> Your distro should have it already as a package (python-matplotlib
> perhaps?  python3-matplotlib perhaps?) and you may want to get
> it from there.  If you don't want to get it from there, you may
> want to use conda instead of pip/easy_install and so on.
> http://conda.pydata.org/docs/intro.html
>
> If the scientific python stack, and not just matplotlib is in
> your future, just use conda.  It is so much easier.
>
> Laura
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Create a .lua fle from Python

2015-10-02 Thread jmp

On 10/01/2015 09:12 PM, Steven D'Aprano wrote:

On Wed, 30 Sep 2015 07:21 pm, jmp wrote:


Is Ariel's xml file user-supplied? If so, how does your suggestion
prevent the resulting lua script from executing arbitrary code?


It does not. Like it doesn't fulfill the millions of possible
requirements the OP could have written but did not. What if the OP want
a thread safe, super fast, multi core solution distributed on multiple
remote hosts ?


Then he should have said so.

We are not *required* to guess every last requirement that somebody might
have but didn't mention. But we do have a professional[1] duty of care to
warn an *obvious beginner* that he may be introducing a serious security
vulnerability into his code.


I agree with you and to some extend to Peter's answer, my solution is 
not safe but note that I didn't mean it to be nor did I claimed it was safe.


What I disagree with, is the suggestion that I should provide a safe 
version of my solution, just in case the OP forgot to mention that he 
was going public with his application while a simple "beware this 
solution is not safe" would have sufficed.


Safety is like speed optimization, you care about it only when it can be 
a problem. And the vast majority (there's a recent trolling thread about 
the equivalent percentage of vast majority if you want to have fun) of 
python code may run on trusted networks. Meaning it's probable you are 
wrong when assuming security of a python snippet is a concern.



JM

Note : becoming public on the internet is not even enough for security 
to be a concern. Consider the OP's request, someone around the world 
would need to be willing to hack into the OP's server, guess/find out 
that the xml is able to execute lua and then attack the server for a 
reason yet to be known. If the OP's name is google, yeah someone will 
want to do that. If you're a complete anonymous...


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


Re: compiling matplotlib in virtual env

2015-10-02 Thread Laura Creighton
Lots of egg problems can be fixed if you pip install this
package first.

https://pypi.python.org/pypi/ez_setup

However, you are trying to install matplotlib.
Your distro should have it already as a package (python-matplotlib
perhaps?  python3-matplotlib perhaps?) and you may want to get
it from there.  If you don't want to get it from there, you may
want to use conda instead of pip/easy_install and so on.
http://conda.pydata.org/docs/intro.html

If the scientific python stack, and not just matplotlib is in
your future, just use conda.  It is so much easier.

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


Re: Only getting the first 6 lines

2015-10-02 Thread Peter Otten
Cecil Westerhof wrote:

> I want to get the first 6 lines of ps output. For this I use:
> 
> from subprocess import check_output
> 
> ps_command = ('ps', '-eo', 'user,pid,pcpu,pmem,stat,start,time,cmd',
> '--sort') message = '\n'.join(check_output(ps_command +
> ('-%cpu',)).decode("utf-8").splitlines()[0:6])
> 
> 
> It works, but does not look very efficient. Is there a better way to
> do this?

Efficiency be damned, readability counts ;)

With that in mind here's a little code cleanup:

 
import subprocess

def text_head(text, n):
return "\n".join(text.split("\n", n)[:n])

def ps(sort=None):
cmd = ['ps', '-eo', 'user,pid,pcpu,pmem,stat,start,time,cmd']
if sort is not None:
cmd += ["--sort", sort]
return subprocess.check_output(cmd, universal_newlines=True)

if __name__ == "__main__":
print(text_head(ps("-%cpu"), 6))

For long strings and small n text.split(\n", n)[:n] is a bit faster than 
text.splitlines()[n]

$ wc -l fodder.txt
969 fodder.txt
$ python3 -m timeit -s 'text = open("fodder.txt").read()' 'text.split("\n", 
6)[:6]'
10 loops, best of 3: 7.54 usec per loop
$ python3 -m timeit -s 'text = open("fodder.txt").read()' 'text.splitlines()
[:6]'
1000 loops, best of 3: 215 usec per loop

but the effect on the total time to run the code should be negligable.

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


Re: Check if a given value is out of certain range

2015-10-02 Thread Ian Kelly
On Thu, Oct 1, 2015 at 3:45 PM, John Gordon  wrote:
> In <87r3le1ht3@elektro.pacujo.net> Marko Rauhamaa  
> writes:
>
>> > I wasn't commenting directly to the "ask not..." quote; I was
>> > referring upthread to the choice between
>> >
>> > not 0 <= x <= 10
>> >
>> > and
>> >
>> > x < 0 or x > 10
>> >
>> > Both are of course understandable, but in my opinion, the latter one
>> > takes slightly less effort to grok.
>
>> Wouldn't
>
>>x < 0 or 10 < x
>
>> be even more visual?
>
> I don't know what you mean by "more visual".

Visually, it places the x outside the range suggested by 0 and 10,
similarly to how 0 <= x <= 10 places the x inside.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python 3.5.0 (32-bit) Setup error

2015-10-02 Thread Hadassah Harland
The python for windows setup program is constantly opening on my computer,
every couple seconds. Nothing I can do will make it stop. Please, make it
stop.

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