Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80430 > unrolled thread

Re:dictionary issue for formatted print

Started byDave Angel <davea@davea.name>
First post2014-11-09 08:41 -0500
Last post2014-11-09 08:41 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re:dictionary issue for formatted print Dave Angel <davea@davea.name> - 2014-11-09 08:41 -0500

#80430 — Re:dictionary issue for formatted print

FromDave Angel <davea@davea.name>
Date2014-11-09 08:41 -0500
SubjectRe:dictionary issue for formatted print
Message-ID<mailman.15598.1415540514.18130.python-list@python.org>
Yusuf Can Bayrak <yusufcanbayrak@gmail.com> Wrote in message:
> when dictionary has one value for each key it's okey. I'm just type '% greek_letters' and it's working. 
> 
> But how can i assign dict's values to formatted print, if it has more values than one. # -*- coding: utf-8 -*-greek_letters = {                    'omega': ['ω','Ω'], 'psi': ['ψ', 'Ψ'] , 'kapa': 'κ', 'to': ['τ', 'Τ'], 'lambda': ['λ', 'Λ'],                    'ksi': ['ξ', 'Ξ'], 'delta': ['δ', 'Δ'], 'mu': ['μ'], 'sigma': ['σ', 'Σ'], 'epsilon': ['ε', 'Ε'],                    'gamma': ['γ', 'Γ'], 'phi': ['φ', 'Φ'], 'theta': ['θ', 'Θ']                }print 'x(%(to)s) = A * cos(%(omega)s * %(to)s + %(theta)s)' % greek_letters.values()[1]
> 

How do you intend for the logic to choose? You need to decide the
 logic  (usually by doing it by hand) before you can figure out
 how to code it.

My assumption is that you want the expression to decide  (the
 thing starting "A *"
). So you'll need to have two separate keys,
 like omega and Omega. The dictionary gets a little larger,  and
 it just works.

-- 
DaveA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web