Re: py.test/tox InvocationError

2016-10-17 Thread Stephane Wirtel
You have a conflict with the installed version and the need version of 
coverage. Just fix that.


On 10/16, D.M. Procida wrote:

When I run:

  py.test --cov=akestra_utilities --cov=akestra_image_plugin
--cov=chaining --cov=contacts_and_people --cov=housekeeping --cov=links
--cov=news_and_events --cov=vacancies_and_studentships --cov=video
--cov-report=term-missing example tests

it works quite happily.

When I run tox -e coveralls, which runs the same thing, it raises an
InvocationError.

You can see the same error at
.

Any suggestions on what is different in the two cases?

Thanks,

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


--
Stéphane Wirtel - http://wirtel.be - @matrixise
--
https://mail.python.org/mailman/listinfo/python-list


Re: Writing library documentation?

2016-10-17 Thread Stephane Wirtel


Please, could you read this part: 
http://docs.python-guide.org/en/latest/writing/documentation/


Thank you

On 10/16, tshep...@rcsreg.com wrote:

Is there a standard or best way to write documentation for
a particular python library?  I'd mostly target HTML, I guess.

Thanks!


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


--
Stéphane Wirtel - http://wirtel.be - @matrixise
--
https://mail.python.org/mailman/listinfo/python-list


difference with parenthese

2016-10-17 Thread chenyong20000
Hi,

i'm confused by a piece of code with parenthese as this:

code 1--
>>> def outer():
...   def inner():
... print 'inside inner'
...   return inner
...
>>> foo = outer()
>>> foo

>>> foo()
inside inner



code 2---
>>> def outer():
...   def inner():
... print 'inside inner'
...   return inner()
...
>>> foo = outer()
inside inner
>>> foo
>>> foo()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'NoneType' object is not callable


the difference between these two piece of code is that the code 2 has a "()" 
when "return inner".

My questions are:
(1) what is the function difference between these two pieces of code? what does 
"return inner()" and "return inner" mean?
(2) when foo = outer() is run, why output is defferent for two pieces of code?

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


Re: difference with parenthese

2016-10-17 Thread Wolfgang Maier

On 17.10.2016 10:52, chenyong20...@gmail.com wrote:

Hi,

i'm confused by a piece of code with parenthese as this:

code 1--

def outer():

...   def inner():
... print 'inside inner'
...   return inner
...

foo = outer()
foo



foo()

inside inner



code 2---

def outer():

...   def inner():
... print 'inside inner'
...   return inner()
...

foo = outer()

inside inner

foo
foo()

Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'NoneType' object is not callable


the difference between these two piece of code is that the code 2 has a "()" when 
"return inner".

My questions are:
(1) what is the function difference between these two pieces of code? what does "return 
inner()" and "return inner" mean?
(2) when foo = outer() is run, why output is defferent for two pieces of code?

thanks



I suggest you look at a simpler example first:

def func():
print('inside func')

func()
a = func
b = func()

print(a)
print(b)

and see what that gives you.
There are two things you need to know here:

- functions are callable objects and the syntax to call them (i.e., to 
have them executed) is to append parentheses to their name; without 
parentheses you are only referring to the object, but you are *not* 
calling it


- functions without an explicit return still return something and that 
something is the NoneType object None. So the function above has the 
side-effect of printing inside func, but it also returns None and these 
are two totally different things


Once you have understood this you can try to go back and study your 
original more complicated example.


Best,
Wolfgang

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


Re: Build desktop application using django

2016-10-17 Thread Ned Batchelder
On Sunday, October 16, 2016 at 10:53:45 PM UTC-4, Mario R. Osorio wrote:
> On Sunday, October 16, 2016 at 1:42:23 PM UTC-4, Ayush Saluja wrote:
> > Hello I want to build a desktop application which retrieves data from 
> > server and stores data on server. I have basic experience of python and I 
> > dont know how to build that thing.
> 
> I agree with Martin's suspicion on you having no idea of what the F you are 
> talking about. Nevertheless, I'm throwing in my 2 cents:
> 

Wow, that seems needlessly harsh. :(

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


Making IDLE3 ignore non-BMP characters instead of throwing an exception?

2016-10-17 Thread Adam Funk
I'm using IDLE 3 (with python 3.5.2) to work interactively with
Twitter data, which of course contains emojis.  Whenever the running
program tries to print the text of a tweet with an emoji, it barfs
this & stops running:

  UnicodeEncodeError: 'UCS-2' codec can't encode characters in
  position 102-102: Non-BMP character not supported in Tk

Is there any way to set IDLE to ignore these characters (either drop
them or replace them with something else) instead of throwing the
exception?

If not, what's the best way to strip them out of the string before
printing?

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


Re: difference with parenthese

2016-10-17 Thread chenyong20000
Hi Wolfgang,

thanks for your kind reply. I try to explain what I got from your reply:

for code1, when running "foo = outer()", since outer() is callable, function 
outer() is running and it returns an object, which referring to function 
inner(). When "foo" is running, it indicates it is referring to object inner(). 
When "foo()" is running, object inner() is called, so it prints "inside inner".

for code2, when running "foo = outer()", since outer() is callable, function 
outer() is running and returns results from function inner(), which prints 
"inside inner". so "foo" now is a string, which contains "inside inner". since 
this string isn't a function, foo() will make an error.

Do you think my understanding is right? thanks.


regards
skyworld chen

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


Re: difference with parenthese

2016-10-17 Thread Wolfgang Maier

On 17.10.2016 16:45, chenyong20...@gmail.com wrote:

Hi Wolfgang,

thanks for your kind reply. I try to explain what I got from your reply:

for code1, when running "foo = outer()", since outer() is callable, function outer() is running and it 
returns an object, which referring to function inner(). When "foo" is running, it indicates it is referring 
to object inner(). When "foo()" is running, object inner() is called, so it prints "inside inner".

for code2, when running "foo = outer()", since outer() is callable, function outer() is running and returns 
results from function inner(), which prints "inside inner". so "foo" now is a string, which 
contains "inside inner". since this string isn't a function, foo() will make an error.

Do you think my understanding is right? thanks.


regards
skyworld chen



Not quite. Your understanding of code 1 is correct.
In your example code 2, however:

> code 2---
> >>> def outer():
> ...   def inner():
> ... print 'inside inner'
> ...   return inner()
> ...
> >>> foo = outer()
> inside inner
> >>> foo
> >>> foo()
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: 'NoneType' object is not callable

calling outer returns the result of inner, as you are saying, but that 
result is *not* the string 'inside inner', but None (implicitly 
returned). As I explained before, the printed string is a side-effect of 
the function inner, but it is *not* what that function returns.


So:

foo = outer()

*prints* the string 'inside inner', but sets foo to refer to None. 
That's why the following TypeError mentions NoneType.


Best,
Wolfgang

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


Re: No registration confirmation at https://bugs.python.org/

2016-10-17 Thread Al Schapira
No spam or junk on either email client or server.

On Sun, 2016-10-16 at 11:20 +1100, Steve D'Aprano wrote:
> On Sun, 16 Oct 2016 07:09 am, Al Schapira wrote:
> 
> > 
> > I have tried to register at   https://bugs.python.org/  over a
> > period
> > of many months, and I never receive the confirmation email to
> > complete
> > the process.  Who can help with this?  Thanks.
> > --Al
> Have you checked your Junk Mail folder?
> 
> Unfortunately there are at least four open issues relating to email
> from the
> bug tracker being marked as spam:
> 
> http://psf.upfronthosting.co.za/roundup/meta/
> 
> 
> 
> 
> -- 
> Steve
> “Cheer up,” they said, “things could be worse.” So I cheered up, and
> sure
> enough, things got worse.
> 
-- 
https://mail.python.org/mailman/listinfo/python-list


Meta classes - real example

2016-10-17 Thread Mr. Wrobel

Hi,

I am looking for an example of metaclass usage. Especially I am 
interestet in manipulating instance variables, for example:


My class:
class MrMeta(type):
pass

class Mr(object):
__metaclass__ = MrMeta

def __init__(self):
self.imvariable = 'Zmienna self'

def aome method(self):
print 'I am in instance'

So in general, I would like to create a mechanism, that is changing 
value for self.imvariable to capital letters and this should be included 
in my metaclass called MrMeta(type).


Can you guide me please?

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


Re: Meta classes - real example

2016-10-17 Thread Chris Angelico
On Tue, Oct 18, 2016 at 3:03 AM, Mr. Wrobel  wrote:
> Hi,
>
> I am looking for an example of metaclass usage. Especially I am interestet
> in manipulating instance variables, for example:
>
> My class:
> class MrMeta(type):
> pass
>
> class Mr(object):
> __metaclass__ = MrMeta
>
> def __init__(self):
> self.imvariable = 'Zmienna self'
>
> def aome method(self):
> print 'I am in instance'
>
> So in general, I would like to create a mechanism, that is changing value
> for self.imvariable to capital letters and this should be included in my
> metaclass called MrMeta(type).
>
> Can you guide me please?

Are you sure you can't just use a descriptor, such as @property?

class Mr(object):
@property
def imvariable(self):
return self._imvariable
@imvariable.setter
def imvariable(self, value):
self._imvariable = str(value).upper()

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


Re: Meta classes - real example

2016-10-17 Thread Mr. Wrobel

W dniu 17.10.2016 o 18:16, Chris Angelico pisze:

On Tue, Oct 18, 2016 at 3:03 AM, Mr. Wrobel  wrote:

Hi,

I am looking for an example of metaclass usage. Especially I am interestet
in manipulating instance variables, for example:

My class:
class MrMeta(type):
pass

class Mr(object):
__metaclass__ = MrMeta

def __init__(self):
self.imvariable = 'Zmienna self'

def aome method(self):
print 'I am in instance'

So in general, I would like to create a mechanism, that is changing value
for self.imvariable to capital letters and this should be included in my
metaclass called MrMeta(type).

Can you guide me please?


Are you sure you can't just use a descriptor, such as @property?

class Mr(object):
@property
def imvariable(self):
return self._imvariable
@imvariable.setter
def imvariable(self, value):
self._imvariable = str(value).upper()

ChrisA


Hi,

I am sure that I can do that with setter/getter, but I want to be closer 
to black magic, that is why I wanted to inlcude Metaclasses.


I know how to acomplish that for class variables, but don;t have any 
idea how to instance.


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


Re: Build desktop application using django

2016-10-17 Thread John Gordon
In  
ayuchitsalu...@gmail.com writes:

> Hello I want to build a desktop application which retrieves data from
> server and stores data on server. I have basic experience of python and
> I dont know how to build that thing.

The term "desktop application" generally means something which runs
locally on your computer, such as Microsoft Word or a game.

But Django is for building websites, not local applications.

So Django probably isn't what you want.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: Python Data base help

2016-10-17 Thread Brandon McCaig
(Apologies for the old thread reviving)

On Sun, Oct 09, 2016 at 09:27:11PM +0200, Irmen de Jong wrote:
> What is your 'database'?
> >From the little information you provided it seems that it is just a text 
> >file where
> every drone measurement is on a line. So simply read every line and check if 
> the time
> entered is in that line, then print it.

On the other hand, if your "database" really is just a text file
and you want to find the records that match a strict time string
there's already a fast native utility for this available: grep
(*nix) or findstr (Windows).

The advantage being that you could search for more than just the
time. It's still limited to only textual matches, not smart
matches (e.g., ranges). In the end, a custom program will be more
powerful to process the data.

Alternatively, if the data is a text file and you want to query
it regularly, consider learning a bit about SQL and sqlite3 and
import the data into a "real" database first. Then you'll get the
full expressive power of a query language and the performance
improvements of binary data and indexing (if you tune it right).

Regards,


-- 
Brandon McCaig  
Castopulence Software 
Blog 
perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'

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


Re: Making IDLE3 ignore non-BMP characters instead of throwing an exception?

2016-10-17 Thread Adam Funk
On 2016-10-17, Adam Funk wrote:

> I'm using IDLE 3 (with python 3.5.2) to work interactively with
> Twitter data, which of course contains emojis.  Whenever the running
> program tries to print the text of a tweet with an emoji, it barfs
> this & stops running:
>
>   UnicodeEncodeError: 'UCS-2' codec can't encode characters in
>   position 102-102: Non-BMP character not supported in Tk
>
> Is there any way to set IDLE to ignore these characters (either drop
> them or replace them with something else) instead of throwing the
> exception?
>
> If not, what's the best way to strip them out of the string before
> printing?

Well, to answer part of my own question, this works for stripping them
out:

 s = ''.join([c for c in s if ord(c)<65535])



-- 
Master Foo said: "A man who mistakes secrets for knowledge is like
a man who, seeking light, hugs a candle so closely that he smothers
it and burns his hand."--- Eric Raymond
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Making IDLE3 ignore non-BMP characters instead of throwing an exception?

2016-10-17 Thread eryk sun
On Mon, Oct 17, 2016 at 2:20 PM, Adam Funk  wrote:
> I'm using IDLE 3 (with python 3.5.2) to work interactively with
> Twitter data, which of course contains emojis.  Whenever the running
> program tries to print the text of a tweet with an emoji, it barfs
> this & stops running:
>
>   UnicodeEncodeError: 'UCS-2' codec can't encode characters in
>   position 102-102: Non-BMP character not supported in Tk
>
> Is there any way to set IDLE to ignore these characters (either drop
> them or replace them with something else) instead of throwing the
> exception?
>
> If not, what's the best way to strip them out of the string before
> printing?

You can patch print() to transcode non-BMP characters as surrogate
pairs. For example:

import builtins

def print_ucs2(*args, print=builtins.print, **kwds):
args2 = []
for a in args:
a = str(a)
if max(a) > '\u':
b = a.encode('utf-16le', 'surrogatepass')
chars = [b[i:i+2].decode('utf-16le', 'surrogatepass')
 for i in range(0, len(b), 2)]
a = ''.join(chars)
args2.append(a)
print(*args2, **kwds)

builtins._print = builtins.print
builtins.print = print_ucs2

On Windows this should allow printing non-BMP characters such as
emojis (e.g. U+0001F44C). On Linux it prints a non-BMP character as a
pair of empty boxes. If you're not using Windows you can modify this
to print something else for non-BMP characters, such as a replacement
character or \U literals.
-- 
https://mail.python.org/mailman/listinfo/python-list


New to python

2016-10-17 Thread Bill Cunningham
I just installed python I might start with 3. But there is version 2 out 
too. So far I can '3+4' and get the answer. Nice. I typed the linux man page 
and got a little info. So to learn this language is there an online 
tutorial? I am interested in the scripting too.

Bill


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


Re: New to python

2016-10-17 Thread Skip Montanaro
> So to learn this language is there an online
> tutorial?

Yup, go to https://docs.python.org/3/ and check out the tutorial links.
Also, if you want useful replies in the future, please provide a valid
email address. A private reply to this particular question would have been
better than bombing the entire list.

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


Re: New to python

2016-10-17 Thread Jan Erik Moström

On 17 Oct 2016, at 21:51, Bill Cunningham wrote:

I just installed python I might start with 3. But there is version 
2 out
too. So far I can '3+4' and get the answer. Nice. I typed the linux 
man page

and got a little info. So to learn this language is there an online
tutorial? I am interested in the scripting too.


I searched the web and the first listed are

http://www.learnpython.org

https://www.python.org/about/gettingstarted/

https://learnpythonthehardway.org/book/

http://www.makeuseof.com/tag/5-websites-learn-python-programming/

(never tried anyone of them)

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


Re: Making IDLE3 ignore non-BMP characters instead of throwing an exception?

2016-10-17 Thread Random832
On Mon, Oct 17, 2016, at 14:20, eryk sun wrote:
> You can patch print() to transcode non-BMP characters as surrogate
> pairs. For example:
> 
> On Windows this should allow printing non-BMP characters such as
> emojis (e.g. U+0001F44C).

I thought there was some reason this wouldn't work with tk, or else
tkinter would do it already?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to python

2016-10-17 Thread breamoreboy
On Monday, October 17, 2016 at 8:51:52 PM UTC+1, Bill Cunningham wrote:
> I just installed python I might start with 3. But there is version 2 out 
> too. So far I can '3+4' and get the answer. Nice. I typed the linux man page 
> and got a little info. So to learn this language is there an online 
> tutorial? I am interested in the scripting too.
> 
> Bill

If you can all ready program I recommend http://www.diveintopython3.net/

Kindest regards.

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


Re: New to python

2016-10-17 Thread justin walters
On Mon, Oct 17, 2016 at 12:51 PM, Bill Cunningham 
wrote:

> I just installed python I might start with 3. But there is version 2 out
> too. So far I can '3+4' and get the answer. Nice. I typed the linux man
> page
> and got a little info. So to learn this language is there an online
> tutorial? I am interested in the scripting too.
>


I highly recommend http://www.composingprograms.com/ if you are new to
programming in general. It teaches basic concepts using Python 3 in the
style of S.I.C.P.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Meta classes - real example

2016-10-17 Thread Ethan Furman

On 10/17/2016 09:23 AM, Mr. Wrobel wrote:

W dniu 17.10.2016 o 18:16, Chris Angelico pisze:

On Tue, Oct 18, 2016 at 3:03 AM, Mr. Wrobel wrote:



I am looking for an example of metaclass usage. Especially I am interestet
in manipulating instance variables, for example:

My class:
class MrMeta(type):
pass

class Mr(object):
__metaclass__ = MrMeta

def __init__(self):
self.imvariable = 'Zmienna self'

def aome method(self):
print 'I am in instance'

So in general, I would like to create a mechanism, that is changing value
for self.imvariable to capital letters and this should be included in my
metaclass called MrMeta(type).

Can you guide me please?


Are you sure you can't just use a descriptor, such as @property?

class Mr(object):
@property
def imvariable(self):
return self._imvariable
@imvariable.setter
def imvariable(self, value):
self._imvariable = str(value).upper()


I am sure that I can do that with setter/getter, but I want to be closer to 
black magic, that is why I wanted to inlcude Metaclasses.

I know how to acomplish that for class variables, but don;t have any idea how 
to instance.


Metaclasses work on the class level, not the instance level.  The only* 
influnce a metaclass is going to have on instances is changes it makes while 
it's creating the class.

For example, MrMeta could set descriptors in Mr when it is creating the Mr 
class; it could even put it's own __init__ in the class; but to affect things 
like instance variables that are added in methods -- well, it is possible, but 
it is *a lot* of work.

--
~Ethan~

* Okay, somebody prove me wrong!  :)
--
https://mail.python.org/mailman/listinfo/python-list


need help for an assignment plz noob here

2016-10-17 Thread pedrorenato1998
Hello guys. so my assignment consists in creating a key generator so i can use 
it in later steps of my work. In my first step i have to write a function 
called key_generator that receives an argument, letters, that consists in a 
tuple of 25 caracters. The function returns a tuple of 5 tuples of caracters, 
each tuple with 5 elements.
 Sounds confusing right? well I have the final product but i dont know how to 
get there. I was told by my professor that I dont really have to use any 
complicated knowledge of python so I have to keep it simple. Can u help me plz? 
just give me a hint how to do it and i'll do everything plz.

example:
Python Shell

>>> letters = (‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’, \
... ‘H’, ‘I’, ‘J’, ‘ ’, ‘L’, ‘M’, ‘N’, \
... ‘O’, ‘P’, ‘Q’, ‘R’, ‘S’, ‘T’, ‘U’, \
... ‘V’, ‘X’, ‘Z’, ‘.’)
>>> key_generator(letters)
... ((‘A’, ‘B’, ‘C’, ‘D’, ‘E’),
... (‘F’, ‘G’, ‘H’, ‘I’, ‘J’),
... (‘ ’, ‘L’, ‘M’, ‘N’, ‘O’),
... (‘P’, ‘Q’, ‘R’, ‘S’, ‘T’),
... (‘U’, ‘V’, ‘X’, ‘Z’, ‘.’))
-- 
https://mail.python.org/mailman/listinfo/python-list


How to creat a function that receives a tuple of characters and returns them in an organised form so I can use it as a key generator

2016-10-17 Thread pedrorenato1998
Hello guys. so my assignment consists in creating a key generator so i can use 
it in later steps of my work. In my first step i have to write a function 
called key_generator that receives an argument, letters, that consists in a 
tuple of 25 caracters. The function returns a tuple of 5 tuples of caracters, 
each tuple with 5 elements. 
 Sounds confusing right? well I have the final product but i dont know how to 
get there. I was told by my professor that I dont really have to use any 
complicated knowledge of python so I have to keep it simple. 
I've tried so many times to reproduce a code that does that but i just cant do 
it! When i google it i only find complicated python concepts that i didnt even 
studied in class. Can u help me plz? just give me a hint how to do it and i'll 
do everything plz. 

example: 
Python Shell 

>>> letters = (‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’, \ 
... ‘H’, ‘I’, ‘J’, ‘ ’, ‘L’, ‘M’, ‘N’, \ 
... ‘O’, ‘P’, ‘Q’, ‘R’, ‘S’, ‘T’, ‘U’, \ 
... ‘V’, ‘X’, ‘Z’, ‘.’) 
>>> key_generator(letters) 
... ((‘A’, ‘B’, ‘C’, ‘D’, ‘E’), 
... (‘F’, ‘G’, ‘H’, ‘I’, ‘J’), 
... (‘ ’, ‘L’, ‘M’, ‘N’, ‘O’), 
... (‘P’, ‘Q’, ‘R’, ‘S’, ‘T’), 
... (‘U’, ‘V’, ‘X’, ‘Z’, ‘.’))
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: need help for an assignment plz noob here

2016-10-17 Thread Rob Gaddi
pedrorenato1...@gmail.com wrote:

> Hello guys. so my assignment consists in creating a key generator so i can 
> use it in later steps of my work. In my first step i have to write a function 
> called key_generator that receives an argument, letters, that consists in a 
> tuple of 25 caracters. The function returns a tuple of 5 tuples of caracters, 
> each tuple with 5 elements.
>  Sounds confusing right? well I have the final product but i dont know how to 
> get there. I was told by my professor that I dont really have to use any 
> complicated knowledge of python so I have to keep it simple. Can u help me 
> plz? just give me a hint how to do it and i'll do everything plz.
>
> example:
> Python Shell
>
 letters = (‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’, \
> ... ‘H’, ‘I’, ‘J’, ‘ ’, ‘L’, ‘M’, ‘N’, \
> ... ‘O’, ‘P’, ‘Q’, ‘R’, ‘S’, ‘T’, ‘U’, \
> ... ‘V’, ‘X’, ‘Z’, ‘.’)
 key_generator(letters)
> ... ((‘A’, ‘B’, ‘C’, ‘D’, ‘E’),
> ... (‘F’, ‘G’, ‘H’, ‘I’, ‘J’),
> ... (‘ ’, ‘L’, ‘M’, ‘N’, ‘O’),
> ... (‘P’, ‘Q’, ‘R’, ‘S’, ‘T’),
> ... (‘U’, ‘V’, ‘X’, ‘Z’, ‘.’))

Start by playing with letters in the shell and seeing what you can do
with it.  The word you're looking for is 'slices'.  Figure out
interactively what you need to do, then write it up.

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


[FAQ] "Best" GUI toolkit for python

2016-10-17 Thread pozz

I'm sorry, I know it is a FAQ..., but I couldn't find a good answer.

I'm learning python and I'd like to start creating GUI applications, 
mainly for Windows OS. In the past, I wrote many applications in Visual 
Basic 4: it was very fast and you could create simple but effective GUIs 
in Windows in some minutes.


Actually I'm not interested in cross-platform application, however it 
could be a good feature to have.


I understand there are some alternatives, with pros and cons:

- Tkinter
- GTK (pyGObject for Python3)
- QT (pyQt or pySide for LGPL licence)
- wxPython (wxPython/Phoenix for Python3)
- FLTK

There is an entire page on python website that talks about GUI toolkits: 
https://wiki.python.org/moin/GuiProgramming

I can't test all of them to understand what is the best for my needs.


I started with GTK some weeks ago and I encountered many troubles:
- pyGtk is old, better to use pyGObject (it isn't so clear at first)
- Glade Windows binaries on website are old, better to use the binary
  that can be downloaded from Msys2 project
I'm not sure, but I don't like too much this solution... maybe it's only 
a matter of time.
Glade application (for visual GUI building) seems not very stable under 
Windows. I had many crashes. Moreover it's very complex to understand 
the arrangement of widgets on a window. Even a simple listbox is 
implemented through the GtkTreeView widget that is... very complex to 
understand.
Documentation isn't so good: it's so simple to put a note on the Windows 
binaries page of glade to download a more recent version through Msys2!



So I'm thinking to evaluate other solutions. wxWidgets is attractive for 
it's native look&feel, but python implementation Phoenix for Python3 is 
in alpha stage. Moreover wxGlade (the GUI builder application) needs 
Python2, but I couldn't understand if the generated code is compatible 
with wxPython/Phoenix.



QT is another alternative, but I need pySide for LGPL support (pyQt 
isn't LGPL). Is it good as pyQt project?



Any suggestions? One of my requirement is to have a good 
documentation/support from community... and the solution must be 
currently active.

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


Re: Making IDLE3 ignore non-BMP characters instead of throwing an exception?

2016-10-17 Thread eryk sun
On Mon, Oct 17, 2016 at 8:35 PM, Random832  wrote:
> On Mon, Oct 17, 2016, at 14:20, eryk sun wrote:
>> You can patch print() to transcode non-BMP characters as surrogate
>> pairs. For example:
>>
>> On Windows this should allow printing non-BMP characters such as
>> emojis (e.g. U+0001F44C).
>
> I thought there was some reason this wouldn't work with tk, or else
> tkinter would do it already?

I don't know whether it causes problems elsewhere in Tk, but it has no
problem passing along a UTF-16 string to Windows. For example, see the
following with a breakpoint set on TextOut [1]:

>>> root = tkinter.Tk()
>>> w = tkinter.Label(root, text='test: \ud83d\udc4c')
>>> w.pack()

Breakpoint 0 hit
GDI32!TextOutW:
7fff`6d6c61d0 ff2532a10200jmp
qword ptr [GDI32!_imp_TextOutW (7fff`6d6f0308)]
ds:7fff`6d6f0308={gdi32full!TextOutW (7fff`6a3143c0)}

0:000> du @r9
00d6`dfdeea50  "test: .."

0:000> dw @r9 l8
00d6`dfdeea50  0074 0065 0073 0074 003a 0020 d83d dc4c

The lpString parameter (x64 register r9) is the label's text,
including the surrogate pair "\ud83d\udc4c" (i.e. U+0001F44C).

[1]: https://msdn.microsoft.com/en-us/library/dd145133:
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [FAQ] "Best" GUI toolkit for python

2016-10-17 Thread Wildman via Python-list
On Tue, 18 Oct 2016 00:58:42 +0200, pozz wrote:

> I'm sorry, I know it is a FAQ..., but I couldn't find a good answer.
> 
> I'm learning python and I'd like to start creating GUI applications, 
> mainly for Windows OS. In the past, I wrote many applications in Visual 
> Basic 4: it was very fast and you could create simple but effective GUIs 
> in Windows in some minutes.

I am also learning Python so my experience is limited.  I have
tried pyGTK and Tkinter.  GTK's concept of the hbox and vbox
gave me of difficulty.  I couldn't get the GUI to look the way
I wanted.  OTOH, Tkinter offers a way to place widgets on a
window/frame in a precise way:  self.widget.place(x=#, y=#)
That is similar to VB's move statement.  GTK may have such a
feature but I was not able to find it.  Anyway, my choice based
on my limited experience is Tkinter.  Here is a good place to
start...

http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html

This will give you several places to look for additional info...

https://duckduckgo.com/?q=tkinter+tutorials&t=h_&ia=web

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: difference with parenthese

2016-10-17 Thread chenyong20000
Hi Wolfgang,

thanks for your kind reply. I got.


regards
skyworld

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


Re: [FAQ] "Best" GUI toolkit for python

2016-10-17 Thread Paul Rubin
If you're just getting started and you're not trying to make something
super slick, I'd suggest Tkinter.  It's easy to learn and use, you can
bang stuff together with it pretty fast, it's included with various
Python distributions so you avoid download/installation hassles, and
it's pretty portable across various desktop OS's (not mobile for some
reason).  The downside is that you get industrial-looking UI's that
implement typical GUI functionality but don't have ultra precise control
or carefully crafted widgets like some of the other toolkits do.

Kivy (kivy.org) also seems worth looking at if you're trying to be
cross-platform.  It runs on both desktop and mobile.  Although, one of
my mobile-using buddies tells me that mobile apps are now passé and
these days people just write web apps for mobile.
-- 
https://mail.python.org/mailman/listinfo/python-list


Tkinter with native look-and-feel (was: [FAQ] "Best" GUI toolkit for python)

2016-10-17 Thread Ben Finney
Paul Rubin  writes:

> If you're just getting started and you're not trying to make something
> super slick, I'd suggest Tkinter.  It's easy to learn and use, you can
> bang stuff together with it pretty fast, it's included with various
> Python distributions so you avoid download/installation hassles, and
> it's pretty portable across various desktop OS's (not mobile for some
> reason).

There is also a very good tutorial site for Tk for various languages,
including Python http://www.tkdocs.com/tutorial/>.

> The downside is that you get industrial-looking UI's that implement
> typical GUI functionality but don't have ultra precise control or
> carefully crafted widgets like some of the other toolkits do.

The “themed Tk” extension is now part of the Python standard library
https://docs.python.org/3/library/tkinter.ttk.html> and allows
native look-and-feel widgets:

[…] new widgets which gives a better look and feel across platforms;
however, the replacement widgets are not completely compatible.

-- 
 \   “Corporation, n. An ingenious device for obtaining individual |
  `\   profit without individual responsibility.” —Ambrose Bierce, |
_o__)   _The Devil's Dictionary_, 1906 |
Ben Finney

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


Re: Making IDLE3 ignore non-BMP characters instead of throwing an exception?

2016-10-17 Thread Chris Angelico
On Tue, Oct 18, 2016 at 10:23 AM, eryk sun  wrote:
> I don't know whether it causes problems elsewhere in Tk, but it has no
> problem passing along a UTF-16 string to Windows. For example, see the
> following with a breakpoint set on TextOut [1]:
>
> >>> root = tkinter.Tk()
> >>> w = tkinter.Label(root, text='test: \ud83d\udc4c')
> >>> w.pack()

That's not a UTF-16 encoded byte string, though. It's a Unicode string
that contains two surrogates. So maybe the solution is to convert from
true Unicode strings into strings like the above - but if so, it
absolutely must not be done in any user-facing way. It should be an
implementation detail of Tkinter.

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


Re: Build desktop application using django

2016-10-17 Thread Mario R. Osorio
On Monday, October 17, 2016 at 1:00:14 PM UTC-4, John Gordon wrote:
> In  
> ayuchitsalu...@gmail.com writes:
> 
> > Hello I want to build a desktop application which retrieves data from
> > server and stores data on server. I have basic experience of python and
> > I dont know how to build that thing.
> 
> The term "desktop application" generally means something which runs
> locally on your computer, such as Microsoft Word or a game.
> 
> But Django is for building websites, not local applications.
> 
> So Django probably isn't what you want.
> 
> -- 
> John Gordon   A is for Amy, who fell down the stairs
> gor...@panix.com  B is for Basil, assaulted by bears
> -- Edward Gorey, "The Gashlycrumb Tinies"

Then again, nothing stops you from creating a Django app and run it locally 
with the development server...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Making IDLE3 ignore non-BMP characters instead of throwing an exception?

2016-10-17 Thread eryk sun
On Tue, Oct 18, 2016 at 2:09 AM, Chris Angelico  wrote:
> That's not a UTF-16 encoded byte string, though. It's a Unicode string
> that contains two surrogates. So maybe the solution is to convert from
> true Unicode strings into strings like the above - but if so, it
> absolutely must not be done in any user-facing way. It should be an
> implementation detail of Tkinter.

Yes, it's an invalid Unicode string, since it contains surrogate
codes. At the C level this gets passed as a UTF-16 string, even in
Unix, i.e. in most cases a Tcl_UniChar is defined as a C unsigned
short since the macro TCL_UTF_MAX defaults to 3 (UTF-8 bytes).

As I said, I'm not experienced with TCL/Tk enough to know whether
UTF-16 strings with surrogate pairs cause other problems. On Linux it
prints the surrogate codes as empty box characters, which is certainly
ugly and also incorrect to print two characters in place of one. It
seems that TCL's UTF-8 conversion doesn't work with UTF-16. Thus
supporting non-BMP characters would be limited to Windows until the
default TCL_UTF_MAX is greater than 3 on Unix platforms. Supposedly
this has actually worked in the core TCL implementation for some time,
but extensions are holding it back.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Build desktop application using django

2016-10-17 Thread Denis Akhiyarov
Have a look at automatic web app builder using Django or Flask called Wooey 
based Gooey.

https://github.com/wooey/Wooey
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Meta classes - real example

2016-10-17 Thread Mr. Wrobel

W dniu 17.10.2016 o 23:23, Ethan Furman pisze:

On 10/17/2016 09:23 AM, Mr. Wrobel wrote:

W dniu 17.10.2016 o 18:16, Chris Angelico pisze:

On Tue, Oct 18, 2016 at 3:03 AM, Mr. Wrobel wrote:



I am looking for an example of metaclass usage. Especially I am
interestet
in manipulating instance variables, for example:

My class:
class MrMeta(type):
pass

class Mr(object):
__metaclass__ = MrMeta

def __init__(self):
self.imvariable = 'Zmienna self'

def aome method(self):
print 'I am in instance'

So in general, I would like to create a mechanism, that is changing
value
for self.imvariable to capital letters and this should be included
in my
metaclass called MrMeta(type).

Can you guide me please?


Are you sure you can't just use a descriptor, such as @property?

class Mr(object):
@property
def imvariable(self):
return self._imvariable
@imvariable.setter
def imvariable(self, value):
self._imvariable = str(value).upper()


I am sure that I can do that with setter/getter, but I want to be
closer to black magic, that is why I wanted to inlcude Metaclasses.

I know how to acomplish that for class variables, but don;t have any
idea how to instance.


Metaclasses work on the class level, not the instance level.  The only*
influnce a metaclass is going to have on instances is changes it makes
while it's creating the class.

For example, MrMeta could set descriptors in Mr when it is creating the
Mr class; it could even put it's own __init__ in the class; but to
affect things like instance variables that are added in methods -- well,
it is possible, but it is *a lot* of work.

--
~Ethan~

* Okay, somebody prove me wrong!  :)


Ok,so in general, we could say that using Metclasses is ok for 
manipulating __new__ but not that what is setting by __init__. Am I right?


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