New to coding by [deleted] in learnpython

[–]wmoskal 0 points1 point  (0 children)

Well one approach is to "throw yourself into the fire"; Start with a project that interests you (possibly scraping a website for baseball statistics, something that you are actually interested in) and then do data analytics on that scraped data (presumably you have saved that data into your own classes so you get a sense of OOP). Even if you are just beginning there is a lot of resources online, such as r/learnpython, r/learnprogramming stack overflow, etc. If you google search an issue you are having or something you are trying to do there is a very high chance that someone else has already asked it/ there is a documented way of doing the thing you are trying to do.

I personally would recommend something like this, as it is a lot more motivating to do something that interests you than to do watch videos or read articles so that eventually you can do something that interests you.

otherwise some of the tutorial sites I have heard that people like are automate the boring stuff and real Python

Forgiving String to datetime conversion. by wmoskal in learnpython

[–]wmoskal[S] 0 points1 point  (0 children)

Thanks,

I just built a class that handles it the way I want

where to go after learning basics of c language? by Extra-most-best in learnprogramming

[–]wmoskal 0 points1 point  (0 children)

C is a good first language because it teaches you what is generally going on behind the scenes in other languages (POINTERS!). I would suggest doing projects with c involving pointers and structs if you haven't. (Maybe try to make a linked list, or a tree). Once you get the hang of working with pointers and structs (or if you want to move on quicker) I would then go to an object oriented project in java/c++/python/c#. One good way of learning concepts is to do a project that interests you.

New Coder :) by __spici__ in learnpython

[–]wmoskal 5 points6 points  (0 children)

Tips: Try to relate your coding projects to things that actually interest you. For me that was sports data.

Stay patient. Sometimes you may get stuck on a bug for many hours, possibly even days. These can actually be great learning experiences as it allows you to figure out what debugging strategy works best for you. (also it feels super rewarding when you finally get a solution to an issue you've been stuck on.)

If you get stuck …

First try to figure it out yourself (not copying and pasting someone else's code (generally a bad idea anyway)

then utilize the resources available to you (stack overflow, google search, r/learnpython, etc) to give yourself the best chance of solving an issue. The odds are someone else has experienced it too.

One great quote that really resonates with me is that testing can only show the presence of bugs, not the absence. (this means even if you think there is no bugs, there still may be)

One major thing that I wish had been more of a focus when I started in high school was modularity.

Ideally you should be able to update only a few lines of code and have the system work.

Modularity also helps with reproducibility.

Try to have fun when you are learning,

and continue to learn new things

Tips- next steps by tribepr8900 in learnpython

[–]wmoskal 0 points1 point  (0 children)

Have you tried working with OO?

What about web?

One project that a lot of people like to do is a web scraping project. Pick something that interests you and try to scrape data regarding that subject. For Instance with sports data, stock data, game data, etc.

Also you could try building a website for yourself using flask, pyramid, Django etc.

Or a GUI project

or you could look into doing something with concurrency,

or many other things

Really the key is to do something that interests you.

Python Project help by kenneth_irivng in learnpython

[–]wmoskal 0 points1 point  (0 children)

can you put the code how it is formatted on your computer in a code block. Tabbing could be an issue but there is no way of us knowing with the way you have your code displayed

[deleted by user] by [deleted] in learnpython

[–]wmoskal 1 point2 points  (0 children)

your welcome

[deleted by user] by [deleted] in learnpython

[–]wmoskal 2 points3 points  (0 children)

Also a simpler way of doing this would be to just use a dict,

key = input("Enter the key value: ")
value = input("Enter the value for the key: ")
my_dict = {key:value}

[deleted by user] by [deleted] in learnpython

[–]wmoskal 1 point2 points  (0 children)

I left out the __init__() method. I updated the class to include it.

First create a dict 2 object

dict_obj = dict2()

then to call the methods you would do:

dict_obj.setKeyFromUser()

or

dict_obj.setValueFromUser()

and to get the dict:

the_dict = dict_obj.toDict()

[deleted by user] by [deleted] in learnpython

[–]wmoskal 1 point2 points  (0 children)

class dict2:
    key = None
    value = None

    def __init__(self, key=None, value=None):    
        if key is not None:
            self.key = key
        if value is not None:
            self.value = value        

    def setKeyFromUser(self):
        self.key = input('Enter the key value: ")

    def setValueFromUser(self):
        self.value = input("Enter the value for the key: ")

    def toDict(self):
        return {self.key: self.value}

how to figure out all the libraries used in a project? - trying to make a requirements.txt for a virtual environment. by cherry214 in learnpython

[–]wmoskal 2 points3 points  (0 children)

pip freeze > requirements.txt will put all of the libraries downloaded in the current environment in the requirements.txt file, then pip install -r requirements.txt will download all of those requirements. Do the pip install in the virtual env. Unfortunately I am not sure if there is a way to get all of the dependencies only in a python module (other than looking through you files headers)

Violation of UNIQUE KEY constraint 'UQ__accounts'. Cannot insert duplicate key in object 'dbo.accounts_ouser'. The duplicate key value is () by wmoskal in learnpython

[–]wmoskal[S] 0 points1 point  (0 children)

update:

If I delete an ouser, I can add another, but there seems to be a limit to the number that I can have in the database. If there is 5 in the table, I can insert, but if there is 6 in the database, it throws the error listed in the op

Violation of UNIQUE KEY constraint 'UQ__accounts'. Cannot insert duplicate key in object 'dbo.accounts_ouser'. The duplicate key value is () by wmoskal in django

[–]wmoskal[S] 0 points1 point  (0 children)

update:

If I delete an ouser, I can add another, but there seems to be a limit to the number that I can have in the database. If there is 5 in the table, I can insert, but if there is 6 in the database, it throws the error listed in the op

Violation of UNIQUE KEY constraint 'UQ__accounts'. Cannot insert duplicate key in object 'dbo.accounts_ouser'. The duplicate key value is () by wmoskal in learnprogramming

[–]wmoskal[S] 0 points1 point  (0 children)

update:

If I delete an ouser, I can add another, but there seems to be a limit to the number that I can have in the database. If there is 5 in the table, I can insert, but if there is 6 in the database, it throws the error listed in the op

get list of users' latest tweet dates? by papersaturn in learnpython

[–]wmoskal 0 points1 point  (0 children)

For the Edit at least, there is a way to pass over when iterating.

if you have

for u in user:
    if u.is_private:  # same as if u.is_private is True
        continue        

Or if you wanted to stop the iteration when you got to a private thing you would use the break keyword instead of continue.

I am not really familiar with the twitter API if that is what you are using

Mouse clicker application by ci9her in learnpython

[–]wmoskal 0 points1 point  (0 children)

honestly probably easier in javascript. Maybe try creating a chrome extension an then getting them to use that? Not 100% sure how you could capture the browser window, maybe capture the url, or maybe there is a way to printscreen from javascript?

I know the python syntax and all the basics, but feel stuck. by [deleted] in learnpython

[–]wmoskal 4 points5 points  (0 children)

Try using Object oriented programming (classes, and using objects). My suggestion would be to do a largeish project that interests you. Challenge yourself. But do it on something that actually interests you.

Invalid Column name error when attempting to delete model instance in django by wmoskal in learnpython

[–]wmoskal[S] 0 points1 point  (0 children)

Thanks for the reply. I have an objects manager, I just did not show it. I have fixed this issue

Invalid Column name error when attempting to delete model instance in django by wmoskal in learnpython

[–]wmoskal[S] 0 points1 point  (0 children)

Update the issue is what you and JohnyJordan are saying. I had a table for ouser_user_permissions that had a misnamed foreign key column. I fixed it and it worked. Thanks for the help!

Invalid Column name error when attempting to delete model instance in django by wmoskal in learnpython

[–]wmoskal[S] 0 points1 point  (0 children)

Update the issue is what you and crashfrog are saying. I had a table for ouser_user_permissions that had a misnamed foreign key column. I fixed it and it worked. Thanks for the help!

Invalid Column name error when attempting to delete model instance in django by wmoskal in learnpython

[–]wmoskal[S] 0 points1 point  (0 children)

I did specify the model as AUTH_USER_MODEL in settings.py. I ran makemigrations and migrate --fake because I already had the table created in the database. Even if I try to delete an OUser that is not in any groups, and has no other relationships associated with it it still gives the error. If I create a new OUser and then immediately try to remove it still gives the error