Jump to content


Photo

learning python, join me if you'd like


  • Please log in to reply
37 replies to this topic

#21 positiveContact

positiveContact

    Anti-Brag Queen

  • Patron
  • PipPipPipPipPipPip
  • 65228 posts
  • LocationLimbo

Posted 25 January 2023 - 04:16 AM

Square brackets seems like an "or" and not an "and". Like if I put in [ab] I would get stings that contain a, b or a ava b.

#22 Stains_not_here_man

Stains_not_here_man

    Phat O'Mic Chef Winner!

  • Patron
  • PipPipPipPipPipPip
  • 105525 posts

Posted 25 January 2023 - 08:40 AM

Ok so you want to match any word with an "a" and a "b" in any order?

Match:
banana
absinthe
cabana
baccarat

No match:
ankle
browser
elbow
shanty

?
Also match:

Brand
Drawback

#23 positiveContact

positiveContact

    Anti-Brag Queen

  • Patron
  • PipPipPipPipPipPip
  • 65228 posts
  • LocationLimbo

Posted 25 January 2023 - 08:44 AM

I think you get what I'm going for, yes.

 

I have the words in a list object like this:

 

word_list = ['apple', 'guy', 'stuck', 'blah']

 

eta:  I picked those words at random, only blah meets the criteria :P


Edited by postSingularityHumanoid, 25 January 2023 - 08:47 AM.


#24 Stains_not_here_man

Stains_not_here_man

    Phat O'Mic Chef Winner!

  • Patron
  • PipPipPipPipPipPip
  • 105525 posts

Posted 25 January 2023 - 08:49 AM

So for that particular example, again this isn't python specific but the regex itself would be

/.*a.*b.*|.*b.*a.*/

.* matches 0 or more of any character (basically a wildcard)

So this translates as

Anything followed by an a, followed by anything, followed by a b, followed by anything. OR anything followed by b, followed by anything, followed by a, followed by anything.

And note that in this context "anything" really means "anything or nothing".

Regexpal.com is your friend btw

Edited by Stains_not_here_man, 25 January 2023 - 08:48 AM.


#25 positiveContact

positiveContact

    Anti-Brag Queen

  • Patron
  • PipPipPipPipPipPip
  • 65228 posts
  • LocationLimbo

Posted 25 January 2023 - 08:54 AM

So for that particular example, again this isn't python specific but the regex itself would be

/.*a.*b.*|.*b.*a.*/

.* matches 0 or more of any character (basically a wildcard)

So this translates as

Anything followed by an a, followed by anything, followed by a b, followed by anything. OR anything followed by b, followed by anything, followed by a, followed by anything.

And note that in this context "anything" really means "anything or nothing".

Regexpal.com is your friend btw

 

oh, I didn't know these were sort of universal.  so the * always modifies the thing that precedes it, right?  and it basically means, "any number of that thing" and since period is "anything" that's how you arrived there?



#26 Stains_not_here_man

Stains_not_here_man

    Phat O'Mic Chef Winner!

  • Patron
  • PipPipPipPipPipPip
  • 105525 posts

Posted 25 January 2023 - 09:31 AM

Yep!

#27 positiveContact

positiveContact

    Anti-Brag Queen

  • Patron
  • PipPipPipPipPipPip
  • 65228 posts
  • LocationLimbo

Posted 25 January 2023 - 12:40 PM

Yep!

 

okay, cool.  thanks!



#28 positiveContact

positiveContact

    Anti-Brag Queen

  • Patron
  • PipPipPipPipPipPip
  • 65228 posts
  • LocationLimbo

Posted 26 January 2023 - 06:11 AM

damn, so something that complicates this a little is the number of letters is variable.  could be 1, 2, 3, etc.

 

you kind of hard coded it for 2 letters but I guess for 3 I'd need 6 small REs divided up with "or"s?  I haven't thought about it too long yet though so I may not have right....



#29 Stains_not_here_man

Stains_not_here_man

    Phat O'Mic Chef Winner!

  • Patron
  • PipPipPipPipPipPip
  • 105525 posts

Posted 26 January 2023 - 06:13 AM

Keep in mind that regex itself is mostly useful for things that are "patterns". In some cases a for loop or a series of them may be more appropriate depending on the variability of the thing you're looking at.

#30 positiveContact

positiveContact

    Anti-Brag Queen

  • Patron
  • PipPipPipPipPipPip
  • 65228 posts
  • LocationLimbo

Posted 26 January 2023 - 06:19 AM

Keep in mind that regex itself is mostly useful for things that are "patterns". In some cases a for loop or a series of them may be more appropriate depending on the variability of the thing you're looking at.

 

yeah, I was just trying to exercise my RE skills.



#31 SnowMan

SnowMan

    Advanced Snowman

  • Patron
  • PipPipPipPipPip
  • 13153 posts
  • LocationWinter...

Posted 09 February 2023 - 06:22 PM

My 9, almost 10 year old got a python for beginners book from the library. How do i get python on a Chromebook?

I can't load Linux the way I've seen others do online... Samsung has tht bios locked.

#32 Stains_not_here_man

Stains_not_here_man

    Phat O'Mic Chef Winner!

  • Patron
  • PipPipPipPipPipPip
  • 105525 posts

Posted 09 February 2023 - 06:23 PM

Go to the chrome web store to download the Python Shell Chrome Extension.
Click on add to chrome to install and add the extension to the browser.
After the extension is installed, click on it to launch it.
A small window will appear where you can write and execute the python code.

#33 positiveContact

positiveContact

    Anti-Brag Queen

  • Patron
  • PipPipPipPipPipPip
  • 65228 posts
  • LocationLimbo

Posted 09 February 2023 - 06:26 PM

So no unlocking Linux?

I mean, if they just want to learn basics a lot of the websites I find when I look stuff up have interpreters built in and you can edit and run bits if code.

Go to the chrome web store to download the Python Shell Chrome Extension.
Click on add to chrome to install and add the extension to the browser.
After the extension is installed, click on it to launch it.
A small window will appear where you can write and execute the python code.


Can save files and stuff? That's pretty neat.

#34 positiveContact

positiveContact

    Anti-Brag Queen

  • Patron
  • PipPipPipPipPipPip
  • 65228 posts
  • LocationLimbo

Posted 09 February 2023 - 07:13 PM

Also, I found that python guru website in the op really helpful to quickly get me over a bunch of syntax hurdles. But I already know basic coding "stuff". Do they know anything? That website still might be good but they won't be able to whiz through it like someone who knows another language.

#35 SnowMan

SnowMan

    Advanced Snowman

  • Patron
  • PipPipPipPipPip
  • 13153 posts
  • LocationWinter...

Posted 09 February 2023 - 08:42 PM

He knows nothing. I've done C and C++ but know nothing of Python.


The book he has seems to build the components logically. We'll see

#36 positiveContact

positiveContact

    Anti-Brag Queen

  • Patron
  • PipPipPipPipPipPip
  • 65228 posts
  • LocationLimbo

Posted 09 February 2023 - 08:56 PM

He knows nothing. I've done C and C++ but know nothing of Python.


The book he has seems to build the components logically. We'll see


It will still be fine. Python is easier than c.

#37 positiveContact

positiveContact

    Anti-Brag Queen

  • Patron
  • PipPipPipPipPipPip
  • 65228 posts
  • LocationLimbo

Posted 15 February 2023 - 05:05 AM

This seems really dangerous to python noobs like myself. This would just require mistyping something when using pip, right?  Or in the case of using pyCharm to install a package, clicking on the wrong item in the index list?

 

https://arstechnica....ealing-malware/

 

More than 400 malicious packages were recently uploaded to PyPI (Python Package Index), the official code repository for the Python programming language, in the latest indication that the targeting of software developers using this form of attack isn’t a passing fad.


Edited by postSingularityHumanoid, 15 February 2023 - 05:06 AM.


#38 TonyBrown

TonyBrown

    Comptroller of C-Blocking and Wet Streak Marks

  • Members
  • PipPipPipPipPipPip
  • 82532 posts
  • LocationRedneckistan

Posted 15 February 2023 - 11:04 AM

still disappointed at the lack of silly walks here.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users