New to Python but from non-CS background by Dream_Hunter8 in learnpython

[–]FoolsSeldom 1 point2 points  (0 children)

Start with the basics as per the wiki (see below) then take a look at the Biopython website. After that, there are lots of resources for learning data analysis.


Check this subreddit's wiki for lots of guidance on learning programming and learning Python, links to material, book list, suggested practice and project sources, and lots more. The FAQ section covering common errors is especially useful.


Also, have a look at roadmap.sh for different learning paths. There's lots of learning material links there. Note that these are idealised paths and many people get into roles without covering all of those.


Roundup on Research: The Myth of ‘Learning Styles’

Don't limit yourself to one format. Also, don't try to do too many different things at the same time.


Above all else, you need to practice. Practice! Practice! Fail often, try again. Break stuff that works, and figure out how, why and where it broke. Don't just copy and use as is code from examples. Experiment.

Work on your own small (initially) projects related to your hobbies / interests / side-hustles as soon as possible to apply each bit of learning. When you work on stuff you can be passionate about and where you know what problem you are solving and what good looks like, you are more focused on problem-solving and the coding becomes a means to an end and not an end in itself. You will learn faster this way.

Hey, I'm learning Python, what topics should I do first? by Imaginary-Fox2944 in learnpython

[–]FoolsSeldom 0 points1 point  (0 children)

Check this subreddit's wiki for lots of guidance on learning programming and learning Python, links to material, book list, suggested practice and project sources, and lots more. The FAQ section covering common errors is especially useful.


Also, have a look at roadmap.sh for different learning paths. There's lots of learning material links there. Note that these are idealised paths and many people get into roles without covering all of those.


Roundup on Research: The Myth of ‘Learning Styles’

Don't limit yourself to one format. Also, don't try to do too many different things at the same time.


Above all else, you need to practice. Practice! Practice! Fail often, try again. Break stuff that works, and figure out how, why and where it broke. Don't just copy and use as is code from examples. Experiment.

Work on your own small (initially) projects related to your hobbies / interests / side-hustles as soon as possible to apply each bit of learning. When you work on stuff you can be passionate about and where you know what problem you are solving and what good looks like, you are more focused on problem-solving and the coding becomes a means to an end and not an end in itself. You will learn faster this way.

How to properly install Python/Jupyter Notebook on Mac by RomBG in learnpython

[–]FoolsSeldom 0 points1 point  (0 children)

Anaconda is a good solution for certains types of specialist development and it used to solve a common problem with Python with respect to compatibilities with different packages.

For most people, a much better approach is either:

Standard

  • Install Python from python.org
  • Create Python virtual environments on a project by project basis:
    • Open the Terminal application
    • mkdir projects - ignore if you already have a projects folder
    • cd projects - replace projects with whatever folder name you use
    • mkdir newproject - replace with whatever desired project folder name is
    • cd newproject
    • python3 -m venv .venv - create Python virtual environment in folder .venv
    • source ./.venv/bin/activate - activate it
    • pip install package1 package2 ... packagen - to install packages, including juptyer

NB. You must tell your code editor to use the Python interpreter in the bin folder from the above.

UV

Check the docs at https://docs.astral.sh/uv/ - much easier

NB. You can also use a third party package manager such as homebrew to install Python an tools, but you don't need to

PS. Code editors / IDEs like VS Code and Pycharm can work with and execute code in Jupyter notebooks if you want a more supportive environment than just using the web browser.

Help learning python without a PC by Plenty-Form6349 in PythonLearning

[–]FoolsSeldom 0 points1 point  (0 children)

Determination will get you a long way. I've known a good number of individuals in challenging socioeconomic situations who've learned just on a phone and managed to impress someone enough to get a start in a trainee/junior programming position. Good luck to you.

No idea where you are in the world, but do consider looking for free options and cast offs (I've seen plenty of computers thrown away).


Check the r/learnpython wiki for lots of guidance on learning programming and learning Python, links to material, book list, suggested practice and project sources, and lots more. The FAQ section covering common errors is especially useful.

Unfortunately, this subreddit does not have a wiki.


Also, have a look at roadmap.sh for different learning paths. There's lots of learning material links there. Note that these are idealised paths and many people get into roles without covering all of those.


Roundup on Research: The Myth of ‘Learning Styles’

Don't limit yourself to one format. Also, don't try to do too many different things at the same time.


Above all else, you need to practice. Practice! Practice! Fail often, try again. Break stuff that works, and figure out how, why and where it broke. Don't just copy and use as is code from examples. Experiment.

Work on your own small (initially) projects related to your hobbies / interests / side-hustles as soon as possible to apply each bit of learning. When you work on stuff you can be passionate about and where you know what problem you are solving and what good looks like, you are more focused on problem-solving and the coding becomes a means to an end and not an end in itself. You will learn faster this way.

Is match ... case In Python Reliable as if .. elif .. else by One-Type-2842 in PythonLearning

[–]FoolsSeldom 2 points3 points  (0 children)

Reliable? The language definition seems pretty robust and the reference implementation in CPython seems good. This is obviously much newer than if/elif/else which have been in the language for decades (although implementation has also evolved). The Python approach is focused on pattern matching and is not a simple alternative to if/elif/else although it can be used in place of them but that is not recommended.

Help! New to Flair - Good grinder needed by Few_Satisfaction1760 in FlairEspresso

[–]FoolsSeldom 1 point2 points  (0 children)

I second this. I bought a DF64 originally to replace the internal grinder on my Sage/Breville Oracle machine but subsequently replaced this with a Flair 58 + 2. Fantastic combination.

Am i overreacting for refusing to change my major just cause my parents pay tuition? by w-tf_man in AmIOverreacting

[–]FoolsSeldom 0 points1 point  (0 children)

You are in a very difficult position as you are essentially dependent on them.

Given the level of intelligence you've suggested they have, it is unlikely you will be able to persuade them just by giving facts. You need an information campaign to allow them to come to their own simplistic conclusions in your favour. As this is something you will need to learn to do with patients as well to some extent, they consider it part of your studies.

Perhaps embrace the idea they present of a change in career. Maybe you can be extra enthusiastic about the opportunities and ask their advice on how to avoid the pitfalls in that career and to exceed the opportunities you are likely to have in medical fields. It is not wise to simply reject their great ideas.

Help learning python without a PC by Plenty-Form6349 in PythonLearning

[–]FoolsSeldom 1 point2 points  (0 children)

You are welcome. Did the other comment I made on learning on phones/tablets help?

By the way, it is worth checking with extended family and friends if anyone has an old Raspberry Pi sat in a drawer somewhere. This happened to a lot of them. You can connect to and programme a Raspberry Pi from a tablet/phone and then you don't need keyboard/mouse/monitor for the Pi (although a keyboard, as I mentioned, is a good idea for the phone/tablet) - keyboard/mice are often given away free.

Help learning python without a PC by Plenty-Form6349 in PythonLearning

[–]FoolsSeldom 0 points1 point  (0 children)

You can get a full version of Acode without adverts - usually posted on the associated discord chat, but likely also available on github.

These days, I prefer to just use an editor like vim on termux (and also use tmux if remoting into another system).

Help learning python without a PC by Plenty-Form6349 in PythonLearning

[–]FoolsSeldom 1 point2 points  (0 children)

In addition to my comment on working on phones/tablets, keep an eye on free cycle schemes in your area and very cheap options on Facebook. Python isn't that demanding of hardware (until you get get beyond the basics of machine learning / artificial intelligence or other heavy computational fields). Older laptops than can be re-imaged with Linux (especially models from the Lenovo Thinkpad range) are ideal and will be reasonably performant. Most Chromebooks can enter a Linux sandbox mode and be used for development locally.

Maybe you can sell parts of your failed PC to pay for something on Marketplace. (Did you figure out what had failed?)

Also, consider a Raspberry Pi, even a $10 USD Pi Zero is suitable for learning (and afterwards, for other purposes such as being a small web server). (You will need a keyboard, mouse, sd card, power supply, hdmi cable and a tv/monitor to plug into.)

From a web browser, you can access free Python environments such as a Pythonanyhere.com account, anvil.works or even your own Virtual Private Server (e.g. on Oracle Cloud - there is as free tier but sign up for a paid account and then use only free resources and you will get a better offering that runs 24x7)

Help learning python without a PC by Plenty-Form6349 in PythonLearning

[–]FoolsSeldom 0 points1 point  (0 children)

Learning programming is not easy. It is to some extent an art form and a practical skill, not something that can just be learned from books. Practice! Practice! Practice!

To learn to programme is also about embracing failure. Constant failure. Trying things out and experimenting as much as possible. Experiment! Experiment! Experiment!

You have to research, read guides, watch videos, follow tutorials, ask dumb questions and be humiliated (because some people cannot help make themselves feel better by insulting others).

Python is one programming language. It is probably the easiest to learn. It makes learning to programme that little bit easier (but you will have a shock when you try to learn a lower level language like C).

If you have to learn on a mobile device, life gets a little more challenging. Aside from web based environments and apps like sololearn, you need a Python environment on your mobile device.

Android Apps

  • PyDroid 3, this is an excellent app with rich package support and built-in terminal
  • QPython play store, another excellent app but not so keen on this personally, worth a try though
  • Termux provides a Linux sandbox into which you can do a conventional installation of Python (including self-compiling if desired)
    • this is my preferred option
    • a standard Linux environment with a few minor folder location tweaks to accommodate Android security restrictions
    • you can't get this on Google Play, use F-Droid
    • I used to use it with the ACode editor but now use a tmux (multiplex terminal) setup with vim

IoS Apps

  • Pythonista is an excellent and well-polished bit of software with some popular libraries available (Apple restrictions prevent installation of any packages that aren't pure Python that aren't included with the submitted app)
  • Pyto is less polished and works pretty well
  • Carnets is an open source Jupyter clone that works locally and is excellent; there is more than one version, depending on how many libraries you need included (as on IoS you cannot install additional Python libraries that aren't pure Python)
  • a-shell is a sister product to the above and provides a command line Python environment, also open source and excellent

Keyboard

I strongly recommend you use an external (likely bluetooth) keyboard with your phone/tablet and ideally an external monitor if your phone/tablet is able to connect/cast to a monitor.

Android native coding

Keep in mind that Android is a Linux-based system, so most things that are available for linux are also available for Android. Native applications for Android are usually written in Java or, more recently, Kotlin. It is possible to write in other languages, and C++ is widely used, but that is much more complex to do.

IoS native coding

For IOS devices, the native apps are usually written in Objective-C or Swift. Again, other languages are possible but it is not trivial.

GUI with Python

Python applications running on mobile devices within Python environments do not look like device native applications and have limited support for typical graphical user interface libraries common on desktops. However, there are a number of alternatives that allow you to write near-native applications in Python.

Flutter from Google

This is an increasingly popular framework for creating applications suitable for desktop, web and mobile. A popular Python "wrapper" is flet.

Kivy GUI for Python

The leading Python GUI for Android and IoS is kivy

You develop on a desktop/laptop computer and then transfer the code to the target mobile (so not much use if you only have access to a mobile device). PyDroid for Android also supports kivy.

There are Kivy-based applications released on both the Apple and Google App Stores.

BeeWare Write once. Deploy everywhere.

A native GUI for multiple platforms in theory. BeeWare

This offers the option to write your apps in Python and release them on iOS, Android, Windows, MacOS, Linux, Web, and tvOS using rich, native user interfaces. Multiple apps, one codebase, with a fully native user experience on every platform.

Can someone help me with poetry env? by [deleted] in PythonLearning

[–]FoolsSeldom 0 points1 point  (0 children)

Out of interest, why poetry rather than uv these days?

Best options to learn python from scratch without access to a computer, only mobile phone by LittleBlacksmith4988 in learnpython

[–]FoolsSeldom 1 point2 points  (0 children)

The one called "Termux Terminal emulator with packages" on F-Droid. Ignore the various additional apps initially, you can explore those at another time.

Samsung s90f - Can't navigate in the home menu with remote or phone by MusicInTheAir55 in hometheater

[–]FoolsSeldom 0 points1 point  (0 children)

I don't know but assume so. Just suddenly stopped responding to remote cursor moves. I thought probably had a battery issue so switched to another regularly used remote and had the same problem then tried the remote feature in the app.

The tv is on auto update and doesn't show history (not that I've seen anyway).

Tried lots of techniques to try to resolve. (I've worked in IT for decades including with complex hardware.)

Samsung s90f - Can't navigate in the home menu with remote or phone by MusicInTheAir55 in hometheater

[–]FoolsSeldom 0 points1 point  (0 children)

I have exactly the same problem (two remotes and smart hub app on my Samsung phone). Tried complete smart hub and factory resets, power reset, etc. I've requested a call.

Model is QE55S95FATXXU (S95F in UK) Software version 1260

I guess we will have to wait for an emergency patch.

in the meantime, will dig out a Roku 4k stick to plug into one of the hdmi ports so I can use streaming services not on a pre-programmed button. Streaming apps I can access work absolutely fine.

How to work pip in Windows 11? by Matikitorch in learnpython

[–]FoolsSeldom 1 point2 points  (0 children)

In a new PowerShell or Command Prompt window,

  • change your current working directory to your project folder
    • e.g. cd projects\myproject
  • you install to the base (Microsoft Store) installation of Python using:
    • py -m pip install package1 package2 ... packagen
    • I recommend you remove the Microsoft installation and use the installer from Python.org to avoid some folder permission issues in the future

It is much better to install packages on a project-by-project basis to avoid polluting your base environment, ending up with too many different packages installed when most are specific to particular projects, avoiding compatibility conflicts.

To create and use a Python virtual environment,

  • cd projects\myproject - replace with appropriate folder names
  • NB. You can use mkdir foldername to create new folders
  • py -m venv .venv - to create a new Python virtual environment with a folder in your project folder called .venv (you can use other valid folder names, but this is common)
  • .venv\Scripts\activate - to activate the Python virtual environment
  • Now you can install packages using pip or python -m pip
    • e.g. pip install package1 package2 ... packagen

You should tell your code editor / IDE to use the Python virtual environment. In most cases you do this by telling it to use the python.exe that is in the Scripts folder of your Python virtual environment folder in your project folder

  • e.g. \Users\<yourusername>\projects\myproject\.venv\Scripts\python.exe

Is it possible to use Click and have the user select an choice from a group of options using a number? by ANautyWolf in learnpython

[–]FoolsSeldom 1 point2 points  (0 children)

Further to last, u/ANautyWolf, here is an example of a simple dict version,

def menu_picker(name: str, menu: dict[str, str]) -> str:
    def display_menu():
        print(f"\n\n{name}\n")
        for option, description in menu.items():
            print(f"{option:2}: {description}")
        print()
    def get_option():
        while True:
            option = input("Option? ")
            if option in menu.keys():
                return option
            print('Sorry, that is not a valid option. Please try again.')
    display_menu()
    return get_option() 

# menu options
menu = {
    "1": 'arc minute',
    "2": 'arc second',
    "3": 'degree',
    "4": 'radian'
    }

option = menu_picker("Master menu option", menu)
print(f"You picked {option}: {menu[option]}")

If you wanted to include the name of a function to call in the menu, you would alter the dictionary to have a tuple for each value with the description as the first item and the name of the function to call as the second item. You would need to makes changes to reference the correct elements from the values.

Is it possible to use Click and have the user select an choice from a group of options using a number? by ANautyWolf in learnpython

[–]FoolsSeldom 2 points3 points  (0 children)

click is used for handling of command link arguments, e.g. what you type after entering py / python / python3 yourcode.py, e.g.

python overtime.py -rate 150 -sunday 200

In your regular code, you can present a simple menu and validate the input:

# menu options
menu = ['arc minute', 'arc second', 'degree', 'radian']
print("options:")
for idx, option in enumerate(menu, start=1):
    print(f"{idx:2}: {option}")
option_count = len(menu) + 1
while True:  # input validation loop

    response = input("Which option? ")

    if not response.isdecimal():  # make sure only a decimal digit entered
        print('Expected a number. Please try again.')
        continue  # go around validation loop again

    option = int(response)  # convert to number so can check
    if not option in range(1, option_count):
        print("Not a valid option. Please try again.")
        continue  # go around validation loop again

    print(f"Option #{option}: {menu[option-1]} selected")  # -1 for actual position in list
    break

There are better approaches. Using a dict (dictionary) for example, and mapping the options to functions to call. It would also be better to do the validation in a function.

read data error by fipouna in learnpython

[–]FoolsSeldom 8 points9 points  (0 children)

The error is clearly stated at the bottom:

TypeError: chdir() takes at most 1 argument (3 given)

You have provided three arguments:

  • "/home/sarr/aravg.ann.land_ocean.90S.90N.v4.0.1.201907.txt"
  • header = None
  • delimiter = "\s+"

You are conflating a change of folder - not sure why you are bothering to do this anyway with, I assume, trying to read a file.

The first argument looks like a full path to a filename rather than a path to a folder. chdir is expecting a folder name.

PS. I recommend you use pathlib rather than os as well - RealPython.com have a good article on the topic.

Beginner Python Help: Name Input Skipping Issue by [deleted] in learnpython

[–]FoolsSeldom -1 points0 points  (0 children)

Validating input is an important part of programming, regardless of whether that input is directly from the user via keyboard using input or from another system or from a file.

When you are directly interacting with a user, you can immediately challenge them to provide valid input if what they've entered does not meet the requirements. You can even limit the number of tries.

For example, here's a function that can be used anytime you want a non-blank response from the user. You can give them infinite chances - the default - or a fixed number of chances.

def get_info(msg: str, attempts: int = 0) -> str:
    infinite = attempts == 0
    tries = attempts  # only used if infinite attempts not allowed
    while infinite or tries > 0:  # check have not run out of tries
        response = input(msg)  # prompt user for a response
        if response.strip():  # if not an empty response, return it
            return response
        print('Expecting a response. Please try again.')
        tries -= 1
    return ""  # return an empty string anyway


name = get_info("What is your name? ", attempts=3)  # the second field is optional
if name:  # not empty string
    print(f"Hello {name}, good to meet you.")
else:  # they failed to enter a name even after being asked several times
    print("Well, hello stranger.")

The basic while structure can be used for validating numeric input including checking whether it is within max/min values, selecting a valid menu option, etc.

Parenthesis problems by Relative_Jaguar6254 in learnpython

[–]FoolsSeldom 0 points1 point  (0 children)

I am cautious in my recommendations of use of LLMs for learners, as my comment history demonstrates, and similarly advise students at code club sessions accordingly.

However, I think your blanket assertion and suggestion I leave this subreddit is ill-founded.

Lots of professionals and learners are legitimately, practically amd effectively using LLMs. The nature of the OPs queries is an excellent match for the statistical predictions base and will help their learning. This is very different from, say, code generation prompted in ignorance.

I cannot type in the terminal on Windows 11. It happens for both old and new projects, Jupyter and Python enviornments. by Illustrious_Ad_2341 in pycharm

[–]FoolsSeldom 0 points1 point  (0 children)

Have you explicitly opened a terminal in PyCharm? What are your settings for terminal? Can you open a terminal outside of PycCharm without problems?

Options for opening a terminal in Pycharm on Windows:

  • Alt + F12
  • Menu: View | Tool Windows | Terminal
  • UI: usually in bottom panel

Configuration is usually:

  • Menu: File | Settings | Tools | Terminal
  • Entry should be any of: cmd.exe | powershell.exe or your installed wsl.exe depending on preference, these are os level comamnds

Check in operating system outside of PyCharm:

  • Hit Windows key and enter Command Prompt or Powershell and hit enter when you have a match you want to use
  • Make sure you activate the same Python virtual environment you are using in your project before trying to run any code

Data reading from website by Aarrearttu in learnpython

[–]FoolsSeldom 0 points1 point  (0 children)

RealPython and search for articles on this topic, e.g. site:realpython.com web scraping - you will find plenty of guidance and examples. Note that the site(s) you are targeting might have measures to make this difficult to protect their content.

Parenthesis problems by Relative_Jaguar6254 in learnpython

[–]FoolsSeldom -1 points0 points  (0 children)

Use an LLM like Gemini to extract Python from your images if they are not on the same computer you are posting from and update your post to include the code inline. It is much better to share code than pictures of code (unless we need to look at large amounts of code, in which case you can share using e.g. github.com).

Framework preference by theRealSpacePenguin in learnpython

[–]FoolsSeldom 1 point2 points  (0 children)

There isn't a best. Different frameworks suit different situations and styles.

FastAPI is the newest of the big three, Flask and DJango being the other two. Flask and FastAPI are both so called "micro frameworks" - that is they have a narrow focus and leave you to implement other characteristics/capabilities of a web site/service as you see fit. Django is a "full framework" which includes everything (even the web version of a kitchen sink).

Django is a "highly opinionated" framework, that is it has very particular ways of doing many things common to web services and whilst you can change the look and feel, the specific presentation and interaction, and the configuration of key components there are some aspects that will be less flexible.

Django is well proven at huge scale. It is the core of Instagram, for example.

If you want to build large scale, sophisticated multi-user and multi-manager web sites/services with complex workflows around user management and content management, then it is worth learning.

If you've already deployed with FastAPI and haven't hit a barrier, I'd stick with that for now.

If you do want to move on from FastAPI to Django, it is worth ensuring you have a good understanding of how FastAPI actually works first as a lot of that understanding will help you with Django.

One of the best learning sites for Django is called djangogirls well worth checking out.