Re: Recommendations for intro to python+programming lecture to Humanities MA students

2019-11-20 Thread Andrew Z
Look into https://repl.it


On Wed, Nov 20, 2019, 15:43 Göktuğ Kayaalp  wrote:

>
> Andrew Z   wrote:
> > Goktug,
> >   Im not clear what is the objective of the lecture? I understand it is
> an
> > intro, but what are you trying to achieve?
>
> Basically I need to introduce my non-programmer friends to Python and
> show them that they can easily learn to do their statistics with it,
> produce nice graphs, etc.  And I need to give them nice pointers so that
> they can self-teach w/o much friction.
>
> > I didnt read all the details, but maybe you can look into creating a
> > docker/virtual box image with everything preinstalled.
> > Good luck.
>
> That’d definitely be my cup of tea, but sadly also too involved /
> technical for my audience of absolute non-techies.
>
> Cheers,
>
> -gk.
>
> --
> İ. Göktuğ Kayaalp   <https://www.gkayaalp.com/>
>  024C 30DD 597D 142B 49AC
>  40EB 465C D949 B101 2427
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Recommendations for intro to python+programming lecture to Humanities MA students

2019-11-20 Thread Andrew Z
Goktug,
  Im not clear what is the objective of the lecture? I understand it is an
intro, but what are you trying to achieve?

I didnt read all the details, but maybe you can look into creating a
docker/virtual box image with everything preinstalled.
Good luck.

On Wed, Nov 20, 2019, 11:54 Göktuğ Kayaalp  wrote:

> Hi all,
>
> I am responsible of giving my colleagues in from linguistics MA
> programme an intro to Python, and programming, with a focus on
> statistics.  It’ll be a single lecture, and I probably won’t be able to
> do more than give some demos and then some pointers to actually properly
> learn how to use the tools.
>
> The problem is I’m a rather techie power user and my audience the exact
> opposite, so I feel like I could make use of some guidance as to how to
> bridge the gap and be useful.
>
> I want to stick to Python 3, demo them a few basics of programming, then
> how to use matplotlib, Jupyter notebooks (is this what IPyNBs became?),
> and some descriptive statistics.  All this needs to happen within the
> span of a single lecture (tho if people are interested I’ll offer to do
> a few more in our own time), so 45min~1h.
>
> The first problem is installation: apart from me, a Debian user,
> everybody has Windows or Mac laptops, and IDK how you install Python on
> them.  I feel like choosing one of the distros is a good idea: I could
> just put the installers on a USB and hand it out, or just send them a
> message with simple steps to follow and set themselves up beforehand.
> Thing is, IDK nothing about distros.  Anaconda seems to be the best
> options, but comes with complications like an IDE, as opposed to just
> working with notebooks, and is huge.  Also, seems to include R stuff.
> Spyder looks nice, but I don’t want to freak people out with such an
> unfamiliar environment as an IDE just within the first few moments they
> encounter programming.  These are all humanities people.  Another
> problem is that Anaconda has ‘conda’, a non-standard package manager,
> and I’m kinda vary of introducing that to people: should I talk of pip,
> should I leave it out?  I feel like I should just stick to pip and leave
> conda out, but IDK.  Python(x,y) is interesting, but it’s apparently
> Py2k only, and that’s a no-no.
>
> So, am I better off telling people to install Anaconda, or plain Py3k +
> a selection of packages (which maybe I make into a .zip or something)?
>
> Then, I need good pointers to hand out: links to good introductions to
> Python, programming, and statistical use of Python.  Thing is, I’ve
> always learned the hacker way, i.e. skip the docs, tinker with stuff.
> Thus, IDK of any good resources out of experience, and I want to ask you
> all for some recommendations.  I prefer free and tutorial-like stuff,
> but I’ll teach them how to use the stdlib reference too.
>
> What are some good self-teaching material for those who are new to
> programming and Python, and need to mainly do statistics with
> experimental data?
>
> Finally, I’m looking for recommendations on what to show and how.  My
> current master plan is
>
> - what’s the use of programming for a linguist
> - an abstract idea of what programming is
> - basic intro to Python syntax
> - demo how to load and clean up some data
> - demo matplotlib
> - demo jupyter notebooks
> - compare with alternatives: R, SPSS, other?
> - briefly refer to libraries for
>   - NLP
>   - AI?
> - lots of links on
>   - how to learn enough coding for number crunching and plotmaking
>   - how to make use of stdlib reference
>   - how to find and utilise packages and their docs
>   - ...?
>
> I plan to produce a handout with all this info neatly organised, and
> just go with a (few) Jupyter notebooks for the rest (resisting hard the
> urge to go in with Emacs Org Mode instead :)).
>
> I’m looking forward to any recommendations from youse.  The deadline is
> about a month and a half away, and I really want to give people
> something operationable.  People are stuck with BS like SPSS, too simple
> and too pricy, when a few lines of Python (or R) is all they need.  I
> came here because IDK teaching about this stuff, and I haven’t left the
> comfort zones of a programmer ever before, so this is some new
> experience for me and I don’t want to botch it.
>
> Thanks a lot in advance,
>
>Göktuğ.
>
> --
> İ. Göktuğ Kayaalp   
>  024C 30DD 597D 142B 49AC
>  40EB 465C D949 B101 2427
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Blasphemy

2019-10-24 Thread Andrew Z
Space.

On Thu, Oct 24, 2019, 18:53 Marek Mosiewicz 
wrote:

> What about, if Python would have optional end keyword. In fact most of
> blocks have starting : sign. What if you would have also keyword to
> optionaly mark end of block.
>
> That would be big win for IDEs to format code and ensure that there is
> no problems with intendation. There could be some keyword to mark
> script as strictly marking blocks and then it would have this kind of
> validation.
>
> Cheers,
> Marek Mosiewicz
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Books for Python 3.7

2019-07-16 Thread Andrew Z
Thats a good idea. Indeed- take an online course,  it is cheap, gets your
thru basics and you have an instructor to help if you r stuck.
Id vote for online course vs buying a book .

On Mon, Jul 15, 2019, 19:43 DL Neil  wrote:

> Wlfraed probably knows a thing-or-two about kicking-over ants'
> nests/wasps' nests...
>
> Talking about books is one thing. Judging them by asyncio coverage is
> quite another - and rather unfair. The use and methods of asyncio have
> changed frequently and markedly since '3.0'. Books take time to produce,
> sell, buy, and consume...
>
>
> Recommend OP takes a look at the LeanPub series: Python Apprentice;
> Journeyman; and Master. They also publish Mike Driscoll - few of which I
> have read personally [hangs head in embarrassment/shame], but I do
> follow his "Mouse Vs Python" web site...
>
>
> I much prefer to learn from a dead-tree presentation - and likely gain
> as much benefit from being able to 'look stuff up', thereafter. However,
> YMMV!
>
> Accordingly, the OP might like to broaden his analysis beyond books
> (paper or on-line) and take a look at MOOCs (on-line courses). Each
> platform seems to offer something on Python (some good, some tedious,
> some little more than puffery) [disclaimer: 'my' courses (non-Python)
> are hosted on edX].
>
> Just this morning I noted a veritable wave of free courses being
> released on the Swayam platform (Indian universities) including:  The
> Joy of Computing using Python
> (
> https://www.classcentral.com/course/swayam-the-joy-of-computing-using-python-14329).
>
>
>
> NB sadly I don't have time to attempt/review this myself, but would be
> intrigued to hear from you, should you...
>
>
> Last comment (to OP): you should be aware of the Python version
> 'covered'. Am not convinced that v3.7 is that important - to a beginner.
> Thus, maybe accept v3.5+, and make a practice of reviewing the Python
> docs - especially the Release Notes if you think version differences are
> important/worthy of particular concern.
>
>
> On 16/07/19 9:24 AM, Andrew Z wrote:
> > Gys - hats off.
> >
> > Basically what Dennis is saying- you dont need a book "about python ".
> > Tutorials and general search online will get you further and faster than
> > any book.
> >
> > Blah-blah about myself:
> > my bookshelf has 2 technical books, just because i got them to prepare
> for
> > certifications.
> > For my trading app, i had to figure  out how to work with asyncio module,
> > at the time -2017 , there were no semi- decent explanation for it, let
> > alone books. By 2018 it became "the thing" with a ton of books.
> > Blah-blah= off
> >
> > Good luck.
> >
> > P.s. and if you want to implement your idea really fast and easy - look
> at
> > the go (golang.org). In my humble opinion- it is super easy and
> excellent
> > all around. Doing their golangtour is all you need to write a working
> app.
> > P.p.s. i just started a holy war .. damn.
> >
> > On Mon, Jul 15, 2019, 17:03 Dennis Lee Bieber 
> wrote:
> >
> >> On Mon, 15 Jul 2019 22:17:34 +0200, Gys  declaimed
> >> the
> >> following:
> >>
> >>> I also would like to have a good book, but have not yet decided which
> >>> one. There is a 50$ book on learning Python; the language reference (?)
> >>> There is a 50$ book for learning PyQt5 programming of a GUI. There is a
> >>> 50$ book on using Python in Pandas for analysing tabular data.
> >>>
> >>
> >>  For the language and "batteries" -- every distribution should
> >> provide
> >> the language reference, and the standard library reference. If one has
> a)
> >> experience with other languages, the LRM should be sufficient for
> learning
> >> the syntax; b) skill at interpreting technical documents, one should
> become
> >> familiar with the contents of the SL reference (this does not mean
> >> memorizing all of it -- critical would be the chapters on data types
> [which
> >> explains what one can do with lists, dictionaries, tuples...] and then
> get
> >> an idea of the contents of other chapters, so one can look up specifics
> for
> >> tasks.
> >>
> >>  After that, one ends up with print books that tend to focus on
> >> narrow
> >> application domains: XML, WxPython, SQLAlchemy, MatPlotLib, Win32 (just
> >> from scanning my bookshelf).
> >>
> >>  If one lacks both A and B, one ends up with various editions of
> >> "Learning Python", "Programming Python", and "Fluent Python" (among many
> >> others).
> >>
> >>
> >> --
> >>  Wulfraed Dennis Lee Bieber AF6VN
> >>  wlfr...@ix.netcom.com
> >> http://wlfraed.microdiversity.freeddns.org/
> >>
> >> --
> >> https://mail.python.org/mailman/listinfo/python-list
> >>
>
> --
> Regards =dn
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Books for Python 3.7

2019-07-15 Thread Andrew Z
Gys - hats off.

Basically what Dennis is saying- you dont need a book "about python ".
Tutorials and general search online will get you further and faster than
any book.

Blah-blah about myself:
my bookshelf has 2 technical books, just because i got them to prepare for
certifications.
For my trading app, i had to figure  out how to work with asyncio module,
at the time -2017 , there were no semi- decent explanation for it, let
alone books. By 2018 it became "the thing" with a ton of books.
Blah-blah= off

Good luck.

P.s. and if you want to implement your idea really fast and easy - look at
the go (golang.org). In my humble opinion- it is super easy and excellent
all around. Doing their golangtour is all you need to write a working app.
P.p.s. i just started a holy war .. damn.

On Mon, Jul 15, 2019, 17:03 Dennis Lee Bieber  wrote:

> On Mon, 15 Jul 2019 22:17:34 +0200, Gys  declaimed
> the
> following:
>
> >I also would like to have a good book, but have not yet decided which
> >one. There is a 50$ book on learning Python; the language reference (?)
> >There is a 50$ book for learning PyQt5 programming of a GUI. There is a
> >50$ book on using Python in Pandas for analysing tabular data.
> >
>
> For the language and "batteries" -- every distribution should
> provide
> the language reference, and the standard library reference. If one has a)
> experience with other languages, the LRM should be sufficient for learning
> the syntax; b) skill at interpreting technical documents, one should become
> familiar with the contents of the SL reference (this does not mean
> memorizing all of it -- critical would be the chapters on data types [which
> explains what one can do with lists, dictionaries, tuples...] and then get
> an idea of the contents of other chapters, so one can look up specifics for
> tasks.
>
> After that, one ends up with print books that tend to focus on
> narrow
> application domains: XML, WxPython, SQLAlchemy, MatPlotLib, Win32 (just
> from scanning my bookshelf).
>
> If one lacks both A and B, one ends up with various editions of
> "Learning Python", "Programming Python", and "Fluent Python" (among many
> others).
>
>
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.com
> http://wlfraed.microdiversity.freeddns.org/
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Books for Python 3.7

2019-07-12 Thread Andrew Z
Then look at, for example, tutorialpoint.com for basic concepts - loops,
data structures,  objects .

Pet- project- something you want to build.

For example, my  current petproject is a android based clock with a voice
recognition.
Use case - clock should understand 2-3 commands to set time 8nterval and
start/stop countdown.
I have 0 knowledge in android and kotlin. So for me to get to voice
recognition part i need to learn basics of the android and kotlin.



On Fri, Jul 12, 2019, 15:35 RIchy M  wrote:

> On Friday, July 12, 2019 at 2:45:48 PM UTC-4, Andrew Z wrote:
> > Richy,
> >  What specific part you consider hard?
> > If i may suggest,  get a (pet) project as you read it.
> >
> > On Fri, Jul 12, 2019, 13:46 RIchy M  wrote:
> >
> > > On Friday, July 12, 2019 at 1:00:01 PM UTC-4, MRAB wrote:
> > > > On 2019-07-12 16:40, Terry Reedy wrote:
> > > > > On 7/12/2019 11:27 AM, Richard Mok wrote:
> > > > >
> > > > >> It does not mention on the book which version of Python it is
> using.
> > > > >
> > > > > That would likely mean 2.x.  Easy way to tell:
> > > > > 2.x has 'print x' statements.  3.x has 'print(x)' function calles.
> > > > >
> > > > I had a brief look online and saw a preview. It was written in 2006
> and
> > > > Appendix B stops at Python 2.5. A lot has happened since then!
> > >
> > > I already stopped studying from this book.
> > > Now just reading the 3.7 tutorial that came with the install.
> > > But I am a beginner...
> > > Finding it tough to learn like that.
> > > I need like a beginners guide to Python 3.7 sort of book.
> > > --
> > > https://mail.python.org/mailman/listinfo/python-list
> > >
>
> Hi Andrew
>
> I feel that that guide is written for people who already have some basic
> knowledge of Python.
> I am on the beginners level only.
>
> What is a (pet) project?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Books for Python 3.7

2019-07-12 Thread Andrew Z
Richy,
 What specific part you consider hard?
If i may suggest,  get a (pet) project as you read it.

On Fri, Jul 12, 2019, 13:46 RIchy M  wrote:

> On Friday, July 12, 2019 at 1:00:01 PM UTC-4, MRAB wrote:
> > On 2019-07-12 16:40, Terry Reedy wrote:
> > > On 7/12/2019 11:27 AM, Richard Mok wrote:
> > >
> > >> It does not mention on the book which version of Python it is using.
> > >
> > > That would likely mean 2.x.  Easy way to tell:
> > > 2.x has 'print x' statements.  3.x has 'print(x)' function calles.
> > >
> > I had a brief look online and saw a preview. It was written in 2006 and
> > Appendix B stops at Python 2.5. A lot has happened since then!
>
> I already stopped studying from this book.
> Now just reading the 3.7 tutorial that came with the install.
> But I am a beginner...
> Finding it tough to learn like that.
> I need like a beginners guide to Python 3.7 sort of book.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Pandas- yahoo finance

2019-06-04 Thread Andrew Z
Hello,
 Do i get it right that yahoo finance is no longer available as a data
source for pandas?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why Python has no equivalent of JDBC of Java?

2019-05-20 Thread Andrew Z
Exactly right. Im not sure why Marco is wondering about native drivers not
to be a part of python module (for oracle).
Id be very unhappy, if a python module come with a native drivers for
something as complex as a database.

Cx guys gave you the power to install what and how your project requires.
In  Microsoft case .. that would be a different discussion :)

On a flip side, if you dont need oracle specific features, then maybe u
should use something basic for data storage. //but thats a different
discussion


On Mon, May 20, 2019, 19:18 Michael Torrie  wrote:

> On 05/20/2019 04:23 PM, Andrew Z wrote:
> > What does 249 specification mention about drivers?
>
> Nothing that I can see.
>
> But it stands to reason that at some point the Python code is going to
> have to interface with the SQL database server's API. And when the
> database in question is proprietary, the original poster should probably
> not be surprised that a special driver install is required. I assume
> it's also required for JDBC also, but since Java is owned by Oracle,
> they probably install such things automatically.
>
> >
> > On Mon, May 20, 2019, 17:39 Marco Sulla via Python-list <
> > python-list@python.org> wrote:
> >
> >> On Mon, 20 May 2019 at 17:32, Thomas Jollans  wrote:
> >>
> >>> Python has a the "Python Database API" (DB API 2.0)
> >>> https://www.python.org/dev/peps/pep-0249/
> >>>
> >>
> >> So why Oracle need instantclient for using cx_Oracle? They say they use
> >> DB-API:
> >>
> >>> *cx_Oracle* is a Python extension module that enables access to Oracle
> >>> Database. It conforms to the Python database API 2.0 specification
> >> <http://www.python.org/topics/database/DatabaseAPI-2.0.html> with
> >>> a considerable number of additions and a couple of exclusions.
> >>
> >> https://oracle.github.io/python-cx_Oracle/
> >>
> >>
> >> On Sun, 19 May 2019 at 23:47, Chris Angelico  wrote:
> >>
> >>> I've no idea what the hassles are with Oracle, as it's a database
> >>> engine that I don't use. But with PostgreSQL, which I *do* use, I can
> >>> assure you that it's much easier
> >>>
> >>
> >> I use Postgres if I can choose, but companies uses Oracle unluckily.
> Oracle
> >> and MSSQL. And I must say that surprisingly, being a Microsoft product,
> I
> >> find MSSQL more simple to install than Oracle, like Postregres, and has
> an
> >> easier SQL syntax.  Like Postgres.
> >> --
> >> https://mail.python.org/mailman/listinfo/python-list
> >>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why Python has no equivalent of JDBC of Java?

2019-05-20 Thread Andrew Z
What does 249 specification mention about drivers?

On Mon, May 20, 2019, 17:39 Marco Sulla via Python-list <
python-list@python.org> wrote:

> On Mon, 20 May 2019 at 17:32, Thomas Jollans  wrote:
>
> > Python has a the "Python Database API" (DB API 2.0)
> > https://www.python.org/dev/peps/pep-0249/
> >
>
> So why Oracle need instantclient for using cx_Oracle? They say they use
> DB-API:
>
> > *cx_Oracle* is a Python extension module that enables access to Oracle
> > Database. It conforms to the Python database API 2.0 specification
>  with
> > a considerable number of additions and a couple of exclusions.
>
> https://oracle.github.io/python-cx_Oracle/
>
>
> On Sun, 19 May 2019 at 23:47, Chris Angelico  wrote:
>
> > I've no idea what the hassles are with Oracle, as it's a database
> > engine that I don't use. But with PostgreSQL, which I *do* use, I can
> > assure you that it's much easier
> >
>
> I use Postgres if I can choose, but companies uses Oracle unluckily. Oracle
> and MSSQL. And I must say that surprisingly, being a Microsoft product, I
> find MSSQL more simple to install than Oracle, like Postregres, and has an
> easier SQL syntax.  Like Postgres.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why Python has no equivalent of JDBC of Java?

2019-05-19 Thread Andrew Z
The pg python lib requires
https://www.postgresql.org/docs/current/libpq.html
pip pulls it as a part of the lib install, whereas in oracle case you
install the driver yourself first.(suize matters)

//for some reason i thought the driver libs come as part of cx . But it was
a year ago and my memory may play tricks on me.


On Sun, May 19, 2019, 17:44 Chris Angelico  wrote:

> On Mon, May 20, 2019 at 7:34 AM Marco Sulla via Python-list
>  wrote:
> >
> > I programmed in Python 2 and 3 for many years, and I find it a fantastic
> > language.
> >
> > Now I'm programming in Java by m ore than 2 years, and even if I found
> its
> > code much more boilerplate, I admit that JDBC is fantastic.
> >
> > One example over all: Oracle. If you want to access an Oracle DB from
> > Python, you have to:
> >
> > 1. download the Oracle instantclient and install/unzip it
> > 2. on Linux, you have also to install/unzip Development and Runtime
> package
> > 3. on windows, you have to add the instantclient to PATH
> > 4. on Linux, you have to create a script to source that sets PATH,
> > ORACLE_HOME and LD_LIBRARY_PATH
> >
> > Finally, you can use cx_Oracle.
> >
> > Java? You have only to download ojdbcN.jar and add it to Maven/Gradle.
> >
> > Why Python has no equivalent to JDBC?
>
> I've no idea what the hassles are with Oracle, as it's a database
> engine that I don't use. But with PostgreSQL, which I *do* use, I can
> assure you that it's much easier:
>
> $ pip install psycopg2
> >>> import psycopg2
>
> Job done.
>
> If Oracle is harder to use, it may be a specific issue with installing
> the Oracle client. Have you tried using pip to install cx_oracle?
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why Python has no equivalent of JDBC of Java?

2019-05-19 Thread Andrew Z
Marco,
  You clearly know more about python/java universe than i do.
 But im infinitely thankful to cx team for putting out the package.
Feature and performance wise , even with non supported oracle timesten, it
was fantastic.
Id always go after "native" vs jdbc. But i understand that most of apps
have a very general workflow of " select some, insert some/delete" thus
most of the native features are not required..

Sorry, its Sunday,  float off the subject.

On Sun, May 19, 2019, 17:33 Marco Sulla via Python-list <
python-list@python.org> wrote:

> I programmed in Python 2 and 3 for many years, and I find it a fantastic
> language.
>
> Now I'm programming in Java by m ore than 2 years, and even if I found its
> code much more boilerplate, I admit that JDBC is fantastic.
>
> One example over all: Oracle. If you want to access an Oracle DB from
> Python, you have to:
>
> 1. download the Oracle instantclient and install/unzip it
> 2. on Linux, you have also to install/unzip Development and Runtime package
> 3. on windows, you have to add the instantclient to PATH
> 4. on Linux, you have to create a script to source that sets PATH,
> ORACLE_HOME and LD_LIBRARY_PATH
>
> Finally, you can use cx_Oracle.
>
> Java? You have only to download ojdbcN.jar and add it to Maven/Gradle.
>
> Why Python has no equivalent to JDBC?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python resources recommendations

2019-03-09 Thread Andrew Z
I would think that your experience with other languages would guide you on
the route of learning another tool..

On Sat, Mar 9, 2019, 13:01 Arup Rakshit  wrote:

> Hello Python,
>
> This is my first time in this mailing list. I am a Ruby/JS developer by
> day. I have decided to learn Python now this year. Being an experienced
> developer as I said above which resources I should pick to learn Python in
> and out? Currently I am reading this
> https://docs.python.org/3/tutorial/index.html <
> https://docs.python.org/3/tutorial/index.html> . What next you would
> recommend me after this? I would like to learn Flask once I feel good with
> Python core.
>
>
> Thanks,
>
> Arup Rakshit
> a...@zeit.io
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hands-On Quantum Computing with Python

2019-01-05 Thread Andrew Z
Good for you.

On Sat, Jan 5, 2019, 06:25 Bhagvan Kommadi  I am coauthoring a packt book : Hands-On Quantum Computing with Python.
> The book will be published around Aug 2019
>
>
>
> The book will introduce quantum computing and a comprehensive overview of
> the quantum programming languages currently available, such as QCL, QASM,
> QUIL, and the differences between them. It will have examples and teach the
> reader how to write popular quantum algorithms in some of these languages,
> such as Grover’s search and Shor’s factorization algorithm.
>
>
>
> #python #quantumcomputing #cryptography
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Good editor for python

2018-11-11 Thread Andrew Z
Brian, thank you for sharing. Looks very interesting.

On Sun, Nov 11, 2018, 10:46 Brian J. Oney via Python-list <
python-list@python.org wrote:

> Hi Olivier
>
> I am glad you did not trigger an editor war. I don't know how familiar you
> are
> with emacs. The answer depends alot on your preference and future work.
> Emacs
> and vi have been around for a long time for good reasons.
>
> If you prefer an extensible and futureproof editor, I can wholeheartedly
> recommend emacs or vi. I went from a happy emacs user to an even happier
> spacemacs user. Spacemacs is a batteries-included emacs configuration which
> lets you choose between emacs-like or vi keybindings, which are mnemonic,
> efficient, consistent, and, above all, discoverable. Discoverability
> allows a
> person who has been using something for a while to find out even more
> tricks
> in the moment that those tricks would be useful. Spacemacs has tons of
> bells
> and whistles and still manages to be fast (through lazy configuration
> loading).
>
> If you are looking at literate programming, Jupyter Notebooks are hard to
> beat, especially if you want to share code with novices. In case you want a
> medusa that eats everything else for lunch, look further. Such a beast can
> be
> harnessed with org-mode, an emacs mode which can be just about anything you
> want it to be. You can do literate devops, literate programming, mix
> programming languages, export to your grandma's toaster, and feed the dog
> with
> org-mode, if you want to play. Org-mode's syntax and power is unmatched,
> to my
> knowledge.
>
> That all depends on how far down the rabbit hole you want to dive. Emacs
> with
> pdb is pretty good though. To get the functionality you miss is pretty
> simple
> with spacemacs.  For more information and platform-specific instructions,
> please see the following link.
>
> https://github.com/syl20bnr/spacemacs
>
> The basic template already activates python support.
>
> That's my two cents.
>
> Cheers
> Brian
>
> On Sun, 2018-11-11 at 08:45 -0600, Spencer Graves wrote:
> >People rave about Jupyter Notebooks, which reportedly allow you
> > to mix narrative with code describing what you are doing and why.
> >
> >
> >I primarily program in R, and RMarkdown Documents in RStudio
> > allow me to mix narrative with R and Python code.  I explain what I'm
> > doing and why, then write "```{python}" ... "```" to encapsulate a
> > Python code snippet and "```{r}" ... "```" for an R code snippet. Or I
> > just use the Idle editor that comes with Python.
> >
> >
> >Someone suggested that Apache Zeppelin  and / or BeakerX might be
> > able to do this also, but I've not tried or verified them.
> >
> >
> >Spencer Graves
> >
> >
> > On 2018-11-11 08:11, Andrew Z wrote:
> > > If you do scripts - emacs/vi is the way to go.
> > > If you need something more (like creating libraries,  classes) go with
> > > pycharm. It is a professionally made IDE.
> > >
> > > Over past 2 years ive been trying to "downgrade" myself to something
> with
> > > less belts and whistles,  but come back to it all the time.
> > >
> > > On the other hand , if you already use emacs - u should not need
> anything
> > > else.
> > >
> > > On Sun, Nov 11, 2018, 04:15 Olive  wrote:
> > >
> > > > I am not a professional programmer but I use Python regularly for
> custom
> > > > scripts (and plot with matplotlib). I have just learned VBA for
> Excel: what
> > > > I found amazing was their editor: it is able to suggest on the spot
> all the
> > > > methods an object support and there is a well-integrated debugger. I
> wonder
> > > > if something similar exists for Python. For now I just use emacs
> with the
> > > > command line pdb. What do people use here? Ideally I would like to
> have
> > > > something that is cross platform Windows/Linux.
> > > >
> > > > Olivier
> > > >
> > > > --
> > > > https://mail.python.org/mailman/listinfo/python-list
> > > >
> >
> >
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Good editor for python

2018-11-11 Thread Andrew Z
If you do scripts - emacs/vi is the way to go.
If you need something more (like creating libraries,  classes) go with
pycharm. It is a professionally made IDE.

Over past 2 years ive been trying to "downgrade" myself to something with
less belts and whistles,  but come back to it all the time.

On the other hand , if you already use emacs - u should not need anything
else.

On Sun, Nov 11, 2018, 04:15 Olive  I am not a professional programmer but I use Python regularly for custom
> scripts (and plot with matplotlib). I have just learned VBA for Excel: what
> I found amazing was their editor: it is able to suggest on the spot all the
> methods an object support and there is a well-integrated debugger. I wonder
> if something similar exists for Python. For now I just use emacs with the
> command line pdb. What do people use here? Ideally I would like to have
> something that is cross platform Windows/Linux.
>
> Olivier
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cloud platform with GPU

2018-11-10 Thread Andrew Z
Denis,
 ..none of them was very satisfactory.
Sharing your requirements will be a good first step for getting good
answers.

On Sat, Nov 10, 2018, 02:26 denis meng  Good day all,
>
> I am looking for a good cloud platform to do all my python development for
> machine learning with GPU availability, so far I have used Amazon ec2,
> google colab, kaggle etc but none of them was very satisfactory.
>
> Anyone has good experience with other options? please share and TIA
>
> Denis
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Keys in dict and keys not in dict

2018-03-19 Thread Andrew Z
Beautiful.
Thank you Chris, Ben, Peter and Inada.

On Mar 19, 2018 3:14 AM, "INADA Naoki"  wrote:

> > expected = {"foo", "bar", "spam"}
> > missing = expected - set(json.keys())
> >
>
> dict.keys() returns set-like object.
> So `missing = expected - json.keys()` works fine, and it's more efficient.
>
> --
> INADA Naoki  
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Keys in dict and keys not in dict

2018-03-18 Thread Andrew Z
hello,

 i'd like to check if a function parameter (json) has all the keys I expect
it to have and if it doesn't - point out the one that is missing.

 What's the good way of doing that?

"good way" - something concise... i'd like to avoid using :
 if key in json:
#pass
 else
   print(" Oops, i did it again ...")

thank you
AZ
-- 
https://mail.python.org/mailman/listinfo/python-list


A better solution

2018-03-16 Thread Andrew Z
Hello,
 im not entirely happy with my solution and would love to hear your
suggestions on how to improve the solution.

I simplified the task while keeping the code working.

Task:
 financial accounts are described by XML documents. I want to architecture
the code to be easily extendible ( easy to add more accounts) and with
minimum repetitive code in each class.

All XML documents have a few common (SSN, first/last, sex, etc.) and unique
fields. Both common and unique fields may or may not be present in the
passed parameters.

I came up with the following solution:
 one class as a common "account" with children that have specific
functionality for their specific fields.
What i _really_ don't like is the a repetitive code in each _init_ and
"update" method.
Code:
-start 

from flask import Flask, jsonify, request
import xml_oper


app = Flask(__name__)

@app.route('/')
def index():
   return "Hello, World!"


@app.route('/INT/API/1.0/Accounts/IRA_Simple', methods =['POST'])
def post_IRA_Simple():

   json = request.get_json()

   account = xml_oper.account_type['IRA']
   account.update_xml(output_file_name='IRA.xml',json=json)
   return jsonify( 'all good ), 201

if __name__ == '__main__':
   app.run(debug=True)


xml_oper,py

from lxml import etree
from bs4 import BeautifulSoup as Soup


class Account():
   '''
  Parent for all account types

   '''
   _file_path_source   = 'XXX/XML_Docs/Sample_ApplicationXML/'
   _file_path_dest = 'X/src/XML/'

   def __init__(self):
  pass

   def _open_xml(self, file_name):
  self._soup = Soup(open(Account._file_path_source + file_name,
'r'), 'lxml')

   def _write_xml(self, file_name):
  f = open(Account._file_path_dest + file_name, 'w')
  f.write(self._soup.prettify())
  f.close()

   def _update(self, json):
  # update only common fields
  self._soup.application.customer['email'] = 'b...@email.com'


class IRA(Account):
   def __init__(self, source_file_name):
  super().__init__()
  super()._open_xml(file_name=source_file_name)

   def update_xml(self, output_file_name, json):
  super()._update(json= json)
  # update specific to IRA account fields
  # values may or may not exit
  super()._write_xml(file_name=output_file_name)


class Checking(Account):

   def __init__(self, source_file_name):
  super().__init__()
  super()._open_xml(file_name=source_file_name)

   def update_xml(self, output_file_name, json):
  super()._update(json= json)
  # update specific to CHK account fields
  # values may or may not exit
  super()._write_xml(file_name=output_file_name)


account_type = {
'IRA' : IRA('IRA_Sample.xml'),
'Checking' : Checking('Checking_Sample.xml')
}




--- end

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


Re: Flask: request vs Request

2018-03-12 Thread Andrew Z
Thank you Christopher.

On Mar 12, 2018 09:10, "Christopher Mullins" 
wrote:

> Could you please give some context when you reply, TIA
>>
>
> Whoops, thanks for the reminder Mark.
>
> So what for the Request is used  for then?
>
>
> In general when you see that something in Python starts with a capital
> letter, that indicates a class. Check out the relevant section of the PEP8
> coding style [1], this is a good reference to have on hand.  (This
> generalization doesn't apply to builtin types which follow a separate
> convention, also outlined in [1] -- and of course there are a numerous
> exceptions.)
>
> This holds for your variable in question "request" which is an instance of
> the Request class.  Check out [2] for more information on this.  PyCharm
> tries to do its best but I've had this problem too.  You can always open up
> a python REPL and look at the object yourself:
>
> >>> import flask
> >>> r = flask.Request
> >>> r
> 
> >>> dir(r)
>
> and so on.  When I'm working in python I like to keep one of these open
> for this purpose.
>
> HTH,
> Chris
>
> [1] https://www.python.org/dev/peps/pep-0008/#class-names
> [2] http://flask.pocoo.org/docs/0.12/api/#incoming-request-data
>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask: request vs Request

2018-03-11 Thread Andrew Z
 after reading the docs and stackoverflow i got some rudimentary
understanding of Request vs request.
i still don't understand why i PyCharm won't show properties, but it is
tool centric question that hardly belongs to this group.

On Sun, Mar 11, 2018 at 10:02 AM, Andrew Z <form...@gmail.com> wrote:

> Sorry guys. i realized i was "mumbling" .
>
> What is the difference between Request and request?  -   RTFM
> <http://flask.pocoo.org/docs/0.12/api/#flask.Request>, Andrew
>
> Questions:
>  a. when do i use Request?
>  b. why can't I see any properties of the request?  For example, in
> Michael's tutorial, there is a call for  request.json. PyCharm brings no
> suggestions when i type in "request. "
>
>
>
>
> On Sat, Mar 10, 2018 at 11:30 PM, Mark Lawrence <breamore...@gmail.com>
> wrote:
>
>> On 11/03/18 04:09, Christopher Mullins wrote:
>>
>>> In the code you linked, I don't see where the *R*equest is used. The
>>> request variable is setup by flask when you annotate the function with
>>> the
>>> resource endpoint and POST method. It contains the content of the request
>>> which can be converted to json if that content type was specified.
>>>
>>>
>> Could you please give some context when you reply, TIA.
>>
>> --
>> 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
>>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask: request vs Request

2018-03-11 Thread Andrew Z
Sorry guys. i realized i was "mumbling" .

What is the difference between Request and request?  -   RTFM
, Andrew

Questions:
 a. when do i use Request?
 b. why can't I see any properties of the request?  For example, in
Michael's tutorial, there is a call for  request.json. PyCharm brings no
suggestions when i type in "request. "




On Sat, Mar 10, 2018 at 11:30 PM, Mark Lawrence 
wrote:

> On 11/03/18 04:09, Christopher Mullins wrote:
>
>> In the code you linked, I don't see where the *R*equest is used. The
>> request variable is setup by flask when you annotate the function with the
>> resource endpoint and POST method. It contains the content of the request
>> which can be converted to json if that content type was specified.
>>
>>
> Could you please give some context when you reply, TIA.
>
> --
> 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
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask: request vs Request

2018-03-10 Thread Andrew Z
that's right there is no Request used.
So what for the Request is used  for then?

Here

it is explained that request is for current request... that's kinda of
clears the air a bit.
but where do i find it's methods?



On Sat, Mar 10, 2018 at 11:09 PM, Christopher Mullins <
christopherrmull...@gmail.com> wrote:

> In the code you linked, I don't see where the *R*equest is used. The
> request variable is setup by flask when you annotate the function with the
> resource endpoint and POST method. It contains the content of the request
> which can be converted to json if that content type was specified.
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Flask: request vs Request

2018-03-10 Thread Andrew Z
hello,

 i'm playing with  Michael Grinberg's "Restful API with python and flask"
tutorial

.

And i'm very much confused whats the difference between request and Request.
 the "request" is introduced @ the point he talks about "POST". Here is the
sample from the tutorial:

from flask import request
@app.route('/todo/api/v1.0/tasks', methods=['POST'])def create_task():
if not request.json or not 'title' in request.json:
abort(400)
task = {
'id': tasks[-1]['id'] + 1,
'title': request.json['title'],
'description': request.json.get('description', ""),
'done': False
}
tasks.append(task)
return jsonify({'task': task}), 201


the help system talks about somekind of LocalProxy class and then im
getting lost 
The immediate trouble is that i don't see any methods for "request". ( Or,
at least, PyCharm can't find anything) and not sure what the "*r*equest" is
for and what i can do with it. Or should i use the "*R*equest"

Appreciate some guidance on the matter.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: LXML: can't register namespace

2018-03-09 Thread Andrew Z
Stefan,
 thank you for the link. That explains the line of thinking of the package
designer(s).
I also looked@ beautifulsoup and found it to work better with my old brains.

On Fri, Mar 9, 2018 at 9:46 AM, Stefan Behnel <stefan...@behnel.de> wrote:

> Peter Otten schrieb am 09.03.2018 um 14:11:
> > Stefan Behnel wrote:
> >
> >> Andrew Z schrieb am 07.03.2018 um 05:03:
> >>> Hello,
> >>>  with 3.6 and latest greatest lxml:
> >>>
> >>> from lxml import etree
> >>>
> >>> tree = etree.parse('Sample.xml')
> >>> etree.register_namespace('','http://www.example.com')
> >>
> >> The default namespace prefix is spelled None (because there is no prefix
> >> for it) and not the empty string.
> >
> > Does that mean the OP shouldn't use register_namespace() at all or that
> he's
> > supposed to replace "" with None?
>
> It meant neither of the two, but now that you ask, I would recommend the
> first. ;)
>
> An application global setup for the default namespace is never a good idea,
> thus my question regarding the actual intention of the OP. Depending on the
> context, the right thing to do might be be to either not care at all, or to
> not use the default namespace but a normally prefixed one instead, or to
> define a (default) namespace mapping for a newly created tree, as shown in
> the namespace tutorial.
>
> http://lxml.de/tutorial.html#namespaces
>
> Usually, not caring about namespace prefixes is the best approach. Parsers,
> serialisers and compressors can deal with them perfectly and safely, humans
> should just ignore the clutter, pitfalls and complexity that they
> introduce.
>
> Stefan
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: LXML: can't register namespace

2018-03-07 Thread Andrew Z
help(etree.register_namespace)
Help on cython_function_or_method in module lxml.etree:
register_namespace(prefix, uri)
Registers a namespace prefix that newly created Elements in that
namespace will use.  The registry is global, and any existing
mapping for either the given prefix or the namespace URI will be
removed.


On Wed, Mar 7, 2018 at 8:55 AM, Andrew Z <form...@gmail.com> wrote:

> Yes, if i give it any non empty tag - all goes well.
>
> All im trying to do is to extract a namespace ( i try to keep simple here.
> Just first one for now) and register it so i can save xml later on.
>
>
> On Mar 7, 2018 00:38, "Steven D'Aprano" <steve+comp.lang.python@
> pearwood.info> wrote:
>
>> On Tue, 06 Mar 2018 23:03:15 -0500, Andrew Z wrote:
>>
>> > Hello,
>> >  with 3.6 and latest greatest lxml:
>> >
>> > from lxml import etree
>> >
>> > tree = etree.parse('Sample.xml')
>> > etree.register_namespace('','http://www.example.com')
>>
>> > it seems to not be happy with the empty tag . But i'm not sure why and
>> > how to go about it.
>>
>> Have you tried using something other than the empty string?
>>
>> In the interactive interpreter, what does
>>
>> help(etree.register_namespace)
>>
>> say?
>>
>>
>>
>> --
>> Steve
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: LXML: can't register namespace

2018-03-07 Thread Andrew Z
Yes, if i give it any non empty tag - all goes well.

All im trying to do is to extract a namespace ( i try to keep simple here.
Just first one for now) and register it so i can save xml later on.


On Mar 7, 2018 00:38, "Steven D'Aprano" <
steve+comp.lang.pyt...@pearwood.info> wrote:

> On Tue, 06 Mar 2018 23:03:15 -0500, Andrew Z wrote:
>
> > Hello,
> >  with 3.6 and latest greatest lxml:
> >
> > from lxml import etree
> >
> > tree = etree.parse('Sample.xml')
> > etree.register_namespace('','http://www.example.com')
>
> > it seems to not be happy with the empty tag . But i'm not sure why and
> > how to go about it.
>
> Have you tried using something other than the empty string?
>
> In the interactive interpreter, what does
>
> help(etree.register_namespace)
>
> say?
>
>
>
> --
> Steve
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


LXML: can't register namespace

2018-03-06 Thread Andrew Z
Hello,
 with 3.6 and latest greatest lxml:

from lxml import etree

tree = etree.parse('Sample.xml')
etree.register_namespace('','http://www.example.com')

causes:
Traceback (most recent call last):
  File "/home/az/Work/flask/tutorial_1/src/xml_oper.py", line 16, in

etree.register_namespace('','http://www.example.com')
  File "src/lxml/etree.pyx", line 203, in lxml.etree.register_namespace
(src/lxml/etree.c:11705)
  File "src/lxml/apihelpers.pxi", line 1631, in lxml.etree._tagValidOrRaise
(src/lxml/etree.c:35382)
ValueError: Invalid tag name ''

partial Sample.xml:


http://www.example.com;>
 
  



it seems to not be happy with the empty tag .
But i'm not sure why and how to go about it.

thank you
AZ
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python to C code generator

2018-01-23 Thread Andrew Z
Id go this way too. Basic C is straightforward.  I usually consider
learning a new "thing " if the time to support potwntially combersome
solution using existing methods  justifies the effort.

On Jan 23, 2018 09:01, "Ned Batchelder"  wrote:

> On 1/23/18 8:48 AM, kushal bhattacharya wrote:
>
>> On Tuesday, January 23, 2018 at 7:05:02 PM UTC+5:30, bartc wrote:
>>
>>> On 23/01/2018 13:23, kushal bhattacharya wrote:
>>>
 On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal
 bhattacharya wrote:

> Hi,
> Is there any python framework or any tool as  which can generate C
> code from python code as it is .
>
> Thanks,
> Kushal
>
 yes i have but it generates a complex C code with python dependencies.I
 want to call the generated function from another C code but i Cant figure
 out how to do that

>>> Because the translation isn't simply defined.
>>>
>>> I've just tried nuitka on the Python code 'a=b+c', and it generates 2400
>>> lines of C. The main purpose seems to be to generate a self-contained
>>> executable corresponding to the Python, but generating first a C
>>> equivalent then using a C compiler and linker.
>>>
>>> This equivalent code may just contain all the bits in CPython needed to
>>> do the job, but bypassing all the stuff to do with executing actual
>>> byte-code. But it also seems to do some optimisations (in the generated
>>> C before it uses C compiler optimisations), so that if static types can
>>> be inferred it might make use of that info.
>>>
>>> Perhaps you simply want to use Python syntax to write C code? That would
>>> be a different kind of translator. And a simpler one, as 'a=b+c'
>>> translates to 'a+b+c;' in C.
>>>
>>> --
>>> bartc
>>>
>>
>> This is exactly what i meant to say.My goal is to translate the python
>> code into its C equivalent with function name as it is.
>>
>
> The best way to do that is to read the Python code, understand what it
> does, and re-write it in C.  You won't find an automatic tool that can do
> the job you want.  The semantics of Python and C are too different.
>
> --Ned.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: we want python software

2017-12-06 Thread Andrew Z
Can we mark the entire thread "spam", please?


On Dec 6, 2017 17:55, "Gregory Ewing"  wrote:

> Rick Johnson wrote:
>
> DOLT: "Programming is easy! Once you learn the langauge,
>> it's just a matter of fill-in-the-blanks."
>>
>
> To be fair to this person, for someone who has a natural
> aptitude for programming, it can be difficult to appreciate
> how hard it is for people who don't.
>
> When I first started programming, in my early teens, the
> basic ideas all seemed very straightforward, and I had
> no trouble seeing how to apply them. I unconsciously
> assumed it would be the same for anyone else with a
> reasonable level of intelligence.
>
> It was a while before it became clear to me that this is
> not the case at all.
>
> --
> Greg
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Politeness (was: we want python software)

2017-12-06 Thread Andrew Z
Looks like the longest thread for past 2 months.
Should we push it to be the longest for 2017?

:)


On Dec 6, 2017 15:34, "Ian Kelly"  wrote:

> On Wed, Dec 6, 2017 at 10:56 AM, Gene Heskett 
> wrote:
> > On Wednesday 06 December 2017 12:14:32 Ian Kelly wrote:
> >
> >> On Wed, Dec 6, 2017 at 9:42 AM, Gene Heskett 
> > wrote:
> >> > On Wednesday 06 December 2017 11:28:22 Random832 wrote:
> >> >> The third possibility is that he believes that this list is
> >> >> official in some corporate sense, that if he asks for the software
> >> >> and it is not free he will receive a price quote.
> >> >
> >> > Sadly, that an attitude even college profs don't get, having gotten
> >> > their sheepskin with only M$ stuff, that something could be both
> >> > free and good.
> >> >
> >> > It's a concept that makes no sense to the teachers, so of course
> >> > they don't teach it either.  Hell of a way to run a train.
> >>
> >> Depends where you went to school, probably. The CS department at my
> >> college was all over using Linux and free software.
> >
> > Then why not promote that seat of higher learning by naming it? Word of
> > mouth publicity is the best kind.
>
> Earlham College.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pros and cons of Python sources?

2017-11-27 Thread Andrew Z
Martin,
 Im Late to the party, but my (newbish) .02

I learned hard way not to mix rpm and pip (im on fedora).

Yes, pip ...-user is what i use now exclusively.

I doubt you can _easily_ clean everything up..especially considering that a
few linux core utils depend on python nowadays.
 Maybe you can try to "brute-force" it , by using : dnf/rpm --whatprovides
..| sort -u
And comparing with pip list.. (just a general idea).

You may also try to stand up a vm and compare lists from there too... (
agly, but will get the work done)

I have same mess as you do, but with python3. In my situation, i know i
messed something, because matplot would not graph anything despite my best
efforts. One day (in next e-6 months) when i get very annoyed with this
problem, ill wipe clean the machine and reinstall from scratch.

On Nov 27, 2017 15:25, "Martin Schöön"  wrote:

Den 2017-11-26 skrev Cameron Simpson :
> On 26Nov2017 10:00, nospam.Martin Schöön  wrote:
>>
>>Hmm, I seem to remember not being able to install packages with pip
unless I
>>did sudo pip.
>
> And this is exactly what I'm warning about. Many Linux users see some
kind of
> failure and just stick sudo on the front of the command. It is almost
always
> the wrong things to do, leading to effects in the OS install area instead
of
> being safely contained within one's home directory or work area.
>
> Instead of reaching straight for sudo, look at pip's manual or help. You
will
> find that:
>
>   pip install --user ...
>
> installs modules local to your home directory, avoiding troublesome
installs
> into the OS area.
>
Guilty as charged.

So, how do I restore order in my Python 2.7 installation? Uninstall
everything that looks, smells and tastes like Python 2.7 and then
re-install?

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


Re: Increasing the diversity of people who write Python (was: Benefits of unicode identifiers)

2017-11-24 Thread Andrew Z
Thank you Rick for well thought out argument.



On Nov 24, 2017 12:44, "Rick Johnson"  wrote:

> On Thursday, November 23, 2017 at 9:57:12 PM UTC-6, Ben Finney wrote:
> [...]
> > This is a necessary consequence of increasing the diversity
> > of people able to program in Python: people will express
> > ideas originating in their own language, in Python code.
> > For that diversity to increase, we English-fluent folk will
> > necessarily become a smaller proportion of the programming
> > community than we are today. That might be uncomfortable
> > for us, but it is a necessary adaptation the community
> > needs to undergo.
>
> Will your heroic crusade to bring equality to the shire also
> include Python standard library modules written in languages
> other than English? If so, then you'll need to contact
> Guido, as PEP8 will require some editing.
>
> Speaking of GvR...
>
> And even if you did managed to bring multilingualism to
> Python scripts and std-lib modules, wouldn't such
> "diversity" be merely symbolic?
>
> Hmm, because, when we consider the make-up of pydev (aka:
> nothing but English speaking dudes) we realize that there
> really isn't any diversity at all. At least, not where it
> matters. (aka: where the decision are being made)
>
> Furthermore, if we are to march headlong onto the glorious
> battlefields of diversity and equality, for the sake of all
> else, then, why should Guido's position be off limits? I
> mean, sure, he may a brilliant man. But he's surely not the
> most brilliant man on this planet, is he?
>
> And with that liberating thought in mind, may i offer an
> excerpt, for your intellectual consumption, from one of the
> most famous documents of all time?
>
> (emphasis mine)
>
> "Prudence, indeed, will dictate that governments long
> established should not be changed for light and transient
> causes; and accordingly, all experience hath shewn, that
> [humankind] are more disposed to _suffer_ while evils are
> _sufferable_, than to right themselves by abolishing the
> forms to which they are "accustomed"; but when a ~long~
> train of abuses and usurpations, pursuing invariably the
> same object, evinces a _design_ to reduce them under
> absolute *DESPOTISM* -- It is their *RIGHT*! It is their
> *DUTY*! -- to throw off such government and to provide new
> guards for their future security"
>
> ...Declaration of Independence: July 4, 1776
>
> I'm of the opinion that diversity is fine, so long as you
> don't make the fatal mistake of "lopping off your nose to
> spite your face".
>
> Take, for example, the accommodations our societies offer
> for handicapped people -- from wheel chair ramps, to
> reserved front-row parking spaces, to widened doorways,
> etc... -- these accommodations do *NOT*, in any way,
> undermine the accessability of healthy people who also utilize
> these same public spaces. In fact, the worst consequence of
> these accommodations might be that you and i must walk a few
> more steps from our car to the market.
>
> Big deal!
>
> But what you are suggesting is not so much an
> _accommodation_, as it is a fundamental fissure in our
> ability to communicate, one that will fracture the community
> far more than it is today. It would be as foolish as
> mandating that everyone must have their legs lopped-off, so
> that all will be "equal".
>
> Yes, diversity is great! But only when it welcomes outsiders
> without undermining the practical cohesiveness of the wider
> community. And if the result of your little "inclusivity
> project" is merely the replacement of N domestic community
> members with N foreign community members, foreigners who's
> regional dialects will muck-up the communication process,
> then it seems to me that what you have gained is merely a
> fulfillment of your _own_ emotional needs, at the expense of
> all.
>
> In conclusion.
>
> While a wise student of knowledge recognizes that:
>
> (1) social groups who have waxed into a homogenous block
> actually undermine themselves, because they lack the
> essential diversity of ideas required to see beyond the
> walls of their own "box", and the confirmation bias that
> infests such societies, will ensure that such a community is
> an evolutionary dead end.
>
> The same student _also_ recognizes that:
>
> (2) a society which resembles a jig-saw-puzzle dumped
> haphazardly on the floor, lacks the essential _cohesiveness_
> required to maintain a strong sense of _community_, a sense
> which allows multiple individuals to work towards a common
> goal, in manner this is both practical and efficient.
>
> Something to think about.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Increasing the diversity of people who write Python (was: Benefits of unicode identifiers)

2017-11-23 Thread Andrew Z
I have hard time seeing the benefits of this "necessity" , just
unreasonable  overcomplications for the name of "diversity".




On Nov 23, 2017 22:57, "Ben Finney"  wrote:

> Ian Kelly  writes:
>
> > On Thu, Nov 23, 2017 at 1:04 PM, Karsten Hilbert
> >  wrote:
> > > Using function arguments written in Thai script ?
> > >
> > > Understanding, let alone being able to read, code written in Arabic
> > > ?
> >
> > People are going to write code in Arabic whether you like it or not,
> > because not everybody speaks English, and not everybody who does
> > *wants* to use it.
>
> This is, I think, a good reason to allow Unicode identifiers (at least,
> those Unicode subsets which encode writing systems of languages) as
> programming-language identifiers.
>
> > Now, would you prefer to read code where the variable names are
> > written in Arabic script, or where the variable names are still in
> > Arabic but transliterated to Latin characters?
>
> (On the – evidently correct, in Karsten's case and mine – assumption
> that the reader does not understand Arabic script.)
>
> I've thought about this, and if the quesition is which would *I* prefer,
> the answer is I'd prefer the identifiers transliterated to the Latin
> (English-writing) characters.
>
> Because if I already can't understand the words, it will be more useful
> to me to be able to type them reliably at a keyboard, for replication,
> search, discussion with others about the code, etc.
>
> Set against that, though, I want the preferences of *others* to be taken
> into consideration also. And there are many more people who do not
> natively write English/Latin characters, that I want to feel welcome in
> the Python community.
>
> So it's a good thing that my own reading preference *does not* have
> weight in this matter. I'm not the primary audience for code identifiers
> written in Arabic script, so my preference should matter less than those
> who understand it.
>
> > Either way, you're not going to be able to understand it, so I'm not
> > sure why it makes a difference to you.
>
> I hope you can see that it can simultaneously make a difference – I
> would definitely prefer to read Latin-writing identifiers – while also
> being a lesser consideration that should not outweigh the benefits of
> allowing non-Latin-script identifiers.
>
> > If Arabic characters are allowed however, then it might be of use to
> > the people who are going to code in Arabic anyway. And if it isn't,
> > then they have the option not to use it either.
>
> This is a necessary consequence of increasing the diversity of people
> able to program in Python: people will express ideas originating in
> their own language, in Python code.
>
> For that diversity to increase, we English-fluent folk will necessarily
> become a smaller proportion of the programming community than we are
> today. That might be uncomfortable for us, but it is a necessary
> adaptation the community needs to undergo.
>
> --
>  \ “In any great organization it is far, far safer to be wrong |
>   `\  with the majority than to be right alone.” —John Kenneth |
> _o__)Galbraith, 1989-07-28 |
> Ben Finney
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Time travel - how to simplify?

2017-11-18 Thread Andrew Z
Thank you for your input, gentlemen.

I'm thinking about the following approach:

import datetime
from dateutil import relativedelta

fut_suffix ={ 1 : 'F',
  2 : 'G',
  3 : 'H',
  4 : 'J',
  5 : 'K',
  6 : 'M',
  7 : 'N',
  8 : 'Q',
  9 : 'U',
  10: 'V',
  11: 'X',
  12: 'Z'
  }

endDate = datetime.date.today()
startDate = endDate + relativedelta.relativedelta(months = -6,day = 1)

LocalSmlSuffix = [ suffix for mnth, suffix in fut_suffix.items() if
mnth == startDate.month]


On Tue, Nov 14, 2017 at 5:01 PM, Rick Johnson <rantingrickjohn...@gmail.com>
wrote:

> On Tuesday, November 14, 2017 at 1:44:17 PM UTC-6, Ben Finney wrote:
> > Andrew Z <form...@gmail.com> writes:
> >
> > > Now i want to get certain number of months. Say, i need  3 months
> duration
> > > starting from any month in dict.
> > >
> > > so if i start @ 7th:
> > > my_choice =7
> > >  for mnth, value in fut_suffix:
> > > if my_choice >= mnth
> > ># life is great
> > > but if :
> > > my_choice = 12 then my "time travel" becomes pain in the neck..
> >
> > The ‘itertools’ library in the Python standard library
> > <URL:https://docs.python.org/3/library/itertools.html> has what you
> > need:
> >
> > import itertools
> >
> > month_values = sorted(list(fut_suffix.keys()))
> > month_cycle = itertools.cycle(month_values)
> >
> > month_choice = 7
> > three_months_starting_at_choice = []
> > while len(three_months_starting_at_choice) < 3:
> > this_month = next(month_cycle)
> > if this_month >= month_choice:
> > three_months_starting_at_choice.append(this_month)
>
> Ben's advice is spot on[1], and exactly what i would do, but
> i believe it's important for you to discover how to
> implement a simple cycling algorithm yourself, _before_
> reaching for the pre-packaged junkfood in the itertools
> module. Can you do it? If not, then do as much as you can
> and then ask for help. Hey, you're only hurting yourself if
> you don't learn how. And it's surprisingly easy!
>
> [1] and it looks as though he included the kitchen sink,
> washcloths, dish soap, and some fine china as well! ಠ_ಠ
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: for/ if against dict - one liner

2017-11-18 Thread Andrew Z
Gentlemen,
 thank you very much for the replies and help.

Vincent's solution worked perfectly for me.
Alister - you are correct and for me, i was looking to achieve that -
readability and slightly less keystrokes.

On Tue, Nov 14, 2017 at 4:59 AM, alister via Python-list <
python-list@python.org> wrote:

> On Tue, 14 Nov 2017 00:44:18 -0500, Andrew Z wrote:
>
> > Hello,
> >  i wonder how do i get the "for" and "if" to work against a dictionary
> >  in
> > one line?
> >
> > basically i want to "squeeze":
> >  dct= [ 1 : "one", 2:"two", 3:"three"]
> >  for k, val in dct:
> >if k >= 2:
> >   # do magnificent things
> >
> > Thank you AZ
>
> why the need to single line it?
> is your computer running out of new line & space characters?
> it probably could be done with a dictionary comprehension but will that
> make things easier or harder to read/understand?
>
> "Readability counts"
>
>
>
>
> --
> (Presuming for the sake of argument that it's even *possible* to design
> better code in Perl than in C.  :-)
> -- Larry Wall on core code vs. module code design
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Time travel - how to simplify?

2017-11-13 Thread Andrew Z
well, yeah, it's unidirectional and final destination is always the same
and have little to do with the question.

Say, i have a dict:

fut_suffix ={ 1 : 'F',
  2 : 'G',
  3 : 'H',
  4 : 'J',
  5 : 'K',
  6 : 'M',
  7 : 'N',
  8 : 'Q',
  9 : 'U',
  10: 'V',
  11: 'X',
  12: 'Z'
  }

where key is a month.
Now i want to get certain number of months. Say, i need  3 months duration
starting from any month in dict.

so if i start @ 7th:
my_choice =7
 for mnth, value in fut_suffix:
if my_choice >= mnth
   # life is great
but if :
my_choice = 12 then my "time travel" becomes pain in the neck..

And as such - the question is - what is the smart way to deal with cases
like this?

Thank you
AZ
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Time travel - how to simplify?

2017-11-13 Thread Andrew Z
My implied solution is incorrect.


I should start with using the date type and, for example, dateutil package
for date manipulation and building the dictionary of needed dates/months.
And only after that, map against the fut_suffix.


On Tue, Nov 14, 2017 at 12:56 AM, Andrew Z <form...@gmail.com> wrote:

> well, yeah, it's unidirectional and final destination is always the same
> and have little to do with the question.
>
> Say, i have a dict:
>
> fut_suffix ={ 1 : 'F',
>   2 : 'G',
>   3 : 'H',
>   4 : 'J',
>   5 : 'K',
>   6 : 'M',
>   7 : 'N',
>   8 : 'Q',
>   9 : 'U',
>   10: 'V',
>   11: 'X',
>   12: 'Z'
>   }
>
> where key is a month.
> Now i want to get certain number of months. Say, i need  3 months duration
> starting from any month in dict.
>
> so if i start @ 7th:
> my_choice =7
>  for mnth, value in fut_suffix:
> if my_choice >= mnth
># life is great
> but if :
> my_choice = 12 then my "time travel" becomes pain in the neck..
>
> And as such - the question is - what is the smart way to deal with cases
> like this?
>
> Thank you
> AZ
>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


for/ if against dict - one liner

2017-11-13 Thread Andrew Z
Hello,
 i wonder how do i get the "for" and "if" to work against a dictionary in
one line?

basically i want to "squeeze":
 dct= [ 1 : "one", 2:"two", 3:"three"]
 for k, val in dct:
   if k >= 2:
  # do magnificent things

Thank you
AZ
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: matplot plot hangs

2017-11-04 Thread Andrew Z
Tim,
 it won't even advance to that line.

On Thu, Nov 2, 2017 at 8:28 AM, Tim Williams <tjand...@cox.net> wrote:

> On Wednesday, November 1, 2017 at 6:30:27 PM UTC-4, Andrew Z wrote:
> > nope. it doesnt:
> >
> > I added print-s after each line and that produced:
> > [az@hp src]$ cat ./main1.py
> > import matplotlib.pyplot as plt
> > print("imported")
> > plt.plot([1,2,4,1])
> > print("plot is done")
> > plt.show()
> > print("show is done")
> >
> > [az@hp src]$ python3.5 ./main1.py
> > imported
> > ^C^Z
> > [1]+  Stopped python3.5 ./main1.py
> >
> >
> > On Wed, Nov 1, 2017 at 9:31 AM, Vlastimil Brom <vlastimil.b...@gmail.com
> >
> > wrote:
> >
> > > 2017-11-01 13:49 GMT+01:00 Andrew Z <form...@gmail.com>:
> > > > Wolfgang,
> > > >  I tried to ran from ide with no rwsults, so now im trying from a
> > > terminal
> > > > in xwindow.
> > > > The .plot is the last line in the script and it does hang trying to
> > > execute
> > > > it.
> > > >
> > > >
> > > > On Nov 1, 2017 05:44, "Wolfgang Maier" <
> > > > wolfgang.ma...@biologie.uni-freiburg.de> wrote:
> > > >
> > > > On 01.11.2017 00:40, Andrew Z wrote:
> > > >
> > > >> hello,
> > > >>   learning python's plotting by using matplotlib with python35 on
> > > fedora 24
> > > >> x86.
> > > >>
> > > >> Installed matplotlib into user's directory.
> > > >> tk, seemed to work -
> > > >> http://www.tkdocs.com/tutorial/install.html#installlinux - the
> window
> > > >> shows
> > > >> up just fine.
> > > >> but when trying to run the simple plot (
> > > >> https://matplotlib.org/examples/pylab_examples/simple_plot.html)
> the
> > > >> script
> > > >> is hanging on;
> > > >>
> > > >> plt.plot(t, s)
> > > >>
> > > >> attempts to
> > > >> matplotlib.interactive(True) didn't bring anything,
> > > >>
> > > >>
> > > > Hi Andrew,
> > > >
> > > > From which environment are you trying to run the example? In the
> > > terminal,
> > > > from within some IDE, inside a jupyter notebook?
> > > >
> > > > Are you sure the script "is hanging on plt.plot(t, s)" and not after
> > > that?
> > > >
> > > > Best,
> > > > Wolfgang
> > > >
> > > > --
> > > Hi,
> > > sorry if it is too trivial, just to make sure, do you have a call to
> > > "show()" the resulting plot in the code?
> > >
> > > An elementary plotting code might be e.g.:
> > >
> > > import matplotlib.pyplot as plt
> > > plt.plot([1,2,4,1])
> > > plt.show()
> > >
> > > Does this work in your environment?
> > >
> > > It was not quite clear, what do you plan with interactive drawing, or
> > > whether you are using e.g. plt.interactive(True) already - this might
> > > be a problem as there could be collisions or the plot window is closed
> > > after the standalone script finishes.
> > >
> > > hth,
> > >  vbr
> > > --
> > > https://mail.python.org/mailman/listinfo/python-list
> > >
>
> Have you tried
>
> plt.show(block=False)
> ?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: matplot plot hangs

2017-11-01 Thread Andrew Z
nope. it doesnt:

I added print-s after each line and that produced:
[az@hp src]$ cat ./main1.py
import matplotlib.pyplot as plt
print("imported")
plt.plot([1,2,4,1])
print("plot is done")
plt.show()
print("show is done")

[az@hp src]$ python3.5 ./main1.py
imported
^C^Z
[1]+  Stopped python3.5 ./main1.py


On Wed, Nov 1, 2017 at 9:31 AM, Vlastimil Brom <vlastimil.b...@gmail.com>
wrote:

> 2017-11-01 13:49 GMT+01:00 Andrew Z <form...@gmail.com>:
> > Wolfgang,
> >  I tried to ran from ide with no rwsults, so now im trying from a
> terminal
> > in xwindow.
> > The .plot is the last line in the script and it does hang trying to
> execute
> > it.
> >
> >
> > On Nov 1, 2017 05:44, "Wolfgang Maier" <
> > wolfgang.ma...@biologie.uni-freiburg.de> wrote:
> >
> > On 01.11.2017 00:40, Andrew Z wrote:
> >
> >> hello,
> >>   learning python's plotting by using matplotlib with python35 on
> fedora 24
> >> x86.
> >>
> >> Installed matplotlib into user's directory.
> >> tk, seemed to work -
> >> http://www.tkdocs.com/tutorial/install.html#installlinux - the window
> >> shows
> >> up just fine.
> >> but when trying to run the simple plot (
> >> https://matplotlib.org/examples/pylab_examples/simple_plot.html) the
> >> script
> >> is hanging on;
> >>
> >> plt.plot(t, s)
> >>
> >> attempts to
> >> matplotlib.interactive(True) didn't bring anything,
> >>
> >>
> > Hi Andrew,
> >
> > From which environment are you trying to run the example? In the
> terminal,
> > from within some IDE, inside a jupyter notebook?
> >
> > Are you sure the script "is hanging on plt.plot(t, s)" and not after
> that?
> >
> > Best,
> > Wolfgang
> >
> > --
> Hi,
> sorry if it is too trivial, just to make sure, do you have a call to
> "show()" the resulting plot in the code?
>
> An elementary plotting code might be e.g.:
>
> import matplotlib.pyplot as plt
> plt.plot([1,2,4,1])
> plt.show()
>
> Does this work in your environment?
>
> It was not quite clear, what do you plan with interactive drawing, or
> whether you are using e.g. plt.interactive(True) already - this might
> be a problem as there could be collisions or the plot window is closed
> after the standalone script finishes.
>
> hth,
>  vbr
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: matplot plot hangs

2017-11-01 Thread Andrew Z
Wolfgang,
 I tried to ran from ide with no rwsults, so now im trying from a terminal
in xwindow.
The .plot is the last line in the script and it does hang trying to execute
it.


On Nov 1, 2017 05:44, "Wolfgang Maier" <
wolfgang.ma...@biologie.uni-freiburg.de> wrote:

On 01.11.2017 00:40, Andrew Z wrote:

> hello,
>   learning python's plotting by using matplotlib with python35 on fedora 24
> x86.
>
> Installed matplotlib into user's directory.
> tk, seemed to work -
> http://www.tkdocs.com/tutorial/install.html#installlinux - the window
> shows
> up just fine.
> but when trying to run the simple plot (
> https://matplotlib.org/examples/pylab_examples/simple_plot.html) the
> script
> is hanging on;
>
> plt.plot(t, s)
>
> attempts to
> matplotlib.interactive(True) didn't bring anything,
>
>
Hi Andrew,

>From which environment are you trying to run the example? In the terminal,
from within some IDE, inside a jupyter notebook?

Are you sure the script "is hanging on plt.plot(t, s)" and not after that?

Best,
Wolfgang

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


Re: matplot plot hangs

2017-10-31 Thread Andrew Z
Stefan,
I intentionally tried to use the qt backend that i do not have. I wanted to
check i the switch was working (or not).

All i want at this point is to use (seemed to be default) tkagg.

On Oct 31, 2017 20:15, "Stefan Ram" <r...@zedat.fu-berlin.de> wrote:

> Andrew Z <form...@gmail.com> writes:
> >ImportError: *No module named 'PyQt4'*
>
>   Matplotlib requires a large number of dependencies,
>   like »NumPy«, »dateutil«, »libpng«, or »pytz«.
>
>   There are also some capabilities provided by optional
>   backends which have their own dependencies.
>
>   If one would like to use the »Qt4Agg« backend, one would
>   also need to have »PyQt4« installed.
>
>   Some Python distributions might already contain many
>   dependencies.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


matplot plot hangs

2017-10-31 Thread Andrew Z
hello,
 learning python's plotting by using matplotlib with python35 on fedora 24
x86.

Installed matplotlib into user's directory.
tk, seemed to work -
http://www.tkdocs.com/tutorial/install.html#installlinux - the window shows
up just fine.
but when trying to run the simple plot (
https://matplotlib.org/examples/pylab_examples/simple_plot.html) the script
is hanging on;

plt.plot(t, s)

attempts to
matplotlib.interactive(True) didn't bring anything,

I do get an error while trying to switch the backend ( which is fine with me) :
plt.switch_backend('Qt4Agg')
>>> plt.switch_backend('Qt4Agg')
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/az/.local/lib/python3.5/site-packages/matplotlib/pyplot.py",
line 231, in switch_backend
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File 
"/home/az/.local/lib/python3.5/site-packages/matplotlib/backends/__init__.py",
line 60, in pylab_setup
[backend_name], 0)
  File 
"/home/az/.local/lib/python3.5/site-packages/matplotlib/backends/backend_qt4agg.py",
line 10, in 
from .backend_qt4 import (
  File 
"/home/az/.local/lib/python3.5/site-packages/matplotlib/backends/backend_qt4.py",
line 18, in 
from .qt_compat import QtCore, QtWidgets, _getSaveFileName, __version__
  File 
"/home/az/.local/lib/python3.5/site-packages/matplotlib/backends/qt_compat.py",
line 150, in 
from PyQt4 import QtCore, QtGui
ImportError: *No module named 'PyQt4'*
>>> plt.switch_backend('Agg')
>>> plt.switch_backend('TkAgg')


summary:

 why i can't use tkAgg, and how can i troubleshoot the issue?

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


Re: Ide vs ide

2017-10-28 Thread Andrew Z
I like this trajectory of conversation.
Can we re define "small tiny" as "scripts"?
 i can argue, based on my expirience with other languages, that there is no
need for an "ide". The most ive ever needed is a text editor and a few
plugins with "print".

Moving to "average" size projects.
What i found useful and what i use constantly:
 Built in, up to date, correct! help on _installed_classes, functions. The
golden standard all these years for me was Delphi (2,3).
 Drop downs to show list of functions for an object. Also validates your
logic as far as you  use of correct variable, type etc.
Templates- define a language construct,
Type a shortcut and get the whole construct inserted. Saves typing.
Built-in change control,  build.

This is the main functionality i use . Needless to say the ide itself has
to be professional. And, since im not doing coding 24x7, i prefer "buttons"
as opposite to shortcut-to-find-the-shortcut-so-i-can-shortcut to get the
action. (Yeah, i found myself far less productive  while using atom and
company).at the same time, using editors like atom, whenyou work with
multiple filetypes is a gods sent .





On Oct 28, 2017 07:40, "Rustom Mody"  wrote:

> On Saturday, October 28, 2017 at 4:46:03 PM UTC+5:30, Christian Gollwitzer
> wrote:
> > Am 28.10.17 um 09:04 schrieb Rustom Mody:
> > > [The other day I was writing a program to split alternate lines of a
> file;
> > > Apart from file-handling it was these two lines:
> > >
> > >  for x in lines[0::2]:   print(x.strip())
> > >  for x in lines[1::2]:   print(x.strip())
> > > ]
> >
> > ...and using the best(TM) tool for it, it is a one-liner:
> >
> > gawk '{ print > "split" NR%2}' input.txt
>
> Ooo!¡!
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Ide vs ide

2017-10-28 Thread Andrew Z
Yeah, lets start the war!
// joking!

But if i think about it... there are tons articles and flame wars about "a
vs b".
And yet, what if the question should be different:

If you were to create the "ide" for yourself (think lego) , what are the
functions that you _use_ and like a lot?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to plot

2017-10-27 Thread Andrew Z
 Rrhank you Thomas.

On Oct 27, 2017 04:23, "Thomas Jollans" <t...@tjol.eu> wrote:

> On 2017-10-27 07:18, Andrew Z wrote:
> > Hello,
> >  i'd like to create a graph/plot based a DB table's data, but not sure
> > where to start. I
> >
> >  also would like to have the following functionality:
> >  a. i'd like to have it in the separate window ( xwindow to be precise).
> >  b. and i'd like to have the graph updating with every record added to
> the
> > table.
> >
> > The workflow:
> >  a. main code is running and occasionally adding records to the table
> >  b. graph gets updated "automagically" and is shown in a separate from
> the
> > main terminal window.
> >
> > Main program does not have GUI, nor is Web based, just runs in the
> terminal
> > on Xwindows.
> >
> > i don't' really care about cross-platform compability and only want to
> run
> > that on linux xwindows.
> >
> > Thank you for your advise.
> >
>
> Matplotlib <https://matplotlib.org/> is the standard Python plotting
> library, and it has GUI backends (Tk, Qt, Gtk, ...) that should be
> perfectly suitable for your purposes.
>
> The API maybe takes some getting used to, but there are plenty of
> examples to be found around the web, and the main documentation is quite
> good.
>
> If you need the plots to update quickly (it doesn't sound like it) then
> you might need to luck into something else, like pyqtgraph or vispy.
>
>
> --
> Thomas Jollans
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


How to plot

2017-10-26 Thread Andrew Z
Hello,
 i'd like to create a graph/plot based a DB table's data, but not sure
where to start. I

 also would like to have the following functionality:
 a. i'd like to have it in the separate window ( xwindow to be precise).
 b. and i'd like to have the graph updating with every record added to the
table.

The workflow:
 a. main code is running and occasionally adding records to the table
 b. graph gets updated "automagically" and is shown in a separate from the
main terminal window.

Main program does not have GUI, nor is Web based, just runs in the terminal
on Xwindows.

i don't' really care about cross-platform compability and only want to run
that on linux xwindows.

Thank you for your advise.
-- 
https://mail.python.org/mailman/listinfo/python-list


Modern website

2017-10-22 Thread Andrew Z
I realize the following has little todo with python per se. But i hope to
get a guidance on how these types of tasks are done nowadays.

The task:
Ive been asked to create  an integration process. That is a few webpages
with questioneer with the submission to a "mother" company using its API .
Ideally this process will be used by a few 3rd party "child" companies -
they would just point a link from their site to mine. Prospective users
will fill out the pages and "mother company" will create accounts
associated with the referal "child" company.

The problem:
  how do i create a modern , slick  website. I also see , that each of
"child" would want to extend the look and feel of their site onto this
process. So, my process should have at least a few templates i can offer ,
that would match their site...
Im not too excited to use weebly or squarespace - id rather host everything
myself.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to read in the newsreader

2017-10-15 Thread Andrew Z
hmm. i did do that.  maybe just a delay.
I'll see how it will go tomorrow then. Thank you gents.

On Mon, Oct 16, 2017 at 12:30 AM, Chris Angelico <ros...@gmail.com> wrote:

> On Mon, Oct 16, 2017 at 3:19 PM, Andrew Z <form...@gmail.com> wrote:
> > Michael, that's what i use too - gmail. But i get the digest only and
> can't
> > really reply that way. i was hoping to get the mail.python.org list
>
> Turn off digests then. Easy!
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to read in the newsreader

2017-10-15 Thread Andrew Z
i'm typing without thinking. Sorry. Let me try again.

I subscribed to python-list@python.org. That has 0 spam ( as far as i can
see), but i can only get a digest.
They do say the list and comp.python group are bidirectional, but - at comp
- tons of spam, there - none.

The google groups doesn't seemed to filter anything in the comp group. But
what you recommend is to access the group using regular email client and
use it's spam filtering . Did i get that right ?


On Mon, Oct 16, 2017 at 12:19 AM, Andrew Z <form...@gmail.com> wrote:

> Michael, that's what i use too - gmail. But i get the digest only and
> can't really reply that way. i was hoping to get the mail.python.org
> list
>
> On Mon, Oct 16, 2017 at 12:00 AM, Michael Torrie <torr...@gmail.com>
> wrote:
>
>> On 10/15/2017 08:50 PM, Andrew Z wrote:
>> > Gents,
>> >  how do i get this group in a newsreader? The digest i'm getting is not
>> > workable for me - i can't reply , can only read the replies from the
>> > members of the group. Or. maybe, it shouldn't be a news reader
>> > please advise..
>> >
>> > P.S. Oh the comp.lang.python is a nightmare because of spam...
>>
>> Regardless of what usenet reader you use, com.lang.python will have the
>> same spam everywhere.  So maybe reading via usenet isn't that useful
>> anyway.
>>
>> I just subscribe to the mailing list and then have a rule in my email
>> filter to stick all list messages in their own folder (or gmail label).
>> I'm using gmail, so I just use gmail's filtering settings.  Then I view
>> email using IMAP and a conventional email reader that supports real
>> threading of messages.  Works great.  A lot of spam is filtered out this
>> way, also.  In fact very little spam gets through to my folder between
>> python.org's filtering and gmail's spam detection.
>>
>> I'm subscribed to maybe a dozen email lists, and I filter all of them
>> into their own folders.
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to read in the newsreader

2017-10-15 Thread Andrew Z
Michael, that's what i use too - gmail. But i get the digest only and can't
really reply that way. i was hoping to get the mail.python.org list

On Mon, Oct 16, 2017 at 12:00 AM, Michael Torrie <torr...@gmail.com> wrote:

> On 10/15/2017 08:50 PM, Andrew Z wrote:
> > Gents,
> >  how do i get this group in a newsreader? The digest i'm getting is not
> > workable for me - i can't reply , can only read the replies from the
> > members of the group. Or. maybe, it shouldn't be a news reader
> > please advise..
> >
> > P.S. Oh the comp.lang.python is a nightmare because of spam...
>
> Regardless of what usenet reader you use, com.lang.python will have the
> same spam everywhere.  So maybe reading via usenet isn't that useful
> anyway.
>
> I just subscribe to the mailing list and then have a rule in my email
> filter to stick all list messages in their own folder (or gmail label).
> I'm using gmail, so I just use gmail's filtering settings.  Then I view
> email using IMAP and a conventional email reader that supports real
> threading of messages.  Works great.  A lot of spam is filtered out this
> way, also.  In fact very little spam gets through to my folder between
> python.org's filtering and gmail's spam detection.
>
> I'm subscribed to maybe a dozen email lists, and I filter all of them
> into their own folders.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


how to read in the newsreader

2017-10-15 Thread Andrew Z
Gents,
 how do i get this group in a newsreader? The digest i'm getting is not
workable for me - i can't reply , can only read the replies from the
members of the group. Or. maybe, it shouldn't be a news reader
please advise..

P.S. Oh the comp.lang.python is a nightmare because of spam...
-- 
https://mail.python.org/mailman/listinfo/python-list


Best practise for passing time as arguments

2017-10-14 Thread Andrew Z
Hello,
 I wonder what are the "best practises" for passing "time" parameters to
functions?
I noticed that sometimes i pass "time" as a str and then start "massaging"
it into delta or i need this time format or that format. Thats quite
annoying and inconsistent.
I use word "time" as a general word for date/time/timedelta types.

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


Re: unorderable types: list() > int()

2017-10-13 Thread Andrew Z
The answer is:
 The dict returns list - my mistake obviously.

I think list.pop(0) is  better for sanity than list[0]:
 Pos= [k,v for ...].pop(0)



On Oct 13, 2017 00:23, "Andrew Z" <form...@gmail.com> wrote:

> Hello,
> pos = {"CLown":10,"BArbie":20}
> I want to return integer (10) for the keyword that starts with "CL"
>
>
> cl_ = [v for k, v in pos.items() if k.startswith('CL')]
> cl_pos = cl_[0]
> if cl_pos > 0:
>
>blah..
>
>
> There are 2 issues with the above:
>  a. ugly - cl_pos = cl_ [0] .  I was thinking something like
>
>
> cl_ = [v for k, v in pos.items() if k.startswith('CL')][0]
>
>   but that is too much for the eyes - in 2 weeks i'll rewrite this into
> something i can understand without banging against the desk.
> So what can be a better approach here ?
>
>
> b. in "cl_pos > 0:, cl_pos apparently is still a list. Though the run in a
> python console has no issues and report cl_pos as int.
>
>
> Appreciate.
>
>
>
>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


unorderable types: list() > int()

2017-10-12 Thread Andrew Z
Hello,
pos = {"CLown":10,"BArbie":20}
I want to return integer (10) for the keyword that starts with "CL"


cl_ = [v for k, v in pos.items() if k.startswith('CL')]
cl_pos = cl_[0]
if cl_pos > 0:

   blah..


There are 2 issues with the above:
 a. ugly - cl_pos = cl_ [0] .  I was thinking something like


cl_ = [v for k, v in pos.items() if k.startswith('CL')][0]

  but that is too much for the eyes - in 2 weeks i'll rewrite this into
something i can understand without banging against the desk.
So what can be a better approach here ?


b. in "cl_pos > 0:, cl_pos apparently is still a list. Though the run in a
python console has no issues and report cl_pos as int.


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


Re: Logging from files doesn't work

2017-10-12 Thread Andrew Z
Cameron, Peter,
 Thank you. Your comments were spot on. Changing root logger got the logs
spitting into the file. And i now can org these logs into one directory,
instead of the current mess.
Thank you!


On Oct 11, 2017 23:41, "Cameron Simpson" <c...@cskk.id.au> wrote:

> On 11Oct2017 22:27, Andrew Z <form...@gmail.com> wrote:
>
>> aha. So the issue is that main.py's __name__ attribute == "__main__" and
>> test.py is "test1.test".
>>
>
> Yeah. If you invoke a module as "python -m module_name" its __name__ field
> is "__main__". That makes the boilerplate work, but breaks your expectation
> that __name__ is usually module_name.
>
> if i manually assign names:
>> main.py - >
>>
>> log = logging.getLogger("MAIN")
>>
>> test.py - >
>> log = logging.getLogger("MAIN.test1.test")
>>
>> then logging is working perfectly well.
>>
>> This brings me to the question - what is wrong with me file
>> naming/structure that confuses the logging module? I'm not sure i
>> really want to have each little file in it's own directory too..
>>
>
> I confess to not using the logging module in the module-named-based
> fashion that seems to be the default recommendation. I usually prefer to
> set up the root logger to log somewhere suitable to the main program
> (typically just stderr by default), and set up special logging for other
> things as needed.
>
> As what may be a poor example, I've got a mail filing program which
> monitors maildirs for arriving messages to refile. So I've got a class
> associated with each monitored maildir with these methods:
>
>  @property
>  def logdir(self):
>''' The pathname of the directory in which log files are written.
>'''
>varlog = cs.env.LOGDIR(self.environ)
>return os.path.join(varlog, 'mailfiler')
>
> This essentially computes "$HOME/var/log/mailfiler" as the place where all
> the logfiles are saved. And this:
>
>  def folder_logfile(self, folder_path):
>''' Return path to log file associated with the named folder.
>TODO: base on relative path from folder root, not just basename.
>'''
>return os.path.join(self.logdir, '%s.log' %
> (os.path.basename(folder_path)))
>
> which computes "$HOME/var/log/mailfiler/spool.log" as the logfile when
> working on my maildir "$HOME/mail/spool".
>
> And then off it goes with a FileHandler for that path for the filing
> actions for that maildir.
>
> So you're not contrained to drop log files all through your source tree
> (ewww!)
>
> My opinion is that you should decide where your logfiles _should_ live; it
> generally has nothing (or little) to do with the module name. I keep mine,
> generally, in various subdirectories of "$HOME/var/log".
>
> Cheers,
> Cameron Simpson <c...@cskk.id.au> (formerly c...@zip.com.au)
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Logging from files doesn't work

2017-10-11 Thread Andrew Z
aha. So the issue is that main.py's __name__ attribute == "__main__" and
test.py is "test1.test".
if i manually assign names:
main.py - >

log = logging.getLogger("MAIN")

test.py - >
log = logging.getLogger("MAIN.test1.test")

then logging is working perfectly well.

This brings me to the question - what is wrong with me file
naming/structure that confuses the logging module? I'm not sure i
really want to have each little file in it's own directory too..

but i'm open for suggestions.


On Wed, Oct 11, 2017 at 10:15 PM, Andrew Z <form...@gmail.com> wrote:

> if i change print statements in both files to print out "__name__":
> __main__
> test1.test
>
> On Wed, Oct 11, 2017 at 10:02 PM, Andrew Z <form...@gmail.com> wrote:
>
>> Hello,
>>
>>  apparently my reading comprehension is nose diving these days. After
>> reading python cookbook and a few other tutorials i still can't get a
>> simple logging from a few files to work.
>> I suspected my file organization - all files are in the same directory,
>> causing problem. But it appears it is not.
>>
>> Anyway, in the example below, only logging from main.py works. I also
>> want to have login from "test1/test.py" to write into the same common log
>> file.
>>
>> And how can i accomplish the same if test.py is in the same directory as
>> main.py?
>>
>> dir structure:
>> src/
>>  |- main.py
>>  |-test/
>>  |-test.py
>>
>> code:
>> test.py:
>>
>> import logging
>> # neither of below produce any results
>>
>> log = logging.getLogger("test1.test")
>> # log = logging.getLogger(__name__)
>>
>> def fun():
>>print("DADADA")
>>log.debug(" DADADADA " )
>>
>>
>> main.py:
>>
>> from test1.test import fun
>>
>> def main():
>>
>>log = logging.getLogger(__name__)
>>log.setLevel(logging.DEBUG)
>>
>>fh = logging.FileHandler("nja_" + 
>> datetime.now().strftime("%Y_%b_%d_%H_%M_%S") +".log")
>>formatter = logging.Formatter('%(levelname)s - %(asctime)s - 
>> %(funcName)10s() %(lineno)s - %(message)s')
>>fh.setFormatter(formatter)
>>log.addHandler(fh)
>>
>>log.debug("Yes, this line is in the log file")
>>
>>fun()
>>
>>log.debug("And this one is too")
>>
>>
>>
>>  this is 3.5 version.
>>
>> Thank you in advance.
>>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Logging from files doesn't work

2017-10-11 Thread Andrew Z
if i change print statements in both files to print out "__name__":
__main__
test1.test

On Wed, Oct 11, 2017 at 10:02 PM, Andrew Z <form...@gmail.com> wrote:

> Hello,
>
>  apparently my reading comprehension is nose diving these days. After
> reading python cookbook and a few other tutorials i still can't get a
> simple logging from a few files to work.
> I suspected my file organization - all files are in the same directory,
> causing problem. But it appears it is not.
>
> Anyway, in the example below, only logging from main.py works. I also want
> to have login from "test1/test.py" to write into the same common log file.
>
> And how can i accomplish the same if test.py is in the same directory as
> main.py?
>
> dir structure:
> src/
>  |- main.py
>  |-test/
>  |-test.py
>
> code:
> test.py:
>
> import logging
> # neither of below produce any results
>
> log = logging.getLogger("test1.test")
> # log = logging.getLogger(__name__)
>
> def fun():
>print("DADADA")
>log.debug(" DADADADA " )
>
>
> main.py:
>
> from test1.test import fun
>
> def main():
>
>log = logging.getLogger(__name__)
>log.setLevel(logging.DEBUG)
>
>fh = logging.FileHandler("nja_" + 
> datetime.now().strftime("%Y_%b_%d_%H_%M_%S") +".log")
>formatter = logging.Formatter('%(levelname)s - %(asctime)s - 
> %(funcName)10s() %(lineno)s - %(message)s')
>fh.setFormatter(formatter)
>log.addHandler(fh)
>
>log.debug("Yes, this line is in the log file")
>
>fun()
>
>log.debug("And this one is too")
>
>
>
>  this is 3.5 version.
>
> Thank you in advance.
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Logging from files doesn't work

2017-10-11 Thread Andrew Z
Hello,

 apparently my reading comprehension is nose diving these days. After
reading python cookbook and a few other tutorials i still can't get a
simple logging from a few files to work.
I suspected my file organization - all files are in the same directory,
causing problem. But it appears it is not.

Anyway, in the example below, only logging from main.py works. I also want
to have login from "test1/test.py" to write into the same common log file.

And how can i accomplish the same if test.py is in the same directory as
main.py?

dir structure:
src/
 |- main.py
 |-test/
 |-test.py

code:
test.py:

import logging
# neither of below produce any results

log = logging.getLogger("test1.test")
# log = logging.getLogger(__name__)

def fun():
   print("DADADA")
   log.debug(" DADADADA " )


main.py:

from test1.test import fun

def main():

   log = logging.getLogger(__name__)
   log.setLevel(logging.DEBUG)

   fh = logging.FileHandler("nja_" +
datetime.now().strftime("%Y_%b_%d_%H_%M_%S") +".log")
   formatter = logging.Formatter('%(levelname)s - %(asctime)s -
%(funcName)10s() %(lineno)s - %(message)s')
   fh.setFormatter(formatter)
   log.addHandler(fh)

   log.debug("Yes, this line is in the log file")

   fun()

   log.debug("And this one is too")



 this is 3.5 version.

Thank you in advance.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "comprehend" into a single value

2017-10-07 Thread Andrew Z
and how about adding "IF" into the mix ?

as in :

a=0

dict= {10: ['a',1,'c'], 20: ['d',2,'f']}

for i in dict:

 p+= 10 if dict[i][1] in [1,2,3,4,5] else 0


can i "squish" "for" and "if" together ? or will it be too perl-ish ?





On Sun, Oct 8, 2017 at 12:37 AM, Andrew Z <form...@gmail.com> wrote:

> Nathan, Bob - on the money. Thank you !
>
> On Sat, Oct 7, 2017 at 11:30 PM, bob gailer <bgai...@gmail.com> wrote:
>
>> On 10/7/2017 11:17 PM, Nathan Hilterbrand wrote:
>>
>>> dict= {10: ['a',1,'c'], 20: ['d',2,'f']}
>>> p = sum([dict[i][1] for i in dict])
>>>
>>> Something like that?
>>>
>> Ah, but that's 2 lines.
>>
>> sum(val[1] for val in  {10: ['a',1,'c'], 20: ['d',2,'f']}.values())
>>
>> On Sat, Oct 7, 2017 at 11:07 PM, Andrew Z <form...@gmail.com> wrote:
>>>
>>> Hello,
>>>>   i wonder how  can i accomplish the following as a one liner:
>>>>
>>>> dict= {10: ['a',1,'c'], 20: ['d',2,'f']}
>>>> p = 0
>>>> for i in dict:
>>>>  p += dict[i][1]
>>>>
>>>>
>>>> Thank you
>>>> --
>>>> https://mail.python.org/mailman/listinfo/python-list
>>>>
>>>>
>> --
>> Image and video hosting by TinyPic
>>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "comprehend" into a single value

2017-10-07 Thread Andrew Z
Nathan, Bob - on the money. Thank you !

On Sat, Oct 7, 2017 at 11:30 PM, bob gailer <bgai...@gmail.com> wrote:

> On 10/7/2017 11:17 PM, Nathan Hilterbrand wrote:
>
>> dict= {10: ['a',1,'c'], 20: ['d',2,'f']}
>> p = sum([dict[i][1] for i in dict])
>>
>> Something like that?
>>
> Ah, but that's 2 lines.
>
> sum(val[1] for val in  {10: ['a',1,'c'], 20: ['d',2,'f']}.values())
>
> On Sat, Oct 7, 2017 at 11:07 PM, Andrew Z <form...@gmail.com> wrote:
>>
>> Hello,
>>>   i wonder how  can i accomplish the following as a one liner:
>>>
>>> dict= {10: ['a',1,'c'], 20: ['d',2,'f']}
>>> p = 0
>>> for i in dict:
>>>  p += dict[i][1]
>>>
>>>
>>> Thank you
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>>
>>>
> --
> Image and video hosting by TinyPic
>
-- 
https://mail.python.org/mailman/listinfo/python-list


"comprehend" into a single value

2017-10-07 Thread Andrew Z
Hello,
 i wonder how  can i accomplish the following as a one liner:

dict= {10: ['a',1,'c'], 20: ['d',2,'f']}
p = 0
for i in dict:
p += dict[i][1]


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


async. How to wait for async function to complete

2017-09-07 Thread Andrew Z
Hello,
 i need to wait for the callback function (contractDetailsEnd) to finish before 
i can continue with the logic ( in subscribe) further. For that i check the 
flag (ContractsUpdatedEnd) in the "while" loop.

Here is the simplified code:

import asyncio
import ibapi
from tws_async import TWSClient


class TWS(TWSClient):

def __init__( self ):
TWSClient.__init__(self)
self.Contracts = {}
self.ContractsUpdatedEnd = False

def sleep(self, secs):
loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.sleep(secs))

def subscribe( self ):
for forex in ['EURUSD', 'USDJPY', 'GBPUSD']:

self.reqContractDetails(reqId ,c)
while not self.ContractsUpdatedEnd:
self.sleep(0.1)

self.reqMktData(reqId, c, genericTickList = '', snapshot = False,
regulatorySnapshot = False, mktDataOptions = [])

def contractDetails(self, reqId, contractDetails):
self.Contracts[reqId]= contractDetails.summary
print("Contract is {}".format(contractDetails.summary))

def contractDetailsEnd(self, reqId):
print("End for contract details")
self.ContractsUpdatedEnd = True


if __name__ == '__main__':
tws = TWS()
tws.connect(host = '127.0.0.1', port = 7497, clientId = 1)
tws.subscribe()
loop = asyncio.get_event_loop()
loop.run_forever()



Unfortunately, this throws the :
File "/usr/lib64/python3.5/asyncio/base_events.py", line 408, in run_forever
raise RuntimeError('This event loop is already running')
RuntimeError: This event loop is already running

will greatly appreciate your advise.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python3 : import

2017-07-07 Thread Andrew Z
On Friday, July 7, 2017 at 4:16:38 PM UTC-4, Ian wrote:
> On Fri, Jul 7, 2017 at 2:00 PM, Andrew Z <x...@gmail.com> wrote:
> > [az@hp tst1]$ python3 ./uno.py
> > Traceback (most recent call last):
> >   File "./uno.py", line 1, in 
> > from . import db
> > SystemError: Parent module '' not loaded, cannot perform relative import
> 
> That error message is a bit confusing, but relative imports are
> relative to packages, not directories. If the module is not part of a
> package then it can't do a relative import. You can use an absolute
> import, though:
> 
> import db

Thank you Ian. that's right on the money. All works now.
I was missing the " ..relative imports are relative to packages, not 
directories. If the module is not part of a package then it can't do a relative 
import."
thank you!

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


Re: Python3 : import

2017-07-07 Thread Andrew Z
On Friday, July 7, 2017 at 4:00:51 PM UTC-4, Andrew Z wrote:
> this has bee driving me nutz for the past few hours.
> 2 modules are in the same directory. I want to be able to use them both:
> 
> [code]
> 
> [az@hp tst1]$ pwd
> /home/az/Dropbox/work/Prjs/tst1
> 
> [az@hp tst1]$ ls -l
> total 16
> -rw-rw-r--. 1 az az  66 Jul  7 12:58 db.py
> -rw-rw-r--. 1 az az 182 Jul  7 15:54 uno.py
> [az@hp tst1]$ 
> [az@hp tst1]$ 
> [az@hp tst1]$ cat ./db.py 
> 
> class DB():
>   def __init__(self):
>   print("I'm DB")
> 
> [az@hp tst1]$ cat ./uno.py 
> from . import db
> 
> class Uno():
>   def __init__(self):
>   print("I'm uno")
>   self.db = db.DB()
> 
>   def printing(self):
>   print("Uno.printing DB")
> 
> 
> if __name__ == '__main__':
>   uno = Uno()
> 
> [az@hp tst1]$ 
> [az@hp tst1]$ 
> [az@hp tst1]$ python3 ./uno.py 
> Traceback (most recent call last):
>   File "./uno.py", line 1, in 
> from . import db
> SystemError: Parent module '' not loaded, cannot perform relative import
> 
> [/code]
> 
> 
> Much obliged.


[az@hp tst1]$ python3 --version
Python 3.5.3
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python3 : import

2017-07-07 Thread Andrew Z
On Friday, July 7, 2017 at 4:00:51 PM UTC-4, Andrew Z wrote:
> this has bee driving me nutz for the past few hours.
> 2 modules are in the same directory. I want to be able to use them both:
> 
> [code]
> 
> [az@hp tst1]$ pwd
> /home/az/Dropbox/work/Prjs/tst1
> 
> [az@hp tst1]$ ls -l
> total 16
> -rw-rw-r--. 1 az az  66 Jul  7 12:58 db.py
> -rw-rw-r--. 1 az az 182 Jul  7 15:54 uno.py
> [az@hp tst1]$ 
> [az@hp tst1]$ 
> [az@hp tst1]$ cat ./db.py 
> 
> class DB():
>   def __init__(self):
>   print("I'm DB")
> 
> [az@hp tst1]$ cat ./uno.py 
> from . import db
> 
> class Uno():
>   def __init__(self):
>   print("I'm uno")
>   self.db = db.DB()
> 
>   def printing(self):
>   print("Uno.printing DB")
> 
> 
> if __name__ == '__main__':
>   uno = Uno()
> 
> [az@hp tst1]$ 
> [az@hp tst1]$ 
> [az@hp tst1]$ python3 ./uno.py 
> Traceback (most recent call last):
>   File "./uno.py", line 1, in 
> from . import db
> SystemError: Parent module '' not loaded, cannot perform relative import
> 
> [/code]
> 
> 
> Much obliged.



Variations on the subject with the same sad results:
[code]
from .db import DB

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


Python3 : import

2017-07-07 Thread Andrew Z
this has bee driving me nutz for the past few hours.
2 modules are in the same directory. I want to be able to use them both:

[code]

[az@hp tst1]$ pwd
/home/az/Dropbox/work/Prjs/tst1

[az@hp tst1]$ ls -l
total 16
-rw-rw-r--. 1 az az  66 Jul  7 12:58 db.py
-rw-rw-r--. 1 az az 182 Jul  7 15:54 uno.py
[az@hp tst1]$ 
[az@hp tst1]$ 
[az@hp tst1]$ cat ./db.py 

class DB():
def __init__(self):
print("I'm DB")

[az@hp tst1]$ cat ./uno.py 
from . import db

class Uno():
def __init__(self):
print("I'm uno")
self.db = db.DB()

def printing(self):
print("Uno.printing DB")


if __name__ == '__main__':
uno = Uno()

[az@hp tst1]$ 
[az@hp tst1]$ 
[az@hp tst1]$ python3 ./uno.py 
Traceback (most recent call last):
  File "./uno.py", line 1, in 
from . import db
SystemError: Parent module '' not loaded, cannot perform relative import

[/code]


Much obliged.

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


Proper architecture

2017-07-02 Thread Andrew Z
Hello,
 I'd appreciate your suggestions for a better approach to the following task.

I have 2 files ( 2 classes). One (ClassA) has all logic related to the main 
workflow of the program. Another (DB), I like to offload all operations with a 
DB ( sql3 in this case).

I'm trying to pass the connection to the main class, but having problems. One 
of them, is i can't pass the conn as a parameter to the function in one 
(ClassA.abc()), because i inherit it ( function abc() ).
I created a self.DBConnection field, but i'm not sure if i'm on the right 
path...
Code is gutted to highlight the problem.

Thank you

--- code -

one.py:
from .DB import *

class ClassA(OtherObject):

def __init__(self):

self.DBConnection = sql3.Connection


def abc(self, reqId: int):
DB.writeTicks(self,self.DBConnection,reqId))


DB.py:
import sqlite3 as sql3
import sys
from .tws import TWS
from utils import current_fn_name


class DB(object):
db_location = ''
# db_location = '../DB/pairs.db'

def __init__(self, location='../DB/pairs.db'):
db_location = location
print(current_fn_name(),' self.db_location = 
{}'.format(db_location))

try:
with open(db_location) as file:
pass
except IOError as e:
print("Unable to locate the Db @ 
{}".format(db_location))

def reqConnection(self):
try:
con = sql3.connect(self.db_location)
con.text_factory = str

except sql3.Error as e:
print("Error %s:".format( e.args[0]))
sys.exit(1)
return con

def write(self, con : sql3.Connection, tickId: int):
con.execute( blah) 

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


math functions with non numeric args

2013-06-30 Thread Andrew Z
Hello,

print max(-10, 10)
10
print max('-10', 10)
-10

My guess max converts string to number bye decoding each of the characters
to it's ASCII equivalent?

Where can i read more on exactly how the situations like these are dealt
with?

Thank you
AZ
-- 
http://mail.python.org/mailman/listinfo/python-list


IndexError: pop index out of range

2013-05-14 Thread Andrew Z
hello,
 going fru some basic examples and can't figureout why the following errors
out. Help is very much appreciated:
code
def front_x(words):
  # +++your code here+++
print words passed : , words
list_xx = []
list_temp = words[:]
print list_temp -, list_temp
print words -, words
for idx, val in enumerate(words):
print val, idx
# str_idx = val.find('x',0,2)
if val[0] == 'x':
vl = list_temp.pop(idx)
list_xx.append(vl)

print appending list_xx, list_xx

list_xx.sort
list_temp.sort
print words sorted :  + str(words)
print list_temp sorted : , list_temp
list_xx.append(words)
print list_xx + str(list_xx)
return True

front_x
words passed : ['bbb', 'ccc', 'axx', 'xzz', 'xaa']
list_temp - ['bbb', 'ccc', 'axx', 'xzz', 'xaa']
words - ['bbb', 'ccc', 'axx', 'xzz', 'xaa']
bbb 0
ccc 1
axx 2
xzz 3
appending list_xx ['xzz']
xaa 4
Traceback (most recent call last):
  File
/home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py,
line 119, in module
main()
  File
/home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py,
line 100, in main
test(front_x(['bbb', 'ccc', 'axx', 'xzz', 'xaa']),
  File
/home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py,
line 55, in front_x
vl = list_temp.pop(idx)
IndexError: pop index out of range

/code
-- 
http://mail.python.org/mailman/listinfo/python-list


noob: print and file.read()

2012-12-03 Thread Andrew Z
Hello,
 why the following code doesn't print the content of the file:
#!/usr/bin/python

from_file =file.txt
in_file = open(from_file)
str = in_file.read()
print Here should be the output from the file - , in_file.read()
print Here should be the output from the STR- , str in_file.close()


The first print has nothing whereas the second properly displays the
content of the file.

Thank you
AZ
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: noob: print and file.read()

2012-12-03 Thread Andrew Z
Mrab,
 you nailed it. thank you very much!
AZ
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] BleachBit 0.8.1 released

2010-10-05 Thread Andrew Z
BleachBit (a pure PyGTK app) deletes traces of online Internet usage
and recovers wasted disk space.

Highlight of changes since 0.8.0:
* Delete DOM Storage in Firefox 3, Google Chrome, Opera, Internet
Explorer, Safari
* Delete evercookie tracking
* Delete more localizations (16MB more on Ubuntu 10.10)
* Clean VLC
* Vacuum Safari
* Add .deb package for Ubuntu 10.10 Maverick Meerkat.
* Add Traditional Chinese
* Update 24 other translations

Detailed release notes
http://bleachbit.sourceforge.net/news/bleachbit-081-released

Download
http://bleachbit.sourceforge.net/download
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Parsing error for ConfigParser

2010-09-23 Thread Andrew Z.
Is there a way to parse RealPlayer's realplayerrc in Python?  I need
to support Python 2.5 - 2.7

Example code

import urllib2
import ConfigParser
f = urllib2.urlopen('http://pastebin.com/download.php?i=N1AcUg3w')
config = ConfigParser.RawConfigParser()
config.readfp(f)


Error
Traceback (most recent call last):
  File test_config_parser_real_player.py, line 6, in module
config.readfp(f)
  File /usr/lib/python2.6/ConfigParser.py, line 305, in readfp
self._read(fp, filename)
  File /usr/lib/python2.6/ConfigParser.py, line 510, in _read
raise e
ConfigParser.ParsingError: File contains parsing errors: ???
[line 31]: '%0aCopyright (c) 1995-2000 Macromedia, Inc. All
rights reserved.\r\n'
[line 34]: '%0a\r\n'
-- 
http://mail.python.org/mailman/listinfo/python-list