The discussion centers on the journey of a beginner programmer seeking to develop metaskills in programming rather than focusing on specific languages. The consensus is that Python is the optimal first language due to its simplicity and application-oriented approach. Participants recommend foundational texts such as "Structure and Interpretation of Computer Programs" and suggest exploring logic and automata theory to enhance problem-solving skills. Additionally, learning web frameworks like Django or Pylons is advised for those interested in contract work.
PREREQUISITES
Basic understanding of programming concepts
Familiarity with Python programming language
Knowledge of logic and its application in problem-solving
Awareness of web frameworks such as Django or Pylons
NEXT STEPS
Study "Structure and Interpretation of Computer Programs" by MIT Press
Learn Python web frameworks, specifically Django or Pylons
Research automata theory, including finite automata and Turing machines
Explore online resources for Python tutorials, such as CodingBat and YouTube
USEFUL FOR
Beginner programmers, aspiring software developers, and individuals interested in enhancing their problem-solving skills through foundational computer science concepts.
#61
G037H3
280
2
story645 said:
It actually works just as expected. What do you think is wrong with it? The python looks fine to me, and I use python all the time.
The python's sort of advanced, but he got the answer from stackoverflow.
yeah, I was the asker of that question. I joined stackoverflow and stuff. I had a different solution, but it was more convoluted. I actually don't find list comprehensions to be very advanced at all...it's a lot easier to me than using dictionaries.
yeah, I was the asker of that question. I joined stackoverflow and stuff. I had a different solution, but it was more convoluted. I actually don't find list comprehensions to be very advanced at all...it's a lot easier to me than using dictionaries.
No, it's not very complex-- it's something you'd learn in your first course in programming.
So, why look for only things that have 2-4 letters at the end of the string? If you're looking for valid domains in the list, you probably want to check the validity of the leading characters. Perl-wise, I'd probably do a regex for that:
Dunno how tricky it is to incorporate pattern matches in Python, but it probably makes for a better solution if you're checking for validity rather than something simple like length.
DaveE
Last edited:
#63
story645
678
2
G037H3 said:
yeah, I was the asker of that question. I joined stackoverflow and stuff. I had a different solution, but it was more convoluted.
Convoluted solutions are good-that's how you learn the ins and outs of a language. I usually go through a whole bunch of them before finding the magical list comprehension that does what I need.
I actually don't find list comprehensions to be very advanced at all...it's a lot easier to me than using dictionaries.
They're not, but a list comprehension with two levels of filtering and an uncommon condition is what tipped me off that you probably didn't write it. Be careful with using stackoverflow when you're starting out 'cause the guru answers often obscure the steps you need to learn to be able to craft those answers.
dave said:
Dunno how tricky it is to incorporate pattern matches in Python
Dead simple 'cause the python re library uses perl style regexs. The stackoverflow link actually has the regex variant too:
So the code G037H3 gave acts on the same urls input.
You're pretty much spot on with how it works, but to recap:
urlssplit(') would take urls= 'albatross.org, boogaloo.boolean.net, bedei9.paralex.zenoparadox.herc.gr, takeawalkon.the.wildside,fuzzy.logic.it, bronzeandiron.age, areyou.serious, mydom.dom.net, hun.com'
and split on (',') to return a list of urls
['albatross.org' , 'boogaloo.boolean.net', ..., 'mydom.net', 'hun.com']
then split on ('.') would work on every element in the url list and split it up into lists, so:
['albatross', 'org'], ['boogaloo', 'boolean', 'net'], ... ['mydom', 'net'],...['hun', 'com']
and 2 <= len(url.split('.')[-1]) <=4 tests every last list element, so:
'org', 'net', ..., 'net', 'com'
#64
davee123
671
4
story645 said:
a list comprehension with two levels of filtering and an uncommon condition is what tipped me off that you probably didn't write it.
That's true-- a beginner solution to the same problem would be more step-by-step rather than rolled up into a single line:
Works just as well as the posted solution (probably takes a negligible amount more memory/CPU), but is easier to understand piece by piece.
DaveE
#65
story645
678
2
davee123 said:
That's true-- a beginner solution to the same problem would be more step-by-step rather than rolled up into a single line:
The python equivalent is:
Code:
urlslist = urls.split(',')
final_list = []
for domain in urllist:
parts = domain.split('.')
if ((len(parts[-1]) >=2) and (len(parts[-1])<=4)):
final_list.append(parts[-1])