René's URL Explorer Experiment


Title: Runtime error in Example A-2 · Issue #52 · fluentpython/example-code · GitHub

Open Graph Title: Runtime error in Example A-2 · Issue #52 · fluentpython/example-code

X Title: Runtime error in Example A-2 · Issue #52 · fluentpython/example-code

Description: I'm trying to run the Example A-2 (page 689 in the First Edition). I'm not sure if it's something wrong that I'm doing.. but I read the code 10 times. I'm sure it is the same of the book. I'm running this code as: $python example_a_2__ge...

Open Graph Description: I'm trying to run the Example A-2 (page 689 in the First Edition). I'm not sure if it's something wrong that I'm doing.. but I read the code 10 times. I'm sure it is the same of the book. I'm runni...

X Description: I'm trying to run the Example A-2 (page 689 in the First Edition). I'm not sure if it's something wrong that I'm doing.. but I read the code 10 times. I'm sure it is the same of...

Opengraph URL: https://github.com/fluentpython/example-code/issues/52

X: @github

direct link

Domain: redirect.github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Runtime error in Example A-2","articleBody":"I'm trying to run the `Example A-2` (page 689 in the First Edition).\r\nI'm not sure if it's something wrong that I'm doing.. but I read the code 10 times. I'm sure it is the same of the book.\r\n\r\nI'm running this code as:\r\n```\r\n$python example_a_2__generate_array.py\r\n```\r\nwhere my Python version is `3.8.5`. Then I see this error:\r\n```\r\ninitial sample: 10500000 elements\r\nTraceback (most recent call last):\r\n  File \"example_a_2__generate_array.py\", line 19, in \u003cmodule\u003e\r\n    with len(sample) \u003c SAMPLE_LEN:\r\nAttributeError: __enter__\r\n```\r\n\r\n**Some reasoning:**\r\nI'm not reasigning the `open` function (as suggested [here](https://stackoverflow.com/questions/53564755/python-error-attributeerror-enter) for one possible cause).\r\n\r\n**Possible solution:**\r\nMaybe line 19 should be replaced by:\r\n```\r\nif len(sample) \u003c SAMPLE_LEN:\r\n```\r\n\r\nI tried that and got a good looking output:\r\n```\r\ninitial sample: 10500000 elements\r\ncomplete sample: 10500000 elements\r\nnot selected: 500000 samples\r\n  writing not_selected.arr\r\nselected: 10000000 samples\r\n  writing selected.arr\r\n ```\r\n \r\n And they seem to have been created correctly:\r\n```\r\n$ls -la *selected*\r\n-rw-rw-r-- 1 lucas lucas  4000000 mai 13 14:57 not_selected.arr\r\n-rw-rw-r-- 1 lucas lucas 80000000 mai 13 14:57 selected.arr\r\n```\r\n\r\n\r\nPS.: Thank you for the book and sharing your knowledge!","author":{"url":"https://github.com/CavalcanteLucas","@type":"Person","name":"CavalcanteLucas"},"datePublished":"2021-05-13T18:55:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/52/example-code/issues/52"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:2edeacc5-52a4-881b-79b6-34a29a4b28bd
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAA96:3C62DE:4E31402:6681A3C:696D70BF
html-safe-noncebfbcbc3611c3798945b42c8e1933e862f3ad17bca0edb5a751a433b2d2b33d81
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTk2OjNDNjJERTo0RTMxNDAyOjY2ODFBM0M6Njk2RDcwQkYiLCJ2aXNpdG9yX2lkIjoiMzEzNzE0NTY5NTAzODY5NzY2MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac956015bb27f3a4bd05f5687a6366f1e2ed28a8ab3827d9897c1028fd45df9f66
hovercard-subject-tagissue:891288530
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/fluentpython/example-code/52/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7460fdcbcacf1c2b74d5ddebe3e8fa4e90c2b8792c5d8831219671340a85d05d/fluentpython/example-code/issues/52
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7460fdcbcacf1c2b74d5ddebe3e8fa4e90c2b8792c5d8831219671340a85d05d/fluentpython/example-code/issues/52
og:image:altI'm trying to run the Example A-2 (page 689 in the First Edition). I'm not sure if it's something wrong that I'm doing.. but I read the code 10 times. I'm sure it is the same of the book. I'm runni...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameCavalcanteLucas
hostnamegithub.com
expected-hostnamegithub.com
None4922b452d03cd8dbce479d866a11bc25b59ef6ee2da23aa9b0ddefa6bd4d0064
turbo-cache-controlno-preview
go-importgithub.com/fluentpython/example-code git https://github.com/fluentpython/example-code.git
octolytics-dimension-user_id9216311
octolytics-dimension-user_loginfluentpython
octolytics-dimension-repository_id25216588
octolytics-dimension-repository_nwofluentpython/example-code
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id25216588
octolytics-dimension-repository_network_root_nwofluentpython/example-code
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7e5ae23c70136152637ceee8d6faceb35596ec46
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://redirect.github.com/fluentpython/example-code/issues/52#start-of-content
https://redirect.github.com/
Sign in https://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ffluentpython%2Fexample-code%2Fissues%2F52
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ffluentpython%2Fexample-code%2Fissues%2F52
Sign up https://redirect.github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=fluentpython%2Fexample-code
Reloadhttps://redirect.github.com/fluentpython/example-code/issues/52
Reloadhttps://redirect.github.com/fluentpython/example-code/issues/52
Reloadhttps://redirect.github.com/fluentpython/example-code/issues/52
fluentpython https://redirect.github.com/fluentpython
example-codehttps://redirect.github.com/fluentpython/example-code
Notifications https://redirect.github.com/login?return_to=%2Ffluentpython%2Fexample-code
Fork 2.2k https://redirect.github.com/login?return_to=%2Ffluentpython%2Fexample-code
Star 5.6k https://redirect.github.com/login?return_to=%2Ffluentpython%2Fexample-code
Code https://redirect.github.com/fluentpython/example-code
Issues 14 https://redirect.github.com/fluentpython/example-code/issues
Pull requests 10 https://redirect.github.com/fluentpython/example-code/pulls
Actions https://redirect.github.com/fluentpython/example-code/actions
Projects 0 https://redirect.github.com/fluentpython/example-code/projects
Wiki https://redirect.github.com/fluentpython/example-code/wiki
Security Uh oh! There was an error while loading. Please reload this page. https://redirect.github.com/fluentpython/example-code/security
Please reload this pagehttps://redirect.github.com/fluentpython/example-code/issues/52
Insights https://redirect.github.com/fluentpython/example-code/pulse
Code https://redirect.github.com/fluentpython/example-code
Issues https://redirect.github.com/fluentpython/example-code/issues
Pull requests https://redirect.github.com/fluentpython/example-code/pulls
Actions https://redirect.github.com/fluentpython/example-code/actions
Projects https://redirect.github.com/fluentpython/example-code/projects
Wiki https://redirect.github.com/fluentpython/example-code/wiki
Security https://redirect.github.com/fluentpython/example-code/security
Insights https://redirect.github.com/fluentpython/example-code/pulse
Runtime error in Example A-2https://redirect.github.com/fluentpython/example-code/issues/52#top
https://github.com/CavalcanteLucas
https://github.com/CavalcanteLucas
CavalcanteLucashttps://github.com/CavalcanteLucas
on May 13, 2021https://github.com/fluentpython/example-code/issues/52#issue-891288530
herehttps://stackoverflow.com/questions/53564755/python-error-attributeerror-enter
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.