Re: [Tutor] urllib confusion

2014-11-22 Thread Steven D'Aprano
On Fri, Nov 21, 2014 at 01:37:45PM -0800, Clayton Kirkwood wrote:

 Got a general problem with url work. I've struggled through a lot of code
 which uses urllib.[parse,request]* and urllib2. First q: I read someplace in
 urllib documentation which makes it sound like either urllib or urllib2
 modules are being deprecated in 3.5. Don't know if it's only part or whole.

Can you point us to this place? I would be shocked and rather dismayed 
to hear that urllib(2) was being deprecated, but it is possible that one 
small component is being renamed/moved/deprecated.

 I've read through a lot that says that urllib..urlopen needs urlencode,
 and/or encode('utf-8') for byte conversion, but I've seen plenty of examples
 where nothing is being encoded either way. I also have a sneeking suspicious
 that urllib2 code does all of the encoding. I've read that if things aren't
 encoded that I will get TypeError, yet I've seen plenty of examples where
 there is no error and no encoding.

It's hard to comment and things you've read when we don't know what they 
are or precisely what they say. I read that... is the equivalent of a 
man down the pub told me

If the examples are all ASCII, then no charset encoding is 
needed, although urlencode will still perform percent-encoding:

py from urllib.parse import urlencode
py urlencode({key: value})
'key=%3Cvalue%3E'

The characters '' and '' are not legal inside URLs, so they have to be 
encoded as '%3C' and '%3E'. Because all the characters are ASCII, the 
result remains untouched.

Non-ASCII characters, on the other hand, are encoded into UTF-8 by 
default, although you can pick another encoding and/or error handler:

py urlencode({key: © 2014})
'key=%C2%A9+2014'

The copyright symbol © encoded into UTF-8 is the two bytes 
\xC2\xA9 which are then percent encoded into %C2%A9.


 Why do so many examples seem to not encode? And not get TypeError? And yes,
 for those of you who are about to suggest it, I have tried a lot of things
 and read for many hours.

One actual example is worth about a thousand vague descriptions.

But in general, I would expect that the urllib functions default to 
using UTF-8 as the encoding, so you don't have to manually specify an 
encoding, it just works.


-- 
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Enquiry on technology stack to use

2014-11-22 Thread arlus ishmael
Hello,

I'm a student with intermediate python skill. I intend to build a hospital
management system using Python. The intended design is a desktop
application with an embedded server that listens for HTTP requests that
come from a browser or a desktop client. This should be packaged into a
single executable and preferably it should be cross platform. Furthermore,
but not a must, bundling with it a message queue could also be great.

I have tried bundling django + cherrypy in Qt4 application but that proved
difficult to bundle into an executable. I was looking for some suggestions
on what technology stack I could use. Any help will be greatly appreciated.

Regards,
Aurlus I. Wedava
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Enquiry on technology stack to use

2014-11-22 Thread Alan Gauld

On 22/11/14 13:47, arlus ishmael wrote:


I'm a student with intermediate python skill. I intend to build a
hospital management system using Python. The intended design is a
desktop application with an embedded server that listens for HTTP
requests that come from a browser or a desktop client.


That's a very odd architecture for a server component. Why not have
a desktop client that runs on the server and talks to the server
in the same way as the web and remote desktops?


packaged into a single executable


Again a very odd choice that will greatly limit your ability to
scale the application to handle multiple clients. Especially if
you have a mixture of desktop and web clients.

Most server applications use several replicable processes to enable load 
balancing and scalability. Also I assume you will be using a separate 
database which will have its own server processes?



and preferably it should be cross platform.


I assume you know that a single executable will not work cross
platform, although you can build a single executable solution
per platform from a common code base.


Furthermore, but not a must, bundling with it a message queue
could also be great.


Message queues are usually a part of the infrastructure so we'd need to 
know more about the details to say anything about that. Python can 
support a generic message queue but its not generally compatible with 
things like Java or .Net message queues or CORBA. You need more specific 
solutions for that.



I have tried bundling django + cherrypy in Qt4 application but that
proved difficult to bundle into an executable. I was looking for some
suggestions on what technology stack I could use. Any help will be
greatly appreciated.


Frankly, unless this is a very small hospital, I'd forget about trying 
to produce a single executable. And that doubly so if you want to

embed a GUI into it too. It makes life much more complicated and
limits your options for in-flight configuration/scalability.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my phopto-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Enquiry on technology stack to use

2014-11-22 Thread Danny Yoo
I'm not sure if we on tutor are the best folks to provide advice on this
subject.  You may want to ask on a more general forum such as:

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

Good luck!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] yes, I am being lazy...

2014-11-22 Thread Clayton Kirkwood
I have had my first experience in downloading and trying to lay-in several
new modules. I downloaded requests and urllib3, unpacked them (on a windows
system) and extracted them from the zip.  I don't understand how setup.py
and .cfg are supposed to implant them into the python hierarchy. The install
doesn't seem to insert them in the python directory. The build puts them
under the current directory. Seems odd. I've moved the sub-directory into
python/lib by hand. Doesn't seem right. I am tired and frustrated.

 

Not that you care Steven:)))

 

Clayton

 

You can tell the caliber of a man by his gun--c. kirkwood

 

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor