Johan Martinez writes:
> Where can I find syntax for list comps?
The same place as other syntax descriptions: in the language reference
https://docs.python.org/3/reference/expressions.html#displays-for-lists-sets-and-dictionaries>.
> I am confused how/whether they are evaluated left-right or ri
On Wed, Feb 3, 2016 at 8:52 PM, Johan Martinez wrote:
> Where can I find syntax for list comps? I am confused how/whether they are
> evaluated left-right or right-left. Consider following list flattening
> example:
>
> mx = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
>
> [value for row in mx for value in ro
Where can I find syntax for list comps? I am confused how/whether they are
evaluated left-right or right-left. Consider following list flattening
example:
mx = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
[value for row in mx for value in row]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
It seems like 'for' loops are eval
Alex Kleider writes:
> How does a dict fit into this scheme?
> Is it a sequence?
No, a dict is not a sequence. But it is a container: all its items
remain available and can be retrieved again and again, and you can
interrogate whether a value is one of the items in that container.
An instance o
On 2016-02-03 13:24, Ben Finney wrote:
You have discovered the difference between an iterable (an object you
can iterate over with ‘for’), versus a sequence (an object whose items
remain in place and can be iterated many times).
Every sequence is an iterable, but not vice versa.
File objects
Thank you all. The only reason i tried both ways is to experiment with
Python. They made sense to me and thought why not try them both. And i am
relatively new to Python.
Thanks again--EKE
___
Tutor maillist - Tutor@python.org
To unsubscribe or change
Ek Esawi writes:
> I have a code that reads a csv file via DictReader. I ran into a peculiar
> problem. The python interpreter ignores the 2nd code. That is if I put the
> reader iterator 1st, like the code below, the enumerate code is ignored; if
> I put the enumerate code 1st, the reader code i
Steven D'Aprano writes:
> I think the right answer is that testing main() is *not* a unit test,
> it's an integration test. You're testing that the application as a
> whole works the way you expect, rather than testing individual units
> of the application (functions, class, methods, modules).
A
> I have a code that reads a csv file via DictReader. I ran into a peculiar
> problem. The python interpreter ignores the 2nd code. That is if I put the
> reader iterator 1st, like the code below, the enumerate code is ignored; if
> I put the enumerate code 1st, the reader code is ignored. I am cur
On 03/02/16 15:29, Ek Esawi wrote:
> reader = csv.DictReader(MyFile)
>
> for row in reader:
> list_values = list(row.values())
> print (list_values)
>
At this point the reader has reached the end of the file.
> for i,j in enumerate(reader):
> print(j)
So yo
Hi All
I have a code that reads a csv file via DictReader. I ran into a peculiar
problem. The python interpreter ignores the 2nd code. That is if I put the
reader iterator 1st, like the code below, the enumerate code is ignored; if
I put the enumerate code 1st, the reader code is ignored. I am
On Tue, Feb 02, 2016 at 10:46:04AM +, Pedro Miguel wrote:
> Hi guys, I'm trying to test the code in the main() but I'm a bit
> unsure how to go about it since I'm not passing any arguments or even
> returning anything other then logging. For the purposes of the example
> I've shortened the
knnleow GOOGLE wrote:
> advice on how to filter VARIABLES from output below.
>
> 01. need to strip out
>BEGIN_STRINGS b'{ and
>END_STRINGS }\n'
In b'{...}' the b prefix indicates that you are dealing with a byte string.
You have to decode it and then you can use the json module
Pedro Miguel wrote:
> Hi guys, I'm trying to test the code in the main() but I'm a bit unsure
> how to go about it since I'm not passing any arguments or even returning
> anything other then logging. For the purposes of the example I've
> shortened the tree statements in the function.. Can anyone
On 03/02/16 01:30, knnleow GOOGLE wrote:
> advice on how to filter VARIABLES from output below.
>
> 01. need to strip out
>BEGIN_STRINGS b'{ and
>END_STRINGS }\n'
Are you sure those are actually part of the string and not just the
representation output by Python?
The b at the st
On 02/02/16 21:54, Chelsea G wrote:
> date row. I am trying to see if I can read in a csv file and search for a
> certain date range like 1/2/2016 to 1/5/2016.
Ben has given you some good advice on how to tackle the overall issue.
To deal with the dates you will probably want to use the time an
On 02/02/16 17:46, Chelsea G wrote:
> ...but then in the def json_output instead of having the
> filename which i have now is 'test.txt' I want to have weekly_20160102.txt
> same naming convention as the csv file i am inputting.
Take a look at the os.path module documentation.
There are several
advice on how to filter VARIABLES from output below.
01. need to strip out
BEGIN_STRINGS b'{ and
END_STRINGS }\n'
02. need to filter out these FIELDS
FIELD 1 "ip":"222.187.222.220"
FIELD 2 "country_code":"CN"
FIELD 3 "country_name":"China"
FIELD 6 "city":"Shanghai"
FIELD 8 "
18 matches
Mail list logo