Re: [Tutor] Merge a dictionary into a string

2019-03-16 Thread Mats Wichmann
On March 16, 2019 5:57:23 PM MDT, Alan Gauld via Tutor wrote: >On 16/03/2019 18:44, Peter Otten wrote: >> >> In Python 3.6 and above you can use f-strings: >> > d = dict(a="hello", b="world") > " ".join(f'{k} "{v}"' for k, v in d.items()) >> 'a "hello" b "world"' > >Cool, I'd missed

Re: [Tutor] Merge a dictionary into a string

2019-03-16 Thread Alan Gauld via Tutor
On 16/03/2019 18:44, Peter Otten wrote: > > In Python 3.6 and above you can use f-strings: > d = dict(a="hello", b="world") " ".join(f'{k} "{v}"' for k, v in d.items()) > 'a "hello" b "world"' Cool, I'd missed f-strings. Time for some reading Thanks Peter, -- Alan G Author of

Re: [Tutor] Merge a dictionary into a string

2019-03-16 Thread Alex Kleider
On 2019-03-16 10:39, Valerio Pachera wrote: Consider this: import collections d = OrderedDict(a='hallo', b='world') I wish to get a single string like this: 'a "hallo" b "world"' Notice I wish the double quote to be part of the string. In other words I want to wrap the value of a and b. I

Re: [Tutor] Merge a dictionary into a string

2019-03-16 Thread Peter Otten
Valerio Pachera wrote: > Consider this: > > import collections > d = OrderedDict(a='hallo', b='world') > > I wish to get a single string like this: > > 'a "hallo" b "world"' > > Notice I wish the double quote to be part of the string. > In other words I want to wrap the value of a and b. > >

Re: [Tutor] Merge a dictionary into a string

2019-03-16 Thread Alan Gauld via Tutor
On 16/03/2019 17:39, Valerio Pachera wrote: > I wish to get a single string like this: > > 'a "hallo" b "world"' > > Notice I wish the double quote to be part of the string. > In other words I want to wrap the value of a and b. When dealing with string layouts I tend to go to string

[Tutor] Merge a dictionary into a string

2019-03-16 Thread Valerio Pachera
Consider this: import collections d = OrderedDict(a='hallo', b='world') I wish to get a single string like this: 'a "hallo" b "world"' Notice I wish the double quote to be part of the string. In other words I want to wrap the value of a and b. I was thinking to use such function I created:

Re: [Tutor] Remove soft line break

2019-03-16 Thread Valerio Pachera
- Messaggio originale - > Da: "Valerio Pachera" > A: "Tutor Python" > Inviato: Giovedì, 28 febbraio 2019 13:05:27 > Oggetto: Re: [Tutor] Remove soft line break > ... > I noticed that the end of file doesn't get preserve if I create a copy of the > file ... I've been told by a

Re: [Tutor] Question for tutoring page

2019-03-16 Thread Albert-Jan Roskam
On 13 Mar 2019 18:14, Alan Gauld via Tutor wrote: On 11/03/2019 16:10, Diana Katz wrote: > What is the best way to ..program using python - that could recognize > a 3D object and then rank drawings of the object as to which are more > accurate. ===>> check this out:

Re: [Tutor] (no subject)

2019-03-16 Thread Peter Otten
Glenn Dickerson wrote: > class Student(): > > def__init__(self, name, major, gpa, is_on_probation): > self.name = name > self.major = major > self.gpa = gpa > self.is_on_probation = is_on_probation > > > import Student > student1 = Student('Jim', 'Business',

Re: [Tutor] (no subject)

2019-03-16 Thread Alan Gauld via Tutor
On 16/03/2019 01:54, Glenn Dickerson wrote: > class Student(): > > def__init__(self, name, major, gpa, is_on_probation): > self.name = name > self.major = major > self.gpa = gpa > self.is_on_probation = is_on_probation > > > import Student > student1 =

Re: [Tutor] (no subject)

2019-03-16 Thread Steven D'Aprano
Hi Glenn, and welcome. On Fri, Mar 15, 2019 at 09:54:41PM -0400, Glenn Dickerson wrote: > class Student(): > def__init__(self, name, major, gpa, is_on_probation): > self.name = name > self.major = major > self.gpa = gpa > self.is_on_probation = is_on_probation

[Tutor] (no subject)

2019-03-16 Thread Glenn Dickerson
class Student(): def__init__(self, name, major, gpa, is_on_probation): self.name = name self.major = major self.gpa = gpa self.is_on_probation = is_on_probation import Student student1 = Student('Jim', 'Business', 3.1, False) student2 = Student('Pam', 'Art',