little help in homework required

2017-06-16 Thread JAIDIP patel
I just wrote the code with Python 3.6.1, I am just a beginner in python. while compiling having below error, can anyone help me in this TypeError: a bytes-like object is required, not 'str' The code I wrote: import socket mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) mysock.connec

Re: little help in homework required

2017-06-16 Thread Lutz Horn
Hi, TypeError: a bytes-like object is required, not 'str' ... mysock.send('GET http://data.pr4e.org/intro-short.txt HTTP/1.0\n\n') Here you must encode the str as bytes: mysock.send('GET http://data.pr4e.org/intro-short.txt HTTP/1.0\n\n'.encode("UTF-8")) The actual encoding does not

Re: little help in homework required

2017-06-16 Thread Chris Angelico
On Fri, Jun 16, 2017 at 7:06 PM, JAIDIP patel wrote: > The code I wrote: > > import socket > > mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > mysock.connect(('data.pr4e.org', 80)) > mysock.send('GET http://data.pr4e.org/intro-short.txt HTTP/1.0\n\n') > while True: > data =x.recv(

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

2017-06-16 Thread alister
On Fri, 16 Jun 2017 00:10:58 +1000, Chris Angelico wrote: > On Fri, Jun 16, 2017 at 12:00 AM, alister > wrote: >> On Thu, 15 Jun 2017 22:27:40 +1000, Chris Angelico wrote: >> >>> On Thu, Jun 15, 2017 at 9:47 PM, Rhodri James >>> wrote: > 1) It is not secure. Check this out: > https://sta

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

2017-06-16 Thread alister
On Thu, 15 Jun 2017 21:17:05 +0100, Erik wrote: > On 15/06/17 15:10, Chris Angelico wrote: >> On Fri, Jun 16, 2017 at 12:00 AM, alister >> wrote: >>> Json is designed to be legal Javascript code & therefore directly >>> executable so no parser is posible. >>> >>> >> "no parser is possible"??? >

Re: Developers Who Use Spaces Make More Money!

2017-06-16 Thread alister
On Thu, 15 Jun 2017 21:11:41 -0600, Ian Kelly wrote: > On Thu, Jun 15, 2017 at 8:51 PM, Larry Martell > wrote: >> On Thu, Jun 15, 2017 at 6:35 PM, Christopher Reimer >> wrote: >>> One commentator on a tech website admonished programmers for wasting >>> time by pressing the space bar four times i

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-16 Thread Andre Müller
Am 15.06.2017 um 07:09 schrieb Jussi Piitulainen: > Andre Müller writes: > >> I'm a fan of infinite sequences. Try out itertools.islice. >> You should not underestimate this very important module. >> >> Please read also the documentation: >> https://docs.python.org/3.6/library/itertools.html >> >>

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-16 Thread Peter Otten
Andre Müller wrote: > # to impress your friends you can do > for chunk in itertools.zip_longest(*[iter(s)]*4): > chunked_str = ''.join(c for c in chunk if c) # generator expression > inside join with condition > print(chunked_str) This can be simplified with a fillvalue >>> s = "abracad

EuroPython 2017: Django Girls Workshop

2017-06-16 Thread M.-A. Lemburg
EuroPython 2017 is happy to host and sponsor a Django Girls free workshop on Sunday 9th, from 9:00 to 18:00 CEST. The non-profit organization FuzzyBrains will lead you through HTML/CSS, Python/Django to the design of a new blog in a single day workshop. No prior programming knowledge is needed to

How to calculate Value in (%) and than create new column with percentage of used time. (Python)

2017-06-16 Thread Alla Perlova
Dear folks, I need some help with: I am working with some Hospital data, and I need to calculate Operating Room Utilization per day df.groupby(by = ['Actual_Surgery_Day','Actual_Surgery_Room']) .agg({'Actual_Surgery_Duratation' : 'sum', 'Procedure_Code' : 'count'})

Re: Customise the virtualenv `activate` script

2017-06-16 Thread Tim Chase
On 2017-06-16 15:53, Ben Finney wrote: > > I must admit my initial preference would be the differently named > > wrapper. Surely users of the codebase will be invoking stuff via > > something opaque which sources the requisite things? > > That “something opaque” is the ‘$VENV/bin/activate’ scrip

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

2017-06-16 Thread Grant Edwards
On 2017-06-16, Ben Finney wrote: > alister writes: > >> Json is designed to be legal Javascript code & therefore directly >> executable so no parser is posible. > > JSON is designed to be *a strictly limited subset* of legal JavaScript > that only defines data structures. The explicit goal is tha

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

2017-06-16 Thread Ben Finney
Grant Edwards writes: > On 2017-06-16, Ben Finney wrote: > > JSON is designed to be *a strictly limited subset* of legal > > JavaScript that only defines data structures. The explicit goal is > > that it is statically parseable as non-executable data. > > That doesn't mean that it's reasonable/a

Re: API Help

2017-06-16 Thread Tobiah
> I still think it _could_ be the output of a Python repr() or similar > (something that is expected to be evaluated as a Python expression). It may be valid fodder for python eval(), but if it came from repr() It would have used single quotes, yes? -- https://mail.python.org/mailman/listinfo/

Instagram: 40% Py3 to 99% Py3 in 10 months

2017-06-16 Thread Terry Reedy
https://thenewstack.io/instagram-makes-smooth-move-python-3/ -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list

Re: Instagram: 40% Py3 to 99% Py3 in 10 months

2017-06-16 Thread Rauklei P . S . Guimarães
Very Nice. Em sex, 16 de jun de 2017 às 13:30, Terry Reedy escreveu: > https://thenewstack.io/instagram-makes-smooth-move-python-3/ > -- > Terry Jan Reedy > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list

Re: Instagram: 40% Py3 to 99% Py3 in 10 months

2017-06-16 Thread Paul Barry
The process they followed is discussed in their recent Keynote at PyCon 2017: https://youtu.be/66XoCk79kjM Well worth the 40 minutes it takes to watch :-) Paul. On 16 June 2017 at 18:43, Rauklei P. S. Guimarães wrote: > Very Nice. > > Em sex, 16 de jun de 2017 às 13:30, Terry Reedy > escreve

Re: sqlite in 2.7 on redhat 6

2017-06-16 Thread Thomas Jollans
On 15/06/17 14:45, Larry Martell wrote: > I am trying to use sqlite > > $ python2.7 > Python 2.7.10 (default, Feb 22 2016, 12:13:36) > [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. import _sqlite3 > Traceback (most r

python and post gis question

2017-06-16 Thread Xristos Xristoou
I have create a python script where use post gis queries to automate some intersection tasks using postgis database. in my database I have polygons,points and lines. here my snippet code of my script : try: if str(geomtype) == 'point': geomtype = 1 elif str(geomtype

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

2017-06-16 Thread Erik
On 16/06/17 12:03, alister wrote: (The non native English speaker excuse is not an option for me) Does that mean it's mandatory for you? I'm confused :D :D E. -- https://mail.python.org/mailman/listinfo/python-list

Re: Customise the virtualenv `activate` script

2017-06-16 Thread Cameron Simpson
On 16Jun2017 06:40, Tim Chase wrote: At least within virtualenvwrapper (I'm not sure whether they come with virtualenv proper), in my $WORKON_HOME and $WORKON_HOME/$VIRTUALENV/bin directories, I have a bunch of pre* and post* templates including preactivate and postactivate hooks in which I can

Re: How to calculate Value in (%) and than create new column with percentage of used time. (Python)

2017-06-16 Thread mcmxl
I assigned the optimal time of 960min to x. >>> x=960.0 Then I assigned the time used 189min to y. >>> y=189.0 Then I divide the time used(y) by the optimal time(x) and multiply the answer by 100 and assign the answer to z. >>> z=(y/x)*100 The answer. >>> z 19.6875 For Python to give you an ac