Re: choice of web-framework

2017-10-24 Thread John Black
In article <mailman.50.1508843658.2821.python-l...@python.org>, 
ros...@gmail.com says...
> 
> On Tue, Oct 24, 2017 at 6:57 AM, Chris Warrick <kwpol...@gmail.com> wrote:
> > On 23 October 2017 at 21:37, John Black <jbl...@nopam.com> wrote:
> >> Chris, thanks for all this detailed information.  I am confused though
> >> with your database recommendation.  You say you teach SQLAlchemy but
> >> generally use PostgreSQL yourself.  I can maybe guess why there seems to
> >> be this contradiction.  Perhaps PostgreSQL is better but too advanced for
> >> the class you are teaching?  Can you clarify on which you think is the
> >> better choice?  Thanks.
> >
> > Different Chris, but I?ll answer. Those are two very different things.
> >
> > PostgreSQL is a database server. It talks SQL to clients, stores data,
> > retrieves it when asked. The usual stuff a database server does.
> > Alternatives: SQLite, MySQL, MS SQL, Oracle DB, ?
> >
> > SQLAlchemy is an ORM: an object-relational mapper, and also a database
> > toolkit. SQLAlchemy can abstract multiple database servers/engines
> > (PostgreSQL, SQLite, MySQL, etc.) and work with them from the same
> > codebase. It can also hide SQL from you and instead give you Python
> > classes. If you use an ORM like SQLAlchemy, you get database support
> > without writing a single line of SQL on your own. But you still need a
> > database engine ? PostgreSQL can be one of them. But you can deploy
> > the same code to different DB engines, and it will just work?
> > (assuming you didn?t use any DB-specific features). Alternatives:
> > Django ORM.
> >
> > psycopg2 is an example of a PostgreSQL client library for Python. It
> > implements the Python DB-API and lets you use it to talk to a
> > PostgreSQL server. When using psycopg2, you?re responsible for writing
> > your own SQL statements for the server to execute. In that approach,
> > you?re stuck with PostgreSQL and psycopg2 unless you rewrite your code
> > to be compatible with the other database/library. Alternatives (other
> > DBs): sqlite3, mysqlclient. There are also other PostgreSQL libraries
> > available.
> >
> 
> Thanks, namesake :)
> 
> The above is correct and mostly accurate. It IS possible to switch out
> your back end fairly easily, though, even with psycopg2; there's a
> standard API that most Python database packages follow. As long as you
> stick to standard SQL (no PostgreSQL extensions) and the standard API
> (no psycopg2 extensions), switching databases is as simple as changing
> your "import psycopg2" into "import cx_oracle" or something. (And,
> most likely, changing your database credentials.)
> 
> The point of an ORM is to make your databasing code look and feel like
> Python code, rather than manually crafting SQL statements everywhere.
> Here's how a simple database operation looks in SQLAlchemy:

Thank you Chris and Chris!

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


Re: choice of web-framework

2017-10-23 Thread John Black
In article <mailman.0.1508668886.2821.python-l...@python.org>, 
ros...@gmail.com says...
> For the database, I generally use PostgreSQL, unless the job's so
> simple it can be done with flat files. Using Flask with SQLAlchemy is
> a popular option, but you can also dive into psycopg2 directly (the
> "2" doesn't mean "Python 2.7 only", it's fine). The tech stack
> Python+Flask+SQLAlchemy+PostgreSQL+Linux is an extremely solid one, or
> you can switch out any part fairly easily.
> 
> Disclaimer: I use Flask and SQLAlchemy when I'm teaching my students
> how to build web apps in Python, but I don't have much experience with
> any other frameworks or ORMs. Other options may very well be viable
> and/or superior; all I can say is that the above *is* viable.

Chris, thanks for all this detailed information.  I am confused though 
with your database recommendation.  You say you teach SQLAlchemy but 
generally use PostgreSQL yourself.  I can maybe guess why there seems to 
be this contradiction.  Perhaps PostgreSQL is better but too advanced for  
the class you are teaching?  Can you clarify on which you think is the 
better choice?  Thanks.

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


Re: Is there a way to globally set the print function separator?

2017-10-09 Thread John Black
In article <mailman.59.1507585675.12137.python-l...@python.org>, 
eryk...@gmail.com says...
> 
> On Mon, Oct 9, 2017 at 10:04 PM, John Black <jbl...@nopam.com> wrote:
> > In article <org8pq$fgm$1...@gioia.aioe.org>, python@example.invalid says...
> >>
> >> Le 09/10/2017 à 18:22, John Black a écrit :
> >> > I want sep="" to be the default without having to specify it every time I
> >> > call print.  Is that possible?
> >>
> >>  >>> oldprint = print
> >>  >>> def print(*args,**kwargs):
> >> ...   oldprint(*args,**kwargs,sep='')
> >> ...
> >>  >>> print(1,2,3)
> >> 123
> >
> > Winner!  Thanks all.
> 
> functools.partial(print, sep='') is the winner, IMO.

Ok, I got that working too after someone told me I have to import 
functools.  Can you explain what it means?  It looks like it is not 
defining another function like the other solutions but is truly changing 
the defaults for the existing function print?

John Black

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


Re: Is there a way to globally set the print function separator?

2017-10-09 Thread John Black
In article <org8pq$fgm$1...@gioia.aioe.org>, python@example.invalid says...
> 
> Le 09/10/2017 à 18:22, John Black a écrit :
> > I want sep="" to be the default without having to specify it every time I
> > call print.  Is that possible?
> 
>  >>> oldprint = print
>  >>> def print(*args,**kwargs):
> ...   oldprint(*args,**kwargs,sep='')
> ...
>  >>> print(1,2,3)
> 123

Winner!  Thanks all.

I want to make sure I understand what this line is doing: 

> oldprint = print

Experimenting, I find this is not a rename because I can use both 
function names.  It looks it literally copies the function "print" to 
another function called "oldprint".  But now, I have a way to modify the 
builtin funciton "print" by referencing oldprint.  Without oldprint, I 
have no way to directly modify print?  For example, based on your post, I 
tried:

def print(*args, **kw):
print(*args, sep='', **kw)

meaning print calls print (itself) with sep=''.  But this failed and I 
guess the reason is that it would keep calling itself recursively adding 
sep='' each time?  Thanks.

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


Re: Is there a way to globally set the print function separator?

2017-10-09 Thread John Black
In article <mailman.52.1507567528.12137.python-l...@python.org>, 
__pete...@web.de says...
> 
> John Black wrote:
> 
> > I want sep="" to be the default without having to specify it every time I
> > call print.  Is that possible?
> 
> No, but you can replace the print function with your own:
> 
> >>> print = functools.partial(print, sep="")
> >>> print("I", "recommend", "you", "choose", "another", "name", "and", 
> "preserve", "your", "sanity")
> Irecommendyouchooseanothernameandpreserveyoursanity
> 
> And everybody else's.

print=functools.partial(print, sep="")
NameError: name 'functools' is not defined

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


Is there a way to globally set the print function separator?

2017-10-09 Thread John Black
I want sep="" to be the default without having to specify it every time I 
call print.  Is that possible?

John Black

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


Re: What's with all of the Case Solution and Test Bank nonsense posts?

2017-07-10 Thread John Black
In article <slrnom6vdt.rbm.jon+use...@sable.unequivocal.eu>, 
jon+use...@unequivocal.eu says...
> 
> On 2017-07-10, John Black <jbl...@nopam.com> wrote:
> > While you're at it, throw these rules in and the group will appear very 
> > clean and on topic.
> >
> > Subject contains "PEDOFILO"
> > Or
> > Subject contains "MAI"
> > Or
> > Subject contains "SEGRETO"
> [snip >100 lines of rules]
> 
> Or just "subject does not contain any lower-case letters".

That is probably ok, but I was worried some legit posts would get caught 
in that.

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


Re: What's with all of the Case Solution and Test Bank nonsense posts?

2017-07-09 Thread John Black
In article <477bde19-0653-4e41-a717-0efe90ac5...@googlegroups.com>, 
timetowal...@gmail.com says...
> 
> I use https://groups.google.com/forum/#!forum/comp.lang.python to look over 
> message posts.
> 
> What's with all of the Case Solution and Test Bank nonsense posts?
> Is is possible to have these posts filtered out?

Yes it very easy to filter these out with most usenet readers.  Use one 
that lets you setup rules for what gets automatically discarded.  I've 
added these rules to my discard list:

>From contains "Case Solution"
Or
>From contains "Test Banks"

Poof.  All gone.

While you're at it, throw these rules in and the group will appear very 
clean and on topic.

Subject contains "PEDOFILO"
Or
Subject contains "MAI"
Or
Subject contains "SEGRETO"
Or
Subject contains "SETTA"
Or
Subject contains "BAMBINI"
Or
Subject contains "FIGLIO"
Or
Subject contains "PAOLO"
Or
Subject contains "NATALE"
Or
Subject contains "SONO"
Or
Subject contains "GRAZIA"
Or
Subject contains "PORNOSTAR"
Or
Subject contains "PEZZO"
Or
Subject contains "MERDA"
Or
Subject contains "CAZZO"
Or
Subject contains "GALERA"
Or
Subject contains "SICARIO"
Or
Subject contains "ESSERE"
Or
Subject contains "CRIMINALE"
Or
Subject contains "LECCA"
Or
Subject contains "COCAINA"
Or
Subject contains "LESBICA"
Or
Subject contains "NESSUNO"
Or
Subject contains "MAFIOSO"
Or
Subject contains "BERLUSCONI"
Or
Subject contains ""
Or
Subject contains "HARDCORE"
Or
Subject contains "PEDERASTA"
Or
Subject contains "CULO"
Or
Subject contains "NOSTRA"
Or
Subject contains "FOGLIO"
Or
Subject contains "USARE"
Or
Subject contains "FAMIGLIA"
Or
Subject contains "FECE"
Or
Subject contains "CAPO"
Or
Subject contains "SUICIDARE"
Or
Subject contains "OGNI"
Or
Subject contains "CANE"
Or
Subject contains "MERCATO"
Or
Subject contains "VOLTA"
Or
Subject contains "MAFIOSA"
Or
Subject contains "ALMENO"
Or
Subject contains "BASTARDO"
Or
Subject contains "FIGLIA"
Or
Subject contains "BASTARD"
Or
Subject contains "CRIMINAL"
Or
Subject contains "ANNI"
Or
Subject contains "PEDINA"

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


Re: comp.lang.python killfile rule

2017-06-26 Thread John Black
In article <mailman.264.1498415358.10125.python-l...@python.org>, 
miragewebstudi...@gmail.com says...
> Just felt like posting, wouldn't it be pythonic if it was
> if word in [list]:
> ignore
> 
> Save time and easily maintainable

Yes for readers that can interpret Python.  Mine doesn't.  This is the 
rule per the syntax of my reader but as you say that is easily translated 
to any other format.

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


comp.lang.python killfile rule

2017-06-22 Thread John Black
All, in case this is useful to anyone, this rule that tells my newsreader 
which posts to kill really cleans up the group.  I could not find a way 
to key off of anything in the header except keywords because the From 
keeps changing and I didn't want to overkill real posts.  I may have to 
add a thing or two to this over time, but right now, this seems to be 
nailing everything.

John Black 

Subject contains "PEDOFILO"
Or
Subject contains "MAI"
Or
Subject contains "SEGRETO"
Or
Subject contains "SETTA"
Or
Subject contains "BAMBINI"
Or
Subject contains "FIGLIO"
Or
Subject contains "PAOLO"
Or
Subject contains "NATALE"
Or
Subject contains "SONO"
Or
Subject contains "GRAZIA"
Or
Subject contains "PORNOSTAR"
Or
Subject contains "PEZZO"
Or
Subject contains "MERDA"
Or
Subject contains "CAZZO"
Or
Subject contains "GALERA"
Or
Subject contains "SICARIO"
Or
Subject contains "ESSERE"
Or
Subject contains "CRIMINALE"
Or
Subject contains "LECCA"
Or
Subject contains "COCAINA"
Or
Subject contains "LESBICA"
Or
Subject contains "NESSUNO"
Or
Subject contains "MAFIOSO"
Or
Subject contains "BERLUSCONI"
Or
Subject contains ""
Or
Subject contains "HARDCORE"
Or
Subject contains "PEDERASTA"
Or
Subject contains "CULO"
Or
Subject contains "NOSTRA"
Or
Subject contains "FOGLIO"
Or
Subject contains "USARE"
Or
Subject contains "FAMIGLIA"
Or
Subject contains "FECE"
Or
Subject contains "CAPO"
Or
Subject contains "SUICIDARE"
Or
Subject contains "OGNI"
Or
Subject contains "CANE"
Or
Subject contains "MERCATO"
Or
Subject contains "VOLTA"
Or
Subject contains "MAFIOSA"
Or
Subject contains "ALMENO"
Or
Subject contains "BASTARDO"
Or
Subject contains "FIGLIA"
Or
Subject contains "BASTARD"
Or
Subject contains "CRIMINAL"
Or
Subject contains "ANNI"
Or
Subject contains "PEDINA"
-- 
https://mail.python.org/mailman/listinfo/python-list