Re: pystl

2016-08-16 Thread Steven D'Aprano
On Wednesday 17 August 2016 16:36, Poul Riis wrote:

> Can someone deliver a minimal, fully working example with the pystl module,
> https://pypi.python.org/pypi/pystl/
> 
> The only example code mentioned is the following:
> 
> with PySTL(‘stl_test.stl’) as stl:
> stl.add_triangle( (0.0, 0.0, 0.5), (0.0, 1.0, 0.0), (1.0, 1.0, 0.5) )
> 
> 
> but no matter what 'import'-statement I try I cannot make it work.

Don't make us guess. What have you tried, and what happens when you do? Cut and 
paste the *actual* code you try, and the *actual* results.

http://mattgemmell.com/what-have-you-tried/

http://www.sscce.org/


> I have installed the module and a program containing only the following line
> 
> from pystl import PySTL
> 
> runs without any error message.

Great. Then try this:

from pystl import PySTL
with PySTL(‘stl_test.stl’) as stl:
stl.add_triangle( (0.0, 0.0, 0.5), (0.0, 1.0, 0.0), (1.0, 1.0, 0.5) )



If it doesn't work, what does it do?



-- 
Steve

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


Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Steven D'Aprano
On Wednesday 17 August 2016 06:59, Lawrence D’Oliveiro wrote:

> On Wednesday, August 17, 2016 at 6:46:22 AM UTC+12, alister wrote:
>> I don't think I am missing anything by not bothering with them YMMV
> 
> Here
> 
> are some examples of that varying mileage.

Quote:

The Python syntax for conditional expressions (introduced in Python 2.5) is

trueval if cond else falseval 

I think this is bloody awful. Why couldn’t they have adopted the standard C
syntax, as used in a whole bunch of other C-derivative languages?

cond ? trueval : falseval 



Because the C syntax is horrifically ugly, whereas the Python syntax is very 
close to real English syntax.

"What will you do tonight?"

"Go to the movies, if I finish work on time, otherwise just go home."

Every time you read the C syntax, you lose another three minutes off your 
lifespan. That's how ugly it is.

The background to the Python ternary operator is documented here:

https://www.python.org/dev/peps/pep-0308/


Rather than ask why Python uses `trueval if cond else falseval`, you should ask 
why C uses `cond ? trueval : falseval`. Is that documented anywhere?



-- 
Steve

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


pystl

2016-08-16 Thread Poul Riis
Can someone deliver a minimal, fully working example with the pystl module,
https://pypi.python.org/pypi/pystl/

The only example code mentioned is the following:

with PySTL(‘stl_test.stl’) as stl:
stl.add_triangle( (0.0, 0.0, 0.5), (0.0, 1.0, 0.0), (1.0, 1.0, 0.5) )


but no matter what 'import'-statement I try I cannot make it work.



I have installed the module and a program containing only the following line

from pystl import PySTL

runs without any error message.


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


Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Steven D'Aprano
On Wednesday 17 August 2016 04:46, alister wrote:

> > squared_plus_one_list = map(lambda x: x**2 + 1, some_list)
> 
> probably the cleanest example I have seen so far, & I still cant see the
> point

Hmmm. Well, let's have a look at some analogies with other kinds of values.

Out of each pair of examples, *in general* would you prefer (A) or (B)?

I realise that there are occasions where we might deliberate choose to assign 
an intermediate value to its own variable, but all else being equal, which 
would you prefer?


#A
alist = []
alist.append(2)
alist.append(4)
alist.append(8)
process(alist)


#B
process([2, 4, 8])



#A
value = 0
for i in range(100):
value += 1
process(value)

#B
process(100)



#A
tmp = get_some_string()
s = tmp[1]
s += tmp[2]
s += tmp[3]
process(s)

#B
process(get_some_string()[1:4])



#A
def callback(btn):
return btn.do_the_thing(42) or default
the_button.setcommand(callback)
process(the_button)

#B
the_button.setcommand(lambda btn: btn.do_the_thing(42) or default)
process(the_button)



If you find yourself preferring B, B, B, A, you might ask yourself what makes a 
function different that you prefer to keep temporary functions around where 
they're not needed.




-- 
Steve

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


Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Lawrence D’Oliveiro
On Wednesday, August 17, 2016 at 6:46:22 AM UTC+12, alister wrote:
> I don't think I am missing anything by not bothering with them YMMV

Here 
 
are some examples of that varying mileage.
-- 
https://mail.python.org/mailman/listinfo/python-list


SQLObject 3.1.0

2016-08-16 Thread Oleg Broytman
Hello!

I'm pleased to announce version 3.1.0, the first stable release of branch
3.1 of SQLObject.


What's new in SQLObject
===

Features


* Add UuidCol.

* Add JsonbCol. Only for PostgreSQL.
  Requires psycopg2 >= 2.5.4 and PostgreSQL >= 9.2.

* Add JSONCol, a universal json column.

* For Python >= 3.4 minimal FormEncode version is now 1.3.1.

* If mxDateTime is in use, convert timedelta (returned by MySQL) to
  mxDateTime.Time.

Documentation
-

* Developer's Guide extended to explain SQLObject architecture and how
  to create a new column type.

* Fix URLs that can be found; remove missing links.

* Rename reStructuredText files from *.txt to *.rst.

Source code
---

* Fix all `import *` using https://github.com/zestyping/star-destroyer.

Tests
-

* Tests are now run at Circle CI.

* Use pytest-cov for test coverage. Report test coverage
  via coveralls.io and codecov.io.

* Install mxDateTime to run date/time tests with it.

Contributor for this release is Lutz Steinborn.

For a more complete list, please see the news:
http://sqlobject.org/News.html


What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).

Python 2.6, 2.7 or 3.4+ is required.


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
https://pypi.python.org/pypi/SQLObject/3.1.0

News and changes:
http://sqlobject.org/News.html

Oleg.
-- 
 Oleg Broytmanhttp://phdru.name/p...@phdru.name
   Programmers don't die, they just GOSUB without RETURN.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread alister
On Mon, 15 Aug 2016 11:35:07 -0700, sohcahtoa82 wrote:

> On Monday, August 15, 2016 at 8:07:32 AM UTC-7, alister wrote:
>> On Mon, 15 Aug 2016 07:00:47 -0700, Sickfit92 wrote:
>> 
>> > 1. How long did it take you guys to master the language or, let me
>> > put it this way to completely get the hang and start writing code?
>> > 
> 
>> Some concepts took more time than others before I had the "Light bulb"
>> moment, Comprehensions & decorators being the most notable although
>> Lambda still escapes me, fortunately these can all be unrolled into
>> larger functions so are not essential in the early stages
>> 
> 
> 
> What helped me understand Lambdas is figuring out that they're really
> just a $1,000 term for a $5 concept.
> 
> A lambda is just a single-line function without a name (Unless you
> assign it to one).  A syntactic shortcut.
> 
> def square_plus_one(x):
> return x ** 2 + 1
> 
> squared_plus_one_list = map(square_plus_one, some_list)
> 
> is equivalent to:
> 
> squared_plus_one_list = map(lambda x: x**2 + 1, some_list)

probably the cleanest example I have seen so far, & I still cant see the 
point

the most enlightening thing here for me is your comet about it being a 
$1000 term for a $5 concept.

I don't think I am missing anything by not bothering with them YMMV



-- 
"The C Programming Language -- A language which combines the flexibility 
of
assembly language with the power of assembly language."
-- 
https://mail.python.org/mailman/listinfo/python-list


Check required modules using autotools

2016-08-16 Thread Rudra Banerjee
Hi,
I am compiling a python3 project using gnu-autotools.
This is my configure.ac file (Please ignore the recursive Makefile, I have not 
managed to make the non-recursive one).

AC_INIT([mkbib], [0.1],[],[mkbib])
AM_INIT_AUTOMAKE([1.9.6 dist-bzip2 subdir-objects])
AM_PATH_PYTHON([3.0])
dnl AX_PYTHON_MODULE([bibtexparser],[required])

AC_CONFIG_FILES([Makefile 
 data/Makefile
 data/mkbib.desktop
 data/icons/Makefile
 data/icons/hicolor/Makefile
 data/icons/hicolor/48x48/Makefile
 data/icons/hicolor/48x48/apps/Makefile
 data/icons/hicolor/scalable/Makefile
 data/icons/hicolor/scalable/apps/Makefile
 data/ui/Makefile
 ])
AC_OUTPUT

I am trying to check presence of bibtexparser module 
(https://pypi.python.org/pypi/bibtexparser/0.5.2); which is giving error:

./configure: line 2589: syntax error near unexpected token `bibtexparser,'
./configure: line 2589: `AX_PYTHON_MODULE(bibtexparser, fatal)'

I have also tried:
PKG_CHECK_MODULES([GTK], [gtk+-2.0])
PKG_CHECK_MODULES([GLIB], [glib-2.0])
PKG_CHECK_MODULES([bibtex], [bibtexparser])

But This is  giving error as well.
./configure: line 2589: syntax error near unexpected token `GTK,'
./configure: line 2589: `PKG_CHECK_MODULES(GTK, gtk+-2.0)'
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: docs on pythonhosted.org not updating with new version?

2016-08-16 Thread Irmen de Jong
On 16-8-2016 0:11, Irmen de Jong wrote:
> Hi,
> as I've always done for a new release I've uploaded new versions of my 
> package's
> documentation files, but they are not showing up on Pythonhosted.org - the 
> previous
> version is still there.
> 
> Is there something wrong with the update mechanism?
> 
> I've been using "python3 setup.py build_sphinx upload_docs" to build and 
> upload the docs
> and it comes back with a 200 Ok response from the pypi server. The same 
> commands used to
> work fine on previous occasions...


Btw, manually uploading a zip file with the documentation via the web form on my
project's Pypi page *did* work as advertised and updated the documentation. So 
it seems
to me as if the setuptools upload_docs task is no longer working?

I tried to extract more information from setuptools but adding the -v option 
didn't
result in more diagnostic info. So I have no idea what is happening with it 
behind the
curtains yet.


Irmen

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


Re: mentor training python Romania with certification

2016-08-16 Thread tommy yama
Check it out. It is pretty basic material,though!

https://www.python.org

Go for it.




On Tue, Aug 16, 2016 at 11:14 PM, blue  wrote:

> Hi.
>
> I'm from Romania.
> I need to update my skils under python.
> I need to find one mentor ( class, training ) to obtain one certified
> under python language.
>
> Cătălin George Feștilă
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


mentor training python Romania with certification

2016-08-16 Thread blue
Hi. 

I'm from Romania.
I need to update my skils under python.
I need to find one mentor ( class, training ) to obtain one certified under 
python language.

Cătălin George Feștilă
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Paul Rudin
Lawrence D’Oliveiro  writes:

> On Tuesday, August 16, 2016 at 6:26:01 PM UTC+12, Paul Rudin wrote:
>> sohcahtoa82 writes:
>>> squared_plus_one_list = map(lambda x: x**2 + 1, some_list)
>> 
>> I realise that this is about understanding lambda, but it's worth noting
>> in passing that we tend to write this sort of thing as:
>> 
>> squared_plus_one_list = [x**2 + 1 for x in some_list]
>
> The difference being that the “map” function takes an iterable and returns an 
> iterator.

Ah well - that depends the python version. Since the OP used a name
including the substring 'list' I assumed python 2.


> Why could this difference be important?

The main thing is to understand the difference, and then it's possible
to reason about whether it matters in a given context.

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


Pyjs

2016-08-16 Thread Uri Even-Chen
Hi,

Anybody used Pyjs? I have an error message:

C:\Uri\Projects\pyjs\examples\helloworld>pyjsbuild Hello.py
failed to create process.

I want to create a new web app which will receive 2 inputs - a positive
integer  (default=2) and a number of digits  (default=500),
calculate the square root of the integer (on the client side) with 
digits after the dot and print it. I never used Pyjs but I used GWT and
Python. Do you know how I start with developing this webapp? I want to do
something simple, not more than 4 to 5 hours of work. If I can do it in
less time - it's better.

I developed this app in GWT (in Java) in 2010:
http://chess-queens.sourceforge.net/

And this is the Python program that calculates the square root of a
positive number:
http://www.speedysoftware.com/uri/blog/my-first-programs-in-python/

By the way, I want to have a few buttons with numbers (or ) that
when clicking on them it will set the input to a specific number, such as
2, 3, 4 or 900. And then the program will calculate the square root of
this number.

I also want to create another program which calculates e^x (default: x=1).

The web app should be mobile-friendly.

Thanks,
Uri.

*Uri Even-Chen*
[image: photo] Phone: +972-54-3995700
Email: u...@speedy.net
Website: http://www.speedysoftware.com/uri/en/
  
    
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Marko Rauhamaa
Chris Angelico :

> most of the point of map() is to make use of an existing function:
>
> # Instead of
> lengths = (len(x) for x in items)
> # Use
> lengths = map(len, items)

Both methods are available and I have used each of them, but the former
is probably always preferable.


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


Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Chris Angelico
On Tue, Aug 16, 2016 at 5:18 PM, Ian Kelly  wrote:
> Also, unless the mapped function is already defined (and preferably
> built-in), a generator expression or list comprehension is usually more
> readable and avoids the significant overhead of repeatedly calling a Python
> function.

Don't know why "built-in" is significant, but most of the point of
map() is to make use of an existing function:

# Instead of
lengths = (len(x) for x in items)
# Use
lengths = map(len, items)

One problem: Not all languages have map() defined the same way.
Built-in function or method? If function, what order are the arguments
in? If method, is it a method on a function or an array/list? If you
add extra arguments, are they treated as parallel arrays, or are they
static arguments to the function - or are they not allowed at all?

Actually, I've never seen map as a function method (which would be
used as "len.map(items)"). All the others, I've seen in various
different languages. Can anyone fill in the gap?

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


Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Jussi Piitulainen
Lawrence D’Oliveiro writes:

> On Tuesday, August 16, 2016 at 6:53:24 PM UTC+12, Jussi Piitulainen wrote:
>> Lawrence D’Oliveiro writes:
>> 
>>> Why could this difference be important?
>> 
>> Different comprehensions (pun!) and performance characteristics.
>
> A potential difference in memory usage. When could this be important?
> Consider a situation where the iterable being mapped is returning
> records from a database query. If it were a million records, you might
> not want them all in memory at the same time.

That's what I meant by different performance characteristics, and I
agree that it's an important difference.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Christian Gollwitzer

Am 15.08.16 um 16:00 schrieb Sickfit92:

1. How long did it take you guys to master the language or, let me
put it this way to completely get the hang and start writing code?


You never learn a language completely. I'm using Python for 3 years, 
getting started was a matter of one or two days. But I have written code 
in ~10 different languages since 25 years. I started from here: 
https://wiki.python.org/moin/SimplePrograms



2. What made you want to learn python?


Numpy. I am writing scientific software, and numpy/scipy is becoming the 
new standard. Scientists shift from Matlab because Python is free.



3. Was it difficult to learn the language?


Comparable to other scripting languages.


4. Have you been able to get a job out of your new skill?


In my current job/profession, you choose the language. The objective is 
to get the job done, and often to throw away the program in the end. The 
faster you get the job done, the more successful you are. For many of 
those tasks, Python works very well. For others, I use different languages.


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


Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Lawrence D’Oliveiro
On Tuesday, August 16, 2016 at 7:19:01 PM UTC+12, Ian wrote:
> On Aug 16, 2016 12:36 AM, "Lawrence D’Oliveiro" wrote:
>
> The difference being that the “map” function takes an iterable and returns
> an iterator.
> 
> In Python 3, yes. However, assigning the result to the name
> "squared_plus_one_list" implies that the author was probably considering
> Python 2 code, in which map returns a list, so the comprehension is
> equivalent.

Why was the change made?

Because it was important.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Lawrence D’Oliveiro
On Tuesday, August 16, 2016 at 6:53:24 PM UTC+12, Jussi Piitulainen wrote:
> Lawrence D’Oliveiro writes:
> 
>> Why could this difference be important?
> 
> Different comprehensions (pun!) and performance characteristics.

A potential difference in memory usage. When could this be important? Consider 
a situation where the iterable being mapped is returning records from a 
database query. If it were a million records, you might not want them all in 
memory at the same time.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Lawrence D’Oliveiro
On Tuesday, August 16, 2016 at 7:22:42 PM UTC+12, Ian wrote:
> On Aug 16, 2016 12:57 AM, "Lawrence D’Oliveiro" wrote:
> 
> But perhaps this limitation wasn’t intentional, just an inherent
> consequence of the fact that Python’s significant-whitespace rules only
> apply to statements, not expressions...
> 
> I think the primary reason for that is just that nobody has yet come up
> with a good syntax proposal for anonymous functions to contain statement
> lists.

Only because Python makes it difficult, for the reason I mentioned.

Other languages have had no trouble with it. For example, Perl and JavaScript 
use their existing function-definition constructs, just omitting the function 
name.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Marko Rauhamaa
Steven D'Aprano :
> E.g. out of the following:
>
> [len(x)+1 for x in sequence]
>
> list(map(lambda x: len(x) + 1, sequence))
>
> the first will probably be faster as well as easier to read and write.

It's mostly about idioms. Comprehensions belong to Python's core idioms,
lambdas don't.

In Scheme, I think it's the other way around. Too many Scheme
programmers are infatuated with Scheme's powerful macros and bury
Scheme's idiomatic, functional core under truckloads of foreign patterns
-- just because they can.

So use lambda in Scheme as much as you can. Avoid lambda in Python as
much as you can.


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


Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Ian Kelly
On Aug 16, 2016 12:57 AM, "Lawrence D’Oliveiro" 
wrote:


I see. I thought I saw a mention somewhere else that Python lambdas were
designed to be less functional than full def-style functions.

But perhaps this limitation wasn’t intentional, just an inherent
consequence of the fact that Python’s significant-whitespace rules only
apply to statements, not expressions...


I think the primary reason for that is just that nobody has yet come up
with a good syntax proposal for anonymous functions to contain statement
lists.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Ian Kelly
On Aug 16, 2016 12:36 AM, "Lawrence D’Oliveiro" 
wrote:

On Tuesday, August 16, 2016 at 6:26:01 PM UTC+12, Paul Rudin wrote:
> sohcahtoa82 writes:
>> squared_plus_one_list = map(lambda x: x**2 + 1, some_list)
>
> I realise that this is about understanding lambda, but it's worth noting
> in passing that we tend to write this sort of thing as:
>
> squared_plus_one_list = [x**2 + 1 for x in some_list]

The difference being that the “map” function takes an iterable and returns
an iterator.


In Python 3, yes. However, assigning the result to the name
"squared_plus_one_list" implies that the author was probably considering
Python 2 code, in which map returns a list, so the comprehension is
equivalent.

Why could this difference be important?


Assigning an iterator to a variable is usually considered un-Pythonic,
because it's easy to accidentally consume the iterator resulting in
difficult-to-diagnose bugs later. If you're immediately iterating over the
result, then sure, use Python 3 map (or a generator expression). If you're
going to reference it later then materializing it (or, if the iteration is
cheap, creating a repeatable iterable) is preferred. Of course, the size of
the list can also be a consideration here.

Also, unless the mapped function is already defined (and preferably
built-in), a generator expression or list comprehension is usually more
readable and avoids the significant overhead of repeatedly calling a Python
function.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Steven D'Aprano
On Tuesday 16 August 2016 16:28, Lawrence D’Oliveiro wrote:

> On Tuesday, August 16, 2016 at 6:26:01 PM UTC+12, Paul Rudin wrote:
>> sohcahtoa82 writes:
>>> squared_plus_one_list = map(lambda x: x**2 + 1, some_list)
>> 
>> I realise that this is about understanding lambda, but it's worth noting
>> in passing that we tend to write this sort of thing as:
>> 
>> squared_plus_one_list = [x**2 + 1 for x in some_list]
> 
> The difference being that the “map” function takes an iterable and returns an
> iterator.
> 
> Why could this difference be important?

*shrug*

Some members of the Python community, particularly GvR, prefer list 
comprehensions and generator expressions to using the Lisp-ish "map()" 
function.

At least in the past, and possibly still, using a comprehension or a generator 
expression may be more efficient, as it can avoid the expense of a function 
call. The advice that used to be given (and which may still be valid, for all I 
know) is that if you have to write a function using lambda in order to use 
map(), it's usually faster to use a comprehension/genexp.


E.g. out of the following:

[len(x)+1 for x in sequence]

list(map(lambda x: len(x) + 1, sequence))

the first will probably be faster as well as easier to read and write.



-- 
Steve

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


Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Jussi Piitulainen
Lawrence D’Oliveiro writes:

> On Tuesday, August 16, 2016 at 6:26:01 PM UTC+12, Paul Rudin wrote:
>> sohcahtoa82 writes:
>>> squared_plus_one_list = map(lambda x: x**2 + 1, some_list)
>> 
>> I realise that this is about understanding lambda, but it's worth noting
>> in passing that we tend to write this sort of thing as:
>> 
>> squared_plus_one_list = [x**2 + 1 for x in some_list]
>
> The difference being that the “map” function takes an iterable and
> returns an iterator.

They tend to write that sort of thing as:

squared_plus_one_thing = (x**2 + 1 for x in some_thing)

> Why could this difference be important?

Different comprehensions (pun!) and performance characteristics.
-- 
https://mail.python.org/mailman/listinfo/python-list