Hi, ALL,
I hope it is OK to ask a question about Python itself.
Here is my problem.
I have following code:
def MyFunc(self, originalData):
data = {}
dateStrs = []
for i in xrange(0, len(originalData)):
dateStr, freq, source = originalData[i]
data[str(dateStr)] = {source: freq}
dateStrs.append(dateStr)
for i in xrange(0, len(dateStrs) - 1):
currDateStr = str(dateStrs[i])
nextDateStrs = str(dateStrs[i + 1])
It seems very strange that I need the dateStrs list just for the
purpose of looping thru the dictionary keys.
Can I get rid of the "dateStrs" variable?
Thank you.
As this is such a basic question I suggest you take it to either the tutorial mailing list or the main one. These are available as gmane.comp.python.tutor or gmane.comp.python.general, but can be accessed via other mechanisms.
···
On 06/12/2013 06:52, Igor Korot wrote:
Hi, ALL,
I hope it is OK to ask a question about Python itself.
Here is my problem.
I have following code:
def MyFunc(self, originalData):
data = {}
dateStrs =
for i in xrange(0, len(originalData)):
dateStr, freq, source = originalData[i]
data[str(dateStr)] = {source: freq}
dateStrs.append(dateStr)
for i in xrange(0, len(dateStrs) - 1):
currDateStr = str(dateStrs[i])
nextDateStrs = str(dateStrs[i + 1])
It seems very strange that I need the dateStrs list just for the
purpose of looping thru the dictionary keys.
Can I get rid of the "dateStrs" variable?
Thank you.
--
My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language.
Mark Lawrence
Thank you for the suggestion.
···
On Fri, Dec 6, 2013 at 1:35 AM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
On 06/12/2013 06:52, Igor Korot wrote:
Hi, ALL,
I hope it is OK to ask a question about Python itself.
Here is my problem.
I have following code:
def MyFunc(self, originalData):
data = {}
dateStrs =
for i in xrange(0, len(originalData)):
dateStr, freq, source = originalData[i]
data[str(dateStr)] = {source: freq}
dateStrs.append(dateStr)
for i in xrange(0, len(dateStrs) - 1):
currDateStr = str(dateStrs[i])
nextDateStrs = str(dateStrs[i + 1])
It seems very strange that I need the dateStrs list just for the
purpose of looping thru the dictionary keys.
Can I get rid of the "dateStrs" variable?
Thank you.
As this is such a basic question I suggest you take it to either the
tutorial mailing list or the main one. These are available as
gmane.comp.python.tutor or gmane.comp.python.general, but can be accessed
via other mechanisms.
--
My fellow Pythonistas, ask not what our language can do for you, ask what
you can do for our language.
Mark Lawrence
--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.