Re: Final statement from Steering Council on politically-charged commit messages

2020-08-18 Thread justin walters
I believe the commit message was written in bad faith. It reeks of virtue
signaling. Commit messages should remain purely technical in nature.
However, I do think the change itself is valid.

I don't care about the style of comments as long as they are clear and
communicate their message well. How is that determined? During the PR
review process. If you are performing a review and a comment is so poorly
written that you can't figure out what it means, request improvements.

Non technical discussion should be left out of commit messages and issues.
Instead, that sort of discussion should take place on mailing lists,
forums, and in person. As a community, we need to be more open to
discussing these sort of topics without resorting to condescending remarks.

I apologize for being ageist earlier as well. That was out of line.

On Tue, Aug 18, 2020, 9:36 AM Tim Daneliuk  wrote:

> On 8/17/20 1:26 PM, Chris Angelico wrote:
> > For context, see this commit:
> >
> >
> https://github.com/python/peps/commit/0c6427dcec1e98ca0bd46a876a7219ee4a9347f4
> >
> > The commit message is highly politically charged and is now a
> > permanent part of the Python commit history. The Python Steering
> > Council has this to say:
> >
> >
> https://github.com/python/steering-council/issues/34#issuecomment-675028005
> >
> > "The SC discussed this and ... we do not deplore the message."
> >
> > So now we know: go ahead and put all the political messages you like
> > into the commit messages, just don't put anything inappropriate into
> > the content. White supremacy has been mentioned; who wants to pick the
> > next hot topic?
> >
> > ChrisA
> >
> Just a few thoughts here ...
>
> - While languages evolve over time, _in any given moment_ there are better
>   and worse ways to express ideas in a given language. "The Elements Of
> Style"
>   remains relevant today because it provides guidance on improving
>   written clarity.  It is not some blind defence of the
>   perfect English.
>
> - Precision of language and precision of thought go hand in hand.  Much
>   of the grousing about languages standards (in this case, hiding in
>   drag as social consciousness) is little more than intellectual laziness.
>   In actual fact, our discipline has burned a lot of intellectual
>   fuel in trying to find ways to be _more precise_ for things like
>   specifications, formal semantics, and the like.
>
> - It is my consistent experience when working with non-native English
>   speakers, that they wish to _improve_ their use and precision of the
>   language, not simplify it.
>
> - Why is English the only target of these social pieties?  You never
>   hear these demands to relax these linguistic standards for, say, French,
>   German, or Spanish.  Similarly, where is the outcry to make
>   Mandarin, Bantu, Swahili, or Arabic more approachable for
>   Westerners?
>
> Methinks there is an ideological skunk in the parlor ...
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Final statement from Steering Council on politically-charged commit messages

2020-08-17 Thread justin walters
I for one don't want to see politics involved in PL development. However,
inclusivity isn't a political issue, it's a human rights issue.

Do I agree with the PR, not exactly. However, I do think we as a community
should be accommodating to people
Whose use of the English language differs from the standard as long as the
meaning is clear.

This thread reads like a bunch of old fuddy duddies complaining about
immigrants not speaking perfect English at a fast food restaurant.

Feel free to ban me from the list if this doesn't meet your standards.



On Mon, Aug 17, 2020, 9:03 PM  wrote:

> On Monday, August 17, 2020 at 1:26:33 PM UTC-5, Chris Angelico wrote:
> > For context, see this commit:
> >
> >
> https://github.com/python/peps/commit/0c6427dcec1e98ca0bd46a876a7219ee4a9347f4
> >
> > The commit message is highly politically charged and is now a
> > permanent part of the Python commit history. The Python Steering
> > Council has this to say:
> >
> >
> https://github.com/python/steering-council/issues/34#issuecomment-675028005
> >
> > "The SC discussed this and ... we do not deplore the message."
> >
> > So now we know: go ahead and put all the political messages you like
> > into the commit messages, just don't put anything inappropriate into
> > the content. White supremacy has been mentioned; who wants to pick the
> > next hot topic?
> >
> > ChrisA
>
> It should be noted that these Darlings Of Conspicuous Caring are still
> using that - gasp! - horrid  "master' branch.  The very idea ...
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Introducing Coconut

2018-06-25 Thread justin walters
From: justin walters 

On Sun, Jun 24, 2018 at 5:51 AM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:

> Coconut, the functional programming language which compiles to Python:
>
> http://coconut.readthedocs.io/en/master/FAQ.html
>
> http://coconut-lang.org/
>
> (Its not my language. I just think its cool.)
>
>
> --
> Steven D'Aprano
> "Ever since I learned about confirmation bias, I've been seeing
> it everywhere." -- Jon Ronson
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


As someone who has been studying Elixir and Phoenix lately, This is pretty
neat.

There have definitely been some pieces of my Python projects that could have
benefited from a
Functional structure.

I don't think writing an entire project in Cocounut would be worth while. At
that point, why not use an actual FP language? However, I do think it sounds
useful for when certain parts of a project could be cleaned up
or optimized with functional code. Almost like a better `functools`.

All that said though, I am interested to see performance metrics for the
transpiled python.

--- BBBS/Li6 v4.10 Toy-3
 * Origin: Prism bbs (1:261/38)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Introducing Coconut

2018-06-24 Thread justin walters
On Sun, Jun 24, 2018 at 5:51 AM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:

> Coconut, the functional programming language which compiles to Python:
>
> http://coconut.readthedocs.io/en/master/FAQ.html
>
> http://coconut-lang.org/
>
> (Its not my language. I just think its cool.)
>
>
> --
> Steven D'Aprano
> "Ever since I learned about confirmation bias, I've been seeing
> it everywhere." -- Jon Ronson
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


As someone who has been studying Elixir and Phoenix lately, This is pretty
neat.

There have definitely been some pieces of my Python projects that could
have benefited from a
Functional structure.

I don't think writing an entire project in Cocounut would be worth while.
At that point, why not use an actual FP language?
However, I do think it sounds useful for when certain parts of a project
could be cleaned up
or optimized with functional code. Almost like a better `functools`.

All that said though, I am interested to see performance metrics for the
transpiled python.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The perils of multiple Pythons

2018-04-30 Thread justin walters
On Mon, Apr 30, 2018 at 3:24 PM, Rich Shepard <rshep...@appl-ecosys.com>
wrote:

> On Mon, 30 Apr 2018, justin walters wrote:
>
> With Python 3.5+, venv is a built in module. If using a venv, default to
>> using the binary in the venv. That's what I do anyways.
>>
>
>   I'm running Python3-3.6.5 and have a developing application in
> ~/development/project/. Can I run 'python3 -m venv ~/development/project/'
> to install it in a directory with existing modules?
>
> Rich
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Yes, you can create a virtual env with all of the global packages. Though,
you would probably want to run:
`python3 -m venv ~/development/project/venv` to put the virtualenv files in
their own directory. Then you
just need to activate it with: `source venv/bin/activate`. As long as the
virtualenv is activated, you can interact
with it in the same way you would with the system/global environment. i.e.
running the interpreter will use the binary
from the virtualenv, pip install will install in the virtualenv only, etc.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The perils of multiple Pythons

2018-04-30 Thread justin walters
On Mon, Apr 30, 2018 at 1:40 PM, Chris Angelico <ros...@gmail.com> wrote:

> On Tue, May 1, 2018 at 6:22 AM, justin walters
> <walters.justi...@gmail.com> wrote:
> > On Mon, Apr 30, 2018 at 10:32 AM, Chris Angelico <ros...@gmail.com>
> wrote:
> >
> >> On Tue, May 1, 2018 at 3:30 AM, Ned Batchelder <n...@nedbatchelder.com>
> >> wrote:
> >> > On 4/30/18 1:15 PM, Chris Angelico wrote:
> >> >>
> >> >> https://xkcd.com/1987/
> >> >>
> >> >> So take-away is: On a Mac, just use Homebrew.
> >> >>
> >> >> (Cue the angry hordes telling me how wrong I am.)
> >> >>
> >> >
> >> > My take-away (though not really, since I held this view before this
> >> > morning): pick a way and stick to it.
> >>
> >> Well, yes. Until that way stops working, in which case you have to try
> >> another way. And that's when the problems start...
> >>
> >> ChrisA
> >> --
> >> https://mail.python.org/mailman/listinfo/python-list
> >>
> >
> > I feel like this problem is pretty handily solved by virtual
> environments.
> > Also, if a single project requires all of this,
> > perhaps Python isn't the best choice for the project.
>
> Some of it is definitely solved by venvs. But which Python binary do
> you use? And is venv installed? Do you need to install virtualenv
> first? How do you... etc, etc, etc, etc, etc. Endless fun!
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

With Python 3.5+, venv is a built in module. If using a venv, default to
using the binary in the venv.

That's what I do anyways.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The perils of multiple Pythons

2018-04-30 Thread justin walters
On Mon, Apr 30, 2018 at 10:32 AM, Chris Angelico  wrote:

> On Tue, May 1, 2018 at 3:30 AM, Ned Batchelder 
> wrote:
> > On 4/30/18 1:15 PM, Chris Angelico wrote:
> >>
> >> https://xkcd.com/1987/
> >>
> >> So take-away is: On a Mac, just use Homebrew.
> >>
> >> (Cue the angry hordes telling me how wrong I am.)
> >>
> >
> > My take-away (though not really, since I held this view before this
> > morning): pick a way and stick to it.
>
> Well, yes. Until that way stops working, in which case you have to try
> another way. And that's when the problems start...
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

I feel like this problem is pretty handily solved by virtual environments.
Also, if a single project requires all of this,
perhaps Python isn't the best choice for the project.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Jobs] Need some help with Python Job Board

2017-11-13 Thread justin walters
On Mon, Nov 13, 2017 at 1:16 AM, M.-A. Lemburg  wrote:

> Hi Justin,
>
> the default markup is currently set to restructuredtext:
>
> https://github.com/python/pythondotorg/blob/master/jobs/models.py
>
> but this can be changed to any of these supported ones:
>
> https://github.com/jamesturk/django-markupfield
>
> as long as we make sure that all existing records continue
> to be set to ReST (to not mess up the formatting).
>
> Since I had a look at WYSIWYG editors, some new ones may have
> surfaced.
>
> The templates are defined here:
>
> https://github.com/python/pythondotorg/tree/master/templates/jobs
>
> and the main project page has instructions on how to get
> a local copy of the website working:
>
> https://pythondotorg.readthedocs.io/
>
> Thanks,
> --
> Marc-Andre Lemburg
> Python Software Foundation
> http://www.python.org/psf/
> http://www.malemburg.com/
> _
> > Jobs mailing list
> > j...@python.org
> > https://mail.python.org/mailman/listinfo/jobs
> >
>
>

Thank you Marc.

I'll take a look over this stuff and hopefully I can squeeze in some time
this week to work on it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need some help with Python Job Board

2017-11-12 Thread justin walters
On Sat, Nov 11, 2017 at 3:27 PM, Skip Montanaro 
wrote:

> The Python Job Board could use a little help in a couple areas. One, we can
> always use help reviewing and approving (or rejecting) submissions. The
> backlog keeps growing, and the existing volunteers who help can't always
> keep up. (This is a good problem to have, reflecting on Python's broad
> popularity in many application domains.)
>
> Two, and perhaps more important, the submission form really needs to
> support WYSIWYG editing. Apparently, most posters are unable to handle
> markup-based systems, probably just pasting content from Word documents.
> Making this change would streamline the review process, as formatting
> problems are currently the biggest impediment to successful submissions.
> There is an open ticket to add this feature:
>
> https://github.com/python/pythondotorg/issues/655
>
> If you can help with either task, please drop a note to j...@python.org.
>
> Thanks,
>
> Skip
> --
> https://mail.python.org/mailman/listinfo/python-list
>

I might be able to help implement a wysiwyg editor. The only issue I can
think of at the moment
would be finding a way to determine if the template should render wysiswyg
content or Markdown content.

I'll need to look over the repo a bit more closely first.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: choice of web-framework

2017-10-24 Thread justin walters
On Tue, Oct 24, 2017 at 4:14 AM, Chris Angelico  wrote:

>
> (There are other ORMs than SQLAlchemy, of course; I can't recall the
> exact syntax for Django's off the top of my head, but it's going to be
> broadly similar to this.)
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>


I can help with that:

## Defining a model:

class Thing(models.Model):
"""
This is the "schema" for the `thing` table. The pk field is created
automatically and is called `id` by default. This table with have
four columns: `id`, `foo`, `baz`, and `score`.
"""
foo = models.Charfield(
max_length=140,
blank=False
)
baz = models.CharField(
max_length=140,
blank=True
)
score = models.IntegerField()

## Create an object:

new_thing = Thing.objects.create(foo="bar", baz="foo")

## Get a list of objects:

Thing.objects.all()

## Filter a list of objects:

Thing.objects.filter(foo="bar")

## Modify an object:

thing = Thing.objects.get(id=1)
thing.foo = "baz"
thing.save()

## Perform an aggregation:

data = Thing.objects.aggregate(avg=Avg("score"))
print(data)
>>> {"avg": 50}

## Django basic view(called controllers in other frameworks normally) and
template:

def person_list(request):
"""
Get a collection of `User` objects from the database.
"""
people = User.objects.filter(is_active=True).order_by("date_joined")
return render(
request,
"person/list.html",
context={"people": people}
)


Then, in `templates/person/list.html`:

{% extends 'base.html' %}

{% block content %}

{% for person in people %}

{{person.first_name}} {{person.last_name}}

{% endfor %}

{% endblock %}


Alternatives to Django's ORM and SQLAlchemy include but are not limited to:

- Peewee: https://github.com/coleifer/peewee
- PonyORM: https://ponyorm.com/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: choice of web-framework

2017-10-22 Thread justin walters
On Sun, Oct 22, 2017 at 3:24 AM, Patrick Vrijlandt 
wrote:

> Hello list,
>
> I would like your recommendation on the choice of a web framework.
>
> The project is completely new, there are no histories to take into account
> (current solutions are paper-based). The website involves questionnaires
> that will be developed, filled out and stored. Users are not programmers or
> developers. They should be authenticated. Version control is required.
> Internationalization is not an issue. I expect that the project will add
> additional requirements and complexity later on that I can not foresee yet.
> I'm targeting a single deployment (maybe a second on a development
> machine). I usually work on Windows, but Linux can be considered.
>
> I'm not afraid to learn a (=one) new framework (that would actually be
> fun) but trying out a lot of them is not feasible. My current goal is a
> demonstration version of the project as a proof of concept. I may want to
> hand it over to a commercial solution at that stage.
>
> I'm an experienced python programmer but not an experienced web developer.
> A few years ago I read some books about Zope and Plone, but never did
> serious development with those. I currently maintain an intranet site in
> MoinMoin. I assume Zope could still be a potential choice, but it may have
> lost the vibrancy of a few years ago. Also, I would not know which version
> to choose (Zope 4, BlueBream, or something like Grok). The problem seems
> too complicated for micro frameworks like bottle of Flask. Django could be
> the next alternative.
>
> Finally, for a new project, I would not like to be confined to Python 2.7.
>
> What are your ideas?
>
> Thanks in advance,
>
> --
> Patrick
> --
> https://mail.python.org/mailman/listinfo/python-list
>

I think your best choice here would be Django. I've been doing web
development with Python
for about 5 years now and I have only found thing that Django can't handle:
replacing the authentication
framework's dependence on SQL. i.e., if you wanted to use a noSQL db like
MongoDb for your user
model, it's not really possible without a ton of work. Other than that
though, Django can pretty much do everything.

Since you need to get this prototype done quickly, I think Django is your
absolute best choice. The projects motto is
"The web framework for perfectionists with deadlines." You get a ton of
stuff out of the box:

- User authentication
- Sessions
- Admin interface
- Fantastic ORM
- Templating (like jinbja2 but with some Django flair)
- The best documentation I have ever seen
- A huge ecosystem of third party libraries and plugins
- A strong and heavilly opinionated MVC architecture
- One of ths strongest and best suppported OSS projects in existence
- Built in and versioned schema migrations

The reasons I would not reccomend Flask/Bottle for your project
specifically:

- Flask is better for more "customized" solutions or simpler projects
- Flask is a great framework, but offers very little out of the box as far
as modern web application features
- It takes longer to get rolling with Flask(a lot more initial
configuration)
- When using Flask, many devs end up building their own version of Django
anyways
- Flask's tutorial is a lot less in-depth than Django's
- Although learning Flask in its entirety is much simpler than learning
Django in its entirety, it takes more time
  to get up and running with Flask in my experience.

Web2py/zope/other small and old frameworks:

- I would stay away from these unless you have a lot of experience with
them.
- These projects do not have a modern ecosystem of libraries and may not
have full Python3 support
- You will find less community memebers that are able to help you as there
are less people using these frameworks

Hug/Sanic/Falcon/ApiStar:

- These are designed around the idea of REST apis
- They offer less than Flask does out of the box(except for building REST
apis)
- They are fairly new and have not had the time to build up a supportive
ecosystem yet
- They rely on new language features like async
- Their docs are not up to par with more mature projects

Pyramid:

Though I haven't ever worked with Pyramid, I have met several people who
are very happy with it. I also met with
one of the project's core contributors and he spoke about how the
architecture is "plugin based". There is the the core library
and all of the other layers of the application such as the data layer or
authentication, for example, are officially supported
plugins. Might be worth looking into.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Beginners and experts (Batchelder blog post)

2017-09-29 Thread justin walters
On Fri, Sep 29, 2017 at 12:14 PM, Bill  wrote:

>
> I'll write for the possible benefit of any beginners who may be reading.
> I guess by definition, if one still has a "bug" it's because one doesn't
> quite understand what the code is doing. And I would say you should lose
> your license if you "fix something", and don't understand why it works
> (within reason of course--some mystery's of library functions should
> probably remain so forever). So ADT (Any Damn Thing--I just made that up
> that acronym) you can do to understand your code better is fair game! : )
>   In fact, in my experience, the sooner you start getting a little bit
> angry, the sooner you'll get to the heart of matter.  Usually, what looks
> like a long route, isn't, in the end.  Don't be afraid to write *really
> descriptive* output statements, and do so even though you "don't need to".
> Besides for making you more productive, it will help soothe you : )
>  Beginners almost never need to...  I think that getting out of the
> beginner phase requires developing a certain amount of humility.  Just wait
> 5 or 10 years, any look back, and see if what I've written isn't more true
> than false.
>
> The only part I am unsure of is whether you are supposed to get a little
> big angry or not (YMMV).  I find 2 cups of coffee about right. That is, 2
> before and 2 after lunch. Of course, that does not include "meetings".
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Reminds me of a bug I had to chase down recently.

I've been working on the front-end of this web application for a while.
It's an SPA built
with Vuejs. The bug arose in the login workflow. Basically, it went like
this:

client loads login screen -> user enters credentials into form and submits
-> client sends credentials to server ->
server verifies credentials -> server sends back auth token -> client
receives auth token and stores it ->
client redirects user to home screen -> home screen makes get request for
some data

Now, this worked perfectly fine everywhere except for Safari 9.1 on OSX.

A user could login just fine on Safari 9.1, but after that, no requests
would complete. Safari's dev tools
were no help because they were not showing any errors or any failed
requests. I checked the server logs
and found that no requests were even sent.

It took me 2 days to figure out this bug. I tracked it down to the function
that injected the authorization
header into all requests if the user was logged in. Based on
troubleshooting, I knew it couldn't be anything else.
That said, I was still confused because this worked on literally every
other browser(even IE 9).

After searching for people with similar problems and coming up with nothing
I got to thinking about the
asynchronous nature of JS. So, out of sheer frustration I moved the line of
code that stored the auth token
from one function to another, booted up my testing environment, and it
worked.

So, the bug was basically because Safari was waiting for a specific
function call to complete before
it committed the token to local storage even though the line of code that
did so was within said function.

So, two days worth of work to move a single line of code from one function
to another. You can only imagine
the tirade of curse words directed at apple during the above calamity.

Had I simply written a console log for every function down the chain, I may
have been able to find the
cause of the bug more quickly.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Beginners and experts (Batchelder blog post)

2017-09-29 Thread justin walters
On Fri, Sep 29, 2017 at 2:57 AM, Leam Hall  wrote:

> On 09/27/2017 10:33 PM, Stefan Ram wrote:
>
>Some areas of knowledge follow, a programmer should not be
>>ignorant in all of them:
>>
>
> ---
>
> Stefan, this is list AWESOME!
>
> I have started mapping skills I have to the list and ways to build skills
> I don't have. Last night I started working on a project that has been on my
> mind for over a year; taking a CSV list of game characters and putting them
> into a MongoDB datastore. Now I need to figure out how to build an
> interface for CRUD operations using Python, pymongo, and maybe Tk.
>
> I appreciate the structure your list provides. Thank you!
>
> Leam
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Python web backends just happen to be my specialty. I do mostly Django, but
it doesn't
mesh well with MongoDB. Well, it does if you still use an RDBMS forsome
things.

I can recommend the following:

- Flask: http://flask.pocoo.org/
Small and light But not tiny. Not really fast, not really slow. Not a
ton of batteries included.
Tons of third-party extensions.

- ApiStar: https://github.com/encode/apistar
New kid on the block. Specializes in APIS. No template integrations.
Best for serving
JSON through a RESTful interface. Fairly quick, but not blazing fast.
Has the upside that any
web API can be exposed as a CLI API. Not a ton of third party
extensions available. Would
be a good choice if you don't want to build a desktop application
instead of a web application
as it will help design the API that something like Tkinter will sit on
top of.

- Sanic: https://github.com/channelcat/sanic
Another new kid. Python 3.5+ only. Uses the new async capabilities
quite heavilly.
Based on falcon. Blazing fast. No batteries included. Small number of
fairly high
quality third-party extensions.

- Django: https://www.djangoproject.com/
The old workhorse. Mature and proven. Best choice for reliability. Not
fast, not slow.
Huge collection of third party extensions ranging in quality. Though,
it is pretty heavilly
integrated with it's relational Db backends. If you decide on this, you
would need to
use postgres/sqlite/mysql to store all of Django's built in model
classes(tables).

I got through writing all of the above without realizing that you meant you
wanted to build a
desktop application and not a web application. Though, I think the advice
is still helpful.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Even Older Man Yells At Whippersnappers

2017-09-20 Thread justin walters
On Wed, Sep 20, 2017 at 7:29 AM, Larry Martell 
wrote:

> On Wed, Sep 20, 2017 at 5:09 AM, Gregory Ewing
>  wrote:
> >
> > Never mind that fake assembly rubbish, learn a real assembly
> > language! And hand-assemble it and toggle it into the front
> > panel switches like I did!
>
> 1979, I was working at Bausch and Lomb in Rochester NY. We had a 16
> bit Data General Nova 'Minicomputer'. It had 4 registers, called
> accumulators. It had 16 front panel toggle switches, one for each bit,
> one that said 'deposit', and one that said run. It had a dial with
> stops for AC0, AC1, AC2, AC3 (for the 4 accumulators), PC (program
> counter), address and contents.
>
> When you powered up the machine it did not boot. You had to hand enter
> a short bootstrap program in binary. Do to this you had to turn the
> dial to address, key in a 16 bit address, click deposit, turn the dial
> to contents, key in a 16 bit line of assembly code, click deposit, and
> repeat this for each line of code (there were like 5 or 6). Then key
> in the address of where you wanted to run from turn the dial to PC,
> deposit, and click run. Any mistake and it would not boot. Often took
> 3 or 4 tries.
>
> After a few weeks of this I was sick of it. I had the boot code burned
> into an EEPROM (which I had to send out to be programmed). Then I
> build a very small wire wrapped board with the EEPROM and an
> oscillator and few TTL chips. I tapped into the 5V power on the CPU
> board and used the leading edge of that to trigger a one shot which
> 'woke up' my circuit, and caused it to clock out the code from the
> EEPROM and load it to the appropriate place, set the program counter
> and start the program. I drilled holes in the CPU board and mounted
> this with little plastic standoffs.
>
> I did this all on my own, coming in on the weekends, without company
> approval, and when it was working I showed my boss. He was blown away
> and he was sure we could patent this and sell it. He had me formalize
> the design, write it up, have an actual PCB made, go to the company
> lawyers, the whole 9 yards. Then Data General announced the new
> version of the Nova  with auto boot.
> --
> https://mail.python.org/mailman/listinfo/python-list
>


That's crazy!

The oldest computer I ever owned was a 1984 Tandy 1000. I actually still
miss that thing.

It had an option where you could change the 8-bit music that played on
startup.

Luckily for me, it took 5.25" floppys.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Even Older Man Yells At Whippersnappers

2017-09-19 Thread justin walters
On Tue, Sep 19, 2017 at 9:12 AM, Rhodri James  wrote:

> On 19/09/17 16:59, Grant Edwards wrote:
>
>> On 2017-09-19, Rhodri James  wrote:
>>
>>> On 19/09/17 16:00, Stefan Ram wrote:
>>>
 D'Arcy Cain  writes:

> of course, I use calculators and computers but I still understand the
> theory behind what I am doing.
>

 I started out programming in BASIC. Today, I use Python,
 the BASIC of the 21st century. Python has no GOTO, but when
 it is executed, its for loop eventually is implemented using
 a GOTO-like jump instruction. Thanks to my learning of BASIC,
 /I/ can have this insight. Younger people, who never learned
 GOTO, may still be able to use Python, but they will not
 understand what is going on behind the curtains. Therefore, for
 a profound understanding of Python, everyone should learn BASIC
 first, just like I did!

>>>
>>> Tsk.  You should have learned (a fake simplified) assembler first, then
>>> you'd have an appreciation of what your processor actually did.
>>>
>>> :-)
>>>
>>
>> Tsk, Tsk.  Before learning assembly, you should design an instruction
>> set and implement it in hardare.  Or at least run in in a VHDL
>> simulator.  [Actually, back in my undergrad days we used AHPL and
>> implemented something like a simplified PDP-11 ISA.]
>>
>
> 
> Eh, my school never 'ad an electronics class, nor a computer neither. Made
> programming a bit tricky; we 'ad to write programs on a form and send 'em
> off to next county.  None of this new-fangled VHDL neither, we 'ad to do
> our simulations with paper and pencil.
> 
>
> (All true, as it happens.  My school acquired a computer (just the one: a
> NorthStar Horizon) in my O-Level year, but before that we really did have
> to send programs off to Worcester where someone would laboriously type them
> in for you.  A week later you got a print out of the results and a roll of
> paper tape with your program on it.)
>
>
> --
> Rhodri James *-* Kynesim Ltd
> --
> https://mail.python.org/mailman/listinfo/python-list
>

What happened if there was a bug? Did you have to re-send it?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Old Man Yells At Cloud

2017-09-19 Thread justin walters
On Tue, Sep 19, 2017 at 9:17 AM, Grant Edwards 
wrote:

> On 2017-09-19, Jan Erik =?utf-8?q?Mostr=C3=B6m?= 
> wrote:
>
> > And I'm amazed how often I see people trying to calculate
> >
> >  change = sum handed over - cost
> >
> > and then trying to figure out what bills/coins should be returned
> > instead of doing the simple thing of just adding to the cost.
>
> When I was a kid, making change like that was something we were all
> taught in school.  I have a feeling that's been dropped from most
> curricula.
>
> --
> Grant Edwards   grant.b.edwardsYow! MMM-MM!!  So THIS
> is
>   at   BIO-NEBULATION!
>   gmail.com
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


Not sure about the most recent decade, but back when I was in elementary
school(1995-2001-ish),
we definitely still learned math through how to make change.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Even Older Man Yells At Whippersnappers

2017-09-19 Thread justin walters
On Tue, Sep 19, 2017 at 8:59 AM, Grant Edwards 
wrote:

> On 2017-09-19, Rhodri James  wrote:
> > On 19/09/17 16:00, Stefan Ram wrote:
> >> D'Arcy Cain  writes:
> >>> of course, I use calculators and computers but I still understand the
> >>> theory behind what I am doing.
> >>
> >>I started out programming in BASIC. Today, I use Python,
> >>the BASIC of the 21st century. Python has no GOTO, but when
> >>it is executed, its for loop eventually is implemented using
> >>a GOTO-like jump instruction. Thanks to my learning of BASIC,
> >>/I/ can have this insight. Younger people, who never learned
> >>GOTO, may still be able to use Python, but they will not
> >>understand what is going on behind the curtains. Therefore, for
> >>a profound understanding of Python, everyone should learn BASIC
> >>first, just like I did!
> >
> > Tsk.  You should have learned (a fake simplified) assembler first, then
> > you'd have an appreciation of what your processor actually did.
> >
> >:-)
>
> Tsk, Tsk.  Before learning assembly, you should design an instruction
> set and implement it in hardare.  Or at least run in in a VHDL
> simulator.  [Actually, back in my undergrad days we used AHPL and
> implemented something like a simplified PDP-11 ISA.]
>
> Alternatively, you should design an instruction set and implement it
> using microcode and AM2900 bit-slice processors.
>
> --
> Grant Edwards   grant.b.edwardsYow! Could I have a drug
>   at   overdose?
>   gmail.com
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Even Assembly is easy nowadays:
https://fresh.flatassembler.net/index.cgi?page=content/1_screenshots.txt
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Even Older Man Yells At Whippersnappers

2017-09-19 Thread justin walters
On Tue, Sep 19, 2017 at 8:00 AM, Stefan Ram  wrote:

> D'Arcy Cain  writes:
> >of course, I use calculators and computers but I still understand the
> >theory behind what I am doing.
>
>   I started out programming in BASIC. Today, I use Python,
>   the BASIC of the 21st century. Python has no GOTO, but when
>   it is executed, its for loop eventually is implemented using
>   a GOTO-like jump instruction. Thanks to my learning of BASIC,
>   /I/ can have this insight. Younger people, who never learned
>   GOTO, may still be able to use Python, but they will not
>   understand what is going on behind the curtains. Therefore, for
>   a profound understanding of Python, everyone should learn BASIC
>   first, just like I did!
>
>   ;-)
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

As a young person (read: late 20s), the one thing I've learned is that if a
language
has a `GOTO` instruction, it's probably a bad idea to use said instruction.

I'm sure there's exceptions to this rule, but I'm lucky enough to have
better solutions
for calling the same procedure multiple times, i.e. functions.

I always wonder what my "old man yells at cloud" moment will be once I get
older.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The Incredible Growth of Python (stackoverflow.blog)

2017-09-13 Thread justin walters
On Tue, Sep 12, 2017 at 11:44 PM, Paul Rubin 
wrote:

> Chris Angelico  writes:
> > Why? Unless they're going to be maintaining a Py2 codebase, why should
> > they learn the older version with less features?
>
> Are there actually Py3 codebases?  I guess there must be, even though
> I've never seen one.  Every Python codebase of any size that I know of
> is Py2.  So yes, of course they're working on a Py2 codebase.  That's
> the only kind there is, as far as I know.
> --
> https://mail.python.org/mailman/listinfo/python-list
>

This is Zed Shaw levels of willful ignorance here.

The codebase I work on at my job is entirely Python 3.

I'm sure the same is true for anyone building a new piece of software with
Python since at least 2015.

Not everyone gets paid to maintain legacy software in "enterprise"
corporations. Some
of us are contractors or work for startups.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Proposed new syntax

2017-08-10 Thread justin walters
On Thu, Aug 10, 2017 at 7:28 AM, Steve D'Aprano 
wrote:

> Every few years, the following syntax comes up for discussion, with some
> people
> saying it isn't obvious what it would do, and others disagreeing and saying
> that it is obvious. So I thought I'd do an informal survey.
>
> What would you expect this syntax to return?
>
> [x + 1 for x in (0, 1, 2, 999, 3, 4) while x < 5]
>

>>> [1, 2, 3, 4]

>
>
> For comparison, what would you expect this to return? (Without actually
> trying
> it, thank you.)
>
> [x + 1 for x in (0, 1, 2, 999, 3, 4) if x < 5]
>
>
>>> [1, 2, 3, 4, 5]


>
> How about these?
>
> [x + y for x in (0, 1, 2, 999, 3, 4) while x < 5 for y in (100, 200)]
>

I'd expect this to throw a syntax error.


>
> [x + y for x in (0, 1, 2, 999, 3, 4) if x < 5 for y in (100, 200)]
>

Syntax error again.


>
>
>
> Thanks for your comments!
>
>
>
> --
> Steve
> “Cheer up,” they said, “things could be worse.” So I cheered up, and sure
> enough, things got worse.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Planning a Python Course for Beginners

2017-08-08 Thread justin walters
On Tue, Aug 8, 2017 at 7:19 AM, Stefan Ram  wrote:

>   I am planning a Python course.
>
>   I started by writing the course akin to courses I gave
>   in other languages, that means, the course starts roughly
>   with these topics:
>
> - number and string literals
> - types of number and string literals
>   (just giving the names »int«, »float«, and »string«)
> - using simple predefined operators (+, -, *, /)
>   (including 2*"a" and "a"+"b")
> - calling simple predefined functions (len, type, ...)
>
>   . This is a little bit boring however and might not
>   show off Python's strength early in the course.
>
>   So, I now think that maybe I should start to also
>   include list (like
>
> [1,2,3]
>
>   ) right from the start. A list conceptually is not
>   much more difficult than a string since a string
>   "abc" resembles a list ["a","b","c"]. I.e., the
>   course then would start as follows:
>
> - number, string, and list literals
> - types of number, string and list literals
>   (just giving the names »int«, »float«, »string«,
>   and »list«)
> - using simple predefined operators (+, -, *, /)
>   (including 2*"a", "a"+"b",  2*["a"], and [1]+[2])
> - calling simple predefined functions (len, type, ...)
>
>   However, once the box has been opened, what else
>   to let out? What about tuples (like
>
> (1,2,3)
>
>   ). Should I also teach tuples right from the start?
>
>   But then how to explain to beginners why two
>   different types (lists AND tuples) are needed for
>   the concept of a linear arrangement of things?
>
>   Are there any other very simple things that
>   I have missed and that should be covered very
>   early in a Python course?
>
>   (Especially things that can show off fantastic
>   Python features that are missing from other
>   programming languages, but still only using
>   literals, operators and function calls.)
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

One thing I find that gets overlooked in a lot of beginner Python
courses is Python's module system. Covering the module system
will allow you to hit on the subject of namespacing and scope.

Python's module system is one of its greatest strengths in my opinion.
No other language I've used makes it so simple to structure a project.

Another idea: Dictionaries

Dictionaries are a conceptually simple data structure that should be easy
for beginners to grok. Obviously, their implementation is a bit complex,
but I
don't think you would need to get into that. Dictionaries are very powerful
data structures that can be used to keep code DRY and store important
data to be accessed from anywhere in an application or script. Dictionaries
also have a time complexity average of O(1) for read access which
makes them fairly efficient.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do you do deep input data validation?

2017-07-22 Thread justin walters
On Sat, Jul 22, 2017 at 2:01 AM, Amirouche Boubekki <
amirouche.boube...@gmail.com> wrote:

> It seems that aiohttp recommends using one of trafaret, colander or
> jsonschema
>  >.
> I am not very familiar with those libraries.
>
> I am wondering what's the rational behind this choice. Why is trafaret the
> first in this list? Is it a strong recommendation to use trafaret?
>
> I tried to ask a question on SO about deep validation
>  validate-application-logic-using-pyramids-colander>.
> Basically, how do you validate data in your project? What are the best
> pratices?
>
> TIA!
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Personally, I like to use Marshmallow:
http://marshmallow.readthedocs.io/en/latest/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Funding continuous maintenance for PyInstaller?

2017-07-18 Thread justin walters
On Tue, Jul 18, 2017 at 3:01 AM, Hartmut Goebel <
h.goe...@crazy-compilers.com> wrote:

> Hi,
>
> I'm seeking advice how to fund continuous maintenance for an open source
> project.
>
> *Do you have any idea how to fund continuous maintenance for PyInstaller?
> Do you have any idea whom or where to ask?
> Do you know somebody to help setting up a commercial support/maintenance
> model? *
>
> I'm the (remaining) maintainer of PyInstaller (www.pyinstaller,org).
> Currently I'm maintaining PyInstaller in my spare-time. But it's is
> getting to much work for working on it for free: the open issue tickets
> and pull-requests are piling up. Since PyInstaller is quite mature,
> problems are hard to track down and to solve. Thus solving one ticket
> often takes half a day or even more.
>
> I'm already got in tough with the the PSF and the Python Software
> Verband (much like PSF, just for Germany), but they have not experience
> with this. I also read the PSF grants program, but this doesn't fit for
> continous maintenance. I also had a look at bountysource, but the
> numbers offered there may be teasers for students, not for professionals
> - so I did not follow this road. I plan to add a "donate" page to the
> web-site, but I doubt this will bring in noteworthy amounts.
>
> So I was thinking about some commercial support/maintenance model, but I
> have no experience with this. As I'm a freelance consultant already (but
> in the information security business), this could be feasible to
> implement, if I'd know how to address the commercial users.
>
> Thanks for any tip!
>
> *About PyInstaller*
>
> PyInstaller is the successor of "McMillan Installer", a tool like,
> freeze, py2exe, py2app or bbfreeze - but PyInstaller supports Windows,
> MacOS and Unix (GN/Linux, Solaris, HP-UX, etc.). PyInstaller is widely
> used sa you can see when looking at the issues and on the mailinglist.
> E.g. kivy uses/recommends PyInstaller for building Python-Apps for
> mobile platforms.
>
> PyInstaller is also used for commercial applications (as some hints on
> the mailinglist or
> But most commercial users are unknown.
>
> *About me*
>
> I'm based an Germany and developing open source and free software since
> about 1990 and using Python since about 1998. Beside of this I developed
> software like pdfposter, python-ghostscript, python-managesieve, etc. My
> day-job is freelance consultant focused on information security.
>
> --
> Regards
> Hartmut Goebel
>
> | Hartmut Goebel  | h.goe...@crazy-compilers.com   |
> | www.crazy-compilers.com | compilers which you thought are impossible |
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

You could try reaching out to Michael a Talk Python to Me:
https://talkpython.fm/

He may be able to give you a mention on the show or even have you on as a
guest. He may also be able
to point you in the direction of some sponsors.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to make this situation return this result?

2017-07-01 Thread justin walters
On Sat, Jul 1, 2017 at 5:45 AM, Ho Yeung Lee  wrote:

> just want to compare tuples like index (0,1), (0,2), (1,2) without
> duplicate
>  such as (2,0), (1,0) etc
>
>


I'm going to assume that the order of values in the tuple is important to
you.

If so, you can simply use the `==` operator to compare them.

For instance:

```
a = (0, 1)
b = (0, 1)
a == b
>>> True

a = (1, 0)
b = (0, 1)
a == b
>>> False
```

Using the `is` operator will return `False` as a and b are completely
independent objects.

```
a = (0, 1)
b = (0, 1)
a is b
>>> False
```
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Error

2017-06-28 Thread justin walters
On Jun 28, 2017 1:47 PM, "Ken R. Lewis"  wrote:

Hello!

I am running a script,  and it comes up with an error.  What can I do to
make the error be corrected?  I am thinking it is something with the data,
possibly.  I have only had Python for a few days, so maybe I copied some
codes wrong.  Also,  does Python have a way to save files downloaded from
web sites?

Thanks,
Ken


The error is on this line:
data = response.json()

Here is the script:

#Need to install requests package for python
#easy_install requests
import requests
# Set the request parameters
url = 'https://website /file'
# Eg. User name="admin", Password="admin" for this code sample.
user = 'admim'
pwd = 'admin'

# Set proper headers
#headers = {"Content-Type":"application/xml","Accept":"*/*"}
# Do the HTTP request
response = requests.get(url, auth=(user, pwd)) #, headers=headers )

print('Encoding:', response.encoding)

print('headers:', response.headers)

# Check for HTTP codes other than 200
if response.status_code != 200:
print('Status:', response.status_code, 'Headers:', response.headers,
'Error Response:',response.json())
exit()

# Decode the JSON response into a dictionary and use the data
data = response.json()
print(data)

Here is the error:
Encoding: UTF-8


Traceback (most recent call last):
  File "I:/CernerProcesses/ServiceNow/new0628.py", line 31, in 
data = response.json()
  File "C:\Program
Files\Python36\lib\site-packages\requests-2.18.1-py3.6.egg\requests\models.py",
line 894, in json
return complexjson.loads(self.text, **kwargs)
  File "C:\Program Files\Python36\lib\json\__init__.py", line 354, in loads
return _default_decoder.decode(s)
  File "C:\Program Files\Python36\lib\json\decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Program Files\Python36\lib\json\decoder.py", line 357, in
raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)




Ken Lewis
Trinity Health I.T.
Programmer Lead
(701) 858-6423
Cell  (701)833-8234
Fax (701) 858-6407
ken.le...@trinityhealth.org




Confidentiality Notice: This e-mail message, including any attachments, is
for the sole use of the intended recipient(s) and may contain information
that is privileged, confidential, or otherwise exempt from disclosure under
applicable law. Any unauthorized review, copy, use, disclosure or
distribution is prohibited. If you have received this communication in
error, please delete it from your system without copying or forwarding it
and notify the sender of the error by reply e-mail.
--
https://mail.python.org/mailman/listinfo/python-list



Looks to me like you're not receiving any data from your request. In
effect, the response body is empty.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] is JSON all that great? - was Re: API Help

2017-06-14 Thread justin walters
On Wed, Jun 14, 2017 at 7:33 PM, Michael Torrie <torr...@gmail.com> wrote:

> On 06/14/2017 05:06 PM, justin walters wrote:
> > JSON in Python is such a joy! :)
>
> I understand that in this case the data is coming from a server in a
> form intended for easy use with Javascript.  But other than this type of
> communication, I don't see any good reason to choose JSON as a data
> interchange format.
>
> To me JSON seems to hold no real benefits over other serialization
> techniques, including the XML beast. XML may be verbose, but at least
> XML data can be formally validated and formally transformed and queried,
> which is certainly not the case with JSON as we can see from this long
> thread.  JSON's mantra seems to be try parsing it and see what happens.
> Whether it works depends on the parser and any quirks it has (quotes vs
> single quotes, etc).  I don't find JSON any more human readable than XML
> to be honest, perhaps less so because there's no way to define a formal
> schema to follow, at least that I'm aware of.
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

There are 2 main issues with XML:

1) It is not secure. Check this out:
https://stackoverflow.com/questions/1906927/xml-vulnerabilities#1907500

2) It is large. JSON can express the same amount of information while
using much less memory. There are many reasons for this, but the simplest
is that JSON formatting requires less characters.

Also, there are several formal schemas to follow. The most popular is
JSONAPI.

JSON is also fundamentally much simpler than XML. There are strings,
numbers,
arrays, and objects. That's it. It is basically a dumbed down Python
dictionary.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: API Help

2017-06-14 Thread justin walters
On Wed, Jun 14, 2017 at 6:00 PM, Ned Batchelder <n...@nedbatchelder.com>
wrote:

> On Wednesday, June 14, 2017 at 7:06:39 PM UTC-4, justin walters wrote:
> > JSON and Python dictionaries have nearly the exact same syntax. That's
> why
> > working with
> > JSON in Python is such a joy! :)
> >
> > You can paste any valid JSON into a Python REPL and it will be
> interpreted
> > as a Python dictionary.
>
> Careful: JSON booleans are true and false, not True and False, and the
> missing
> value is null, not None.  So valid JSON might not be readable as Python.
>
> --Ned.
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Oh! Yep!

I haven't run into this issue because I generally don't run ``eval()`` on
random data from the internet. I usually use either the built in ``json``
module
or ``marshmallow`` if I have a strict schema to conform to.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: API Help

2017-06-14 Thread justin walters
On Wed, Jun 14, 2017 at 4:40 PM, Grant Edwards <grant.b.edwa...@gmail.com>
wrote:

> On 2017-06-14, justin walters <walters.justi...@gmail.com> wrote:
>
> > I should also specify that the data you have received is malformed.
> >
> > JSON should always have an object as the top level structure, not an
> > array as in your data.
>
> Where is that requirement stated?
>
> RFC7159 explicitly states that a "conforming JSON text" can be either
> an array or an object:
>
>
>2.  JSON Grammar
>
>A JSON text is a sequence of tokens.  The set of tokens includes
>six structural characters, strings, numbers, and three literal
>names.
>
>A JSON text is a serialized value.  Note that certain previous
>specifications of JSON constrained a JSON text to be an object or
>an array.  Implementations that generate only objects or arrays
>where a JSON text is called for will be interoperable in the sense
>that all implementations will accept these as conforming JSON
>texts.
>
> The grammar specified by later in that section also allow a JSON text
> to contain nothing but a single simple value: string, number 'null'
> 'true' or 'false'.  IOW, a file containing a single digit (0-9) is
> valid JSON.
>
> --
> Grant
>
>
>
>
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

That's why I said "should", not "required".

Generally, it's considered best practice for web APIs.

I also did not say that the data is "invalid", I said it is "malformed".
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: API Help

2017-06-14 Thread justin walters
On Wed, Jun 14, 2017 at 4:06 PM, justin walters <walters.justi...@gmail.com>
wrote:

>
>
> On Wed, Jun 14, 2017 at 3:49 PM, Grant Edwards <grant.b.edwa...@gmail.com>
> wrote:
>
>> On 2017-06-14, Erik <pyt...@lucidity.plus.com> wrote:
>> > On 14/06/17 22:54, Ray Cote wrote:
>> >> Definitely JSON:
>> >>>>>
>> >> json.loads(“""[{"itemNumber":"75-5044","inventory":[{"wareho
>> useCode":"UT-1-US","quantityAvailable":0.0},{"wa
>> rehouseCode":"KY-1-US","quantityAvailable":0.0},
>> {"warehouseCode":"TX-1-US","quantityAvailable":14.00
>> 000},{"warehouseCode":"CA-1-US","quantityAvailable":4.
>> 0},{"warehouseCode":"AB-1-CA","quantityAvailable":
>> 1.0},{"warehouseCode":"WA-1-US","quantityAvailab
>> le":0.0},{"warehouseCode":"PO-1-CA","quantityAva
>> ilable":0.0}]}]""")
>> [...]
>> >
>> > If that makes it definitely JSON, then this makes it definitely Python
>> ;) :
>> > >>>
>> > [{"itemNumber":"75-5044","inventory":[{"warehouseCode":"UT-
>> 1-US","quantityAvailable":0.0},{"warehouseCode
>> ":"KY-1-US","quantityAvailable":0.0},{"warehouse
>> Code":"TX-1-US","quantityAvailable":14.0},{"ware
>> houseCode":"CA-1-US","quantityAvailable":4.0},{"
>> warehouseCode":"AB-1-CA","quantityAvailable":1.0
>> },{"warehouseCode":"WA-1-US","quantityAvailable":0.0
>> },{"warehouseCode":"PO-1-CA","quantityAvailable":0.0}]}]
>>
>> Indeed.
>>
>> > So, I think we're agreed that it's definitely one or the other.
>>
>> It's both a floor wax _and_ a dessert topping!
>>
>> --
>> Grant
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
> JSON and Python dictionaries have nearly the exact same syntax. That's why
> working with
> JSON in Python is such a joy! :)
>
> You can paste any valid JSON into a Python REPL and it will be interpreted
> as a Python
> dictionary.
>
> I can assure you with 99.~% confidence that the data you are receiving
> from the API
> is JSON data. You will find very few web APIs around nowadays that aren't
> using JSON or
> JSONB(binary representation of JSON).
>
> All that said, you can use the built in ``json`` module to convert the raw
> data into a Python
> dictionary in the following manner(assuming you are using Python 3.2+).
>
> ```
> import json
>
> response_data = "..." # This is the received JSON data as a binary string.
>
> data = json.loads(
> str(response_data, encoding="utf8")
> )
>
> data["itemNumber"]
>
> >>> "75-5044"
> ```
>
> Hope that helps.
>

I should also specify that the data you have received is malformed.

JSON should always have an object as the top level structure, not an
array as in your data.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: API Help

2017-06-14 Thread justin walters
On Wed, Jun 14, 2017 at 3:49 PM, Grant Edwards 
wrote:

> On 2017-06-14, Erik  wrote:
> > On 14/06/17 22:54, Ray Cote wrote:
> >> Definitely JSON:
> >
> >> json.loads(“""[{"itemNumber":"75-5044","inventory":[{"
> warehouseCode":"UT-1-US","quantityAvailable":0.0},{"
> warehouseCode":"KY-1-US","quantityAvailable":0.0},{"
> warehouseCode":"TX-1-US","quantityAvailable":14.0},{"
> warehouseCode":"CA-1-US","quantityAvailable":4.0},{"
> warehouseCode":"AB-1-CA","quantityAvailable":1.0},{"
> warehouseCode":"WA-1-US","quantityAvailable":0.0},{"
> warehouseCode":"PO-1-CA","quantityAvailable":0.0}]}]""")
> [...]
> >
> > If that makes it definitely JSON, then this makes it definitely Python
> ;) :
> > >>>
> > [{"itemNumber":"75-5044","inventory":[{"warehouseCode":"
> UT-1-US","quantityAvailable":0.0},{"warehouseCode":"KY-1-US","
> quantityAvailable":0.0},{"warehouseCode":"TX-1-US","
> quantityAvailable":14.0},{"warehouseCode":"CA-1-US","
> quantityAvailable":4.0},{"warehouseCode":"AB-1-CA","
> quantityAvailable":1.0},{"warehouseCode":"WA-1-US","
> quantityAvailable":0.0},{"warehouseCode":"PO-1-CA","
> quantityAvailable":0.0}]}]
>
> Indeed.
>
> > So, I think we're agreed that it's definitely one or the other.
>
> It's both a floor wax _and_ a dessert topping!
>
> --
> Grant
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

JSON and Python dictionaries have nearly the exact same syntax. That's why
working with
JSON in Python is such a joy! :)

You can paste any valid JSON into a Python REPL and it will be interpreted
as a Python
dictionary.

I can assure you with 99.~% confidence that the data you are receiving
from the API
is JSON data. You will find very few web APIs around nowadays that aren't
using JSON or
JSONB(binary representation of JSON).

All that said, you can use the built in ``json`` module to convert the raw
data into a Python
dictionary in the following manner(assuming you are using Python 3.2+).

```
import json

response_data = "..." # This is the received JSON data as a binary string.

data = json.loads(
str(response_data, encoding="utf8")
)

data["itemNumber"]

>>> "75-5044"
```

Hope that helps.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python certification

2017-06-08 Thread justin walters
On Thu, Jun 8, 2017 at 4:49 AM, Gonzalo V  wrote:

> hi,
> good day.
> where can i get a python certification?
>
> thanks!
> --
> https://mail.python.org/mailman/listinfo/python-list
>

I don't believe there is any official certification. Nor do I believe that
a Python
certification would be something employers are even looking for.

That said, if you really need some document that says you know Python,
edX and udacity do offer completion certificates for their courses I
believe.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Transitioning from Linux to Windows

2017-06-03 Thread justin walters
On Jun 3, 2017 7:28 AM,  wrote:

On Saturday, June 3, 2017 at 8:50:27 AM UTC-5, Chris Angelico wrote:

> Hmm. ISTM the easiest way would be to run an explicit server, probably
> HTTP (hence Django as you mentioned), and then you can have people
> access it using a client on Windows. With HTTP, that client would
> simply be a web browser. I would advise picking up a quick tutorial on
> Django or Flask, and seeing how easy it is to spin up an app and start
> responding to requests.
>
> ChrisA

Yes, "django" indeed seems to be a good solution - But I am having a tough
time understanding how to set it up :( ...

All I need is a simple example (say in django) with explicit directions
"django for dummies" - that shows how to set it up - access is using
http(s) and execute on the server/ubuntu ... I have indeed looked far and
wide for the "simplest" example in django I can learn from/adapt ... it is
something I have struggled with for sure ... (number crunching is what I do
know, UI's are strange to me!)
--
https://mail.python.org/mailman/listinfo/python-list


Lucky for you!

I work with django almost every single day!

The best place to get started is the official tutorial.
https://docs.djangoproject.com/en/1.11/intro/tutorial01/


Or should take a couple of hours to get through it, but it will teach you
all the basics.

After that, you want to learn how to set up gunicorn to serve a local unix
socket. Then you need to set up nginx to proxy all requests to that socket.
You can use certbot with letsencrypt dor ssl.

Alternatively, i believe heroku has a prebuilt django deployment you can
use.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bug or intended behavior?

2017-06-02 Thread justin walters
On Fri, Jun 2, 2017 at 10:17 AM,  wrote:

> Can someone please explain this to me?  Thanks in advance!
>
> ~Sean
>
>
> Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47)
> [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> print "foo %s" % 1-2
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: unsupported operand type(s) for -: 'str' and 'int'
> >>>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Try this:

print "foo %d" % (1-2)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Scala considering significant indentation like Python

2017-05-23 Thread justin walters
On Tue, May 23, 2017 at 7:10 AM, Grant Edwards 
wrote:

> On 2017-05-23, Michael Torrie  wrote:
> > On 05/22/2017 02:57 PM, Ethan Furman wrote:
> >>> Kind of reminds me of LISP.  Lots of closing parenths, and often then
> >>> just all get stuck together on a long.  But I guess that's why they
> >>> invented paren matching shortcuts in editors.  To make it easy to see
> if
> >>> you have them matched up.  This works with braces too.  Perhaps there
> is
> >>> a plugin for Vim to jump back and forth between the beginning and end
> of
> >>> a blog?  Wouldn't be too hard to just look at indent.
> >
> > Sigh.  Missing words, the wrong words!  Block, not blog.  agg.
> >
> >> It's built-in, no plug-in necessary.
> >>
> >> I still find white-space indentation easier to read, though.  Is that
> > block 20 lines down inside or outside the above
> >> if/for/while?  Just put your cursor on it and go straight down and
> > you'll find out.  Not so easy if the braces aren't
> >> lined up (at least for me).
> >
> > True enough.  Would still be nice to jump, though.  Sometimes things get
> > longer than a page (like a class definition).
>
> A nice folding mode works nicely for that sort of thing.  I normally
> use emacs, but it doesn't seem to have a folding mode built-in, and
> the add-on one's I've tried didn't seem to work in a very useful way.
> I like the folding in Scite, and sometimes I fire it up when I'm
> trying to figure out the logic/flow/looping in unfamiliar code.
>

I don't know how well it's received here, but I find that Pycharm is
fantastic for
doing stuff like this. It does have code folding, auto-complete, auto close
parens, etc.

My favorite feature, however, is the project structure view. It allows you
to view
your project as a tree of variables, classes, and functions instead of
filesystem
directories. It's pretty neat to be honest.

The downside, of course, is that Pycharm is a lot heavier than most
editors.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: type hinting backward compatibility with python 3.0 to 3.4

2017-05-21 Thread justin walters
On Sun, May 21, 2017 at 2:38 AM, Chris Angelico  wrote:

> On Sun, May 21, 2017 at 7:29 PM, bartc  wrote:
> >
> > They might be /created/ at runtime, but it's a pretty good bet that the
> name
> > A in this declaration:
> >
> >   class A...
> >
> > is the name of a class. The question in Python, as always, is whether an
> A
> > used as the name of a type in a type, is still this same A. And
> presumably
> > such a type hint can precede the declaration of A.
> >
> > In fact the declaration of A might be in a different module from its use
> in
> > a type hint, which means that, in the CPython byte-code compiler anyway,
> it
> > is not visible at compile-time, when type hints could best be put to good
> > effect.
>
> That isn't a problem - mypy follows imports. It'd be pretty useless if
> it didn't :)
>
> > Furthermore, both A, and the type-hinting code, might be conditional. So
> > that on Tuesdays, A is a class, the rest of the week it's the name of a
> > module.
>
> Or, more plausible example: on platforms that have a system-provided
> source of entropy, random.random is an instance of SystemRandom, but
> on those that don't, it's an instance of DeterministicRandom with an
> arbitrarily-chosen seed. The two will have slightly different APIs.
>
> > Python doesn't make things easy.
>
> Python makes things flexible, which has a cost.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Perhaps a good way to distinguish between a class that can be used as a
type and a class
that cannot be used as a type would be to require some sort of dunder
method be
defined on the type class. At first I was thinking `__type__`, but then I
remembered that's
already in use. maybe something as simple as `__hint__`.

That or only allow classes that inherit from `type` to be used in type
annotations.

I'm just spit balling ideas here.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: /g/? (was: What if range did not exist?)

2017-05-18 Thread justin walters
On Thu, May 18, 2017 at 12:48 PM, Skip Montanaro 
wrote:

> > It's the technology board on 4chan. It's pretty useless. Mostly just for
> > messing around.
>
> Thanks. I tried to visit 4chan, but company access policy forbade
> it... Something about porn.
>
> Skip
>

The place is a cesspool. I don't recommend visiting.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: /g/? (was: What if range did not exist?)

2017-05-18 Thread justin walters
On Thu, May 18, 2017 at 11:18 AM, Skip Montanaro 
wrote:

> > I visit /g/ quite often ...
>
> Is this a channel on Reddit or something else?
>
> Thx,
>
> Skip Montanaro
>

It's the technology board on 4chan. It's pretty useless. Mostly just for
messing around.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Survey: improving the Python std lib docs

2017-05-18 Thread justin walters
On Thu, May 18, 2017 at 8:08 AM, justin walters <walters.justi...@gmail.com>
wrote:

>
>
> On Thu, May 18, 2017 at 12:09 AM, Deborah Swanson <
> pyt...@deborahswanson.net> wrote:
>
>> Michael Torrie wrote, on Wednesday, May 17, 2017 3:11 PM
>> >
>> > On 05/17/2017 02:31 PM, Ned Batchelder wrote:
>> > > Can you give an example of such a method? Often, that signature is
>> > > used because there is no pre-conception of what the arguments might
>> > > be.
>> >
>> > I'm not sure if this afflicts the standard library, but in my
>> > own code, since Python doesn't support constructors with
>> > different signatures, you pretty much have to rely on kwargs
>> > with __init__() to handle different permutations of
>> > construction arguments.  Not that we don't know what the
>> > arguments might be, we just don't know which of them we'll
>> > have to deal with.  Maybe the standard library is better
>> > designed than my own code, but I find I have to implement
>> > __init__(self, **kwargs) all the time.
>>
>>
>> While I can respect and appreciate your specialized interest in specific
>> kwargs, and I read in other's posts that help()'s display of kwargs is
>> conditional on several things, I really want to reiterate and clarify my
>> beginner's request.
>>
>> I know of several functions I've used without any *args or **kwargs
>> because I had no clue from the docs what they might be. And, I know of
>> one function now, from posts in this list, which takes kwargs, but I
>> only know one application of one possible kwarg in this function because
>> one member of this list, Peter Otten, used it in a suggestion he gave
>> me.
>>
>> This is all there is in the docs for that function:
>>
>>
>> somenamedtuple._replace(kwargs)
>>
>> Return a new instance of the named tuple replacing specified fields
>> with new values:
>> (Examples
>> box)---|
>> |>>>
>> |
>> |
>> |
>> |>>> p = Point(x=11, y=22)
>> |
>> |>>> p._replace(x=33)
>> |
>> |Point(x=33, y=22)
>> |
>> |
>> |
>> |>>> for partnum, record in inventory.items():
>> |
>> |... inventory[partnum] =
>> record._replace(price=newprices[partnum], |
>> |  timestamp=time.now())
>> |
>> |---
>> |
>>
>> From this doc entry's example, I (sort of) get that x is a keyword arg
>> that is to be equal to 33 for any use of p._replace() in the code
>> following, until
>> p._replace(kwarg) is respecified, or the code ends. So the response from
>> Python shows me that p has transformed to the Point(x=33, y=22). A
>> trivial example that doesn't begin to hint at the poential powers of
>> this kwarg.
>>
>> The inventory[partnum] example is also quite trivial compared to the
>> kwarg use that Peter showed me.
>>
>> When I asked him for an explanation, this is what I and he he said:
>>
>> Deborah Swanson wrote:
>>
>> > I know it's your "ugly" answer, but can I ask what the '**' in
>> >
>> > fix = {label: max(values, key=len)}
>> > group[:] = [record._replace(**fix) for record in group]
>> >
>> > means?
>>
>> (Peter wrote)
>> d = {"a": 1, "b": 2}
>> f(**d)
>>
>> is equivalent to
>>
>> f(a=1, b=2)
>>
>> so ** is a means to call a function with keyword arguments when you want
>> to
>> decide about the *names* at runtime. Example:
>>
>> >>> def f(a=1, b=2):
>> ... print("a =", a)
>> ... print("b =", b)
>> ... print()
>> ...
>> >>> for d in [{"a": 10}, {"b": 42}, {"a": 100, "b": 200}]:
>> ... f(**d)
>> ...
>> a = 10
>> b = 2
>>
>> a = 1
>> b = 42
>>
>> a = 100
>> b = 200
>>
>> Starting from a namedtuple `record`
>>
>> record._replace(Location="elswhere")
>>
>> creates a new namedtuple with the Location attribute changed to
>> "elsewhere",
>> and the slice [:] on the left causes all items in the `groups` list to
>> be
>> replaced with new namedtuples,
>>
>> group[:] = [record._replace(Location="elsewhere") for record in group]
>>

Re: Survey: improving the Python std lib docs

2017-05-18 Thread justin walters
On Thu, May 18, 2017 at 12:09 AM, Deborah Swanson  wrote:

> Michael Torrie wrote, on Wednesday, May 17, 2017 3:11 PM
> >
> > On 05/17/2017 02:31 PM, Ned Batchelder wrote:
> > > Can you give an example of such a method? Often, that signature is
> > > used because there is no pre-conception of what the arguments might
> > > be.
> >
> > I'm not sure if this afflicts the standard library, but in my
> > own code, since Python doesn't support constructors with
> > different signatures, you pretty much have to rely on kwargs
> > with __init__() to handle different permutations of
> > construction arguments.  Not that we don't know what the
> > arguments might be, we just don't know which of them we'll
> > have to deal with.  Maybe the standard library is better
> > designed than my own code, but I find I have to implement
> > __init__(self, **kwargs) all the time.
>
>
> While I can respect and appreciate your specialized interest in specific
> kwargs, and I read in other's posts that help()'s display of kwargs is
> conditional on several things, I really want to reiterate and clarify my
> beginner's request.
>
> I know of several functions I've used without any *args or **kwargs
> because I had no clue from the docs what they might be. And, I know of
> one function now, from posts in this list, which takes kwargs, but I
> only know one application of one possible kwarg in this function because
> one member of this list, Peter Otten, used it in a suggestion he gave
> me.
>
> This is all there is in the docs for that function:
>
>
> somenamedtuple._replace(kwargs)
>
> Return a new instance of the named tuple replacing specified fields
> with new values:
> (Examples
> box)---|
> |>>>
> |
> |
> |
> |>>> p = Point(x=11, y=22)
> |
> |>>> p._replace(x=33)
> |
> |Point(x=33, y=22)
> |
> |
> |
> |>>> for partnum, record in inventory.items():
> |
> |... inventory[partnum] =
> record._replace(price=newprices[partnum], |
> |  timestamp=time.now())
> |
> |---
> |
>
> From this doc entry's example, I (sort of) get that x is a keyword arg
> that is to be equal to 33 for any use of p._replace() in the code
> following, until
> p._replace(kwarg) is respecified, or the code ends. So the response from
> Python shows me that p has transformed to the Point(x=33, y=22). A
> trivial example that doesn't begin to hint at the poential powers of
> this kwarg.
>
> The inventory[partnum] example is also quite trivial compared to the
> kwarg use that Peter showed me.
>
> When I asked him for an explanation, this is what I and he he said:
>
> Deborah Swanson wrote:
>
> > I know it's your "ugly" answer, but can I ask what the '**' in
> >
> > fix = {label: max(values, key=len)}
> > group[:] = [record._replace(**fix) for record in group]
> >
> > means?
>
> (Peter wrote)
> d = {"a": 1, "b": 2}
> f(**d)
>
> is equivalent to
>
> f(a=1, b=2)
>
> so ** is a means to call a function with keyword arguments when you want
> to
> decide about the *names* at runtime. Example:
>
> >>> def f(a=1, b=2):
> ... print("a =", a)
> ... print("b =", b)
> ... print()
> ...
> >>> for d in [{"a": 10}, {"b": 42}, {"a": 100, "b": 200}]:
> ... f(**d)
> ...
> a = 10
> b = 2
>
> a = 1
> b = 42
>
> a = 100
> b = 200
>
> Starting from a namedtuple `record`
>
> record._replace(Location="elswhere")
>
> creates a new namedtuple with the Location attribute changed to
> "elsewhere",
> and the slice [:] on the left causes all items in the `groups` list to
> be
> replaced with new namedtuples,
>
> group[:] = [record._replace(Location="elsewhere") for record in group]
>
> is basically the same as
>
> tmp = group.copy()
> group.clear()
> for record in tmp:
> group.append(record_replace(Location="elsewhere"))
>
> To support not just Location, but also Kind and Notes we need the double
>
> asterisk.
>
>
>
> Now, I understood what he meant from the context of the problem he was
> helping me with, but, how in the world would I have gotten that possible
> use of somenamedtuple._replace(kwargs) from the blurb and examples in
> the docs? Or any other possible kwarg and how they're used, including
> special operators like "**" ?
>
> If there's a tutorial somewhere on kwargs in general, what specific
> types of kwargs there are, what special operators can be specifed for
> them and how the kwargs are used, it would be very helpful to have that
> tutorial referenced in a footnote-link next to kwargs whenever kwargs is
> part of a function specification.
>
> Or, if no such tutorial exists, the footnote-link could point to any
> more detailed information that might explain what this creature "kwargs"
> might be.
>
> I have an item on my todo list to google "python kwargs", but it keeps
> getting pushed deeper and deeper down my list because I have so little
> hope that it will turn up 

Re: What if range did not exist?

2017-05-18 Thread justin walters
On Thu, May 18, 2017 at 12:34 AM, Steven D'Aprano 
wrote:

> On Wed, 17 May 2017 14:13:18 -0700, breamoreboy wrote:
>
> > Here it is
> > https://aroberge.blogspot.co.uk/2017/05/what-if-range-did-not-
> exist.html.
> >  I found it interesting as it gives background into the Python
> > community's development philosophy.  I read it from start to finish but
> > some of you may simply wish to jump to the punch line.
>
> This is not the punch line, but I thought it captured the essence of the
> Python-Ideas mailing list perfectly:
>
> "Since this was clearly never going to be considered seriously, another
> very long and pointless side discussion ensued."
>
> A little bit long, but not unamusing :-)
>
>
>
> --
> Steve
> --
> https://mail.python.org/mailman/listinfo/python-list
>


I find it interesting that 4chan was mentioned as the electoral college for
this fictional PL.

I'm sure the author was just trying to make the allusion that asking the
masses to decide on
language features and design is akin to asking a cesspit of trolls to run a
country. I visit /g/ quite
often and I have always noticed the disdain that they have for Python over
there. Sometimes I think
there is implied irony in the hatred, but other times, I think it really is
just people talking out of their
collective you know whats. Just continuing the tradition of irrelevant
tangents . :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to python and programming

2017-05-17 Thread justin walters
On Wed, May 17, 2017 at 12:59 PM, BT  wrote:

> Hi guys,
> I am fairly new to programming. I was just trying to understand how this
> group works. Am i allowed to ask any questions that I may have when i get
> stuck? I mean is this group for new programmers as well..?
> Thanks
> --
> https://mail.python.org/mailman/listinfo/python-list
>

The mailing list info page doesn't mention anything specific about asking
for help: https://mail.python.org/mailman/listinfo/python-list

People do routinely ask for help here though. I think I can speak for
everyone when I say
that you should make sure that you try to find the answer using your search
engine
of choice before bringing the question here. Your question may be a very
common one
and you might be able to find the answer more quickly on, say, stack
overflow.

All that said, welcome to the list! Some of the conversation can get a
little fiery,
but it's entertaining at the least.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ten awesome things you are missing out on if you're still using Python 2

2017-05-08 Thread justin walters
On Mon, May 8, 2017 at 3:40 PM,  wrote:

> Slide 15:
>
> > def sum(a, b, biteme=False):
> > if biteme:
> > shutil.rmtree('/')
> > else:
> > return a + b
>
> Now that's just evil.  :^)
> --
> https://mail.python.org/mailman/listinfo/python-list
>

I sincerely hope no-one is trying to run this example as root.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ten awesome things you are missing out on if you're still using Python 2

2017-05-08 Thread justin walters
On Mon, May 8, 2017 at 9:07 AM, Chris Angelico  wrote:

> On Tue, May 9, 2017 at 1:02 AM, Ian Kelly  wrote:
> > Slide 58: "Not going to lie to you. I still don't get this." Uh, sure,
> > great sales pitch there. If the author doesn't understand asyncio, then
> why
> > include it in the list?
>
> IMO he doesn't understand it because he's aiming at Python 3.4. Aim at
> 3.5 minimum and use "async def". Much easier.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>


Agreed `async` and `await` in Py3.5 made it so much easier for me to
understand the new async
stuff.

I've been toying around with aiohttp a bit and I can say it's actually
fairly enjoyable. Doesn't have all
the creature comforts I've enjoyed while working with Django in my day job,
but I can see some fairly
robust applications being created with aiohttp.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problems

2017-05-04 Thread justin walters
On Thu, May 4, 2017 at 4:42 AM, aohK euqsarraT 
wrote:

> I have been using pycharm + python 3.6 for a year and then i updated
> pycharm, that was when things became a super buggy mess. I tried to
> reinstall everything from scratch but the python installation keeps having
> the previous wrong paths that pycharm and python 3.6 are not connected, how
> do i make my computer forget all these things and reinstall with all things
> automatically work together like the very first time i installed it? (Just
> like my other laptop that i just have to click "next" and tick the
> recommended sections then everything is in its place). Thanks!
> --
> https://mail.python.org/mailman/listinfo/python-list
>

This is soemthing you should contact Pycharm Support about. There is
probably a configuration option
under preferences to point Pycharm at your Python executable. I usually set
this up
with a virtualenv for each project.

This link looks like it could be helpful:
https://www.jetbrains.com/help/pycharm/2017.1/configuring-python-interpreter-for-a-project.html

Also, when selecting an interpreter for a new project or changing the
interpreter for an existing project, you don't
have to choose from the dropdown. You can manually enter a path as well.

Hope this helps.
-- 
https://mail.python.org/mailman/listinfo/python-list


Fwd: Bigotry (you win, I give up)

2017-04-28 Thread justin walters
On Thu, Apr 27, 2017 at 9:52 PM, Mike Reveile 
wrote:

> I can measure a Pineapple... by weight, volume, color, taste, smell,
> ripeness... but none of these numbers are the pineapple. They only help me
> relate to the pineapple. In this way Math itself (and the entire realm of
> computer science) is unreal.



I've always felt that math is simply another language like English or
Spanish. Language is an abstraction
that humans use to convey meaning to other humans. We agreed on common
labels and sounds
to represent things, actions, and ideas. Math is the same. The laws of
physics obviously exist in some sense
because we can observe their effects. We represent these effects with
numbers and symbols. The number 1
could just as well be the number gobbledeegorp. It doesn't matter. The
number one simply represents a single entity
of anything at all. Of course this is all from the narrow field of human
perception. What humans perceive
to be real could, in all possibility, be completely made up in our own
minds. I don't want to get to far into
the "perception is reality" side of things although.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to port a python package to a embedded system

2017-04-24 Thread justin walters
On Mon, Apr 24, 2017 at 2:45 AM, chenchao  wrote:

> Hi, everybody:
>
>  I have port python-2.7 to my arm board. But i don't know how to port
> a python package to my embedded system. For example, numpy pakage.
> Therefore, is there anybody know how to do this? Thanks!
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Could you be a bit more specific?

When you say: " I have port python-2.7 to my arm board.", it could mean:

* You want to run a CPython interpreter on an ARM chip
* You want to compile your Python code into a binary executable for ARM
chips
* Something entirely different

You also say that you need to port numpy. Numpy itself consists of a heck
of a lot of C,
so you will need to compile that with ARM as your target.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Microsoft now ships Python with SQL Server

2017-04-22 Thread justin walters
On Sat, Apr 22, 2017 at 5:05 AM, Steve D'Aprano 
wrote:

> https://blogs.technet.microsoft.com/dataplatforminsider/2017/04/
> 19/python-in-sql-server-2017-enhanced-in-database-machine-learning/
>
> Quote:
>
> We are excited to share the preview release of in-database analytics and
> machine learning with Python in SQL Server. Python is one of the most
> popular languages for data science and has a rich ecosystem of powerful
> libraries.
>
> Starting with the CTP 2.0 release of SQL Server 2017, you can now bring
> Python-based intelligence to your data in SQL Server.
>
> The addition of Python builds on the foundation laid for R Services in SQL
> Server 2016 and extends that mechanism to include Python support for
> in-database analytics and machine learning. We are renaming R Services to
> Machine Learning Services, and R and Python are two options under this
> feature.
>
> /quote
>
>
> --
> Steve
> “Cheer up,” they said, “things could be worse.” So I cheered up, and sure
> enough, things got worse.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Does this mean Python is now Enterprise™?

Nah, in all seriousness though; this is good new I think. I'm all for
Python becoming
even more wide spread.

Although I've never used MS SQL, I'm glad people who do use it for work now
have an easy to
understand language to perform analytics with.

It's also great news that they are defaulting to Python 3.5.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Static typing [was Re: Python and the need for speed]

2017-04-16 Thread justin walters
On Sun, Apr 16, 2017 at 8:46 AM, bartc  wrote:

> What were the results with Python on your machine?



Well, at first I tried to implement it with a generator. I gave up on
waiting for the program to complete
after about 6 minutes.

After using your code almost exactly I get:
>>> Sum:  149985000
>>> ***Execution Time:  17.33912420272827 ***

That's with Python 3.5 on an Intel I5-6600k 3.9Ghz cpu and 16GB DDR4 memory.

> (Nice-looking language, I hadn't heard of it.)

Yeah, it's pretty neat. Some parts of Nim aren't really production ready
yet, but I think it has a bright future.

proc test() =
> var
> sum = 0
> a = 0
> b = 0
> for i in 0..<1:
>
>
Loop iterations should be 100 million, if this is one less. Missing one out
> won't affect the timing, but will give a different result if comparing
> implementations to see if they do the same thing.
>

It's not one less. It will execute exactly 100 million times. Meaning it
will execute when i is
99,999,999 but not when i is 100,000,000. This gives exactly 100,000,000
iterations including
the iteration for i = 0. It could alternatively be written as:


for i in 1..1:


Didn't realize I had messed up the increment on var b with my Nim
implementation!

Fixed:

===
import
times

proc add(a, b: int): int =
result = a + b

proc test() =
var
sum = 0
a = 0
b = 0
for i in 0..<1:
sum += add(a, b)
a += 1
b += 2
echo "a: " & $a & " b: " & $b & "\n"
echo "Sum: " & $sum

when isMainModule:
var t0 = cpuTime()
test()
var t1 = cpuTime()
echo "***Execution Time: " & $(t1 - t0) & "***\n"
===

The above Nim code is a tad bit slower with the larger var b:
>>> a: 1 b: 2
>>> Sum: 149985000
>>> ***Execution Time: 2.888533***

With Speed Optimization:
>>> a: 1 b: 2
>>> Sum: 149985000
>>> ***Execution Time: 2.843629***

With size optimization:
>>> a: 1 b: 2
>>> Sum: 149985000
>>> ***Execution Time: 2.844876***

Compiled with release flag:
>>> a: 1 b: 2
>>> Sum: 149985000
>>> ***Execution Time: 2.842312***

> Hmm, the optimiser is similar to mine then!

I'm pretty new when it comes to compilers. Been trying to learn more and
build my own but
progress is fairly slow. I'm not sure what `nimc` is doing under the hood,
but I do know that it
transpiles to C before running either `gcc` or `clang`.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Static typing [was Re: Python and the need for speed]

2017-04-16 Thread justin walters
On Sun, Apr 16, 2017 at 3:55 AM, bartc  wrote:

> Example C of the same silly program in Python:
>
> def add(a,b):
> return a+b
>
> def testfn():
> sum=a=b=0
> for i in range(1):
> sum += add(a,b)
> a += 1
> b += 2
>
> print (a,b,sum)
>
> testfn()
>
>
> Timings:
>
> A (Pure HLL**)  13   seconds  (dynamic/interpreted)
> A (With ASM module)  3
> A (With ASM module)  2(older version; hmmm...)
>
> B (my compiler)  0.5  (static/compiled)
> B (via C/gcc-O3) 0.14
>
> C (Python 2)   163
> C (Python 2/xrange) 30
> C (Python 3)38
> C (Pypy) 5
>


Just for fun I wanted to write this up in Nim to compare execution time.
Nim has Python-esqe syntax but is statically
typed and compiled. I think this is relevant to the discussion.

Code looks like this:

```
import times

proc add(a, b: int): int =
result = a + b

proc test() =
var
sum = 0
a = 0
b = 0
for i in 0..<1:
sum += add(a, b)
a += 1
b += 1
echo "a: " & $a & " b: " & $b & "\n"
echo "Sum: " & $sum

when isMainModule:
var t0 = cpuTime()
test()
var t1 = cpuTime()
echo "***Execution Time: " & $(t1 - t0) & "***\n"
```


No optimization: ***Execution Time: 2.876923***
Optimized for speed: ***Execution Time: 2.844163***
Optimized for size: ***Execution Time: 2.844901***
Release option: ***Execution Time: 2.844021***

So, generally around 2.8 seconds.

Not too bad for a GC'd language. There are probably some more optimizations
I could make to improve execution time.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Data exchange between python script and bash script

2017-04-04 Thread justin walters
On Tue, Apr 4, 2017 at 10:39 AM, Venkatachalam Srinivasan <
venkatachalam...@gmail.com> wrote:

> Hi,
>
> Thanks for the answer. I need bash for connecting data exchange between
> two python scripts. To be more specific, data from one script has to be
> passed to the another script. You are right, I don't need the data in the
> bash other than to pass the obtained data to the another script which uses
> the data for further analysis.
>
> Regarding using the json file, I am new to this. A naive question is that
> if the data is too large then is json file is easy to handle? Is json file
> for large data is not computationally expensive? I am not using textfile
> for the same reason of being computationally expensive.
>
> Thanks,
> Venkatachalam Srinivasan
> --
> https://mail.python.org/mailman/listinfo/python-list
>

It could be expensive to create a dictionary from the json file depending
on the amount of data.

Alternatively, you could use a Unix socket to transmit the data between
processes
if you're on a linux or OSx machine. This is probably the best option as
you can send the dictionary
object itself. This would eliminate the need for the bash script entirely.
The first script builds the
dictionary object and sends it to the socket. The second script is
listening on the socket and receives
the dictionary object. Python's standard library has built in support for
unix sockets. This means you
can actually run two parallel Python instances and communicate between
them. Assuming that
the first script can build the dictionaries before the second script is
done processing them, you will
probably need some kind of task queue. Celery: http://www.celeryproject.org/
tends to be a good solution
for this problem. In fact, Celery is probably the simplest option now that
I think about it.

Another alternative is using a SQLite database which Python has built in
support for. Should be
a bit faster and less memory-intensive.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Data exchange between python script and bash script

2017-04-04 Thread justin walters
On Tue, Apr 4, 2017 at 8:01 AM,  wrote:

> Hello All,
>
> I am writing a python code for processing a data obtained from a sensor.
> The data from sensor is obtained by executing a python script. The data
> obtained should be further given to another python module where the
> received data is used for adjusting the location of an object.
>
> For achieving this, there is a central bash script, which runs both the
> python modules parallel. Something like:
>
> python a.py &
> python b.py &
>
> I am trying to return the sensor data to the bash .sh file, therefore it
> can be provided to the other script. This, based on the online tutorials
> looks like:
>
> sensor_data=$(python execute_sensor_process.py) &
>
> and the sensor_data is assigned by printing the required data in the
> corresponding python script. For example, the data is printed in
> execute_sensor_process.py as follows:
>
> print >>sys.stderr,sens_data
>
> By printing the data onto sys.stderr and assigning a return variable in
> the bash, I am expecting the data to be assigned.
>
> But this is not happening. The sensor data is a dictionary and I like to
> have this data for further analysis. I am not getting the data returned
> from the python script on to the bash variable.
>
> Can someone help me to understand why the code is not working? I tried
> other approaches of function call such as
>
>
> sensor_data=$`python execute_sensor_process.py` &
>
>
> python execute_sensor_process.py tempfile.txt &
> kinexon_data=`cat tempfile.txt` &
>
> But none of the approaches are working.
>
> Thank you,
> Venkatachalam Srinivasan
> --
> https://mail.python.org/mailman/listinfo/python-list
>

I'm not sure why you need the data in a bash script. What can you do with a
bash script that you
can't do with Python?

That said, it seems to me that you need a data persistence layer, i.e. a
way to store the dictionary
after it is created. My best advice would be to use the json module to
write out to json files. I
believe this is the best approach because json has a near 1-to-1 mapping
with Python
dictionaries.

Json is also a good choice because almost every language has a json parser
as part of it's standard
library, making you data extremely portable.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.

2017-01-02 Thread justin walters
On Mon, Jan 2, 2017 at 3:38 AM, Antonio Caminero Garcia <
tonycam...@gmail.com> wrote:

> Hello, I am having a hard time deciding what IDE or IDE-like code editor
> should I use. This can be overwhelming.
>
> So far, I have used Vim, Sublime, Atom, Eclipse with PyDev, Pycharm,
> IntelliJ with Python plugin.
>
> The thing with the from-the-scratch full featured IDEs (Eclipse, IntelliJ,
> Pycharm) is that they look like a space craft dashboard and that
> unwarranted resources consumption and the unnecessary icons. I want my IDE
> to be minimalistic but powerful. My screen should be mostly “made of code”
> as usually happens in Vim, Sublime or Atom. However, Pycharm is really cool
> and python oriented.
>
> The problem with Vim is the learning curve, so I know the very basic
> stuff, but obviously not enough for coding and I do not have time to learn
> it, it is a pity because there are awesome plugins that turns Vim into a
> lightweight powerful IDE-like. So now it is not an option but I will
> reconsider it in the future, learning little by little. Also, I am not very
> fan GUI guy if the task can be accomplished through the terminal. However,
> I don’t understand why people underrate GUIs, that said I normally use
> shortcuts for the most frequent tasks and when I have to do something that
> is not that frequent then I do it with the mouse, for the latter case in
> vim you would need to look for that specific command every time.
>
> Sublime is my current and preferred code editor. I installed Anaconda, Git
> integration and a couple of additional plugins that make sublime very
> powerful. Also, what I like about sublime compared to the full featured
> IDEs, besides the minimalism, is how you can perform code navigation back
> and forth so fast, I mean this is something that you can also do with the
> others but for some subjective reason I specifically love how sublime does
> it. The code completion in sublime I do not find it very intelligence, the
> SublimeCodeIntel is better than the one that Anaconda uses but the
> completions are not as verbose as in the IDEs.
>
> Now, I am thinking about giving a try to Visual Studio Code Edition (take
> a look, it sounds good https://marketplace.visualstudio.com/items?
> itemName=donjayamanne.python). I need an editor for professional software
> development. What would you recommend to me?
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Have yo tried emacs? It's similar to Vim in that it relies very heavily on
keyboard shortcuts and such.
However, you may like the shortcuts a bit more or find them easier to learn.

I side with Marc Brooks in that I believe you should definitely be willing
to put in the time to learn
an editor of your choice. Becoming an expert at using an editor will make
you a lot more productive.

Personally, I use Pycharm for most of my projects as I deal with large
amounts of different files that can be
thousands of lines long. All of the code completion and structure indexing
really helps when you need to
remember the structure of large applications. Pycharm's debugger
integration is also totally awesome. I usually
use the debugger to run my tests to get more informative tracebacks or to
add breakpoints to failing tests. The git
integration is very useful as well because I personally hate Git's CLI.

For some small projects I'll use Atom as it gives me a sublime-esque
interface without forcing me to use proprietary
software.

Otherwise I'll use nano for small, single file projects.

Have you looked into ipython notebook? It's not exactly an IDE, but it does
have built in code completion and makes'
it really simple to document your code.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Django broken pipe error

2017-01-02 Thread justin walters
On Mon, Jan 2, 2017 at 6:14 AM,  wrote:

>
> Thanks a lot Justin,
>
> The problem was solved when I employed standard Framework methods for
> creation of new database object:
>
> in JS:
> var trendModel = new App.TrendModel();
> trendModel.set("phrase", search_phrase);
> trendModel.set("from_time", time_from);
> trendModel.set(...
> trendModel.save(...
>
> in PY:
> def create(self, request):
> ...
>
> I've also created extra template and additional View. PageView for some
> unclear reason didn't support creation of new object - this event just
> disappeared.
>
> Regards,
>
> Roman
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Glad to hear that you solved the problem!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Django broken pipe error

2016-12-12 Thread justin walters
On Mon, Dec 12, 2016 at 7:27 AM, roma  wrote:

> Thanks Justin,
>
> I believe, the whole database story has no influence on the broken pipe
> error. I've commented out the whole block and leave only return line:
> return HttpResponse(res, content_type="text/plain; charset=utf-8")
> The error is still present. And I have no influence on that.
>
> I call python from js client:
>
> var newTrendReport = new App.TrendReport();
> newTrendReport.set('search_phrase', search_phrase);
> newTrendReport.set('time_from', time_from);
> newTrendReport.set('time_to', time_to);
> newTrendReport.set('time_scale', time_scale);
> newTrendReport.set('category', category);
> newTrendReport.startExport(
>
> function(response){
> console.log("Successfully calculated trend report.");
> App.trendPage = new App.TrendPageView();
> App.trendPage.render(response);
> },
> );
>
> go throw:
>
> App.TrendReport = Backbone.Model.extend({
> urlRoot: "/api/trend_reports/",
> defaults: {
> search_phrase: "",
> time_from: "",
> time_to: "",
> time_scale: "",
> category: ""
> },
>
> startExportSuffix: "/export_report/",
>
> startExport: function( successCallback, errorCallback ) {
> console.log("start trend calculation");
> var that = this;
> var ajaxUrl = this.startExportSuffix;
> var options = {
> method: "POST",
> data: this.attributes,
> contentType: "application/json;charset=UTF-8",
> dataType: "json",
>
> error: errorCallback,
> success: successCallback
> };
> console.log("start trend export sync");
> App.ajax(ajaxUrl, options);
> }
>
> });
>
> and come in export_report method.
>
> My urls.py:
>
> url(r'^export_report', ensure_csrf_cookie(views.export_report),
> name="export_report"),
> --
> https://mail.python.org/mailman/listinfo/python-list
>

I'm not super familiar with the way backbone does http requests, but
something seems off about the startExport function.
It seems to me that you are sending a post request to "/export_report/"
which is an endpoint that I'm guessing is nested
in an include from "/api/trend_reports/". However, it looks like the error
you're getting above says you aren't sending
the request to "https://root.com/api/trend_reports/export_report/;.
Instead, you are sending the request to "https://root.com/export_report/; .
Though, I'm also not sure that's the case because that would normally throw
a 404.

I also noticed that you set content type to 'application/json' in your js,
but the view function returns a 'text/plain' content type. Is
There a reason for this?

The data key in your js http function is set to the attributes variable
which, as far as I can tell, does not exist.

There's a lot going on here, but I think you can probably narrow it down to
something in your backbone code or the way
backbone handles http requests as the error you are getting is caused by
the client prematurely closing the socket.
It's possible backbone will stop reading the response since it isn't the
same content-type as the request.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "Best" websocket implementation for Python 2.x?

2016-12-07 Thread justin walters
On Wed, Dec 7, 2016 at 8:50 AM, Skip Montanaro 
wrote:

> PyPI came back. A bit more sleuthing suggests that the
> websocket-client package on PyPI is Ohtani's package, and is more
> up-to-date than the copyright notices would suggest. The package was
> updated a few days ago on GitHub.
>
> Taking the path of least resistance (no changes necessary to the
> code), I suspect I will just stick with that unless there are
> overriding inputs from the community suggesting something else is way
> better...
>
> S
> --
> https://mail.python.org/mailman/listinfo/python-list
>

I can't vouch for it being better, but if you're using asgi, you may want
to take a look at Daphne: https://github.com/django/daphne.

I believe it uses autobahn to power the websocket side of things. Daphne
was developed for the django-channels project. I have
used channels before and I can say that it works pretty well.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Django broken pipe error

2016-12-07 Thread justin walters
On Wed, Dec 7, 2016 at 1:08 AM,  wrote:

> Thank you Justin,
>
> I'm on the dev server and should present results in this way.
>
> Yes, I use manage.py runserver --insecure to start the server (from
> PyCharm).
>
> My views.py call:
>
> @detail_route(methods=['post'], permission_classes=[permissions.AllowAny])
> def export_report(request):
> body_unicode = request.body.decode('utf-8')
> body_str = body_unicode.encode('ascii','ignore')
> attr_list = body_str.split('&')
> attr_dict = {}
> if (len(attr_list) > 0):
> for attr in attr_list:
>...
>key = key_value_pair[0]
>attr_dict[key] = key_value_pair[1]
> trend = trends.calculate_trend(
> attr_dict['search_phrase']
> , attr_dict['time_from']
> , attr_dict['time_to']
> , attr_dict['time_scale']
> )
> attr_dict['trend'] = trend
> res = str(json.dumps(attr_dict))
> return HttpResponse(res, content_type="text/plain; charset=utf-8")
>
> and trend calculation in trends.py with database calls:
>
> def calculate_trend(query_phrase, time_from, time_to, time_scale):
> # check in database if trend already exists
> try:
> db_trend = Trend.objects.get(pk=query_phrase)
> if db_trend.from_time.strftime("%Y-%m-%d") == time_from \
> and db_trend.to_time.strftime("%Y-%m-%d") == time_to \
> and db_trend.granularity == time_scale:
> logger.info("trend already exists.")
> existing_trend_dict = ast.literal_eval(db_trend.content)
> return existing_trend_dict
> except Trend.DoesNotExist:
> logger.info("It is a new trend search.")
> trend_dict = {}
> start_time = pd.Timestamp(value[0])
> end_time = pd.Timestamp(value[-1])
> freq = ... get frequency using pandas lib
> trend_dict[key] = freq
> json_trend_content = trend_dict_to_sorted_json_str(trend_dict)
> trend = Trend(
> phrase=query_phrase,
> content=json_trend_content,
> from_time=time_from,
> to_time=time_to,
> granularity=time_scale,
> )
> if trend is not None:
> try:
> db_trend = Trend.objects.get(pk=query_phrase)
> db_trend.delete()
> logger.info("delete old trend: %s. " % trend)
> except Trend.DoesNotExist:
> logger.info("create trend: %s. " % trend)
> trend.save()
> return trend_dict
>
> Thank you in advance!
>
> Roman
> --
> https://mail.python.org/mailman/listinfo/python-list
>


It looks like you can probably get rid of the try/except block at the end
of the calculate_trend
method as any existing Trend object will have already been caught in the
first try/except block.

>From what I'm reading here:
http://stackoverflow.com/questions/11866792/how-to-prevent-errno-32-broken-pipe
,
this issue can be caused by the client closing the connection before
sendall() finishes writing. Can you estimate
how long it takes for a request to this endpoint takes to resolve? If it's
a long time(maybe due to the pandas call?),
your browser/client may be timing out. It could be because it takes a while
for the Db to find an existing Trend object
as well.

I can't give you any advice on how to fix it exactly, but I can tell you
what the problem is: The client is closing the
connection before socket.sendall() has finished writing to the socket. My
guess is that the calculate_trend() method
takes a long time to complete and the client is timing out.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Django broken pipe error

2016-12-06 Thread justin walters
On Tue, Dec 6, 2016 at 6:21 AM,  wrote:

> Hi,
>
> I'm facing strange Django broken pipe error (Python 2.7 on Ubuntu) that
> apparently is a not fixed Django bug. Does anybody now how to fix it? I've
> been searching a lot and didn't find any solution.
>
> This error happens very irregularly by Post request in Django. Sometimes
> it works sometimes not:
>
> [06/Dec/2016 13:33:57] "POST /export_report/ HTTP/1.1" 500 59
> Traceback (most recent call last):
>   File "/usr/lib/python2.7/SocketServer.py", line 593, in
> process_request_thread
> self.finish_request(request, client_address)
>   File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
> self.RequestHandlerClass(request, client_address, self)
>   File "/home/ait/.virtualenvs/env1/local/lib/python2.7/site-
> packages/django/core/servers/basehttp.py", line 129, in __init__
> super(WSGIRequestHandler, self).__init__(*args, **kwargs)
>   File "/usr/lib/python2.7/SocketServer.py", line 651, in __init__
> self.finish()
>   File "/usr/lib/python2.7/SocketServer.py", line 710, in finish
> self.wfile.close()
>   File "/usr/lib/python2.7/socket.py", line 279, in close
> self.flush()
>   File "/usr/lib/python2.7/socket.py", line 303, in flush
> self._sock.sendall(view[write_offset:write_offset+buffer_size])
> error: [Errno 32] Broken pipe
> 
> Exception happened during processing of request from ('127.0.0.1', 38224)
>
> It is also described in: https://www.reddit.com/r/
> joinmarket/comments/4atqrm/is_this_exception_normal_exception_happened/
>
> On https://bugs.python.org/issue14574 is stated that this error should
> already be fixed but apparently not.
>
> Best regards,
>
> Roman


Hi Roman,

Is this happening on the dev server or a production server? Did you use the
command ./manage.py runserver to start the server?

Can you please provide the code for the view class/function that is
throwing the error? I believe that this issue
may be caused by a call to the database not being structured correctly.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: When will they fix Python _dbm?

2016-12-06 Thread justin walters
On Mon, Dec 5, 2016 at 5:06 PM, clvanwall  wrote:

> will thid do?  John
>

Looks like you need to use dbm.ndbm.open() instead of just dbm.open().

See the docs here for more info:
https://docs.python.org/3/library/dbm.html#module-dbm.ndbm
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: When will they fix Python _dbm?

2016-12-05 Thread justin walters
On Mon, Dec 5, 2016 at 6:45 AM, clvanwall  wrote:

> I have been a Perl programmer for 15+ years and decided to give Python a
> try.  My platform is windows and I installed the latest 3.5.2. Next I
> decided to convert a perl program that uses a ndbm database since according
> to the doc on python, it should be able to work with it.  Needless to say,
> I get: dbm.error: db type is dbm.ndbm, but the module is not available
> Searching on Python Bug Tracker shows _dbm missing back in 03-03-2012!
> That's a long time for a bug to be left open.
> John Van Walleghen
>
>
> Sent from my Galaxy Tab® A
> --
> https://mail.python.org/mailman/listinfo/python-list
>


Hi there,

Could you please post code that is giving you an error?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Quick help for a python newby, please

2016-11-23 Thread justin walters
On Wed, Nov 23, 2016 at 7:13 AM, Dayton Jones 
wrote:

> ah...yes, but then how could I strip the rest (h:m:s) from it?
>
> Enter the numerical month you were born: 3
> Enter the numerical day of the month you were born: 30
> Enter the year you were born: 1989
> 10100 days, 0:00:00
> --
> https://mail.python.org/mailman/listinfo/python-list
>


You'll probably want to use `timedelta`:
https://docs.python.org/3.4/library/datetime.html#timedelta-objects
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: key and ..

2016-11-17 Thread justin walters
On Thu, Nov 17, 2016 at 7:05 PM, Val Krem via Python-list <
python-list@python.org> wrote:

>
>
> Hi all,
> Sorry for asking such a basic question butI am trying  to merge two
> files(file1 and file2) and do some stuff. Merge the two files by the first
> column(key). Here is the description of files and what I would like to do.
>
>
> file1
>
> key c1   c2
> 1  759   939
> 2 345 154571
> 3  251 350711
> 4 3749  22159
> 5  676  76953
> 6   46756
>
>
> file2
> key  p1p2
> 1   759939
> 2   345 154571
> 3   251 350711
> 4  3915  23254
> 5  7676  77953
> 7   256   4562
>
> create file3
> a) merge the two files by (key) that exit in  file1 and file2
> b) create two variables dcp1 = c1- p1 and dcp2= c2-p2
> c) sort file3 by dcp2(descending) and output
>
> create file4:-  which exist in file1 but not in file2
> create file5:-  that exist in file2 but not in file1;
>
>
> Desired output files
>
> file3
> key   c1c2 p1  p2 dcp1   dcp2
> 4   3749  22159  3915  23254  -166  -1095
> 5676  76953  7676  77953 -7000  -1000
> 1759939   759939 0  0
> 2345 154571   345 154571 0  0
> 3251 350711   251 350711 0  0
>
> file4
> key c1   p1
> 6   46   756
>
> file5
> key p1   p2
> 7  256  4562
>
>
>
> Thank you in advance
> --
> https://mail.python.org/mailman/listinfo/python-list
>

1. Take each file and read it using file.open() declaring a variable to
store the string.
2. Use list.split('\n') to split the file into an array of lines.
3. Build a list of dictionaries by splitting each line at whitespace and
calling int() on the values
of each column for each file.
4. Do what you have to do math wise between each dict storing the values in
a new dict. You can
write this out directly to the file or append it to a new list.
5. Use file.open() to write the resulting lines to a new file.
6. transform one of the lists into a set and use set.difference() or
set.intersection() to create
a new list. This list will be unordered by default, so you may want to
run it through
sorted(set, key=lambda row: row['key']).
7. repeat step 5 above to write out to file 4 and 5. no need to transform
the list into a set again.
Just find the difference/interference again.

This isn't the fastest or most efficient way of doing it, but it is
probably the most straight forward.
If these files are quite large you may want to take a different approach in
the interest of performance
and memory. If you don't want to use dicts, you should have no problem
substituting tuples or
nested lists.

The whole thing could be made into a generator as well.

Basically, there are a lot of ways to approach this.

Hope that helped at least a little bit.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: advanced SimpleHTTPServer?

2016-11-03 Thread justin walters
On Thu, Nov 3, 2016 at 10:27 PM, Rustom Mody  wrote:

> On Thursday, November 3, 2016 at 1:23:05 AM UTC+5:30, Eric S. Johansson
> wrote:
> > On 11/2/2016 2:40 PM, Chris Warrick wrote:
> > > Because, as the old saying goes, any sufficiently complicated Bottle
> > > or Flask app contains an ad hoc, informally-specified, bug-ridden,
> > > slow implementation of half of Django. (In the form of various plugins
> > > to do databases, accounts, admin panels etc.)
> >
> > That's not a special attribute of bottle, flask or Django. Ad hoc,
> > informally specified, bug ridden slow implementations abound.  We focus
> > too much on scaling up and not enough on scaling down. We (designers)
> > also have not properly addressed configuration complexity issues.
>
> This scaling up vs down idea is an important one.
> Related to Buchberger’s blackbox whitebox principle
>
> >
> > If I'm going do something once, if it cost me more than a couple of
> > hours to figure it out, it's too expensive in general but definitely if
> > I forget what I learned. That's why bottle/flask systems meet and need.
> > They're not too expensive to forget what you learned.
> >
> > Django makes the cost of forgetting extremely expensive. I think of
> > using Django as career  rather than a toolbox.
>
> Thats snide... and probably accurate ;-)
> Among my more unpleasant programming experiences was Ruby-on-Rails
> And my impression is that Ruby is fine; Rails not
> Django I dont know and my impression is its a shade better than Rails
>
> It would be nice to discover the bottle inside the flask inside django
>
> Put differently:
> Frameworks are full-featured and horrible to use
> APIs are elegant but ultimately underpowered
> DSLs (eg requests) are in intermediate sweetspot; we need more DSL-families
> --
> https://mail.python.org/mailman/listinfo/python-list
>

I work with Django every day. Knowing Django is like knowing another
ecosystem. It's totally
worth learning though. The speed of development is absolutely unbeatable. I
can build a fully featured
and good-looking blog in about 10 minutes. It's nuts.

The best part about it though, is that it's really just simple Python under
the hood for the most part. You
can override or modify any part of it to make it work in exactly the way
you want it to. I'm a huge Django fanboy,
so excuse the gushing. The docs are also some of the most comprehensive
I've ever seen.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: need some kind of "coherence index" for a group of strings

2016-11-03 Thread justin walters
On Thu, Nov 3, 2016 at 9:18 AM, Fillmore 
wrote:

>
> Hi there, apologies for the generic question. Here is my problem let's say
> that I have a list of lists of strings.
>
> list1:#strings are sort of similar to one another
>
>   my_nice_string_blabla
>   my_nice_string_blqbli
>   my_nice_string_bl0bla
>   my_nice_string_aru
>
>
> list2:#strings are mostly different from one another
>
>   my_nice_string_blabla
>   some_other_string
>   yet_another_unrelated string
>   wow_totally_different_from_others_too
>
>
> I would like an algorithm that can look at the strings and determine that
> strings in list1 are sort of similar to one another, while the strings in
> list2 are all different.
> Ideally, it would be nice to have some kind of 'coherence index' that I
> can exploit to separate lists given a certain threshold.
>
> I was about to concoct something using levensthein distance, but then I
> figured that it would be expensive to compute and I may be reinventing the
> wheel.
>
> Thanks in advance to python masters that may have suggestions...
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


When you say similar, do you mean similar in the amount of duplicate
words/letters? Or were you more interested
in similar sentence structure?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: advanced SimpleHTTPServer?

2016-11-02 Thread justin walters
On Wed, Nov 2, 2016 at 12:52 PM, Eric S. Johansson  wrote:

> So this brings me back to my question. What is missing in
> SimpleHTTPServer to keep it from being secure enough?
>

There's no way to vet requests. You can't stop a request from accessing
anything
in the directory that SimpleHTTPServer is running in. I'm sure an
enterprising
individual could also probably access the shell session SimpleHTTPServer
is running in as well. I haven't looked into the internals very much, but
it is possible
an attacker could use eval() to run a Python script sent in a request body.
Not
sure about that last one. I'll have to try it myself and report back.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: advanced SimpleHTTPServer?

2016-11-02 Thread justin walters
On Wed, Nov 2, 2016 at 11:40 AM, Chris Warrick  wrote:

> The other frameworks are simple to set up, too. I’ve personally had
> Unicode issues with Bottle, and it doesn’t even do sessions. Unlike
> Flask, or of course Django.
>
> Because, as the old saying goes, any sufficiently complicated Bottle
> or Flask app contains an ad hoc, informally-specified, bug-ridden,
> slow implementation of half of Django.
>
> (In the form of various plugins to do databases, accounts, admin panels
> etc.)
>


I've found this to be the case whenever I see a Flask or Bottle project
that does anything
more than expose a data API. I think Flask is great for building small
applications or
microservices. Any more and you are essentially hacking together a bunch of
packages
that may or may not have been designed to work together.

I find that Django can suit almost any use case perfectly well. You can use
whatever part
of the framework you want and toss out/replace any part you don't want.
Plus, built in sessions
and authentication are fantastic time savers.
-- 
https://mail.python.org/mailman/listinfo/python-list


New REST API Library for Django

2016-10-22 Thread justin walters
Hi everyone!

I am working on a new REST API library for Django.

You can see it on:

Github: https://github.com/FFX01/django-restup

PyPI:
https://pypi.python.org/pypi?name=django-restup=0.1.1&:action=display

I know there is already a couple great packages out there for REST API
development with Django. However, I found them to be difficult to use for
very granular data manipulation and permissions for my most recent project.
So, I set out to make that a bit easier for myself. I am not using this
package in production anywhere as I just released this pre-alpha today for
people to mess around with if they want.

I just want to see what you all think. I could use any criticism, feedback,
and  ideas you may have for me. If you want to contribute, that would be
even better!

This is my first time putting something out on PyPI. It's also my first
"serious" open source project.

Let me know what you would like to see from a REST API library and I can
add it to the schedule.

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


Re: Obtain javascript result

2016-10-21 Thread justin walters
On Fri, Oct 21, 2016 at 8:07 AM,  wrote:

> Yes,
>
> the page is http://www.betexplorer.com/next/soccer/
> and You have to open any match You want.
>
> This pop-up new windows with match detail and odds
> (if present).
>
> I try to extract home team, away team, results, and
> bet365's bookmaker odds.
>
> I can't continue in my fun analyses because the odds
> are returned through that javascript code and
> I don't know how manage it in python
> to take that results.
>


The data is being obtained through an ajax call:

jQuery.ajax({
url: '/gres/ajax-matchdetails.php',
type: 'GET',
cache: false,
dataType: 'json',
success: function(data)
{
if (data.user_logged)
{
user.logged = true;
user.oddsformat = data.oddsformat;
}
bookmaker_urls = data.bookmaker_urls;

ajax_to_call--;
if (ajax_to_call == 0)
{
matchdetails_finish();
$('#odds-all-loader').remove();
$('#odds-all').show();
}
}
});

jQuery.ajax({
url: '/gres/ajax-matchodds.php',
type: 'GET',
data: 't=d=' + eventid + '=' + bettype,
success: function(data)
{
$('#odds-all').html(data);

ajax_to_call--;
if (ajax_to_call == 0)
{
matchdetails_finish();
$('#odds-all-loader').remove();
$('#odds-all').show();
}
}

You can see this by opening up your developer tools (chrome or Firefox) and
navigating to the debugger/scripts tab where you will find the
"matchdetails_init" function.

However, I tried fetching the "ajax-matchdetails.php" endpoint via httpie,
and I received a 404 page. Investigating the request via the developer
console led to some strange results as well. There was a small piece of
json data returned containing the keys "user_logged" and "bookmaker_urls".
There was no data about the match at all.

There are several other ajax calls in the script, so you may want to check
those out.

However, it seems like the match data itself is actually populated with
data server-side via a PHP script.

You should be able to get the link for a match, point beautiful soup at it,
parse it, and get the data.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to python

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

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


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


Re: Linear Time Tree Traversal Generator

2016-09-20 Thread justin walters
On Tue, Sep 20, 2016 at 9:46 AM, ROGER GRAYDON CHRISTMAN 
wrote:

> I am trying to find a better (i.e. more efficient) way to implement a
> generator
> that traverses a tree.
>
> The current model of the code (which is also used by a textbook I am
> teaching
> from does this)
>
>def __iter__(node):
>  for x in iter(node._left):
>   yield x
>  yield node._value
>  for x in iter(node._right)
>   yield x
>
> This is nice, simple, and straightforward, but has an O(n log n) running
> time,
> since
> values from the leaves of the tree have to be yielded multiple times to
> the top
> of the tree.
>


Are the left and right attributes collections of more nodes or are they
simply references to the node's position in the tree?

>From the code provided it seems like the former is true and a node's left
attribute is a reference to another node?

I don't know how flexible you are with the structure of your tree, but you
could try taking the modified pre-order tree traversal approach.

This article explains it in the context of a database, but the idea is the
same: https://www.sitepoint.com/hierarchical-data-database-2/

Each node would then have a parent attribute as well as left and right
attributes. The parent would be a reference to a parent node, and the left
and right would be integers that position the element in the tree.

The upside to this is that traversal and lookup is much faster since you do
not need to have an iterator nested in an iterator. This is because the top
level node will always have the lowest integer as it's left attribute and
the highest integer as it's right attribute. That means that you can
instead have a single iterator that iterates through a range of integers to
yield the node with the specified left and right values.

The downside is that inserting a new node can take a long time because,
depending on the insertion point, the left and right values for each node
in the tree may have to be recalculated.

Now, I may have completely missed the mark here. I am completely self
taught and have only been programming for about 3 years. I hope that you
gleaned some value from my response either way.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: learning python. learning defining functions . need help

2016-07-22 Thread justin walters
On Fri, Jul 22, 2016 at 6:24 AM, Chris Angelico  wrote:

> On Fri, Jul 22, 2016 at 11:13 PM, Dennis Lee Bieber
>  wrote:
> > Now... Going much beyond the assignment (if you were having
> trouble
> > with the assignment, this will seem like magic) [Python 2.7]:
>
> I'm not sure, but I think your code would become Py3 compatible if you
> just change your prints. Which I'd recommend - it's not difficult to
> just always print a single string, and most example code is ASCII-only
> and has no difficulty with the bytes/unicode distinction. But, point
> of curiosity...
>
> > class Refrigerator(object):
> > def __init__(self, stock=None):
> > if stock is None or type(stock) != type(dict()):
> > self._stock = dict()
> > else:
> > self._stock = stock
>
> ... why do you call up "type(dict())"? Why not either just "dict" or
> "type({})"?
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Hi Chris,

Try opening the interactive terminal on your command line and type the
following:

type({}) == dict()

That should illustrate why. This is because simply typing '{}' could be
interpreted as
either a dict or a set. My interpreter defaults 'type({})' to 'dict', but
it's best to not
take the risk.

You could also replace that line with:

if stock is None or type(stock) != dict:
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Just starting to learn Python, and encounter a problem

2016-07-22 Thread justin walters
:
On Jul 22, 2016 7:46 AM, "Gordon Levi"  wrote:
>
> Zagyen Leo  wrote:
>
> >yeah, it may be quite simple to you experts, but hard to me.
> >
> >In one of exercises from the Tutorial it said: "Write a program that
asks the user their name, if they enter your name say "That is a nice
name", if they enter "John Cleese" or "Michael Palin", tell them how you
feel about them ;), otherwise tell them "You have a nice name."
> >
> >And i write so:
> >
> >name = input("Enter your name here: ")
> >if name == "John Cleese" or "Michael Palin":
> >print("Sounds like a gentleman.")
> >else:
> >print("You have a nice name.")
> >
> >But strangely whatever I type in (e.g. Santa Claus), it always say
"Sounds like a gentleman.", not the result I want.
>
> The second line should be
> if name == "John Cleese" or name == "Michael Palin":
>
> As discussed in recent lengthy thread in this group the following
> line, and hence your statement, is always true -
>
> If "Michael Palin":
> --
> https://mail.python.org/mailman/listinfo/python-list

The easiest way to right this would be to use a tuple like so:

if name in ('John Cleese', 'Michael Palin'):
print ('They sound like a gentleman')
-- 
https://mail.python.org/mailman/listinfo/python-list


Django Tastypie Vs. Djaogn Rest Framework

2016-07-13 Thread justin walters
Hi guys and gals.

I've been building a new web application with my business partner. We're
using Django and postreSQL. We needed a restful API as we wanted the back
end to be completely decoupled from the front end. We ended up going with
Tastypie over DRF due to the former being seemingly less complex and easier
to get rolling. I've used DRF in the past and found it to have somewhat of
a steeper learning curve compared to Tastypie. The way tastypie has you
define resources seems a lot more intuitive to me than the way DRF does so.

Despite my experience, it seems like DRF is by far the more popular choice
for new applications. I was wondering if anyone could offer some insights
into why this is the case. Does DRF offer more highly optimized queries?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tie dictionary to database table?

2016-06-09 Thread justin walters
It looks like you might be looking for an ORM. Have you checked out
sqlalchemy?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: html & python connection problem with hyperlinks

2016-05-25 Thread justin walters
On Wed, May 25, 2016 at 3:24 AM,  wrote:

> Why not created the field title, that located on the template
> BusinessList.html as a link to go to Business_Detail.html..? please check
>
> Code:
>
> models. py:
>
> from django.db import models
>
>
> REGIONS = (
> ('ΘΕΣ', 'ΘΕΣΣΑΛΟΝΙΚΗ'),
> ('ΣΕΡ', 'ΣΕΡΡΕΣ'),
> ( 'ΑΘΗ', 'ΑΘΗΝΑ'),
>
>
>
> TYPEOFBUSINESS = (
> ('ΕΣΤ', 'ΕΣΤΙΑΤΟΡΙΑ'),
> ('ΦΑΡ', 'ΦΑΡΜΑΚΕΙΑ'),
> ('ΒΙΒ', 'ΒΙΒΛΙΟΠΩΛΕΙΑ'),
> ( 'ΚΟΜ', 'ΚΟΜΜΩΤΗΡΙΑ'),
> ('ΣΙΝ', 'ΣΙΝΕΜΑ')
>
> )
>
> class Business(models.Model):
> created_Date = models.DateTimeField(auto_now_add=True)
> owner = models.ForeignKey('auth.User', related_name='snippets', null=True)
> title = models.CharField(max_length=100, blank=True, default='')
> Type_of_Business = models.CharField(max_length=3, choices=TYPEOFBUSINESS)
> region = models.CharField(max_length=3, choices=REGIONS)
> address = models.CharField(max_length=100, blank=True, default='')
> phone = models.CharField(max_length=15, blank=True, default='')
> image = models.ImageField(null=True)
>
>
> def __str__(self):
> return str(self.title)
>
> views.py
>
> from django.contrib.auth.models import User
> from django.http import HttpResponse
> from django.shortcuts import render, get_object_or_404
> from rest_framework import filters
> from rest_framework import generics
> from rest_framework import permissions
> from snippets.permissions import IsOwnerOrReadOnly
> from snippets.serializers import SnippetSerializer
> from snippets.serializers import UserSerializer
> from .models import Business
>
>
>
> class UserList(generics.ListAPIView):
> queryset = User.objects.all()
> serializer_class = UserSerializer
>
>
> class UserDetail(generics.RetrieveAPIView):
> queryset = User.objects.all()
> serializer_class = UserSerializer
>
> class BusinessList(generics.ListCreateAPIView):
>
> permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
> queryset = Business.objects.all()
> serializer_class = SnippetSerializer
> filter_backends = (filters.DjangoFilterBackend,filters.SearchFilter,
> filters.OrderingFilter,)
> filter_fields = ('Type_of_Business', 'region')
> search_fields = ('Type_of_Business', 'region')
> ordering_fields = ('Type_of_Business','title', 'region')
>
>
> def BusinessList(request):
> business = Business.objects.all();
> return render(request, 'snippets/BusinessList.html' {'business':business})
>
> def perform_create(self, serializer):
> serializer.save(owner=self.request.user)
>
>
>
> class Business_Detail(generics.RetrieveUpdateDestroyAPIView):
> permission_classes = (permissions.IsAuthenticatedOrReadOnly,
> IsOwnerOrReadOnly,)
> queryset = Business.objects.all()
> serializer_class = SnippetSerializer
>
>
> def Business_Detail(request, pk):
> business = get_object_or_404(Business, pk=pk)
> return render(request, 'snippets/Business_Detail.html', {'business':
> business})
>
> serializers.py
>
> from rest_framework import serializers
> from snippets.models import Business
> from django.contrib.auth.models import User
>
>
> class SnippetSerializer(serializers.HyperlinkedModelSerializer):
> owner = serializers.ReadOnlyField(source='owner.username')
>
> class Meta:
> model = Business
> fields = ('created_Date', 'owner', 'title','Type_of_Business', 'region',
> 'address', 'phone', 'image')
>
>
> class UserSerializer(serializers.ModelSerializer):
> snippets = serializers.PrimaryKeyRelatedField(many=True,
> queryset=Business.objects.all())
>
> class Meta:
> model = User
> fields = ('id', 'username', 'snippets')
>
> BusinessList.html
>
> {% extends 'snippets/base.html' %}
>
> {% block content %}
> {% for business in business%}
> 
> 
> {{ business.created_Date }} #τυπωσε ημερ.δημιουργιας του Business
> 
>  {{
> business.title }}
> {{business.Type_of_Business }}
> {{ business.region }} 
> {{ business.address }} 
> {{ business.phone }} 
> {% if business.image %}
> 
> {% endif %}
> 
> {% endfor %}
> {% endblock %}
>
> Business_Detail.html
>
> {% extends 'snippets/base.html' %}' %}
>
> {% block content %}
> 
> {% if business.created_Date %} # αν υπαρχει ημερομηνια δημιουργίας
> 
> {{ business.created_Date }}
> 
> {% endif %}
> {{ business.title }} 
> {{ business.region }} 
> {{ business.Type_of_Business}} 
> {{ business.phone }} 
> 
> {% if business.image %} # αν υπαρχει εικονα
>  # παρε εικονα απο το αντιστοιχο url
> {% endif %}
> 
> 
> {% endblock %}
>
> tutorial/snippets/urls.py
>
> from django.conf.urls import url, include
> from django.contrib import admin
> from rest_framework.urlpatterns import format_suffix_patterns
> from django.contrib.staticfiles.urls import staticfiles_urlpatterns
> from django.conf.urls import include
>
> from . import views
>
> urlpatterns = [
> url(r'^admin/', include(admin.site.urls)),
> url(r'^$', views.BusinessList.as_view()),
> url(r'^business/(?P[0-9]+)/$', views.Business_Detail.as_view()),
> url(r'^users/$', views.UserList.as_view()),
> url(r'^users/(?P[0-9]+)/$', views.UserDetail.as_view()),
> url(r'^api-auth/', 

Re: python - handling HTTP requests asynchronously

2016-05-06 Thread justin walters
On Thu, May 5, 2016 at 11:56 PM,  wrote:

> Hi everyone,
> I need to generate a PDF report for each entry of a django queryset.
> There'll be between between 30k and 40k entries.
>
> The PDF is generated through an external API. Since currently is generated
> on demand, this is handled synchronously via an HTTP request/response. That
> will be different for this task, since I think I'll use a django management
> command to loop through the queryset and perform the PDF generation.
>
> Which approach should I follow for this task? I thought about 3 possibile
> solutions, although are technologies that I never used:
>
> 1) Celery: assign a task (http request with a different payload) to a
> worker, then retrieve it once it's done.
>
> 2) request-futures: using requests in a non-blocking way.
>
> 3) multiprocessing module, with e.g. 10 as workers limit.
>
>
> the goal is to use the API concurrently (e.g. send 10 or 100 http requests
> simultaneously, depending on how many concurrent requests the API can
> handle).
>
> Anybody here that handled a similar task and can give advices on how to
> proceed on this?
> --
> https://mail.python.org/mailman/listinfo/python-list
>



Have you tried channels: https://github.com/andrewgodwin/channels ? If it's
an asyncronous request/response cycle you're looking for, it should work
well. Essentially, you have worker processes that receive a message over a
websocket connection and then send the new message back to the "group". I
would recommend using the redis in memory transaction layer if you go this
route as it is the fastest and most efficient. The best part about channels
is that you can still run a normal django app alongside it. You can have
only one app use websockets while the rest use standard http..
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Best way to clean up list items?

2016-05-02 Thread justin walters
On May 2, 2016 10:03 AM, "Jussi Piitulainen" 
wrote:
>
> DFS writes:
>
> > Have: list1 = ['\r\n   Item 1  ','  Item 2  ','\r\n  ']
> > Want: list1 = ['Item 1','Item 2']
> >
> >
> > I wrote this, which works fine, but maybe it can be tidier?
> >
> > 1. list2 = [t.replace("\r\n", "") for t in list1]   #remove \r\n
> > 2. list3 = [t.strip(' ') for t in list2]#trim whitespace
> > 3. list1  = filter(None, list3) #remove empty items
> >
> > After each step:
> >
> > 1. list2 = ['   Item 1  ','  Item 2  ','  ']   #remove \r\n
> > 2. list3 = ['Item 1','Item 2','']  #trim whitespace
> > 3. list1 = ['Item 1','Item 2'] #remove empty items

You could also try compiled regex to remove unwanted characters.

Then loop through the list and do a replace for each item.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: online python courses

2016-04-28 Thread justin walters
On Thu, Apr 28, 2016 at 7:57 AM, Joel Goldstick 
wrote:

> On Thu, Apr 28, 2016 at 10:15 AM,   wrote:
> > I am follows on this moment two online pythoncourses from
> code.tutsplus.com
> > But I am interested in following more online pythoncourses.
> > Maby someone have some links to websites for me what handles python
> online courses.
> >
> > thanks
> > --
> > https://mail.python.org/mailman/listinfo/python-list
>
> Try here:
>
> http://lmgtfy.com/?q=python+online+courses#seen
>
>
> --
> Joel Goldstick
> http://joelgoldstick.com/blog
> http://cc-baseballstats.info/stats/birthdays
> --
> https://mail.python.org/mailman/listinfo/python-list
>


SICP in Python: http://composingprograms.com/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to create a dictionary from csv file?

2016-04-26 Thread justin walters
On Tue, Apr 26, 2016 at 7:18 AM, +dime+  wrote:

> I am learning python.
>
> if I have a csv file, like this
> banana,4.0
> apple,3.5
> orange,3.0
>
> Can anyone show me how to read the csv file line by line and then create a
> dictionary to contain these keys and values?
>
>
> Regards,
> +dime+
> --
> https://mail.python.org/mailman/listinfo/python-list
>

It's best if you look up how to do this in the docs yourself. An even
better way would be to think about the steps necessary to do this and then
writing them down in pseudo-code. After that you can look up the
functions/tools that will help you accomplish this task. One of the most
important skills a programmer can have is called 'algorithmic thinking'.
That is, essentially, the ability to break a problem down into smaller
pieces in order to eventually solve it.


So, think about this:

What steps do you need to take to turn this csv file into a Python
dictionary object? Imagine that you were going to do this by hand. How
would you do it?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Writing different sections into a file

2016-04-25 Thread justin walters
On Mon, Apr 25, 2016 at 3:04 AM, Karim  wrote:

>
>
> On 25/04/2016 09:30, Palpandi wrote:
>
>> Hi,
>>
>> I need to write different sections into a file.
>> At any point of time, content can be added to any section.
>>
>> I don't want keep each section into a temporary file.
>> What is the better way to store the contents of each section and write
>> them into a file at the end?
>> What is the better datatype to achieve this?
>>
>>
>> Thanks and Regards,
>> Palpandi
>>
>
> Use Stringio:
> -
>
> from cStringIO import StringIO
>
> content = StringIO()
>
> # Header
> content.write('; Header\n')
> content.write('; Body'\n)
> content.write('; Footer\n')
>
> open('my_file', 'wb').write(content.getvalue())
>
> -
> Karim
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


All of the other answers are great too. I was thinking that you could
format the text file to have dividers for each section. For instance it may
look something like this:

Header
Lorem ipsum
<--->
Body
Lorem ipsum...
<--->
Footer
Lorem ipsum..

Then, you could create a list of sections like so:

file = open('file.txt', 'r').read()

section_list = file.split('<--->')

print(section_list[0])

>>>
Header
Lorem ipsum...

Say you wanted to get really fancy, you could even format the file to have
named sections like so:


Lorem ipsum...


Lorem ipsum...


Lorem ipsum...


Then you can use the xmlparser library to parse the file into an xml object.


Alternatively, you could also use JSON formatting:

{
sections: {
header: {
title: "header",
content: "Lorem ipsum..."
},
body: {
title: "Body",
content: "Lorem ipsum..."
},
footer: {
title: "Footer",
content: "Lorem ipsum..."
}
}
}

I hope this helps.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Error 0*80070570

2016-04-21 Thread justin walters
On Thu, Apr 21, 2016 at 2:06 AM, Allan Leo  wrote:

> When running the  setup for your 3.5.1(32-bit version), the setup
> experiences error 0*80070570 and tells me to check the log file. What could
> be the problem and whats the solution.
> On Apr 21, 2016 7:05 AM, "Allan Leo"  wrote:
>
> > When running the setup for your 3.5.1(32-bit version) the setup
> > experiences  error 0*80070570 and tells me to checkout the log file. What
> > could be the problem and whats the resolution.
> >
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Have you tried checking the log file or googling the error code?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP proposal: sequence expansion support for yield statement: yield *

2016-04-21 Thread justin walters
I agree with the others that the new syntax is not needed.

I would also like to point out that I believe any new added syntax or
functionality should avoid the use of '*' and '**' as both of these
characters are already used for many things such as optional arguments and
mathematical operators. Adding more uses for said characters only decreases
the readability of the code.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Static files load problem Django 1.9

2016-04-15 Thread justin walters
On Fri, Apr 15, 2016 at 5:13 AM, asimkon .  wrote:

> I have got a problem with static files regarding Django 1.9. These files
> are (js,css)  in the standard folder static, inside project folder
> directory. I got an error Http 404 that can not be loaded.
>
> Project folder / static / css / several files *.css
> /static / js / several files   *.js
>  several_apps
>
> i have executed the python manage.py collectstatic
>
> settings.py
>
> STATIC_URL = '/static/'
>
> STATIC_ROOT = os.path.join(BASE_DIR, "static")
>
> STATICFILES_DIRS = (
>
> os.path.join(BASE_DIR, 'static'),
> )
>
> and of course  as INSTALLED_APPS
>
> 'django.contrib.staticfiles',
>
> Sorry for my template (at the beginning of my work):
>
> {% load  staticfiles %}
>
> 
> 
> 
> 
>  type="text/javascript"> 
>  type="text/javascript"> 
>  type="text/javascript"> 
> 
> 
> 
> 
>
> 
> 
>
> 
> 
>
> but i am afraid the problem lies in urls.py (i do not know what to do)
>
> http://127.0.0.1:8000/static/css/file_name  (in the firebug  network) but
> i
> can not open it directly via server.
>
> urls.py
>
> urlpatterns = [
> url(r'^admin/', admin.site.urls),
> url(r'^hello/','category.views.hello'),
> ]
>
>
> Any kind of help would be convenient to me?
>
> Kind Regards
> Kostas Asimakopoulos
> --
> https://mail.python.org/mailman/listinfo/python-list
>


You shouldn't need a special pattern in your urls for static files.

I think your issue lies with your STATIC_ROOT setting. It is the same as
your STATICFILES_DIRS setting.

Try changing the STATIC_ROOT setting to:

STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static')

This will put the static root outside of your project folder. This may
solve your problem, and will make it easier to host static files somewhere
else on your server or in a CDN if need be.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Looking for feedback on weighted voting algorithm

2016-04-14 Thread justin walters
Thanks for the advice and the code Michael.

That's definitely a clever way to do it.

The algorithm is going to be used for a web application, so the inputs
should be sanitized for security reasons. It will be trivial to make sure
the inputs are integers and are in the correct range. I will raise a
DivisionByZero error for clarity.

I plan to have the result stored in the cache and then transferred to the
db after every new vote, so this algorithm could see some heavy use for
short periods of time. Therefore, performance is important for me. I
believe the algorithm that I provided is O(n) or O(n+1), but I never really
studied Compsci, so I'm not sure. Either way, I think it should perform
well enough.

On Thu, Apr 14, 2016 at 1:48 PM, Michael Selik <michael.se...@gmail.com>
wrote:

>
>
> On Thu, Apr 14, 2016, 7:37 PM justin walters <walters.justi...@gmail.com>
> wrote:
>
>> On Apr 14, 2016 9:41 AM, "Martin A. Brown" <mar...@linux-ip.net> wrote:
>> >
>> >
>> > Greetings Justin,
>> >
>> > >score = sum_of_votes/num_of_votes
>> >
>> > >votes = [(72, 4), (96, 3), (48, 2), (53, 1), (26, 4), (31, 3), (68, 2),
>> (91, 1)]
>> >
>> > >Specifically, I'm wondering if this is a good algorithm for
>> > >weighted voting. Essentially a vote is weighted by the number of
>> > >votes it counts as. I realize that this is an extremely simple
>> > >algorithm, but I was wondering if anyone had suggestions on how to
>> > >improve it.
>> >
>> > I snipped most of your code.  I don't see anything wrong with your
>> > overall approach.  I will make one suggestion: watch out for
>> > DivisionByZero.
>> >
>> > try:
>> > score = sum_of_votes / num_of_votes
>> > except ZeroDivisionError:
>> > score = float('nan')
>> >
>> > In your example data, all of the weights were integers, which means
>> > that a simple mean function would work, as well, if you expanded the
>> > votes to an alternate representation:
>> >
>> >   votes = [72, 72, 72, 72, 96, 96, 96, 48, 48, 53, 26, 26, 26, 26,
>> >31, 31, 31, 68, 68, 91]
>> >
>> > But, don't bother!
>> >
>> > Your function can handle votes that have a float weight:
>> >
>> >   >>> weight([(4, 1.3), (1, 1),])
>> >   2.695652173913044
>> >
>> > Have fun!
>> >
>> > -Martin
>> >
>> > --
>> > Martin A. Brown
>> > http://linux-ip.net/
>>
>> Thanks Martin!
>>
>> I'll add the check for division by zero. Didn't think about that. I think
>> I'm going to sanitize input anyways, but always better to be safe than
>> sorry.
>>
>
> I suggest not worrying about sanitizing inputs. If someone provides bad
> data, Python will do the right thing: stop the program and print an
> explanation of what went wrong, often a more helpful message than one you'd
> write. Use error handling mostly for when you want to do something *other*
> than stop the program.
>
> I'm not sure I'd use NaN instead of raise division by zero error. NaNs can
> be troublesome for downstream code that might not notice until it gets
> confusing. A div-by-zero error is clear and easier to track down because of
> the traceback.
>
> What do you think of using list comprehensions?
>
> weighted_sum = sum(rating * weight for rating, weight in votes)
> total_weights = sum(weight for rating, weight in votes)
> score = weighted_sum / total_weights
>
> It's two loops as I wrote it, which is instinctively slower, but it might
> actually execute faster because of the built-in sum vs a regular for loop.
> Not sure.
>
>>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I have been dealing with Python for a few weeks...

2016-04-14 Thread justin walters
On Thu, Apr 14, 2016 at 1:50 PM, Fillmore 
wrote:

>
> ...and I'm loving it.
>
> Sooo much more elegant than Perl...and so much less going back to the
> manual to lookup the syntax of simple data structures and operations...
>
> REPL is so useful
>
> and you guys rock too
>
> cheers
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Good to hear you're enjoying it. Out of curiosity, what were you using Perl
for?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Looking for feedback on weighted voting algorithm

2016-04-14 Thread justin walters
On Apr 14, 2016 9:41 AM, "Martin A. Brown"  wrote:
>
>
> Greetings Justin,
>
> >score = sum_of_votes/num_of_votes
>
> >votes = [(72, 4), (96, 3), (48, 2), (53, 1), (26, 4), (31, 3), (68, 2),
(91, 1)]
>
> >Specifically, I'm wondering if this is a good algorithm for
> >weighted voting. Essentially a vote is weighted by the number of
> >votes it counts as. I realize that this is an extremely simple
> >algorithm, but I was wondering if anyone had suggestions on how to
> >improve it.
>
> I snipped most of your code.  I don't see anything wrong with your
> overall approach.  I will make one suggestion: watch out for
> DivisionByZero.
>
> try:
> score = sum_of_votes / num_of_votes
> except ZeroDivisionError:
> score = float('nan')
>
> In your example data, all of the weights were integers, which means
> that a simple mean function would work, as well, if you expanded the
> votes to an alternate representation:
>
>   votes = [72, 72, 72, 72, 96, 96, 96, 48, 48, 53, 26, 26, 26, 26,
>31, 31, 31, 68, 68, 91]
>
> But, don't bother!
>
> Your function can handle votes that have a float weight:
>
>   >>> weight([(4, 1.3), (1, 1),])
>   2.695652173913044
>
> Have fun!
>
> -Martin
>
> --
> Martin A. Brown
> http://linux-ip.net/

Thanks Martin!

I'll add the check for division by zero. Didn't think about that. I think
I'm going to sanitize input anyways, but always better to be safe than
sorry.
-- 
https://mail.python.org/mailman/listinfo/python-list


Looking for feedback on weighted voting algorithm

2016-04-13 Thread justin walters
Hi all,

I'm looking for feedback on the below vote weighting algorithm which
includes sample input. This is written in Python3.

def weight(votes):
"""
Takes a list of tuples in the form of '(vote %, weight)' where vote %
is the
rating that a user gave and weight is the number of votes it counts as.

Returns the average score based on votes and vote weight.
"""

sum_of_votes = 0

num_of_votes = 0

for vote, weight in votes:

sum_of_votes += vote * weight
num_of_votes += weight

score = sum_of_votes/num_of_votes

return score


if __name__ == '__main__':

votes = [(72, 4), (96, 3), (48, 2), (53, 1), (26, 4), (31, 3), (68, 2),
(91, 1)]

print(weight(votes))


Specifically, I'm wondering if this is a good algorithm for weighted
voting. Essentially a vote is weighted by the number of votes it counts as.
I realize that this is an extremely simple algorithm, but I was wondering
if anyone had suggestions on how to improve it. Thank you for your time.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: mod_wsgi not compatible with Wamp 2.4 and python 3.4.3

2016-04-06 Thread justin walters
On Wed, Apr 6, 2016 at 3:57 AM, asimkon .  wrote:

> I managed to connect Apache 2.2 with django framework successfully using
> Python 2.7 and mod_wsgi.so (Apache module) thanks to the instructions from
> https://pusonchen.wordpress.com/2013/06/03/build-django-website-with-apache-mod_wsgi-on-windows/.
> The problem is that i see the Django project Web page using localhost or
> 127.0.0.1 in my browser.
>  I want to change it to localhost/mysite as i have built other projects in
> php with Apache (WampServer) using Cakephp and other php scripts. Is there
> any way or i will have to sacrifice my entire Apache Web server for just
> only Django project?
> Afterwards i just download
> https://dev.mysql.com/downloads/connector/python/  (MySQL driver) install
> it and play with syncdb to create tables in my MySQL database. I create the
> db using phpmyadmin and import the info in my settings.py django project
> folder.
>
> Regards
> Kostas Asimakopoulos
>

So, you are running this on your local machine then?

I did some quick googling for you because I wasn't sure if Apache could run
mod_php and mod_wsgi together. Apparently it can. See this google search:
https://www.google.com/search?client=ubuntu=fs=can+apache+run+mod_php+and+mod_wsgi+at+the+same+time%3F=utf-8=utf-8

The basic premise is that you set one port to your php application, and
another port to your Python application.

So, if you visit, say 127.0.0.1:80, you will arrive at your php
application. If you instead visit 127.0.0.1:8000, you will arrive at your
Python application.

Unfortunately, I do not believe there is any way to have both applications
listen on the same port. You could, however, create an alias so that when
you visit 'htttp://localhost/mysite' it actually points to 127.0.0.1:8000
which is the port for your Python application.

>Afterwards i just download
https://dev.mysql.com/downloads/connector/python/  (MySQL driver) install
it and play with syncdb to create tables in my MySQL database. I create the
db using phpmyadmin and import the info in my settings.py django project
folder.

Can you explain this further? Are you not using the Django ORM?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: mod_wsgi not compatible with Wamp 2.4 and python 3.4.3

2016-04-05 Thread justin walters
On Apr 5, 2016 12:51 PM, "asimkon ."  wrote:
>
> I am using Apache to develop Python Web applications via Django. As i am
> new to python web development, i am having problem to find the right
> version for mod_wsgi.so (compiled version for Apache 2.4.4 - WampServer
2.4
> - and python 3.4.3 latest version from ActivePython on Windows x86) and i
> get a 500 internal server error "The server encountered an internal error
> or misconfiguration and was unable to complete your request".
>
> when i try to run the following script:
>
> def application(environment, start_response):
> status = '200 OK'
> response_headers = [('Content-type', 'text/html')]
> start_response(status, response_headers)
> page = """
> 
> 
> Hello world!
> This is being served using mod_wsgi
> 
> 
> """
> return page
>
> I just found the following link
>
http://grapevine.dyndns-ip.com/download/folder.asp?eid=33=%2Fdownload%2Fapache%2Fmod_wsgi-windows-4.4.6%2Fmod_wsgi-windows-4.4.6%2Fapache24-win32-vc10%2Fmodules%2F
> but unfortunately i have got incompatibility problems with the compiled
> files mentioned. Any kind of help would be convenient to me.
>
> I am looking for the compiled (.so file) version, as it will save me from
a
> lot of trouble.
>
> Regards
> Kostas  Asimakopoulos
> --
> https://mail.python.org/mailman/listinfo/python-list

Have you tried using apache as a proxy server to forward requests to a
dedicated wsgi server such as gunicorn instead of using mod_wsgi? I find
it's a lot easier to set up.
-- 
https://mail.python.org/mailman/listinfo/python-list


Django Channels examples

2016-04-01 Thread justin walters
To all of my Web developer bros and broettes,

You all should check out this github repo:
https://github.com/andrewgodwin/channels-examples

This is not my repo or my work.

Channels is a package for Django that allows Django to work more easily
with websockets through an asgi interface. The Django devs intend to add
Channels into the core packages with the next major release.

The linked repo contains 2 examples. One is a live blogging application,
and one is a live chat application. I just typed out all of the code to
build the chat application myself and it works well. It was a fun exercise.

If you are interested in websocket applications with Python, I highly
recommend checking it out.

Let me know if this kind of thing does not belong on this list.

I'm just really excited about this.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ANN: Python 201 - Intermediate Python book

2016-03-30 Thread justin walters
On Mar 30, 2016 11:21 AM, "Mike Driscoll"  wrote:
>
> Hi Justin,
>
> > > https://mail.python.org/mailman/listinfo/python-list
> >
> > Can you go over a couple of the topics you are going to cover?
> >
> > Are you going to cover any of the most popular packages such as Django
and
> > scrapy?
>
> Sure! I'm planning on covering several of the more popular
intermediate-level modules from Python's standard library, such as
collections, contextlib, functools and itertools.
>
> I am also going to be covering benchmarking, encryption, connecting to
databases, etc.
>
> There is a section on Web-related chapters. While I don't plan to cover a
web framework, I am going to cover other items related to working with the
internet using Python. I do plan to talk about creating a web crawler /
scraper, but I hadn't decided if I was going to use scrapy for that or not.
I also plan to write about working with web APIs, such as Amazon's or
Google's APIs. There will probably be some kind of chapter about Selenium /
Web Driver too. I have some other ideas too.
>
> I hope that answered your question.
>
> Mike
> --
> https://mail.python.org/mailman/listinfo/python-list

That absolutely answers my questions. I'll keep an eye out for your book
when it is realeased. It seems like it will cover some topics that could be
useful in continuing my learning.

I am especially interested in encryption as that is something I have yet to
dive into.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ANN: Python 201 - Intermediate Python book

2016-03-30 Thread justin walters
On Mar 30, 2016 8:41 AM, "Mike Driscoll"  wrote:
>
> Hi,
>
> I just wanted to let you know that I am hard at work on my second book,
which is entitled Python 201 which will come out this Fall 2016. I
currently have a Kickstarter going where you can pre-order the book:
https://www.kickstarter.com/projects/34257246/python-201-intermediate-python
>
> I actually posted to this list last year about what you would consider to
be intermediate topics in Python. From that discussion and from some ideas
I had already been working, this book was born. The book is aimed for
people who already know the basics of Python but would like to learn more.
It is also written with Python 3 in mind.
>
> Let me know if you have any questions.
>
> Thanks,
> Mike Driscoll
>
> --
> https://mail.python.org/mailman/listinfo/python-list

Can you go over a couple of the topics you are going to cover?

Are you going to cover any of the most popular packages such as Django and
scrapy?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Which are best, well-tested ways to create REST services, with Json, in Python?

2016-03-28 Thread justin walters
Hi David, once again, please reply all on this list.

I sent you a couple of step by step guides. Pleas look at the links that I
sent.

On Mon, Mar 28, 2016 at 9:12 PM, David Shi <davidg...@yahoo.co.uk> wrote:

> Hello, Justin,
>
> Is there any official step by step guide.
>
> Send me the download link and link to Official tutorial.
>
> Regards.
>
> David
>
>
> On Tuesday, 29 March 2016, 2:35, justin walters <
> walters.justi...@gmail.com> wrote:
>
>
>
>
> On Mon, Mar 28, 2016 at 5:17 PM, David Shi <davidg...@yahoo.co.uk> wrote:
>
> Hello, Justin,
>
> I am thinking of a fast, responsive, secure way of doing this.  Python at
> server-side.  It provides REST services.  Data exchange with the
> web--page.  Formatted XML or Json.
>
> Ideally, it uses the least code.
>
> Any excellent literature describes this?  I like articles which give
> insight into the nitty-gritty.
>
> Looking forward to hearing from you.
>
> Regards.
>
> Shao
>
>
>
>
>
> David,
>
> Please reply all on this list.
>
> My preferred method is to use Django with Django Rest Framework. Django is
> a very mature and robust framework with a ton of features. I use it in
> production for several projects and have very few issues. It includes
> middleware authentication and security features as well. You can find the
> Django documentation here: https://docs.djangoproject.com/en/1.9/. If
> you've never used Django before, I recommend going through the official
> tutorial. It is also advised to use Python 3.4+.
>
> Django rest framework is probably one of the best documented packages out
> there. You can find it's documentation here:
> http://www.django-rest-framework.org/. The official tutorial is very
> in-depth. I would recommend working through it as well. DRF includes a lot
> of functionality and multiple authentication and serialization methods.
>
>
> There are other options as well depending on the scale of your project you
> may choose to use something like flask: http://flask.pocoo.org/ with
> flask-restful and sqlalchemy.
>
> Like I said my personal recommendation is Django and DRF as it is easy to
> set up, there isn't much overhead, and it scales very well.
>
> Does that answer your question, or were you looking for more information?
>
>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Which are best, well-tested ways to create REST services, with Json, in Python?

2016-03-28 Thread justin walters
On Mon, Mar 28, 2016 at 5:17 PM, David Shi  wrote:

> Hello, Justin,
>
> I am thinking of a fast, responsive, secure way of doing this.  Python at
> server-side.  It provides REST services.  Data exchange with the
> web--page.  Formatted XML or Json.
>
> Ideally, it uses the least code.
>
> Any excellent literature describes this?  I like articles which give
> insight into the nitty-gritty.
>
> Looking forward to hearing from you.
>
> Regards.
>
> Shao
>
>
>
>

David,

Please reply all on this list.

My preferred method is to use Django with Django Rest Framework. Django is
a very mature and robust framework with a ton of features. I use it in
production for several projects and have very few issues. It includes
middleware authentication and security features as well. You can find the
Django documentation here: https://docs.djangoproject.com/en/1.9/. If
you've never used Django before, I recommend going through the official
tutorial. It is also advised to use Python 3.4+.

Django rest framework is probably one of the best documented packages out
there. You can find it's documentation here:
http://www.django-rest-framework.org/. The official tutorial is very
in-depth. I would recommend working through it as well. DRF includes a lot
of functionality and multiple authentication and serialization methods.


There are other options as well depending on the scale of your project you
may choose to use something like flask: http://flask.pocoo.org/ with
flask-restful and sqlalchemy.

Like I said my personal recommendation is Django and DRF as it is easy to
set up, there isn't much overhead, and it scales very well.

Does that answer your question, or were you looking for more information?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Which are best, well-tested ways to create REST services, with Json, in Python?

2016-03-28 Thread justin walters
On Mon, Mar 28, 2016 at 2:06 PM, David Shi via Python-list <
python-list@python.org> wrote:

> Has anyone done a recent reviews of creating REST services, in Python?
> Regards.
> David
> --
> https://mail.python.org/mailman/listinfo/python-list
>

There are a ton of different ways to do this. Can you provide some details
about the application?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re:

2016-03-14 Thread justin walters
How did you install python?
On Mar 14, 2016 1:30 AM, "Ezra Simms"  wrote:

> I cannot seem to get pymongo to find my python installation – keep getting
> an error saying pythin has not been found in the registry? Why is this.
>
> Sent from Mail for Windows 10
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pythonic love

2016-03-08 Thread justin walters
Sorry about the top posting. I'm new to mailing lists. I should just reply
to the python-list@python.org address then?

Also, thank you for the generator clarification.
On Mar 8, 2016 9:09 AM, "jmp" <jeanmic...@sequans.com> wrote:

> On 03/08/2016 05:49 PM, justin walters wrote:
>
>> Correct me if I'm wrong, but don't python generators usually use the yield
>> statement so they can be used in list comprehensions?
>>
>
> Hello,
>
> Please don't top post.
>
> Generator expressions are different from generator functions. They are
> both generators but use a different syntax.
>
> generator function:
>
> def func(iterable):
>   for i in iterable: yield i
>
>
> the generator expression version would be
>
> (i for i in iterable)
>
>
> Both have their use cases but everytime you can actually use an generator
> expression, it's probably the correct thing to do.
>
> Cheers,
>
> jm
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pythonic love

2016-03-08 Thread justin walters
Correct me if I'm wrong, but don't python generators usually use the yield
statement so they can be used in list comprehensions?
On Mar 8, 2016 5:27 AM, "jmp"  wrote:

> On 03/07/2016 11:51 PM, Fillmore wrote:
>
>>
>> learning Python from Perl here. Want to do things as Pythonicly as
>> possible.
>>
>> I am reading a TSV, but need to skip the first 5 lines. The following
>> works, but wonder if there's a more pythonc way to do things. Thanks
>>
>> ctr = 0
>> with open(prfile,mode="rt",encoding='utf-8') as pfile:
>>  for line in pfile:
>>  ctr += 1
>>
>>  if ctr < 5:
>>  continue
>>
>>  allVals = line.strip().split("\t")
>>  print(allVals)
>>
>
> what about a generator expression ? The (not so)new hype:
>
> with open(prfile,mode="rt",encoding='utf-8') as pfile:
>   for values in (l.strip().split("\t") for (i, l) in enumerate(pfile) if i
> >=5):
> print values
>
> slightly dense, could be better with a lambda function
>
> tovalues = lambda l: l.strip().split("\t")
> with open(prfile,mode="rt",encoding='utf-8') as pfile:
>   for values in (tovalues(l) for (i, l) in enumerate(pfile) if i >=5):
> print values
>
>
> This should even work quite efficiently on big files, because I don't
> thing no more than one line is in memory at a given time.
>
> jm
>
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question

2016-03-08 Thread justin walters
My apologies, but I really don't want to argue with you. You may want to be
a bit more humble when asking for help.
On Mar 8, 2016 2:31 AM, "Jon Ribbens" <jon+use...@unequivocal.co.uk> wrote:

> On 2016-03-08, justin walters <walters.justi...@gmail.com> wrote:
> > Well, from that error message, it seems like you may have a permissions
> > issue.
>
> If that's true then it means the Python 3.5 installer is broken.
> However, I don't think it is true as actually running Python presents
> no problems. There's some bug in virtualenv which is making it return
> a permissions error when there is none.
>
> > Also, the git shell is not the sane as a real shell. There are
> > multiple windows terminal emulators. Why not use one of those?
>
> I am - the git shell.
>
> I wanted to run a Python project that's hosted on github,
> so I downloaded Python and Git for Windows - why would
> anyone do otherwise?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question

2016-03-07 Thread justin walters
Well, from that error message, it seems like you may have a permissions
issue. Also, the git shell is not the sane as a real shell. There are
multiple windows terminal emulators. Why not use one of those?
On Mar 7, 2016 5:46 PM, "Jon Ribbens"  wrote:

> On 2016-03-07, Ian Kelly  wrote:
> > On Mon, Mar 7, 2016 at 11:51 AM, Jon Ribbens
> > wrote:
> >> I must say that Python on Windows was a very poor experience indeed,
> >> "virtualenv" does not work and "venv" refuses to create the 'activate'
> >> shell script so does not work either
> >
> > I've used both of these on Windows (although not recently) and had no
> > trouble with them. I never had a problem with venv not creating the
> > activate.bat file.
>
> It's not activate.bat, it's activate (no file extension) the posix
> shell script. I installed Git for Windows which provides bash (or
> something that looks like it). Python venv doesn't cope with this
> situation at all.
>
> 'virtualenv' works even less well, it just says:
>
> $ virtualenv test
> Using base prefix 'd:\\program files (x86)\\python35-32'
> New python executable in D:\Users\Jon
> Ribbens\Documents\Python\test\Scripts\python.exe
> ERROR: The executable "D:\Users\Jon
> Ribbens\Documents\Python\test\Scripts\python.exe" could not be run:
> [WinError 5] Access is denied
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question

2016-03-07 Thread justin walters
Unfortunately, it's difficult for the core devs to know every hardware and
os combination there is. Maybe you could submit a bug report?
On Mar 7, 2016 10:56 AM, "Jon Ribbens"  wrote:

> On 2016-03-07, mm0fmf  wrote:
> > On 07/03/2016 18:09, Jon Ribbens wrote:
> >> It only appears to have downloads for 32-bit, or 64-bit AMD processors,
> >> not 64-bit Intel processors.
> >
> > You didn't read the bit that says
> >
> > "The binaries for AMD64 will also work on processors that implement the
> > Intel 64 architecture. (Also known as the "x64" architecture, and
> > formerly known as both "EM64T" and "x86-64".) "
>
> You are quite correct that I did not read the whole of the
> ridiculously-long and badly-organised download page.
>
> I would strongly suggest that, at the very least, the 'Description'
> for the x86-64 files should say "for all 64-bit PCs (except Itanium*)"
> with the '*' linking to a footnote that explains how to tell if you
> have one of those.
>
> I must say that Python on Windows was a very poor experience indeed,
> "virtualenv" does not work and "venv" refuses to create the 'activate'
> shell script so does not work either (and pygame doesn't work, but
> that's presumably not Python's fault).
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   >